Problem p02629 (python)

Fixed submission:
n = int(input())
a =  ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']


if  n >= ((26 ** 12 - 1) / (26 - 1)):
     n = n - ((26 ** 12 - 1) // (26 - 1))
     l = n // (26 ** 11)
     n = n % (26 ** 11)
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[l] + a[k] + a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]      

elif n >= ((26 ** 11 - 1) / (26 - 1)):
     n = n - ((26 ** 11 - 1) // (26 - 1)) 
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[k] + a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]      
     
elif n >= ((26 ** 10 - 1) / (26 - 1)):
     n = n - ((26 ** 10 - 1) // (26 - 1))
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]      
     
elif n >= ((26 ** 9 - 1) / (26 - 1)):
     n = n - ((26 ** 9- 1) // (26 - 1)) 
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]      
     
elif n >= ((26 ** 8 - 1) / (26 - 1)):
     n = n - ((26 ** 8 - 1) // (26 - 1)) 
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]      
     
elif n >= ((26 ** 7 - 1) / (26 - 1)):
     n = n - ((26 ** 7 - 1) // (26 - 1))
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]

elif n >= ((26 ** 6 - 1) / (26 - 1)):
     n = n - ((26 ** 6 - 1) // (26 - 1))
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[f] + a[e] + a[d] + a[c] + a[b] + a[aa]
     
elif n >= ((26 ** 5 - 1) / (26 - 1)):
     n = n - ((26 ** 5 - 1) // (26 - 1))
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[e] + a[d] + a[c] + a[b] + a[aa]
     
elif n >= ((26 ** 4 - 1) / (26 - 1)):
     n = n - ((26 ** 4 - 1) // (26 - 1)) 
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[d] + a[c] + a[b] + a[aa]
     
elif n >= ((26 ** 3- 1) / (26 - 1)):
     n = n - ((26 ** 3 - 1) // (26 - 1)) 
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[c] + a[b] + a[aa]
     
elif n >= ((26 ** 2 - 1) / (26 - 1)):
     n = n - ((26 ** 2 - 1) // (26 - 1)) 
     b = n // 26
     aa = n % 26
     ans = a[b] + a[aa]
     
else:
    ans = a[n-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a =  ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']


if  n >= ((26 ** 12 - 1) / (26 - 1)):
     n = n - ((26 ** 12 - 1) / (26 - 1)) + 1
     l = n // (26 ** 11)
     n = n % (26 ** 11)
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[l] + a[k] + a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]      

elif n >= ((26 ** 11 - 1) / (26 - 1)):
     n = n - ((26 ** 11 - 1) / (26 - 1)) + 1
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[k] + a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]      
     
elif n >= ((26 ** 10 - 1) / (26 - 1)):
     n = n - ((26 ** 10 - 1) / (26 - 1)) + 1
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[j] + a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]      
     
elif n >= ((26 ** 9 - 1) / (26 - 1)):
     n = n - ((26 ** 9- 1) / (26 - 1)) + 1
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[i] + a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]      
     
elif n >= ((26 ** 8 - 1) / (26 - 1)):
     n = n - ((26 ** 8 - 1) / (26 - 1)) + 1
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[h] + a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]      
     
elif n >= ((26 ** 7 - 1) / (26 - 1)):
     n = n - ((26 ** 7 - 1) / (26 - 1)) + 1
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[g] + a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]

elif n >= ((26 ** 6 - 1) / (26 - 1)):
     n = n - ((26 ** 6 - 1) / (26 - 1)) + 1
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[f] + a[e] + a[d] + a[c] + a[b] + a[aa-1]
     
elif n >= ((26 ** 5 - 1) / (26 - 1)):
     n = n - ((26 ** 5 - 1) / (26 - 1)) + 1
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[e] + a[d] + a[c] + a[b] + a[aa-1]
     
elif n >= ((26 ** 4 - 1) / (26 - 1)):
     n = n - ((26 ** 4 - 1) / (26 - 1)) + 1
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[d] + a[c] + a[b] + a[aa-1]
     
elif n >= ((26 ** 3- 1) / (26 - 1)):
     n = n - ((26 ** 3 - 1) / (26 - 1)) + 1
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[c] + a[b] + a[aa]
     
elif n >= ((26 ** 2 - 1) / (26 - 1)):
     n = n - ((26 ** 2 - 1) / (26 - 1)) + 1
     b = n // 26
     aa = n % 26
     ans = a[b] + a[aa-1]
     
else:
    ans = a[n-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a =  ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

if (26**13) >= n > (26 ** 12):
     m = n // (26 ** 12)
     n = n % (26 ** 12)
     l = n // (26 ** 11)
     n = n % (26 ** 11)
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[m-1] + a[l-1] + a[k-1] + a[j-1] + a[i-1] + a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1] 


elif (26 ** 12) >= n > (26 ** 11):
     l = n // (26 ** 11)
     n = n % (26 ** 11)
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[l-1] + a[k-1] + a[j-1] + a[i-1] + a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1] 
     
elif (26 ** 11) >= n > (26 ** 10):
     k = n // (26 ** 10)
     n = n % (26 ** 10)
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[k-1] + a[j-1] + a[i-1] + a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 10) >= n > (26 ** 9):
     j = n // (26 ** 9)
     n = n % (26 ** 9)
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[j-1] + a[i-1] + a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 9) >= n > (26 ** 8):
     i = n // (26 ** 8)
     n = n % (26 ** 8)
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[i-1] + a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1]+ a[b-1] + a[aa-1]
     
elif (26 ** 8) >= n > (26 ** 7):
     h = n // (26 ** 7)
     n = n % (26 ** 7)
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[h-1] + a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 7) >= n > (26 ** 6):
     g = n // (26 ** 6)
     n = n % (26 ** 6)
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[g-1] + a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]

elif (26 ** 6) >= n > (26 ** 5):
     f = n // (26 ** 5)
     n = n % (26 ** 5)
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[f-1] + a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 5) >= n > (26 ** 4):
     e = n // (26 ** 4)
     n = n % (26 ** 4)
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[e-1] + a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 4) >= n > (26 ** 3):
     d = n // (26 ** 3)
     n = n % (26 ** 3)
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[d-1] + a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 3) >= n > (26 ** 2):
     c = n // (26 ** 2)
     n = n % (26 ** 2)
     b = n // 26
     aa = n % 26
     ans = a[c-1] + a[b-1] + a[aa-1]
     
elif (26 ** 2) > n > (26 ** 1):
     b = n // 26
     aa = n % 26
     ans = a[b-1] + a[aa-1]
     
else:
    ans = a[n-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a =  ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']


if 1 <= n <= 26:
    ans = a[n-1]
elif 27 <= n <= 702:
    n = n - 26
    t = n // 26
    o = n % 26
    ans = a[t] + a[o-1]
elif 703 <= n <= 18278:
    n = n - 702
    h = n // (26**2)
    t = n // 26
    o = n % 26
    ans = a[h] + a[t] + a[o-1]
elif 18279 <= n <= 475254:
    n = n - 18278
    th = n // (26**3)
    h = n // (26**2)
    t = n // 26
    o = n % 26
    ans = a[th] + a[h] + a[t] + a[o-1]
else:
    n = n - 475254
    tth = n// (26 ** 4)
    th = n // (26**3)
    h = n // (26**2)
    t = n // 26
    o = n % 26
    ans = a[tth] + a[th] + a[h] + a[t] + a[o-1]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a =  ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']


if 1 <= n <= 26:
    ans = a[n-1]
elif 27 <= n <= 702:
    n = n - 26
    t = n / 26
    o = n % 26
    ans = a[t-1] + a[o-1]
elif 703 <= n <= 18278:
    n = n - 702
    h = n / (26**2)
    t = n / 26
    o = n % 26
    ans = a[h-1] + a[t-1] + a[o-1]
elif 18279 <= n <= 475254:
    n = n - 18278
    th = n /(26**3)
    h = n / (26**2)
    t = n / 26
    o = n % 26
    ans = a[th-1] + a[h-1] + a[t-1] + a[o-1]
else:
    n = n - 475254
    tth = n/ (26 ** 4)
    th = n / (26**3)
    h = n / (26**2)
    t = n / 26
    o = n % 26
    ans = a[tth-1] + a[th-1] + a[h-1] + a[t-1] + a[o-1]

print(ans)