In a school there are $2023$ students, numbered $1$ to $2023$. The teacher met the students one by one in the order of their numbers, and gave a candy to each student except if that would mean three students whose numbers form an arithmetic sequence all got candies. In this way, the teacher would give a candy to students 1 and 2, but not student 3 (as 1, 2, 3 form an arithmetic sequence), then to students 4 and 5, but not to students 6 and 7 (as both 4, 5, 6 and 1, 4, 7 are arithmetic sequences), and so on. How many students got candies in the end?
I tried to list the number and found the number 1,2,4,5,10,11,13,14,28,29,31,32,37,38,40,41 is available In the first 50 numbers. The thing I could only found is that everytime it start getting a candy, it would be in the form of ✅✅❌✅✅ (for example: In number 10,11,12,13,14, 12 is not available)

I programmed the thing supposing you don't want $3$ consecutive elements of your list to be in an arithmetic sequence, i.e. for $p<q<r$ in your list, $q-p \neq r-q$, here is the list I obtained: $$[1, 2, 4, 5, 10, 11, 13, 14, 28, 29, 31, 32, 37, 38, 40, 41, 82, 83, 85, 86, 91, 92, 94, 95, 109, 110, 112, 113, 118, 119, 121, 122, 244, 245, 247, 248, 253, 254, 256, 257, 271, 272, 274, 275, 280, 281, 283, 284, 325, 326, 328, 329, 334, 335, 337, 338, 352, 353, 355, 356, 361, 362, 364, 365, 730, 731, 733, 734, 739, 740, 742, 743, 757, 758, 760, 761, 766, 767, 769, 770, 811, 812, 814, 815, 820, 821, 823, 824, 838, 839, 841, 842, 847, 848, 850, 851, 973, 974, 976, 977, 982, 983, 985, 986, 1000, 1001, 1003, 1004, 1009, 1010, 1012, 1013, 1054, 1055, 1057, 1058, 1063, 1064, 1066, 1067, 1081, 1082, 1084, 1085, 1090, 1091, 1093, 1094]$$
I double checked it with a verification function. Its length is $128$
Here is my codeine python:
The first describes the candidate you should avoid for the next members of your list, the second just gives the answer and the last checks if you don't have 3 consecutive numbers of an arithmetic sequence in you list.
Mathematically, I had some insights like trying to compute the next arithmetic number, or working with projections of affine lines in $\mathbb{N}^2$ but I did not succeed
Here is the graph of len(Szekeres(n)):
And a second one with bigger $n$

It seems we gat by dezooming a sort of Cantor's staircase or devil's staircase I don't know how you call it
Edit: with the property of the basis $3$ is it clearer why it forms a sort of cantor's staircase...