Stop drinking alcohol, as said elsewhere. It takes about 2-3 weeks of sobriety to regain 80% of the capacity you lost. It's also extremely hard on your emotional regulation, work motivation, patience, and ability to concentrate long after you think you can't feel the effects.
Stop eating carbs, namely because it makes you sleepy and unmotivated. I replaced carbs with tons of fiber and vegetables, like red cabbage, matchstick carrots, and expensive fermented foods. Don't try to imitate your old crappy diet. Stop trying to eat the best meal every night.
Perfect your sleep schedule. I used 10mg EXTENDED RELEASE melatonin about 1 hour before bedtime.
Fight less with your spouse, play boardgames.
Meditate or stare at the wall to learn how to be bored. A lot of "intelligence" is just tolerance for boring/temporarily unrewarding things. Meditation has a lot of benefits as far as clearing out some of the crud.
Exercise, even 5 minutes a day. Anything.
Make sure to work in a variety of settings. If you can take your computer to a park bench and use your phone as a wifi hotspot, great. Being in nature is speculated to improve brain health.
I'd argue one of the edges smart people have is to have a large RAM. They can think through all 10 steps in one shot, maybe 20-30 mins, while people like me have to take triple that time, even a full day because something interrupts us in the middle.
Conclusion: don't f**ing get kid(s) unless you really want them, as air and water, and are willing to sacrifice cognitive ability.
1. Keeping learning and applying new things. New skills like new programming languages, new math, new strategy games, new situations in life in general.
2. Teaching. Whether a peer or a junior or anyone. I taught people since very early in life (say 6th standard). I believe this to be a knowledge multiplier.
3. Programming is a superpower that enables you to think in newer ways, solve problems in newer ways. Learned Prolog, Scheme, Haskell, Ruby, C++, Julia, APL- even if I don’t use them in my work/projects. I kept learning newer things- genetic algorithms, ML, non-linear dynamics, game programming, and coded newer things. This is great.
4. Meditation. It made me calmer, helped me make better decisions. More focused in learning, find patterns quicker and more intently. It's an anti-dote to scrollvirus infested world.
5. Exercise. Doing less is fine as long as I do it regularly.
6. Sleep. Always slept 7-9 hours since childhood.
7. I believe even small exposures to newer areas of knowledge increases your intelligence. It doesn't remotely make you an expert in those areas, but it makes you better in your field/s.
8. Art is really important and significant in my life. Performing arts and consuming them- are both great and enable different things in your life. Reading novels had made me more empathetic and exposed me to different worldviews. It has been valuable. When giving a presentation/convincing someone of a view- all the instincts I learned from performing arts kicks in. Some would call me crazy but while writing theorems, this happens, too. Also art is a great escape, using which you can turn off from the real world and heal from pains/unpleasant situations which enables you learn new things. Learning to play a piece on piano/guitar is like solving a programming problem (yourself, not memorize it). Your brain is in fire.
9. Solving problems regularly makes your brain better in the short term. Like solving Codeforces problem or automating a significant something in Factorio. Just like if you want to look in better shape for few hours, 20 push ups achieve this for you; solving 2 codeforces problems each day for 6 days will enable you to be in sharper state for the next two days.
10. Believing yourself as a force of good in the world helps you stay motivated in trying times.
11. Having a close friend/SO helps a lot.
The sooner you realize that cognitive skills are tied to your mental and physical wellbeing, the better.
Learn the pattern of common logical fallacies. Practice finding them in yourself and your interlocutors.
Write down your thoughts. Writing things down forces you to structure them.
Talk to people you disagree with. Actively challenge your own assumptions and conclusions. When you lose an argument you gain knowledge. When you engage in an argument in good faith (allowing that you could be wrong) you test your assumptions and conclusions.
But then I overdid it and played too much and slept too little. Now I rarely play games.
Actually caring about the activity, if I care about what I'm doing everything improves cognitively.
The more of this you do the easier it is to categorize information and ideas leading to less cognitive load and increasing capacity.