Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:

    a, b, c = map(int, raw_input().split())
    if(a | b | c == 0):break

    i = 0
    canArrive = False
    now = 0
    while True:
        if now <= c and c <= now + b:
            canArrive = True
            break
    
        now += (a + b)
        now %= 60

        if now == 0 : break

        i += 1

    if canArrive:
        print c + 60 * i
    else:
        print -1

Fixed submission:

a, b, c = map(int, raw_input().split())

#if(a | b | c == 0):break

canArrive = False
i = 0
now = 0
while True:
    if now % 60 <= c and c <= now % 60 + a:
        canArrive = True
        break
    #end if
    now += (a + b)
    if now % 60 == 0 : break
#end while
if canArrive:
    print c + 60 * (now // 60)
else:
    print -1
    #end if

#end while

Buggy python submission (verdict: Time Limit Exceeded):

a, b, c = map(int, raw_input().split())

#if(a | b | c == 0):break

canArrive = False
i = 0
now = 0
while True:
    if now % 60 <= c and c <= (now + a) % 60:
        canArrive = True
        break
    #end if
    now += (a + b)
#end while
if canArrive:
    print c + 60 * (now // 60)
else:
    print -1
    #end if

#end while

Fixed submission:

a, b, c = map(int, raw_input().split())

#if(a | b | c == 0):break

canArrive = False
i = 0
now = 0
while True:
    if now % 60 <= c and c <= now % 60 + a:
        canArrive = True
        break
    #end if
    now += (a + b)
    if now % 60 == 0 : break
#end while
if canArrive:
    print c + 60 * (now // 60)
else:
    print -1
    #end if

#end while
Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N == 0: break
    W,H = map(int,input().split())
    fld = [[0 for w in range(W)] for h in range(H)]
    for i in range(N):
        x,y = map(lambda s:int(s)-1,raw_input().split())
        fld[y][x] = 1
    cums = [[0 for w in range(W+1)] for h in range(H+1)]
    for y in range(H):
        for x in range(W):
            cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]
    S,T = map(int,input().split())
    ans = 0
    for y in range(H-T+1):
        for x in range(W-S+1):
            ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])
    print(ans)

Fixed submission:
while True:
    N = int(input())
    if N == 0: break
    W,H = map(int,input().split())
    fld = [[0 for w in range(W)] for h in range(H)]
    for i in range(N):
        x,y = map(lambda s:int(s)-1,input().split())
        fld[y][x] = 1
    cums = [[0 for w in range(W+1)] for h in range(H+1)]
    for y in range(H):
        for x in range(W):
            cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]
    S,T = map(int,input().split())
    ans = 0
    for y in range(H-T+1):
        for x in range(W-S+1):
            ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])
    print(ans)

Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N == 0: break
    W,H = map(int,input().split())
    fld = [[0 for w in range(W)] for h in range(H)]
    for i in range(N):
        x,y = map(lambda s:int(s)-1,raw_input().split())
        fld[y][x] = 1
    cums = [[0 for w in range(W+1)] for h in range(H+1)]
    for y in range(H):
        for x in range(W):
            cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]
    S,T = map(int,input().split())
    ans = 0
    for y in range(H-T+1):
        for x in range(W-S+1):
            ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])
    print(ans)

Fixed submission:
while True:
    N = int(input())
    if N == 0: break
    W,H = map(int,input().split())
    fld = [[0 for w in range(W)] for h in range(H)]
    for i in range(N):
        x,y = map(lambda s:int(s)-1,input().split())
        fld[y][x] = 1
    cums = [[0 for w in range(W+1)] for h in range(H+1)]
    for y in range(H):
        for x in range(W):
            cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]
    S,T = map(int,input().split())
    ans = 0
    for y in range(H-T+1):
        for x in range(W-S+1):
            ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def factors(n):
    sieve = [1]*(n+10)
    m = 1
    while m*7-1 <= n:
        for p in [m*7-1,m*7+1]:
            if sieve[p] == 0: continue
            for pp in range(2*p,n+1,p):
                sieve[pp] = 0
        m += 1
    ret = []
    m = 1
    while m*7-1 <= n:
        for p in [m*7-1,m*7+1]:
            if sieve[p] and n % p == 0:
                ret.append(p)
        m += 1
    return(ret)

while True:
    N = int(input())
    if N == 1: break
    ans = ' '.join(list(map(str,factors(N))))
    print('{0}: {1}'.format(N,ans))

Fixed submission:
MAXN = 300010
sieve = [1]* MAXN
primes = []
for n in range(7,MAXN,7):
    for m in [n-1,n+1]:
        if sieve[m] == 0: continue
        primes.append(m)
        for l in range(2*m,MAXN,m):
            sieve[l] = 0

def solve(n):
    ret = []
    for p in primes:
        if p > n: break
        if n%p == 0:
            ret.append(p)
    return ret

while True:
    N = int(input())
    if N == 1: break
    ans = ' '.join(list(map(str,solve(N))))
    print('{0}: {1}'.format(N,ans))

Buggy python submission (verdict: Time Limit Exceeded):
def factors(n):
    sieve = [1]*(n+10)
    ret = []
    m = 1
    while m*7-1 <= n:
        for p in [m*7-1,m*7+1]:
            if sieve[p] == 0: continue
            if n%p == 0:
                ret.append(p)
            for pp in range(2*p,n+1,p):
                sieve[pp] = 0
        m += 1
    return(ret)

while True:
    N = int(input())
    if N == 1: break
    ans = ' '.join(list(map(str,factors(N))))
    print('{0}: {1}'.format(N,ans))

Fixed submission:
MAXN = 300010
sieve = [1]* MAXN
primes = []
for n in range(7,MAXN,7):
    for m in [n-1,n+1]:
        if sieve[m] == 0: continue
        primes.append(m)
        for l in range(2*m,MAXN,m):
            sieve[l] = 0

def solve(n):
    ret = []
    for p in primes:
        if p > n: break
        if n%p == 0:
            ret.append(p)
    return ret

while True:
    N = int(input())
    if N == 1: break
    ans = ' '.join(list(map(str,solve(N))))
    print('{0}: {1}'.format(N,ans))
Buggy python submission (verdict: Runtime Error):
import math
LIM = 182

def solve(n):
    ans = 0
    for a in range(1,LIM):
        tmp = a*a
        if tmp == n:
            ans += 1
        if tmp >= n:
            break
        for b in range(a,LIM):
            tmp2 = tmp + b*b
            if tmp2 == n:
                ans += 1
            if tmp2 >= n:
                break
            for c in range(b,LIM):
                tmp3 = tmp2 + c*c
                if tmp3 == n:
                    ans += 1
                if tmp3 >= n:
                    break
                d = int(math.sqrt(n - tmp3))
                if tmp3 + d*d == n and c <= d:
                    ans += 1
    return ans

while True:
    N = int(input())
    if N == 0: break
    print(solve(N))

Fixed submission:
MAXN = 2**15
MAXRT = int(MAXN**0.5)
MAXTERM = 4

dp = [[0 for n in range(MAXN+1)] for t in range(MAXTERM+1)]
dp[0][0] = 1
for r in range(MAXRT,0,-1):
    for t in range(MAXTERM):
        for n in range(MAXN+1 - r*r):
            if dp[t][n] == 0: continue
            dp[t+1][n + r*r] += dp[t][n]

while True:
    N = int(input())
    if N == 0: break
    print(sum(map(lambda x:x[N],dp)))

Buggy python submission (verdict: Runtime Error):
import math
LIM = 182

def is_square(n):
    a = int(math.sqrt(n))
    return a*a == n

def solve(n):
    ans = 0
    if is_square(n):
        ans += 1
    for a in range(1,LIM):
        if a*a*2 > n:
            break
        if is_square(n - a*a):
            ans += 1
        for b in range(a,LIM):
            if b*b*2 > (n - a*a):
                break
            if is_square(n - a*a - b*b):
                ans += 1
            for c in range(b,LIM):
                if c*c*2 > (n - a*a - b*b):
                    break
                tmp = n - a*a - b*b - c*c
                if is_square(tmp) and c*c <= tmp:
                    ans += 1
    return ans

while True:
    N = int(input())
    if N == 0: break
    print(solve(N))

Fixed submission:
MAXN = 2**15
MAXRT = int(MAXN**0.5)
MAXTERM = 4

dp = [[0 for n in range(MAXN+1)] for t in range(MAXTERM+1)]
dp[0][0] = 1
for r in range(MAXRT,0,-1):
    for t in range(MAXTERM):
        for n in range(MAXN+1 - r*r):
            if dp[t][n] == 0: continue
            dp[t+1][n + r*r] += dp[t][n]

while True:
    N = int(input())
    if N == 0: break
    print(sum(map(lambda x:x[N],dp)))
Buggy python submission (verdict: Runtime Error):
while True:
    N,W = map(int,input().split())
    if N == 0: break
    src = [int(input()) for i in range(N)]
    highest = max(src)
    bands = highest//W + 1
    hist = [0 for i in range(bands)]
    for i in range(N):
        hist[src[i] // W] += 1
    ans = maxn = 0
    for i,n in enumerate(hist):
        ans += n * (bands-1-i)
        maxn = max(n, maxn)
    print(ans * / maxn / (bands-1) + 0.01)

Fixed submission:
while True:
    N,W = map(int,input().split())
    if N == 0: break
    src = [int(input()) for i in range(N)]
    highest = max(src)
    bands = highest//W + 1
    hist = [0 for i in range(bands)]
    for i in range(N):
        hist[src[i] // W] += 1
    ans = maxn = 0
    for i,n in enumerate(hist):
        ans += n * (bands-1-i)
        maxn = max(n, maxn)
    print(ans / maxn / (bands-1) + 0.01)
Buggy python submission (verdict: Runtime Error):
N,M,A = map(int,input().split())
amd = [{} for i in range(1001)]
for i in range(M):
    h,p,q = map(int,input().split())
    amd[h][p] = q
    amd[h][q] = p
raw_input() #ignore

now = A
for d in reversed(amd):
    if now in d:
        now = d[now]
print(now)

Fixed submission:
while True:
    N,M,A = map(int,input().split())
    if N == 0: break
    amd = [{} for i in range(1001)]
    for i in range(M):
        h,p,q = map(int,input().split())
        amd[h][p] = q
        amd[h][q] = p

    now = A
    for d in reversed(amd):
        if now in d:
            now = d[now]
    print(now)
Buggy python submission (verdict: Runtime Error):
def ok(m,e):
    for x in range(m+1):
        for y in range(m+1-x):
            z = m-x-y
            if z < 0: break
            if x + y**2 + z**3 == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Fixed submission:
import math
while True:
    E = int(input())
    if E == 0: break
    ans = 10**10
    z = 0
    while z**3 <= E:
        y = int(math.sqrt(E - z**3))
        x = E - z**3 - y**2
        ans = min(x+y+z, ans)
        z += 1
    print(ans)

Buggy python submission (verdict: Runtime Error):
def ok(m,e):
    for z in range(m+1):
        if z**3 > e: return False
        for y in range(m-z+1):
            x = m-z-y
            if x + y**2 + z**3 == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Fixed submission:
import math
while True:
    E = int(input())
    if E == 0: break
    ans = 10**10
    z = 0
    while z**3 <= E:
        y = int(math.sqrt(E - z**3))
        x = E - z**3 - y**2
        ans = min(x+y+z, ans)
        z += 1
    print(ans)

Buggy python submission (verdict: Runtime Error):
def ok(m,e):
    for z in range(m+1):
        if z**3 > e: return False
        for y in range(m-z+1):
            if z**3 + y**2 > e: break
            x = m-z-y
            if z**3 + y**2 + x == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Fixed submission:
import math
while True:
    E = int(input())
    if E == 0: break
    ans = 10**10
    z = 0
    while z**3 <= E:
        y = int(math.sqrt(E - z**3))
        x = E - z**3 - y**2
        ans = min(x+y+z, ans)
        z += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
N,M = map(int,input().split())
src = [tuple(map(float,input().split())) for i in range(N)]
if M <= 1:
    print(0)
    exit()
dists = [[None for j in range(N)] for i in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        l1,a1,b1 = src[i]
        l2,a2,b2 = src[j]
        dist = 0
        dist += (l1-l2)**2 + (a1-a2)**2 + (b1-b2)**2
        dists[i][j] = dists[j][i] = dist

ans = 0
for ptn in itertools.permutations(range(N),M):
    total = 0
    for i in range(M-1):
        for j in range(i+1,M):
            total += dists[ptn[i]][ptn[j]]
    ans = max(ans, total)
print(ans)

Fixed submission:
import itertools
N,M = map(int,input().split())
src = [tuple(map(float,input().split())) for i in range(N)]
if M <= 1:
    print(0)
    exit()
dists = [[None for j in range(N)] for i in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        l1,a1,b1 = src[i]
        l2,a2,b2 = src[j]
        dist = 0
        dist += (l1-l2)**2 + (a1-a2)**2 + (b1-b2)**2
        dists[i][j] = dists[j][i] = dist

ans = 0
for ptn in list(itertools.combinations(range(N),M)):
    total = 0
    for i in range(M-1):
        for j in range(i+1,M):
            total += dists[ptn[i]][ptn[j]]
    ans = max(ans, total)
print(ans)
Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N == 0:break
    flgs = [0 for i in range(N)]
    for i in range(N):
        src = map(int,input().split())
        for k in src[1:]:
            flgs[i] |= (1 << k)
    target = 0
    src = map(int,input().split())
    for k in src[1:]:
        target |= (1 << k)

    ans = -1
    for i in range(N):
        if (flgs[i] | target) == flgs[i]:
            if ans < 0:
                ans = i+1
            else:
                ans = -1
                break
    print(ans)

Fixed submission:
while True:
    N = int(input())
    if N == 0:break
    flgs = [0 for i in range(N)]
    for i in range(N):
        src = list(map(int,input().split()))
        for k in src[1:]:
            flgs[i] |= (1 << k)
    target = 0
    src = list(map(int,input().split()))
    for k in src[1:]:
        target |= (1 << k)

    ans = -1
    for i in range(N):
        if (flgs[i] | target) == flgs[i]:
            if ans < 0:
                ans = i+1
            else:
                ans = -1
                break
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
src = []
for i in range(N):
    k = int(input())
    s = input()
    src.append((s,[]))
    if i == 0: continue
    src[k-1][1].append(i)

def dfs(i,depth):
    s,ch = src[i]
    print('.'*depth + s)
    for c in ch:
        dfs(c,depth+1)

dfs(0,0)

Fixed submission:
import sys
sys.setrecursionlimit(1010)

N = int(input())
src = []
for i in range(N):
    k = int(input())
    s = input()
    src.append((s,[]))
    if i == 0: continue
    src[k-1][1].append(i)

def dfs(i,depth):
    s,ch = src[i]
    print('.'*depth + s)
    for c in ch:
        dfs(c,depth+1)

dfs(0,0)
Buggy python submission (verdict: Runtime Error):
def judge(s):
    si = 0
    for t in T:
        if t == s[si]:
            si += 1
            if si == len(s): return True
    return False

S,T = input(),input()
N = len(S)
print('Yes' if judge(S[::2]) or judge(S[1::2]) else 'No')

Fixed submission:
def judge(s):
    if len(s) == 0: return True
    si = 0
    for t in T:
        if t == s[si]:
            si += 1
            if si == len(s): return True
    return False

S,T = input(),input()
N = len(S)
print('Yes' if judge(S[::2]) or judge(S[1::2]) else 'No')
Buggy python submission (verdict: Runtime Error):
ID=0
def dfs(row,col):
    global ID
    if islands[row][col]==1:
        islandsID[row][col]==ID
        if row<11:
            dfs(row+1,col)
        if row>0:
            dfs(row-1,col)
        if col<11:
            dfs(row,col+1)
        if col>0:
            dfs(row,col-1)

while True:
    c=0
    islands=[]
    islandsID=[]
    for i in range(12):
        islands.append(list(map(int,input().split())))
    for _ in range(12):
        islandsID.append([0 for i in range(12)])
    
    for i in range(12):
        for j in range(12):
            if islands[i][j]==1 and islandsID[i][j]==0:
                ID+=1
            dfs(i,j)
    print(ID)
    try:
        c=input()
    except:
        break


Fixed submission:
while True:
    c=0
    islands=[]
    islandsID=[]
    ID=0

    def dfs(row,col):
        global ID
        if 0<=row<12 and 0<=col<12:
            if islands[row][col]==1 and islandsID[row][col]==0:
                islandsID[row][col]=ID
                for dr, dc in [[0,1],[1,0],[0,-1],[-1,0]]:
                    dfs(row+dr,col+dc)

    for i in range(12):
        islands.append(list(int(k) for k in input()))
    for _ in range(12):
        islandsID.append([0 for i in range(12)])

    for i in range(12):
        for j in range(12):
            if islands[i][j]==1 and islandsID[i][j]==0:
                ID+=1
                dfs(i,j)
    print(ID)
    try:
        c=input()
    except:
        break
Buggy python submission (verdict: Runtime Error):
import numpy as np
while True:
    N,M=map(int,input().split())
    if N==0 and M==0:
        break
    allCards=[]
    for i in range(N+M):
        allCards.append(int(input()))
                        
    Taro=np.array(allCards[:N])
    Hanako=np.array(allCards[N:])
    Tsum=np.sum(Taro)
    Hsum=np.sum(Hanako)
    diff=Tsum-Hsum
    tempsum=1e8
    Tchange=-1
    Hchange=-1
    for i in range(N):
        for j in range(M):
            tempdiff=(Taro[i]-Hanako[j])*2
            if diff==tempdiff:
                if(tempsum>Taro[i]+Hanako[j]):
                    tempsum=Taro[i]+Hanako[j]
                    Tchange=Taro[i]
                    Hchange=Hanako[j]
    if Tchange==-1:
        print(-1)
    else:
        print(Tchange,Hchange)

Fixed submission:
while True:
    N,M=map(int,input().split())
    if N==0 and M==0:
        break
    allCards=[]
    for i in range(N+M):
        allCards.append(int(input()))
                        
    Taro=allCards[:N]
    Hanako=allCards[N:]
    Tsum=sum(Taro)
    Hsum=sum(Hanako)
    diff=Tsum-Hsum
    tempsum=1e8
    Tchange=-1
    Hchange=-1
    for i in range(N):
        for j in range(M):
            tempdiff=(Taro[i]-Hanako[j])*2
            if diff==tempdiff:
                if(tempsum>Taro[i]+Hanako[j]):
                    tempsum=Taro[i]+Hanako[j]
                    Tchange=Taro[i]
                    Hchange=Hanako[j]
    if Tchange==-1:
        print(-1)
    else:
        print(Tchange,Hchange)
Buggy python submission (verdict: Runtime Error):
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1):
        temp=e-z**3
        for y in range(int(e**(1/2))+1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)


Fixed submission:
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)

Buggy python submission (verdict: Runtime Error):
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1,-1,-1):
        temp=e-z**3
        for y in range(int(e**(1/2))+1,-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)


Fixed submission:
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)

Buggy python submission (verdict: Runtime Error):
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1,-1,-1):
        temp=e-z**3
        for temp in range(int(e**(1/2))+1,-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)


Fixed submission:
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)

Buggy python submission (verdict: Runtime Error):
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3)),-1,-1):
        temp=e-z**3
        for y in range(int(temp**(1/2)),-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)


Fixed submission:
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)
Buggy python submission (verdict: Runtime Error):
while True:
    N,M,P=map(int,input().split())
    if N==M==P: break
    divSum=0
    for i in range(N):
        temp=int(input())
        divSum+=temp*100
        if i==M-1:
            numWin=temp
    divSum*=(100-P)/100
    if temp!=0:
        dividents=int(divSum/numWin)
    else: dividents=0
    print(dividents)


Fixed submission:
import math
while True:
    N,M,P=map(int,input().split())
    if N==M==P: break
    divSum=0
    for i in range(N):
        temp=int(input())
        divSum+=temp*100
        if i==M-1:
            numWin=temp
    divSum=int(divSum*(100-P)/100)
    if numWin!=0:
        dividents=math.floor(divSum/numWin)
    else: dividents=0
    print(dividents)
Buggy python submission (verdict: Runtime Error):
k = int(raw_input())


l,r = 0,k
while (r-l)>1:
	m = (l+r)/2
	if (m * (m + 1)) < k:
		l = m
	else:
		r = m

b = l

#print b
ad = k - (b * (b + 1))

d = ((ad - 1) % (b + 1)) + 1

#print ad,d
x = 2 * b + 1
y = 1
if (ad - d) > 0:
	x += 1
	
if d  <= (b + 1 + 1) / 2:
	dd = d * 2 - 1
else:
	dz = (b + 1 - d)
	dd = dz * 2 + 2

x -= (dd-1)
y += (dd-1)


def mul(a,b):
	res = [[0,0],[0,0]]
	p,q,r = 2,2,2
	for s in xrange(p):
		for t in xrange(q):
			res[s][t] = 0
			for u in xrange(r):
				y = a[s][u] * b[u][t]
				res[s][t] += y
	return res


def fib(x):
	bt = [[1,1],[1,0]]
	r = [[1,1],[1,0]]
	while x > 0:
		if x % 2 != 0:
			r = mul(r,bt)
		bt = mul(bt,bt)
		x /= 2
	
	return r[0][0]
	

#print x,y

ans = fib(x-1) * fib(y-1)
print ans

Fixed submission:
k = int(raw_input())


l,r = 0,k
while (r-l)>1:
	m = (l+r)/2
	if (m * (m + 1)) < k:
		l = m
	else:
		r = m

b = l

#print b
ad = k - (b * (b + 1))

d = ((ad - 1) % (b + 1)) + 1

#print ad,d
x = 2 * b + 1
y = 1
if (ad - d) > 0:
	x += 1
	
if d  <= (b + 1 + 1) / 2:
	dd = d * 2 - 1
else:
	dz = (b + 1 - d)
	dd = dz * 2 + 2

x -= (dd-1)
y += (dd-1)

mod = 1000000007

def mul(a,b):
	res = [[0,0],[0,0]]
	p,q,r = 2,2,2
	for s in xrange(p):
		for t in xrange(q):
			res[s][t] = 0
			for u in xrange(r):
				y = a[s][u] * b[u][t]
				res[s][t] += y
			res[s][t] %= mod
	return res


def fib(x):
	bt = [[1,1],[1,0]]
	r = [[1,1],[1,0]]
	while x > 0:
		if x % 2 != 0:
			r = mul(r,bt)
		bt = mul(bt,bt)
		x /= 2
	
	return r[0][0]
	

#print x,y

ans = fib(x-1) * fib(y-1)
ans %= mod
print ans
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=''.join([''.join(input().split())for i in range(n//19+1)])
i=0
while True:
 if d.find(str(i))==-1:
  print(i)
  exit() 
 i+=1

Fixed submission:
j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19>0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1