Below are countries sorted by their average ranking in the International Mathematical Olympiad during the last 20 years (https://www.imo-official.org/results.aspx). Countries with larger populations are overrepresented because they have a larger pool to choose participants from.
North Korea is the fifth highest ranking country even though its population is only about 25 million and its GDP per capita is about 2,000 USD. Vietnam is the seventh highest ranking country even though its GDP per capita is also about 2,000 USD.
Lynn and Vanhanen (2006) (https://en.wikipedia.org/w/index.php?title=IQ_and_the_Wealth_of_Nations&oldid=487100081) listed the national IQ as 93 for Vietnam, 84 for Iran, 94 for Romania, 93 for Bulgaria, 91 for Thailand, and 91 for Turkey. North Korea might be another country whose national IQ could be low despite its high ranking in the IMO.
I only included results from the last 20 years, because the participants of the IMO included only Eastern European countries from 1959 when the IMO was first held until 1965, and more than half of the countries which participated in the IMO were communist countries until the year 1977. North Korea has participated in the IMO only since 2007 apart from three participations in the years 1990, 1991, and 1992 (when it ranked 19th, was disqualified, and ranked 16th).
IMO participants are high school students, so as with the participants in PISA, they are not necessarily representative of older generations.
Also how high a country ranks depends on what kind of a program it has for scouting and training the participants. Maybe part of the reason why Eastern European countries rank high is that the IMO originated in the Eastern Bloc, so it might still be given more attention in Eastern Europe.
1.4 People's Republic of China
3.2 United States of America
3.6 Russian Federation
4.9 Republic of Korea
6.8 Democratic People's Republic of Korea
11.8 Islamic Republic of Iran
18.8 United Kingdom
24.2 Hong Kong
27.7 Serbia and Montenegro
37.6 Czech Republic
39.5 Republic of Moldova
49.5 South Africa
50.0 New Zealand
50.1 Bosnia and Herzegovina
58.0 North Macedonia
62.5 Saudi Arabia
66.6 Costa Rica
68.8 Sri Lanka
77.3 Trinidad and Tobago
82.3 Puerto Rico
83.2 El Salvador
89.0 Burkina Faso
89.8 Ivory Coast
98.7 United Arab Emirates
North Korea has won 19 gold medals in the IMO even though it has had a total of only 78 participants. The Nordic countries have won only 9 gold medals even though they have had a total of 1158 participants.
Davide Piffer (2018) (https://www.researchgate.net/publication/328355424_Evidence_for_recent_polygenic_selection_on_educational_attainment_and_intelligence_inferred_from_GWAS_hits_a_replication_of_previous_findings_using_recent_data) calculated polygenic scores based on the frequencies of alleles which are associated with educational attainment.
The "EDU3 (weighted)" score of the three East Asian population groups ("Chinese, Beijing" (1.51), "Chinese, South" (1.32), and "Japanese" (1.44)) was higher than the score of the two Southeast Asian groups ("Vietnam" (1.09) and "Chinese Dai" (1.01)). Dai are a people related to the Thai and Lao peoples whose population is mainly concentrated in Myanmar, but who also live in South China.
North Koreans might be expected to have one of the highest scores along with other East Asian countries, but North Korea might also be one of the countries with the largest discrepancy between the polygenic score and national IQ.
Below are the average PISA scores in each domain (mathematics, science, and reading) for each year where data is available (https://en.wikipedia.org/wiki/Programme_for_International_Student_Assessment) for East Asian and Southeast Asian countries. I also included a column for the score converted to IQ points (where I set the UK average as 100).
(average PISA score;average PISA score as IQ points;country or region)
540.4;105.6;Hong Kong, China
494.9;98.7;International Average (OECD)
Scores are thus scaled so that the OECD average in each domain (mathematics, reading and science) is 500 and the standard deviation is 100. This is true only for the initial PISA cycle when the scale was first introduced, though, subsequent cycles are linked to the previous cycles through IRT scale linking methods.
If for example the score of a country was available for 3 years for reading and for 2 years for mathematics and science, I simply treated the average of all 7 scores as the overall score of the country. There probably would've been some better way to calculate the overall score.
North Korea has not participated in PISA. Vietnam is one of the highest ranking countries even though its GDP per capita is about 2,000 USD, or approximately equal to North Korea, and much lower than Malaysia (about 10,000 USD) and Thailand (about 7,000 USD), both of whose average PISA score was almost 1 SD lower.
"China B-S-J-G" refers to "China (Beijing, Shanghai, Jiangsu, Guangdong)". The score for entire China would probably be lower (http://raceandiqmyths.blogspot.com/2016/10/fake-chinese-iq-studies-richard-lynn.html):
Chinese government did not allow PISA to publish the results of other provinces. A statement was made by PISA that "we have done PISA sampling in 12 provinces in China and in some of the poorest regions, you get performance close to the OECD average."
Its a very generalized statement which doesn't really mean anything. "Close to the OECD average". It can be 50 points less or 20 points. Unless, PISA results on China which are held back are released nothing can be said about average IQ of China.
In any case, Lynn and Vanhanen don't claim that "North Korea is the 3rd/4th most intelligent nation" like the OP said, or even that its actual national IQ would be 104 (not 105 like Wikipedia says) or 106, but rather that they estimated the national IQ of North Korea to be 104 or 106 by calculating the average national IQs of neighboring countries or countries with similar ethnic composition. North Korea might be an extreme example of a country where their method produces an inaccurate result.
In a table from IQ and Global Inequality (Lynn and Vanhanen 2006) below, the countries which were used to estimate the IQ of North Korea (106) are shown as China (105) and South Korea (106).
They wrote that they always rounded 0.5 up:
We have adopted the same method as used previously to estimate the IQs of the countries for which we do not have direct evidence based on intelligence tests: for these, we have estimated the IQs on the basis of the arithmetic means of the measured IQs of neighboring countries. These estimates are given in Table 4.3. In each case, the comparison countries and their national IQs are indicated in the table. Decimal points are rounded to the nearest whole number, 0.5 upwards.
They didn't publish national IQs as numbers with a fractional part, and the estimated IQs also seem to be based on integer IQs.
In IQ and the Wealth of Nations (Lynn and Vanhanen 2002) below, the IQ of North Korea (104) was calculated as the average (not median) of the IQs of South Korea (106), Japan (105), and China (100). I don't know why it was listed as 105 in Wikipedia.
Edit: Like I said in a comment, I'm not arguing that North Korea actually has a high Greenwich IQ. If I had to guess what integer multiple of 5 it would be the closest to, I would pick maybe 95.
Konrad Rudolph said this in a comment:
It’s a well-known fact (hence I leave out the references, they are easily found on Wikipedia) that the NK population is severely under-nourished, and the link between malnutrition in childhood and mental deficits later on is well established. Lynn & Vanhanen completely ignore this effect when averaging neighbouring countries, rendering the resulting value useless.
There are also environmental factors which reduce IQ which typically have a larger impact in countries with a higher level of development, and which might have been in part responsible for the negative Flynn effect during the past two or three decades. In a study from 2014 (https://www.sciencedirect.com/science/article/abs/pii/S0890856714000446), South Korea had a rate of autism of about 2.2% among 7-12 year-olds, which is the highest or among the highest in the world.
Lynn and Vanhanen (2006) did include the graph below for estimated national IQ plotted against percentage of undernourished population in 1999-2001. Mongolia is another country whose IQ they guesstimated (as an average of China and Russia), which might also explain why it's an outlier.
Positive residuals are large (15.3 or higher) for 16 countries: Afghanistan, Angola, Armenia, Burundi, Cambodia, Congo-Zaire, Eritrea, Haiti, North Korea, Madagascar, Mongolia, Mozambique, Sierra Leone, Somalia, Tajikistan, and Zambia. Relative poverty characterizes all these countries, but poverty alone does not provide a satisfactory explanation for the high level of undernourishment in these countries, because there are many other poor countries in which the level of undernourishment deviates less from the regression line. It is possible to find an additional explanatory factor from wars and civil wars which have more or less devastated nearly all of these countries. Mongolia has escaped civil war, but its harsh environmental conditions may explain the country’s poverty and undernourishment. The extremely autocratic and peculiar governmental system of North Korea is responsible for undernourishment and hunger in that country.