Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X = int(input())
c = 0
for i in range(100):
    for j in range(100):
        if i**5-j**5==X:
            a = i
            b = j
            c += 1
            break
    if c ==0:
        for j in range(100):
            if i**5+j**5==X:
            a = i
            b = j
            break
print(a b)            

Fixed submission:
X = int(input())
c = 0
for i in range(-200,200):
    for j in range(-200,200):
        if i**5-j**5==X:
            a = i
            b = j
            print(a, b)    
            c = 1
            break
    if c != 0:
        break

Buggy python submission (verdict: Runtime Error):
X = int(input())
c = 0
for i in range(100):
    for j in range(100):
        if i**5-j**5==X:
            a = i
            b = j
            c += 1
            break
    if c ==0:
        for j in range(100):
            if i**5+j**5==X:
            a = i
            b = j
            break
print(a,b)         

Fixed submission:
X = int(input())
c = 0
for i in range(-200,200):
    for j in range(-200,200):
        if i**5-j**5==X:
            a = i
            b = j
            print(a, b)    
            c = 1
            break
    if c != 0:
        break

Buggy python submission (verdict: Runtime Error):
X = int(input())

for i in range(100):
    for j in range(100):
        if i**5-j**5==X:
            a = i
            b = j
            break
print(a,b)           

Fixed submission:
X = int(input())
c = 0
for i in range(-200,200):
    for j in range(-200,200):
        if i**5-j**5==X:
            a = i
            b = j
            print(a, b)    
            c = 1
            break
    if c != 0:
        break
Buggy python submission (verdict: Runtime Error):
def main():
  a=int(input())
  b=int(input())
  c=6-a-b
  print(c)
  
 if __name__ == ′__main__′:
  main()
  
  

Fixed submission:
def main():
  A = int(input())
  B = int(input())
  C = 6-A-B
  print('{}'.format(C))


if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  S = input()
  day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
  count = 7
  for i in day:
    if S == i:
        print(count)
    i -= 1

if __name__ == '__main__':
  main()


Fixed submission:
def main():
  S = input()
  day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
  count = 7
  for i in day:
    if S == i:
        print(count)
    count -= 1

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  s = list(input())
  divide = []
  compare = 0
  for i in range(len(s)):
    if s[i] == compare :
      s[i+1] = s[i] + s[i+1]
    else:
      compare = s[i]
      divide.append(s[i])
  print(len(divide))


if __name__ == '__main__':
  main()


Fixed submission:
def main():
  s = list(input())
  divide = []
  compare = 0
  for i in range(len(s)):
    if s[i] == compare and i != len(s)-1:
      s[i+1] = s[i] + s[i+1]
    elif s[i] == compare:
      break
    else:
      compare = s[i]
      divide.append(s[i])
      # print(divide)
  print(len(divide))


if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  s = list(input())
  divide = [1]
  for i in range(len(s)):
    if s[i] == divide[-1] :
      s[i+1] = s[i] + s[i+1]
    else:
      divide.append(s[i])
  print(len(divide)-1)


if __name__ == '__main__':
  main()


Fixed submission:
def main():
  s = list(input())
  divide = []
  compare = 0
  for i in range(len(s)):
    if s[i] == compare and i != len(s)-1:
      s[i+1] = s[i] + s[i+1]
    elif s[i] == compare:
      break
    else:
      compare = s[i]
      divide.append(s[i])
      # print(divide)
  print(len(divide))


if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
    return sorted(numbers_array, key=abs)

    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0])

Fixed submission:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-150, 200))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
li = list(map(int, input().split()))

ans = np.prod(li)
print(ans) if ans <= 10**18) else print(-1)

Fixed submission:
x, y = map(int, input().split())

print(x*y)
Buggy python submission (verdict: Runtime Error):
def solve():
    a,b = input().split()

    for i in range(101):
        if i * i == int(f'{a}{b}'):
            print('Yes')
            return
    print('No')
solve()


Fixed submission:
def solve():
    a,b = input().split()

    for i in range(1000):
        if i * i == int('{}{}'.format(a,b)):
            print('Yes')
            return
    print('No')
solve()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = []
for i in range(n):
  s = str(input())
  if s not in list:
    list.append(s)
print(len(list))

Fixed submission:
import collections
n = int(input())
list = []
for i in range(n):
  s = str(input())
  list.append(s)
print(len(collections.Counter(list)))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
for i in range(k):
    h[n-i-1] = 0
print(sum(h))

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
if n <= k:
    print(0)
elif n > k:
    for i in range(k):
        h[n-i-1] = 0
    print(sum(h))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

n = int(input())
a_list = list(map(int, input().split()))

result = reduce(mul, a_list)
if result > 10**18:
    print(-1)
else:
    print(result)

Fixed submission:
from functools import reduce
from operator import mul

n = int(input())
a_list = list(map(int, input().split()))

if 0 in a_list:
    print(0)
    exit()

result = 1
for i in range(n):
    result *= a_list[i]
    if result > 10**18:
        print(-1)
        exit()
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))

routes = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    routes[a-1][b-1] = True
    routes[b-1][a-1] = True

cnt_nice = 0
for i in range(len(H)):
    is_highest = True
    for j in range(len(H)):
        if routes[i][j] and H[j] >= H[i]:
            is_highest = False
            break
    if is_highest:
        cnt_nice = cnt_nice + 1
print(cnt_nice)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
highest = [True for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    if H[a] == H[b]:
        highest[a] = False
        highest[b] = False
    elif H[a] > H[b]:
        highest[b] = False
    else:
        highest[a] = False
print(len([h for h in highest if h]))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

expected_list = [(x+1)/2 for x in p_list]

maximum = 0
for i in range(n-(k-1)):
    maximum = max(maximum, sum(expected_list[i:i+k]))
print(maximum)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

expected_list = [(x+1)/2 for x in p_list]

partsum = sum(expected_list[0:k])
maximum = partsum
for i in range(1, n-(k-1)):
    partsum = partsum + expected_list[i+k-1] - expected_list[i-1]
    maximum = max(maximum, partsum)
print(maximum)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

expected_list = [sum(range(1, x+1))/x for x in p_list]

maximum = 0
for i in range(n-(k-1)):
    maximum = max(maximum, sum(expected_list[i:i+k]))
print(maximum)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

expected_list = [(x+1)/2 for x in p_list]

partsum = sum(expected_list[0:k])
maximum = partsum
for i in range(1, n-(k-1)):
    partsum = partsum + expected_list[i+k-1] - expected_list[i-1]
    maximum = max(maximum, partsum)
print(maximum)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
h = list(map(int, input().split()))

dp = [math.inf] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    one = abs(h[i] - h[i-1]) + dp[i-1]
    two = abs(h[i] - h[i-2]) + dp[i-2]
    dp[i] = min(one, two)
print(dp[n-1])

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

dp = [float("inf")] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    one = abs(h[i] - h[i-1]) + dp[i-1]
    two = abs(h[i] - h[i-2]) + dp[i-2]
    dp[i] = min(one, two)
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, start+i, start_gendar)
    return (start+i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

if __name__ == "__main__":
    main()

Fixed submission:
MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, start+i, start_gendar)
    return (start+i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, i, start_gendar)
    return (i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

if __name__ == "__main__":
    main()

Fixed submission:
MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, start+i, start_gendar)
    return (start+i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
X,Y = map(int,input().split())

while True:
    if Y % 2 == 1:
        print('No')
        break
    elif 2*X >= Y:
        print('No')
    elif 4*X >= Y:
        print('Yes')
        break
    
    else:
        print('No')
        break

Fixed submission:
X,Y = map(int,input().split())

if Y%2 != 0:
    print('No')
elif X*2 > Y:
    print('No')
elif X*4 >= Y:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s=input()
t=s
s_list=list(s)
for i in range(len(t)):
    if t[i]=='?':
        
        if t[i-1]=='D':
            if i==len(t):
                s_list[i]='D'
            if t[i+1]=='P':
                s_list[i]='D'
            else:
                s_list[i]='P'
          
        else:
            s_list[i]='D'
    
s_cha="".join(s_list)            
print(s_cha)            


Fixed submission:
s=input()
t=s
s_list=list(s)
for i in range(len(t)):
    if s_list[i]=='?':
        
        
        if s_list[i-1]=='D':
            if i==len(t)-1:
                s_list[i]='D'
            elif s_list[i+1]=='P':
                s_list[i]='D'
            elif s_list[i+1]=='D':
                s_list[i]='P'
            else:
                s_list[i]='P'
          
        else:
            s_list[i]='D'
    
s_cha="".join(s_list)            
print(s_cha)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int,input().split()))
cnt = 1
for i in a:
    cnt *= i
if cnt > 10 **18:
    print(-1)
else:
    print(cnt)

Fixed submission:
n = input()
a = list(map(int,input().split()))
b = set(a)
if 0 in b:
    print(0)
else:
    cnt = 1
    for i in a:
        cnt *= i
        if cnt > 10 ** 18:
            break
    if cnt > 10**18:
        print(-1)
    else:
        print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = [-1] + [int(i) for i in input().split()]
i = 1
tele = 1
telelist = [1]
while not A[i] in telelist:
    telelist.append(A[i])
    i = A[i]

k = 0
for s in telelist:
    if s == A[i]:
        break
    k += 1
if K<=k:
    print(telelist[K])
else:
    l = len(telelist)-k
    K -= k
    s = K%l
    print(telelist[k+s])

Fixed submission:
N,K = map(int,input().split())
A = [-1] + [int(i) for i in input().split()]
deta = [False for i in range(N+1)]
i = 1
tele = 1
telelist = [1]
while not deta[A[i]]:
    telelist.append(A[i])
    deta[A[i]] = True
    i = A[i]

k = 0
for s in telelist:
    if s == A[i]:
        break
    k += 1
if K<=k:
    print(telelist[K])
else:
    l = len(telelist)-k
    K -= k
    s = K%l
    print(telelist[k+s])
Buggy python submission (verdict: Runtime Error):
from math import gcd
A,B = map(int,input().split())
print(A*B//gcd(A,B))

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
print(A*B//gcd(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
A = prime_factorize(N)
L = []
for i in range(1<<len(A)):
    tmp = 1
    j = bin(i)[2:]
    leng = len(j)
    for k in range(leng):
        if j[leng-k-1]=="1":
            tmp *= A[k]
    L.append(tmp)
    
ans = []
for i in L:
    j = N//i
    ans.append(i+j-2)
    
print(min(ans))

Fixed submission:
N = int(input())
ans = []
for i in range(1,int(pow(N,0.5))+1):
    j = N//i
    if i*j == N:
        ans.append(i+j)

print(min(ans)-2)

Buggy python submission (verdict: Runtime Error):
import sympy as sp
import heapq as hq
N = int(input())
A = sp.factorint(N)
B = []
hq.heapify(B)
for i,j in A.items():
    while j != 0:
        hq.heappush(B,i)
        j -= 1
leng = len(B)
if leng == 1:
    print(B[0]-1)
    exit()

while leng > 2:
    a = hq.heappop(B)
    b = hq.heappop(B)
    hq.heappush(B,a*b)
    leng -= 1
print(sum(B)-2)

Fixed submission:
N = int(input())
ans = []
for i in range(1,int(pow(N,0.5))+1):
    j = N//i
    if i*j == N:
        ans.append(i+j)

print(min(ans)-2)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,L = map(int,input().split())
abc = [[int(i) for i in input().split()] for j in range(M)]
Q = int(input())
INF = 1<<30
Path = [[INF for i in range(N)] for j in range(N)]
AnsPath = [[INF for i in range(N)] for j in range(N)]

def PathInit():
    for i in range(N):
        Path[i][i] = 0

def wasialFloid(Path):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                Path[i][j] = min(Path[i][j],Path[i][k]+Path[k][j])

PathInit()
for i,j,k in abc:
    Path[i-1][j-1] = k
    #双方向

    Path[j-1][i-1] = k
wasialFloid(Path)
for i in range(N):
    for j in range(N):
        if Path[i][j] <= L:
            AnsPath[i][j] = 1
wasialFloid(AnsPath)
for i in range(Q):
    s,t = map(int,input().split())
    if AnsPath[s-1][t-1] == INF:
        print(-1)
    else:
        print(AnsPath[s-1][t-1]-1)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall

N,M,L = map(int,input().split())
abc = [[int(i) for i in input().split()] for j in range(M)]
Q = int(input())
st = [[int(i) for i in input().split()] for j in range(Q)]
INF = 1<<30
Path = [[INF for i in range(N)] for j in range(N)]
AnsPath = [[INF for i in range(N)] for j in range(N)]

def PathInit():
    for i in range(N):
        Path[i][i] = 0

PathInit()
for i,j,k in abc:
    Path[i-1][j-1] = k
    #双方向
    Path[j-1][i-1] = k

Path = floyd_warshall(Path)

for i in range(N):
    for j in range(N):
        if Path[i][j] <= L:
            AnsPath[i][j] = 1
AnsPath = floyd_warshall(AnsPath)
for s,t in st:
    if AnsPath[s-1][t-1] == INF:
        print(-1)
    else:
        print(int(AnsPath[s-1][t-1]-1))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
INF = 10**9+7
s = A[0]
A = set(A)

ans = [0]*(N+1)
ans[0] = 1
if s == 1:
    ans[1] = 0
else:
    ans[1] = 1


for i in range(2,N+1):
    if i in A:
        ans[i] = 0
    else:
        ans[i] = ans[i-1] + ans[i-2]
        ans[i] %= INF
        
print(ans[-1])

Fixed submission:
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
INF = 10**9+7
ans = [0]*(N+1)
ans[1] = 1
if M != 0:
    s = A[0]
    if s == 1:
        ans[1] = 0
A = set(A)
ans[0] = 1

for i in range(2,N+1):
    if i in A:
        ans[i] = 0
    else:
        ans[i] = ans[i-1] + ans[i-2]
        ans[i] %= INF
        
print(ans[-1])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
bosu = [1]*N
for i in range(1:N+1):
    point = i
    while i < K:
        point *= 2
        bosu[i-1] *= 2

print(N/sum(bosu))


Fixed submission:
N,K = map(int,input().split())
bosu = [N]*N
for i in range(1,N+1):
    point = i
    while point < K:
        point *= 2
        bosu[i-1] *= 2
        
ans = 0
for i in bosu:
    ans += 1/i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*5
for i in range(5):
    A[i]=int(input())
ans=0
B=[0]*6
B[0]=N
while B[5]<N:
    ans+=1
    for i in range(4,-1,-1):
        if B[i]>=A[i]:
            B[i+1]+=A[i]
            B[i]-=A[i]
        elif B[i]!=0:
            B[i+1]+=B[i]
            B[i]=0
print(ans)

Fixed submission:
N = int(input())
A,B,C,D,E = map(int,[input() for i in range(5)])
ans = 0
def mymax(s):
    res = N//s
    if N%s==0:
        return res
    else:
        return res+1

k = max(mymax(A),mymax(B),mymax(C),mymax(D),mymax(E))
print(k+4)
Buggy python submission (verdict: Time Limit Exceeded):
input_num=input().split(" ")
input_str=list(input())
anslen=[]
for i in range(int(input_num[1])):
  divpoint=input().split(" ")
  k=''.join(input_str[int(divpoint[0])-1:int(divpoint[1])])
  anslen.append(k.count("AC"))
for i in range(int(input_num[1])):
  print(anslen[i])


Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  start,end=map(int,input().split())
  print(t[end-1]-t[start-1])

Buggy python submission (verdict: Runtime Error):
input_num=list(input())
input_str=list(input())
anslen=[]
for i in range(input_num[1]):
  divpoint=list(input())
  k=''.join(input_str[divpoint[0]:divpoint[1]])
  anslen.append(k.count("AC"))
for i in range(input_num[1]):
  print(anslen[i])


Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  start,end=map(int,input().split())
  print(t[end-1]-t[start-1])

Buggy python submission (verdict: Runtime Error):
input_num=(input().split())
input_str=input().split()
anslen=[]
for i in range(input_num[1]):
  divpoint=(input().split())
  k=''.join(input_str[divpoint[0]:divpoint[1]])
  anslen.append(k.count("AC"))
for i in range(input_num[1]):
  print(anslen[i])


Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  start,end=map(int,input().split())
  print(t[end-1]-t[start-1])

Buggy python submission (verdict: Runtime Error):
input_num=(input().split())
input_str=input()
anslen=[]
for i in range(input_num[1]):
  divpoint=(input().split())
  k=input_str[divpoint[0]:divpoint[1]+1]
  anslen.append(k.count("AC"))
for i in range(input_num[1]):
  print(anslen[i])

Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  start,end=map(int,input().split())
  print(t[end-1]-t[start-1])
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
A=len(S)
for i in range(int(A/2)):
    S=S.replace("01","").replace("10","")
print(A-len(S))

Fixed submission:
S=input()
a_sum=0
b_sum=0
for i in range(len(S)):
    if S[i]=="1":
        b_sum+=1
    else:
        a_sum+=1
print(2*min(a_sum,b_sum))
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
i = 0
while S[i] == "1":
    i += 1
if K-1 < i:
    print(1)
else:
    print(int(S[i]))

Fixed submission:
S = input()
K = int(input())
i = 0
leng = len(S)
while S[i] == "1":
    i += 1
    if i >= leng:
        break
if K-1 < i:
    print(1)
else:
    print(int(S[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def Luca(x):
    if x==0:
        return 2
    elif x==1:
        return 1
    else:
        return Luca(x-1)+Luca(x-2)

print(Luca(N))

Fixed submission:
N = int(input())

def Luca(k,x,y):
    if k == N:
        return y
    else:
        return Luca(k+1,y,x+y)

print(Luca(1,2,1))
Buggy python submission (verdict: Runtime Error):
O = input()
E = input()
length = len(O)*2
ans = [""]*length

for i in range(length):
    if i%2 == 0:
        ans[i] = O[i//2]
    else:
        ans[i] = E[i//2]
        
ans = "".join(ans)
print(ans)

Fixed submission:
O = input()
E = input()
length = len(O)+len(E)
ans = [""]*length

for i in range(length):
    if i%2 == 0:
        ans[i] = O[i//2]
    else:
        ans[i] = E[i//2]
        
ans = "".join(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
X, N=map(int,input().split())
ps=map(int,input().split())

ps_sort=sorted(ps)

ind_crit=N-1
for p in ps_sort:
  if p>=X:
    ind_crit=ps_sort.index(p)
    break
    
if not ps_sort[ind_crit]==X:
  ans=X
else:
  diff=0
  while(True):
    diff+=1
    if not X-diff in ps_sort:
      ans=X-diff
      break
    if not X+diff in ps_sort:
      ans=X+diff
      break

print(ans)


Fixed submission:
import numpy as np
X, N=map(int,input().split())
if N==0:
  ans=X
  print(ans)
else:
  ps=map(int,input().split())

  ps_sort=sorted(ps)

  ind_crit=N-1
  for p in ps_sort:
    if p>=X:
      ind_crit=ps_sort.index(p)
      break

  if not ps_sort[ind_crit]==X:
    ans=X
  else:
    diff=0
    while(True):
      diff+=1
      if not X-diff in ps_sort:
        ans=X-diff
        break
      if not X+diff in ps_sort:
        ans=X+diff
        break

  print(ans)