Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
p = list(map(int, input().split())) 


for i in range(1,N+1):
    a = X+i
    b = X-i
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break

if N==0:
    print(X)

Fixed submission:
li = list(map(int, input().split()))
for i in range(len(li)):
    if li[i]==0:
        print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 
 
for i in range(1,N+1):
    print(A.count(i))

Fixed submission:

N = int(input())
A = list(map(int, input().split())) 
l = [0] * N


for i in range(N-1):
    l[A[i]-1] += 1
for j in l:
    print(j)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 

for i in range(1,N+1):
    print(A.count(i))

Fixed submission:

N = int(input())
A = list(map(int, input().split())) 
l = [0] * N


for i in range(N-1):
    l[A[i]-1] += 1
for j in l:
    print(j)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
cnt =[0]*(n+1)
ans = 0

for i in range(1,n):
    m = (n-1)//i
    for j in range(1,m+1):
        cnt[i*j] += 1
        
for i in range(1,n+1):
    ans += cnt[i]
    
print(ans)

Fixed submission:
n = int(input())
cnt =[0]*(n+1)
ans = 0

for i in range(1,n):
    m = (n-1)//i
    for j in range(1,m+1):
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)

Fixed submission:
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
elif k%5 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        sub = val % k
        if sub == 0:
            ans = i
            break
        else:
            val = 10 * sub + 7
print(ans)

Fixed submission:
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
elif k%5 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)

Buggy python submission (verdict: Runtime Error):
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
else:
    for i in range(1,10**7+1):
        sub = val % k
        if sub == 0:
            ans = i
            break
        else:
            val = 10 * sub + 7
print(ans)

Fixed submission:
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
elif k%5 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = [0]*10001
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

Fixed submission:
import math

n = int(input())
a = [0]*100001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = [0]*10001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

Fixed submission:
import math

n = int(input())
a = [0]*100001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = [0]*10001
b = int(math.sqrt(n)) + 2
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

Fixed submission:
import math

n = int(input())
a = [0]*100001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
m = 1
k = a.index(“B”)
if k == 0:
    print("0")
else:
    for i in range(n):
        m = m * int(a[i])
        if m > 10**18:
        break
    if m > 10**18:
        print("-1")
    else:
        print(m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * int(a[i])
    if m == 0:
        break
    

if m > 10**18:
    print("-1")
else:
    print(m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * a[i]
    if m = 0:
        break
    

if m > 10**18:
    print("-1")
else:
    print(m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)
Buggy python submission (verdict: Runtime Error):
re = input().split())
a = int(re[0])
b = float(re[1]])
for i in range(10):
    if i <= b <i+1:
        c = int(i)
        d = int(100 * (b - i))
        break
    
e = a * c
f = a * d
g = f // 100
h = e + g
print(h)

Fixed submission:
re = input().split()
a = int(re[0])
b = re[1]

c = int(b[0])
d = int(b[2] + b[3])
e = a * c
f = a * d
g = f // 100
h = e + g
print(h)

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(float, input().split())
for i in range(1,11):
    if i <= b <i+1:
        c = int(i)
        d = b - i
        
e = int(a) * c
f = a * d
g = int(math.floor(f))
h = e + g
print(math.floor(h))

Fixed submission:
re = input().split()
a = int(re[0])
b = re[1]

c = int(b[0])
d = int(b[2] + b[3])
e = a * c
f = a * d
g = f // 100
h = e + g
print(h)

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(float, input().split())
for i in range(1,11):
    if i <= b <i+1:
        c = i
        d = b - i
        
e = a * c
f = a * d
g = math.floor(f)
h = e + g
print(math.floor(h))

Fixed submission:
re = input().split()
a = int(re[0])
b = re[1]

c = int(b[0])
d = int(b[2] + b[3])
e = a * c
f = a * d
g = f // 100
h = e + g
print(h)

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(float, input().split())
for i in range(1,11):
    if i <= b <i+1:
        c = i
        d = b - i
        
e = a * c
f = a * d
g = math.floor(f)
h = a + g
print(math.floor(h))

Fixed submission:
re = input().split()
a = int(re[0])
b = re[1]

c = int(b[0])
d = int(b[2] + b[3])
e = a * c
f = a * d
g = f // 100
h = e + g
print(h)
Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m = map(float, input().split())
rot = 5.5 * (60.0*h + m)
rad = ang * math.pi / 180
cal = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
ans = math.sqrt(cal)
print(ans)

Fixed submission:
import math
a,b,h,m = map(float, input().split())
rot = 5.5 * (60.0*h + m)
ang = rot%360
rad = ang * math.pi / 180
cal = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
ans = math.sqrt(cal)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K =  map(int,input().split())
l = list(map(int,input().split()))
score=[]
for i in range(K-1,N):
    tmp_score = 1
    for j in range(0,K):
        tmp_score *= l[i-j]
    score.append(tmp_score)
for i in range(len(score)-1):
    if score[i] < score[i+1]:
        print('Yes')
    else:
        print('No')


Fixed submission:
N,K =  map(int,input().split())
l = list(map(int,input().split()))
score=[]
for i in range(K,N):
    if l[i-K] < l[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def function (n):
    cnt = 0
    for x in range(1,n+1):
        for y in range(1,n+1):
            for z in range(1,n+1):
                if x**2 + y**2 +z**2 + x*y + y*z + z*x == n:
                    cnt += 1
    print(cnt)
for i in range(1,N+1):
    function(i)


Fixed submission:
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
    l.append(list(map(int,input().split())))
for i in range(Q):
    if l[i][0] in A:
        index_num = [n for n, v in enumerate(A) if v == l[i][0]]
        for j in index_num:
            A[j]=l[i][1]
    print(sum(A))


Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
    l.append(list(map(int,input().split())))
c = collections.Counter(A)
sum=sum(A)
for i in range(Q):
    if c[l[i][0]] == 0:
        print(sum)
        continue
    else:
        sum+=c[l[i][0]]*(l[i][1]-l[i][0])
        c[l[i][1]]+=c[l[i][0]]
        del c[l[i][0]]
        print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=list(map(int,input().split()))
v=1
for i in range(N):
    v*=l[i]
if v>10**18:
    print('-1')
else:
    print(v)


Fixed submission:
N=int(input())
l=list(map(int,input().split()))
v=1
if l.count(0)!=0:
    print('0')
else:
    for i in range(N):
        v*=l[i]
        if v>10**18:
            print('-1')
            exit()
    print(v)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
if N%K==0:
    print(0)
    exit()
else:
    while True:
        if N <= abs(N-K):
            print(N)
            break
        else:
            N=abs(N-K)


Fixed submission:
N,K=map(int,input().split())
print(min(N%K,-N%K))
Buggy python submission (verdict: Runtime Error):
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1])
print(t)


Fixed submission:
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1])
print(t)
'''
print('A+B={0},A-B={1},A*B={2},A/B={3}の中で最大の数{4}はです'.format(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1],t))
'''

Buggy python submission (verdict: Runtime Error):
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1])
print(t)
print('A+B={0},A-B={1},A*B={2},A/B={3}の中で最大の数{4}はです'.format(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1],t))


Fixed submission:
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1])
print(t)
'''
print('A+B={0},A-B={1},A*B={2},A/B={3}の中で最大の数{4}はです'.format(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1],t))
'''

Buggy python submission (verdict: Runtime Error):
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1])
print(t)
print('A+B={0},A-B={1},A*B={2},A/B={3}の中で最大の数{4}はです'.format(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1],t))


Fixed submission:
s = list(map(int,input().split()))
t = max(s[0]+s[1],s[0]-s[1],s[0]*s[1])
print(t)
'''
print('A+B={0},A-B={1},A*B={2},A/B={3}の中で最大の数{4}はです'.format(s[0]+s[1],s[0]-s[1],s[0]*s[1],s[0]/s[1],t))
'''
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def start_search(G):
    start=[]
    for i in range(H):
        for j in range(W):
            if G[i][j]=='#':
                start.append((i,j))
    return start
def bfs(G,visited,start):
    queue=deque(start)
    cnt=0
    for p,q in start:
        visited[p][q]=0
    while queue:
        tmp=len(queue)
        for _ in range(tmp):
            (y,x)=queue.popleft()
            for j,k in ([1,0],[0,1],[-1,0],[0,-1]):
                tmp_y,tmp_x = y+j,x+k
                if 0<=tmp_y<=H-1 and 0<=tmp_x<=W-1 and visited[tmp_y][tmp_x]==-1:
                    visited[tmp_y][tmp_x]=visited[y][x]+1
                    queue.append([tmp_y,tmp_x])
        cnt+=1
    return cnt-1
if __name__=="__main__":
    H,W = map(int,input().split())
    G=[input() for _ in range(H)]
    start=start_search(G)
    visited=[[-1]*W for _ in range(H)]
    print(bfs(G,visited,start))


Fixed submission:
from collections import deque
def start_search(G):
    start=[]
    for i in range(H):
        for j in range(W):
            if G[i][j]=='#':
                start.append((i,j))
    return start
def bfs(G,visited,start):
    queue=deque(start)
    cnt=0
    for p,q in start:
        visited[p][q]=0
    while queue:
        tmp=len(queue)
        for _ in range(tmp):
            (y,x)=queue.popleft()
            for j,k in ([1,0],[0,1],[-1,0],[0,-1]):
                tmp_y,tmp_x = y+j,x+k
                if 0<=tmp_y<=H-1 and 0<=tmp_x<=W-1 and visited[tmp_y][tmp_x]==-1:
                    visited[tmp_y][tmp_x]=visited[y][x]+1
                    queue.append([tmp_y,tmp_x])
        cnt+=1
    return cnt-1
if __name__=="__main__":
    H,W = map(int,input().split())
    G=[input() for _ in range(H)]
    start=start_search(G)
    visited=[[-1]*W for _ in range(H)]
    print(bfs(G,visited,start))
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
tmp = len(S)
frag = True
while frag == True and len(S) != 0:
    i = 0
    frag = False
    while i < len(S)-1 and frag == False :
        if S[i] != S[i+1] :
            del S[i]
            del S[i]
            frag = True
        else:
            i += 1
print(tmp - len(S))


Fixed submission:
S = list(input())
print(int(min(S.count('0'),S.count('1')))*2)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import itertools
def bfs(G,visited,sy,sx):
    queue=deque([[sy,sx]])
    visited[sy][sx]=0
    while queue:
        y,x=queue.popleft()
        if (y,x)== (H-1,W-1):
            return visited[y][x]
        for j,k in ([1,0],[0,1],[-1,0],[0,-1]):
            tmp_y,tmp_x = y+j,x+k
            if 0<=tmp_y<=H-1 and 0<=tmp_x<=W-1 and  G[tmp_y][tmp_x]!='#':
                if visited[tmp_y][tmp_x]==-1:
                    visited[tmp_y][tmp_x]=visited[y][x]+1
                    queue.append([tmp_y,tmp_x])
if __name__  =="__main__":
    H,W =map(int,input().split())
    G=[list(input()) for _ in range(H)]
    sy,sx =0,0
    dist=0
    tmp=0
    visited=[[-1]*W for _ in range(H)]
    dist=bfs(G,visited,sy,sx)
    print(list(itertools.chain.from_iterable(G)).count('.')-dist-1)


Fixed submission:
from collections import deque
import itertools
def bfs(G,visited,sy,sx):
    queue=deque([[sy,sx]])
    visited[sy][sx]=0
    while queue:
        y,x=queue.popleft()
        if (y,x)== (H-1,W-1):
            return visited[y][x]
        for j,k in ([1,0],[0,1],[-1,0],[0,-1]):
            tmp_y,tmp_x = y+j,x+k
            if 0<=tmp_y<=H-1 and 0<=tmp_x<=W-1 and  G[tmp_y][tmp_x]!='#':
                if visited[tmp_y][tmp_x]==-1:
                    visited[tmp_y][tmp_x]=visited[y][x]+1
                    queue.append([tmp_y,tmp_x])
    return -1
if __name__  =="__main__":
    H,W =map(int,input().split())
    G=[list(input()) for _ in range(H)]
    sy,sx =0,0
    dist=0
    visited=[[-1]*W for _ in range(H)]
    dist=bfs(G,visited,sy,sx)
    if dist==-1:
        print(-1)
    else:
        print(list(itertools.chain.from_iterable(G)).count('.')-dist-1)
Buggy python submission (verdict: Runtime Error):
S=list(input())
l=sorted(list(set(S)))
for i in range(97,97+26):
    if chr(i) !=l.pop(0):
        print(chr(i))
        break
    elif chr(i) == 'z':
        print('None')


Fixed submission:
S=list(input())
l=sorted(list(set(S)))
for (i,j) in zip(range(len(l)),range(97,97+26)):
    if chr(j) !=l[i]:
        print(chr(j))
        exit()
    elif chr(j) == 'z':
        print('None')
        exit()
print(chr(j+1))

Buggy python submission (verdict: Runtime Error):
S=list(input())
l=sorted(list(set(S)))
for i in range(97,97+26):
    if chr(i) !=l.pop(0):
        print(chr(i))
        break


Fixed submission:
S=list(input())
l=sorted(list(set(S)))
for (i,j) in zip(range(len(l)),range(97,97+26)):
    if chr(j) !=l[i]:
        print(chr(j))
        exit()
    elif chr(j) == 'z':
        print('None')
        exit()
print(chr(j+1))
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
l=[]
for i in range(2):
    l.append(input())
print('#'*(W+2))
for i in range(H):
    print('#'+l[i]+'#')
print('#'*(W+2))


Fixed submission:
H,W = map(int,input().split())
l=[]
for i in range(H):
    l.append(input())
print('#'*(W+2))
for i in range(H):
    print('#'+l[i]+'#')
print('#'*(W+2))
Buggy python submission (verdict: Runtime Error):
O=input()
E=input()
s=''
for i in range (len(O)):
    s+=O[i]+E[i]
print(s)


Fixed submission:
O=input()
E=input()
s=''
if len(O)==len(E):
    for i in range (len(O)):
        s+=O[i]+E[i]
else:
    for i in range (len(O)-1):
        s+=O[i]+E[i]
    s+=O[-1]
print(s)

Buggy python submission (verdict: Runtime Error):
O=input()
E=input()
for i in range (len(O)):
    s+=O[i]+E[i]
print(s)


Fixed submission:
O=input()
E=input()
s=''
if len(O)==len(E):
    for i in range (len(O)):
        s+=O[i]+E[i]
else:
    for i in range (len(O)-1):
        s+=O[i]+E[i]
    s+=O[-1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
power=1
for i in range(1,N+1):
    power=power*i
print(power%(10**9+7))


Fixed submission:
import math

N=int(input())
print(math.factorial(N)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for p in range(K+1):
    for q in range(K+1):
        for r in range(K+1):
            if p+q+r == S:
                count+=1
print(count)


Fixed submission:
K,S = map(int,input().split())
count = 0
for p in range(K+1):
    for q in range(K+1):
        if S-p-q>=0 and S-p-q <= K:
            count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
    if a%x==0 or a==0:
        print(int(b//x)-int(a//x)+1)
    else:
        print(int(b//x)-int(a//x))


#切り捨て除算！！！！！！！


Fixed submission:
a,b,x = map(int,input().split())
if a%x==0 or a==0:
    print((b//x)-(a//x)+1)
else:
    print((b//x)-(a//x))


#切り捨て除算！！！！！！！

Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
count=0
for i in range(a,b+1):
    if i%x==0:
        count+=1
print(count)


Fixed submission:
a,b,x = map(int,input().split())
if a%x==0 or a==0:
    print((b//x)-(a//x)+1)
else:
    print((b//x)-(a//x))


#切り捨て除算！！！！！！！
Buggy python submission (verdict: Runtime Error):
s_a=list(input())
s_b=list(input())
s_c=list(input())

tmp =''
tmp=s_a.pop(0)
while 1:
    if tmp=='a':
        if s_a:
            tmp=s_a.pop(0)
        else:
            print('A')
            break
    elif tmp=='b':
        if s_b:
            tmp=s_b.pop(0)
        else:
            print('B')
            break
    else tmp=='c':
        if s_c:
            tmp=s_c.pop(0)
        else:
            print('C')
            break


Fixed submission:
s_a=list(input())
s_b=list(input())
s_c=list(input())

tmp =''
tmp=s_a.pop(0)
while 1:
    if tmp=='a':
        if s_a:
            tmp=s_a.pop(0)
        else:
            print('A')
            break
    elif tmp=='b':
        if s_b:
            tmp=s_b.pop(0)
        else:
            print('B')
            break
    elif tmp=='c':
        if s_c:
            tmp=s_c.pop(0)
        else:
            print('C')
            break

Buggy python submission (verdict: Runtime Error):
s_a=list(input())
s_b=list(input())
s_c=list(input())

temp =''
temp=s_a.pop(0)
while 1:
    if temp=='a':
        if s_a:
            temp=s_a.pop(0)
        else:
            print('A')
            break
    elif temp=='b':
        if s_b:
            temp=s_b.pop(0)
        else:
            print('B')
            break
    elif temp=='c':
        if s_b:
            temp=s_c.pop(0)
        else:
            print('C')
            break


Fixed submission:
s_a=list(input())
s_b=list(input())
s_c=list(input())

tmp =''
tmp=s_a.pop(0)
while 1:
    if tmp=='a':
        if s_a:
            tmp=s_a.pop(0)
        else:
            print('A')
            break
    elif tmp=='b':
        if s_b:
            tmp=s_b.pop(0)
        else:
            print('B')
            break
    elif tmp=='c':
        if s_c:
            tmp=s_c.pop(0)
        else:
            print('C')
            break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
b = 0
c = 0
while a < n:
    a+=1
    b=0
    if a == n:
        break
    while a*b-n<0:
        b+=1
        if a*b-n>=0:
            break
        c+=1
print(c)

Fixed submission:
n = int(input())
a = 0
b = 0
c = 0
while a < n:
    a+=1
    if a == n:
        break
    if n%a == 0:
        c+= n//a - 1
    else:
        c+= n//a
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0,0)
start = 1
now = start
c = 0
flag = [0]*(n+1)
while c <= k and flag[now] == 0:
    #print(now)
    flag[now] = 1
    c+= 1
    now = a[now]
#print(c, now)
if c == k:
    print(now)
else:
    k-=c
    moto = now
    now = a[now]
    cc = 1
    while now != moto:
        now = a[now]
        cc+=1
    nokori = k % cc
    for i in range(nokori):
        now = a[now]
    print(now)


Fixed submission:
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0,0)
start = 1
now = start
c = 0
flag = [-1]*(n+1)
while c < k and flag[now] == -1:
    #print(now)
    flag[now] = c
    c+= 1
    now = a[now]
#print(c, now)
if c == k:
    print(now)
else:
    k-=c
    cc = c-flag[now]
    nokori = k % cc
    for i in range(nokori):
        now = a[now]
    print(now)
Buggy python submission (verdict: Runtime Error):
x = int(input())
l = []
for i in range(-100,100):
    l.append(i**5)
ans =[]
for i in l:
    for j in l:
        if i - j == x:
            ans.append([i,j])
i,j = ans[0][0],ans[0][1]
print(l.index(i)-100,l.index(j)-100)

Fixed submission:
x = int(input())
l = []
for i in range(-400,400):
    l.append(i**5)
ans =[]
for i in l:
    for j in l:
        if i - j == x:
            ans.append([i,j])
i,j = ans[0][0],ans[0][1]
print(l.index(i)-400,l.index(j)-400)