Jafe posted something very close to my intended answer, and it may be that he is correct, and I've made a mistake somewhere. To compare notes, here's my intended solution: (the tick has gone to a completely different answer, because it was very good, and fit every requirement given, although in a much more clever way that I had intended.
Intended optimal strategy
Interpret the players' impartiality in such a way, that when they have to give an advantage to one of their opponents, they'll choose either opponent with a 50% probability.
Then, for every possible number of candies, plot the best strategy for the player whose turn it is:
1: you lose
2: next player loses
3: you are the kingmaker (you win, and choose the other winner)
4: (ditto)
5: (ditto)
6: (ditto)
7: never happens, automatic loss for the player who left it
8: next player is kingmaker (this is bad for you.)
9: kingmaker-maker (you choose the kingmaker, but it won't be you, so also bad)
10: always leave 9 (50% chance of getting to be the kingmaker)
11: leave 10 or 9 (you are the kingmaker-maker-maker, or km^3:
you choose, which of the other players is the kingmaker-maker)
12: (ditto)
13: (ditto)
14: (ditto)
15: never happens: the person leaving it automatically becomes the kingmaker-maker,
16: next player is the km^3. This is bad for you.
17: you are km^4. (You choose the km^3, but it won't be you. This is bad.)
18: always leave 17. (50% chance of getting to be km^3)
19: leave 17 or 18 (You are the km^5. This is good.)
20: (ditto)
21: (ditto)
22: (ditto)
23: never happens: the person leaving it automatically becomes the km^4
24: next player is km^5 (bad)
25: km^6 (bad)
26: leave 25 (50% for km^5)
27: km^7 (good)
28: (ditto)
29: (ditto)
30: (ditto)
31: never happens (bad)
32: next player is km^7 (bad)
33: km^8 (bad)
34: leave 33 (50% for km^7)
35: km^9 (good)
36: (ditto)
37: (ditto)
38: (ditto)
39: never happens
40: next player is km^9
So there is a repeating pattern all the way from the beginning:
- 1 "bad" number (lose outright, or forced to choose whom to give the advantage, "even-powered kingmaker")
- 1 "good, but forced" number (either you or the player before you gets an advantage)
- 4 "just plain good" numbers (choose a player who gets the disadvantage, "odd-powered kingmaker")
- 1 "impossible" number (automatically very bad for the previous player)
- 1 "unwanted" number (also bad for the previous player, so won't be chosen unless there are only equally bad (or worse) options)
Since each repetition of the pattern exponentially diminishes the advantage gained from being the odd-powered kingmaker, at 40 candies it's almost all the same what to do. But since it does give a tiny advantage, Barry should choose to go second in this game.
EDIT:
Should you want to out exactly how (in)significant this advantage is, we can list the winning probabilities for each player. To construct the next row in the list, choose among the five previous rows the one(s) that has the biggest number in the right hand column. Rotate the numbers one spot to the right to get the numbers for the new row. If there are more than one possible row to choose from, pick one row that favours one opponent, and one row that favours the other, rotate both, and average their values.
N: best strategy | winning probabilities, in 1/512 parts
---------------------------------------------------------
1: take 1 | (0, 512, 512)
2: take 1 | (512, 0, 512)
3: take 1 or 2 | (512, 256, 256) = avg((512, 0, 512), (512, 512, 0))
4: take 2 or 3 | ditto
5: take 3 or 4 | ditto
6: take 4 or 5 | ditto
7: take 5 | (512, 512, 0)
8: take 2-5 | (256, 512, 256)
9: take 1 or 3-5 | (256, 384, 384) = avg((256, 512, 256), (256, 256, 512))
10: take 1 | (384, 256, 384)
11: take 1 or 2 | (384, 320, 320) = avg((384, 256, 384), (384, 384, 256))
12: take 2 or 3 | ditto
13: take 3 or 4 | ditto
14: take 4 or 5 | ditto
15: take 5 | (384, 384, 256)
16: take 2-5 | (320, 384, 320)
17: take 1 or 3-5 | (320, 352, 352) (avg)
18: take 1 | (352, 320, 352)
19: take 1 or 2 | (352, 336, 336) (avg)
20: take 2 or 3 | ditto
21: take 3 or 4 | ditto
22: take 4 or 5 | ditto
23: take 5 | (352, 352, 320)
24: take 2-5 | (336, 352, 336)
25: take 1 or 3-5 | (336, 344, 344) (avg)
26: take 1 | (344, 336, 344)
27: take 1 or 2 | (344, 340, 340) (avg)
28: take 2 or 3 | ditto
29: take 3 or 4 | ditto
30: take 4 or 5 | ditto
31: take 5 | (344, 344, 340)
32: take 2-5 | (340, 344, 340)
33: take 1 or 3-5 | (340, 342, 342) (avg)
34: take 1 | (342, 340, 342)
35: take 1 or 2 | (342, 341, 341) (avg)
36: take 2 or 3 | ditto
37: take 3 or 4 | ditto
38: take 4 or 5 | ditto
39: take 5 | (342, 342, 340)
40: take 2-5 | (341, 342, 341)
-------------------------------------------------
It's pretty easy to see that the winning probabilities all tend towards 2/3 for each player. At 40 candies, there's still a little bit of imbalance left, so that out of 512 games, the player that goes second is expected to gain one more win than the others. In terms of winning percentage, the second player wins with about 66.8% probability, while the others only win with 66.6%, or in other words, there's a gain of about one fifth of a percentage point.