Problem: p03352
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())
lis = []
for i in range(1,100):
    for j in range(2,10):
        lis.append(i**j)
lis.sort()
print(lis)
for i in range(1001):
    if lis[i+1] == x:
        print(lis[i+1])
        break
    elif lis[i+1] > x:
        print(lis[i])
        break

Failing test case input:
1023

Expected output:
1000


Actual output:
[1, 1, 1, 1, 1, 1, 1, 1, 4, 8, 9, 16, 16, 25, 27, 32, 36, 49, 64, 64, 64, 81, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 256, 256, 289, 324, 343, 361, 400, 441, 484, 512, 512, 529, 576, 625, 625, 676, 729, 729, 729, 784, 841, 900, 961, 1000, 1024, 1024, 1089, 1156, 1225, 1296, 1296, 1331, 1369, 1444, 1521, 1600, 1681, 1728, 1764, 1849, 1936, 2025, 2116, 2187, 2197, 2209, 2304, 2401, 2401, 2500, 2601, 2704, 2744, 2809, 2916, 3025, 3125, 3136, 3249, 3364, 3375, 3481, 3600, 3721, 3844, 3969, 4096, 4096, 4096, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 4913, 5041, 5184, 5329, 5476, 5625, 5776, 5832, 5929, 6084, 6241, 6400, 6561, 6561, 6561, 6724, 6859, 6889, 7056, 7225, 7396, 7569, 7744, 7776, 7921, 8000, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9261, 9409, 9604, 9801, 10000, 10648, 12167, 13824, 14641, 15625, 15625, 16384, 16807, 17576, 19683, 19683, 20736, 21952, 24389, 27000, 28561, 29791, 32768, 32768, 35937, 38416, 39304, 42875, 46656, 46656, 50625, 50653, 54872, 59049, 59319, 64000, 65536, 65536, 68921, 74088, 78125, 79507, 83521, 85184, 91125, 97336, 100000, 103823, 104976, 110592, 117649, 117649, 125000, 130321, 132651, 140608, 148877, 157464, 160000, 161051, 166375, 175616, 185193, 194481, 195112, 205379, 216000, 226981, 234256, 238328, 248832, 250047, 262144, 262144, 262144, 274625, 279841, 279936, 287496, 300763, 314432, 328509, 331776, 343000, 357911, 371293, 373248, 389017, 390625, 390625, 405224, 421875, 438976, 456533, 456976, 474552, 493039, 512000, 531441, 531441, 531441, 537824, 551368, 571787, 592704, 614125, 614656, 636056, 658503, 681472, 704969, 707281, 729000, 753571, 759375, 778688, 804357, 810000, 823543, 830584, 857375, 884736, 912673, 923521, 941192, 970299, 1000000, 1048576, 1048576, 1185921, 1336336, 1419857, 1500625, 1679616, 1679616, 1771561, 1874161, 1889568, 1953125, 2085136, 2097152, 2313441, 2476099, 2560000, 2825761, 2985984, 3111696, 3200000, 3418801, 3748096, 4084101, 4100625, 4477456, 4782969, 4826809, 4879681, 5153632, 5308416, 5764801, 5764801, 6250000, 6436343, 6765201, 7311616, 7529536, 7890481, 7962624, 8503056, 9150625, 9765625, 9834496, 10000000, 10077696, 10556001, 11316496, 11390625, 11881376, 12117361, 12960000, 13845841, 14348907, 14776336, 15752961, 16777216, 16777216, 16777216, 17210368, 17850625, 18974736, 19487171, 20151121, 20511149, 21381376, 22667121, 24010000, 24137569, 24300000, 25411681, 26873856, 28398241, 28629151, 29986576, 31640625, 33362176, 33554432, 34012224, 35153041, 35831808, 37015056, 38950081, 39135393, 40353607, 40960000, 43046721, 43046721, 45212176, 45435424, 47045881, 47458321, 49787136, 52200625, 52521875, 54700816, 57289761, 59969536, 60466176, 62742241, 62748517, 64000000, 65610000, 68574961, 69343957, 71639296, 74805201, 78074896, 79235168, 81450625, 84934656, 85766121, 88529281, 90224199, 92236816, 96059601, 100000000, 102400000, 105413504, 113379904, 115856201, 130691232, 134217728, 147008443, 148035889, 164916224, 170859375, 184528125, 191102976, 205962976, 214358881, 229345007, 244140625, 254803968, 268435456, 282475249, 308915776, 312500000, 345025251, 380204032, 387420489, 387420489, 410338673, 418195493, 429981696, 459165024, 481890304, 503284375, 550731776, 594823321, 601692057, 612220032, 656356768, 714924299, 729000000, 777600000, 815730721, 844596301, 887503681, 893871739, 916132832, 992436543, 1000000000, 1073741824, 1073741824, 1160290625, 1252332576, 1280000000, 1291467969, 1350125107, 1453933568, 1475789056, 1544804416, 1564031349, 1680700000, 1801088541, 1804229351, 1838265625, 1934917632, 2073071593, 2176782336, 2219006624, 2357947691, 2373046875, 2494357888, 2535525376, 2562890625, 2565726409, 2706784157, 2887174368, 3010936384, 3077056399, 3276800000, 3404825447, 3486784401, 3518743761, 3707398432, 3939040643, 4096000000, 4182119424, 4294967296, 4437053125, 4586471424, 4704270176, 4750104241, 4984209207, 5159780352, 5277319168, 5489031744, 5584059449, 5904900000, 6103515625, 6240321451, 6321363049, 6590815232, 6956883693, 6975757441, 7256313856, 7339040224, 7737809375, 8031810176, 8153726976, 8303765625, 8587340257, 9039207968, 9474296896, 9509900499, 10460353203, 10604499373, 10779215329, 11019960576, 12230590464, 13492928512, 13841287201, 15625000000, 16983563041, 17249876309, 17596287801, 19770609664, 20661046784, 21870000000, 22164361129, 24794911296, 25600000000, 27512614111, 27680640625, 30840979456, 34296447249, 34359738368, 37822859361, 38068692544, 38443359375, 42180533641, 42618442977, 46656000000, 51520374361, 52523350144, 54875873536, 56800235584, 62523502209, 64339296875, 68719476736, 68719476736, 75418890625, 78310985281, 78364164096, 82653950016, 90458382169, 94931877133, 98867482624, 107918163081, 110075314176, 114415582592, 117649000000, 118587876497, 128100283921, 137231006679, 139314069504, 151334226289, 152587890625, 163840000000, 164206490176, 177978515625, 192699928576, 194754273881, 198359290368, 208422380089, 208827064576, 225199600704, 230539333248, 243087455521, 262144000000, 271818611107, 282429536481, 282429536481, 304006671424, 319277809664, 322687697779, 326940373369, 351298031616, 373669453125, 377149515625, 377801998336, 404567235136, 433626201009, 435817657216, 464404086784, 496981290961, 500246412961, 506623120463, 512000000000, 531441000000, 567869252041, 587068342272, 606355001344, 646990183449, 656100000000, 678223072849, 689869781056, 735091890625, 781250000000, 782757789696, 794280046581, 832972004929, 852891037441, 885842380864, 897410677851, 941480149401, 1028071702528, 1099511627776, 1174711139837, 1207269217792, 1338925209984, 1406408618241, 1522435234375, 1727094849536, 1785793904896, 1801152661463, 1954897493193, 2207984167552, 2251875390625, 2488651484819, 2641807540224, 2799360000000, 2821109907456, 3142742836021, 3512479453921, 3521614606208, 3814697265625, 3938980639167, 4347792138496, 4398046511104, 4902227890625, 5352009260481, 5429503678976, 5455160701056, 6060711605323, 6553600000000, 6722988818432, 7446353252589, 7625597484987, 7984925229121, 8235430000000, 9095120158391, 9682651996416, 10030613004288, 10578455953408, 11047398519097, 11688200277601, 12151280273024, 13348388671875, 14048223625216, 14507145975869, 14645194571776, 16048523266853, 16815125390625, 17565568854912, 19203908986159, 19683000000000, 20047612231936, 20971520000000, 22876792454961, 23811286661761, 24928547056768, 26439622160671, 27136050989627, 28179280429056, 29509034655744, 32057708828125, 33232930569601, 34792782221696, 35184372088832, 37725479487783, 39062500000000, 40867559636992, 44231334895529, 45767944570401, 46411484401953, 47829690000000, 51676101935731, 53459728531456, 55784660123648, 60170087060757, 60716992766464, 62259690411361, 64847759419264, 69833729609375, 72301961339136, 75144747810816, 78815638671875, 80798284478113, 83733937890625, 86812553324672, 93206534790699, 96717311574016, 101559956668416, 111429157112001, 128063081718016, 129961739795077, 146830437604321, 165216101262848, 167961600000000, 191707312997281, 208728361158759, 218340105584896, 248155780267521, 262144000000000, 281474976710656, 318644812890625, 327381934393961, 360040606269696, 406067677556641, 406671383849472, 457163239653376, 502592611936843, 513798374428641, 576480100000000, 618121839509504, 645753531245761, 722204136308736, 756680642578125, 806460091894081, 899194740203776, 922190162669056, 1001129150390625, 1113034787454976, 1119130473102767, 1235736291547681, 1352605460594688, 1370114370683136, 1517108809906561, 1628413597910449, 1677721600000000, 1853020188851841, 1953125000000000, 2044140858654976, 2252292232139041, 2334165173090451, 2478758911082496, 2724905250390625, 2779905883635712, 2992179271065856, 3282116715437121, 3299763591802133, 3596345248055296, 3904305912313344, 3936588805702081, 4304672100000000, 4605366583984375, 4702525276151521, 5132188731375616, 5416169448144896, 5595818096650401, 6095689385410816, 6351461955384057, 6634204312890625, 7213895789838336, 7427658739644928, 7837433594376961, 8507630225817856, 8662995818654939, 9227446944279201, 10077696000000000, 11694146092834141, 13537086546263552, 15633814156853823, 18014398509481984, 20711912837890625, 23762680013799936, 27206534396294947, 31087100296429568, 35452087835576229, 40353607000000000, 45848500718449031, 51998697814228992, 58871586708267913, 66540410775079424, 75084686279296875, 84590643846578176, 95151694449171437, 106868920913284608, 119851595982618319, 134217728000000000, 150094635296999121, 167619550409708032, 186940255267540403, 208215748530929664, 231616946283203125, 257327417311663616, 285544154243029527, 316478381828866048, 350356403707485209, 387420489000000000, 427929800129788411, 472161363286556672, 520411082988487293, 572994802228616704, 630249409724609375, 692533995824480256, 760231058654565217, 833747762130149888, 913517247483640899]
1000


Fixed submission (verdict: Accepted):
x = int(input())
lis = []
for i in range(1,100):
    for j in range(2,10):
        lis.append(i**j)
lis.sort()

for i in range(1001):
    if lis[i+1] == x:
        print(lis[i+1])
        break
    elif lis[i+1] > x:
        print(lis[i])
        break