Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()

flg = "AC"

if s[0] != "A":
    flg ="WA"

if {"C"}  <= set(list(s)[2:-2]):
    pass
elif list(s)[2:-2].count("C") !=1
    flg = "WA" 
else:
    flg ="WA"

a = [chr(i) for i in range(97, 97+26)]
a.append("A")
a.append("C")
if  set(list(s)) <= set(a):
    pass
else:
    flg == "WA"
    
print(flg)


Fixed submission:
s = list(input())

a = [chr(i) for i in range(97, 97+26)]
A = [chr(i) for i in range(65, 65+26)]

flg = "AC"

if not s[0] == "A":
    flg = "WA"

if not s[2:-1].count("C") ==1:
    flg = "WA"

b = set(s)-set(["A","C"])

if not b<=set(a):
    flg = "WA"

print(flg)

Buggy python submission (verdict: Runtime Error):
s = input()

flg = "AC"

if s[0] != "A":
    flg ="WA"

if {"C"}  <= set(list(s)[2:-2]):
    pass
elif list(s)[2:-2].count("C") !=1
    flg = "WA" 
else:
    flg ="WA"

a = [chr(i) for i in range(97, 97+26)]
a.append("A")
a.append("C")
if  set(list(s)) <= set(a):
    pass
else:
    flg == "WA"
    
print(flg)


Fixed submission:
s = list(input())

a = [chr(i) for i in range(97, 97+26)]
A = [chr(i) for i in range(65, 65+26)]

flg = "AC"

if not s[0] == "A":
    flg = "WA"

if not s[2:-1].count("C") ==1:
    flg = "WA"

b = set(s)-set(["A","C"])

if not b<=set(a):
    flg = "WA"

print(flg)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x-i-1) for i,x in enumerate(input().split())]

if len(a)%2==1:
    md = a[len(a)//2]
    ans = 0
    for i in a:
        ans += abs(i-md)
    print(ans)
else:
    md1 = a[len(a)//2]
    md2 = a[len(a)//2]
    ans1 = 0
    ans2 = 0
    for i in a:
        ans1 += abs(i-md1)
        ans2 += abs(i-md2)
    print(min(ans1,ans2))

Fixed submission:
n = int(input())
a = [int(x)-i-1 for i,x in enumerate(input().split())]
a.sort()
if len(a)%2==1:
    md = a[len(a)//2]
    ans = 0
    for i in a:
        ans += abs(i-md)
    print(ans)
else:
    md1 = a[len(a)//2]
    md2 = a[len(a)//2-1]
    ans1 = 0
    ans2 = 0
    for i in a:
        ans1 += abs(i-md1)
        ans2 += abs(i-md2)
    print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a =[int(x) for x in input().split()]

def solve(n,i):
	if n%2!=0:
		return i
	else:
		return(n//2,i+1)

cnt = 0

for i in a:
	cnt +=solve(i,0)

print(cnt)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    while 1:
        if a[i]%2==0:
            a[i] = int(a[i]//2)
            cnt+=1
        else:
            break
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b,c,k =map(int,input().split())

if k==0:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(a-b)
elif k==1:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(b-a)
elif abs(a-b)==0:
    print(0)
else:
    if k>=100:
        print("Unfair")
    else:    
        m = int(2(2**(k-1)-(-1)**(k-1))/3)
        n = int((2**k-(-1)**k)/3)
        ans = (a-b)*(m-n)
        if abs(ans)>=10**18:
            print("Unfair")
        else:
            print(ans)        


Fixed submission:

if __name__ == "__main__":
    a,b,c,k = map(int,input().split())
    if k%2 == 0:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(a-b)
    else:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(b-a)

Buggy python submission (verdict: Runtime Error):
a,b,c,k =map(int,input().split())

if k==0:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(a-b)
elif k==1:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(b-a)
elif abs(a-b)==0:
    print("Unfair")
else:
    if k>=100:
        print("Unfair")
    else:    
        m = int(2(2**(k-1)-(-1)**(k-1))/3)
        n = int((2**k-(-1)**k)/3)
        ans = (a-b)*(m-n)
        if abs(ans)>=10**18:
            print("Unfair")
        else:
            print(ans)        


Fixed submission:

if __name__ == "__main__":
    a,b,c,k = map(int,input().split())
    if k%2 == 0:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(a-b)
    else:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(b-a)

Buggy python submission (verdict: Runtime Error):
a,b,c,k =map(int,input().split())

if k<=1:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(a-b)
elif k==1:
    if abs(a-b)>=10**18:
        print("Unfair")
    else:
        print(b-a)
else:
    m = int(2(2**(k-1)-(-1)**(k-1))/3)
    n = int((2**k-(-1)**k)/3)
    ans = (a-b)*(m-n)
    if abs(ans)>=10**18:
        print("Unfair")
    else:
        print(ans)        


Fixed submission:

if __name__ == "__main__":
    a,b,c,k = map(int,input().split())
    if k%2 == 0:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(a-b)
    else:
        if abs(a-b)>10**18:
            print("Unfair")
        else:
            print(b-a)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d:
    print('Yes')
else:
    print('No')

Fixed submission:

a,b,c,d = map(int,input().split())

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d:
	print('Yes')
else:
	print('No')

Fixed submission:

a,b,c,d = map(int,input().split())

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
abc = [input(x) for x in input().split()]
k = int(input())

m = max(abc)

for i in ragne(k):
    m  *= 2

print(sum(abc)+m-max(abc))


Fixed submission:
abc = [int(x) for x in input().split()]
k = int(input())

m = max(abc)

for i in range(k):
    m  *= 2

print(sum(abc)+m-max(abc))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))

for i in range(n):
    ls = x[:(i)] + x[(i+1):]
    ls.sort()
    print(ls[int(n/2-1)])

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
ls = sorted(x)
a = ls[int(n/2-1)]
b = ls[int(n/2)]


for i in range(n):
    if x[i] >=b:
        print(a)
        
    else:
        print(b)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

result = set()

for i in range(a,min(a+k,b+1)):
    result.add(i)
for j in arnge(max(a,b-k+1),b+1):
    result.add(j)

for k in sorted(list(result)):
    print(k)

Fixed submission:
a,b,k = map(int,input().split())

result = set()

for i in range(a,min(a+k,b+1)):
    result.add(i)
for j in range(max(a,b-k+1),b+1):
    result.add(j)

for k in sorted(list(result)):
    print(k)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 2*max_- sum(ls)
    print(int(cnt/2))


ls.pop(max_)
if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    print(int(cnt/2 +1))    
else:
    cnt = 2*max_- sum(ls) + 1
    print(int(cnt/2 +1))
print(cnt)
    

Fixed submission:
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 2*max_- sum(ls)
    print(int(cnt/2))


ls.pop(max_)
if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    print(int(cnt/2 +1))    
else:
    cnt = 2*max_- sum(ls) + 1
    print(int(cnt/2 +1))
print(cnt)
    

Fixed submission:
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]
ls.pop(max_)

if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    
else:
    cnt = 2*max_- sum(ls)
    
print(cnt)
    

Fixed submission:
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]

from collections import defaultdict

d = defaultdict(str)

for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1

cnt = 0
for k in d.values():
    if k > 0:
        cnt +=k

print(cnt)

Fixed submission:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(max(d.values()),0))
Buggy python submission (verdict: Runtime Error):
def main():
    X,Y = map(int,input())
    if X%Y==0:
        print(-1)
    else:
        for i in range(1,10**8):
            if (X*i)%Y != 0:
                print(X*i)
                exit()
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    X,Y = map(int,input().split())
    if X%Y==0:
        print(-1)
    else:
        for i in range(1,10**8):
            if (X*i)%Y != 0:
                print(X*i)
                exit()
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
b = int(input())
s= x-a
print(int(s-s*(b*(s//b)))

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
s= x-a
print(int(s-(b*(s//b))))
Buggy python submission (verdict: Time Limit Exceeded):
n,y = map(int,input().split())
from itertools import combinations_with_replacement

ls = list(combinations_with_replacement([1000,5000,10000],n))

flg =0
for i in ls:
    if sum(i)==y:
        print(i.count(10000),i.count(5000),i.count(1000))
        flg =1
        break

    else:
        pass

if flg ==1:
    pass
else:
    print("-1 -1 -1")

Fixed submission:
n,y = map(int,input().split())
flg=0

for i in range(n+1):
    for j in range(n-i+1):
        ans = 10000*i + 5000*j + 1000*(n-i-j)
        if  ans == y:
            print(i,j,n-i-j)
            flg = 1
            break
    else:
        continue
    break


if flg == 0:
    print("-1 -1 -1")
else:
    pass
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import sys
from math import ceil
input = sys.stdin.readline

def main():
    # init
    n,h = map(int,input().split())
    a,b = [0 for _ in range(n)],[0 for _ in range(n)]
    for i in range(n):
        a[i],b[i] = map(int,input().split())
    b.sort(reversed=True)
    max_a = max(a)
    # memo
    

    # ans
    ans = 0
    for i in range(n):
        if b[i]>=max_a:
            h -= b[i]
            ans += 1
        if h<=0:
            print(ans)
            exit()
    ans += ceil(h/max_a)
    print(ans)
    
if __name__ == "__main__":

    main()

Fixed submission:
from collections import defaultdict
import sys
from math import ceil
input = sys.stdin.readline

def main():
    # init
    n,h = map(int,input().split())
    a,b = [0 for _ in range(n)],[0 for _ in range(n)]
    for i in range(n):
        a[i],b[i] = map(int,input().split())
    b.sort(reverse=True)
    max_a = max(a)
    # memo
    

    # ans
    ans = 0
    for i in range(n):
        if b[i]>=max_a:
            h -= b[i]
            ans += 1
        if h<=0:
            print(ans)
            exit()
    ans += ceil(h/max_a)
    print(ans)
    
if __name__ == "__main__":

    main()
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl<= b:
        return 1
    else:
        pass

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)

Fixed submission:
n,a,b = map(int,input().split())

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl and pl<= b:
        return n
    else:
        return 0

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)
Buggy python submission (verdict: Runtime Error):
ls = lisr(input())
c = ls.count('1')
print(c)

Fixed submission:
ls = list(input())
c = ls.count('1')
print(c)
Buggy python submission (verdict: Runtime Error):
c1 = input()
c2 - input()

if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')

Fixed submission:
c1 = input()
c2 = input()

if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')

Buggy python submission (verdict: Runtime Error):
c1 = input()
c2 - input()

if c1[0]==c2[2] and c1[1]=c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')

Fixed submission:
c1 = input()
c2 = input()

if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
def solve(i,n):
    if i**2 >n:
        return print((i-1)**2)
    else:
        return solve(i+1,n)

solve(1,n)

Fixed submission:
n = int(input())
import sys
sys.setrecursionlimit(10**5)
def solve(i,n):
    if i**2 >n:
        return print((i-1)**2)
    else:
        return solve(i+1,n)

solve(1,n)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [[x for x in input()] for _ in range(h)]

ls = ['.' for i in range(w)]

s.insert(0,ls)
s.insert(-1,ls)

for i in range(h+2):
    s[i].insert(0,".")
    s[i].insert(-1,".")

for j in range(1,h+1):
    for k in range(1,w+1):
        
        if s[i][j] == ".":
            ls = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
    
            s[i][j] = ls.count("#")

ls = ls[1:h+1][1:w+1]
for l in range(h):
    print(''.join(ls[l]))


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

ls = [[x for x in input()] for _ in range(h)]

for i in range(h):
    ls[i].append(".")
    ls[i].insert(0,".")
a = ["." for _ in range(w+2)]
ls.append(a)
ls.insert(0,a)

ans = [['#' for _ in range(w)] for _ in range(h)]

for j in range(1,h+1):
    for k in range(1,w+1):
        if ls[j][k] == ".":
            c = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
            ans[j-1][k-1] = str(c.count("#"))

for l in ans:
    print("".join(l))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).value()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).values()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

set_a = set(a)

cnt = 0
for i in list(set(a)):
    if a.count(i)%2 == 1:
        cnt += 1

print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).values()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)
Buggy python submission (verdict: Runtime Error):
q,h,s,d = map(int,input().split())
n = int(input())
a = min([q*4,h*2,s])
if n%2==0:
    print(min([a*n,int(b*n/2)]))
else:
    print(min([a*n,int(b*(n-1)/2+a)]))

Fixed submission:
def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    # one per yen
    one = min([q*4,h*2,s])
    # two per yen
    two = d

    if one*2 > two:
        print((n//2)*two + (n%2)*one)

    else:
        print(n*one)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b))

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

if abs(x-a)>abs(x-b):
  print("B")
  
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
s = list(input())
s = set(s)
ls = [chr(i) for i in range(97, 97+26)]
ls = set(ls)
b = ls-s
b = list(b)
b.sort()
print(b[0])

Fixed submission:
s = list(input())
s = set(s)
ls = [chr(i) for i in range(97, 97+26)]
ls = set(ls)
b = ls-s
b = list(b)
if  b == []:
    print("None")
else:
    b.sort()
    print(b[0])
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ls1 = list(input())
    ls2 = list(input())

    if ls1[0]==ls2[0]:
        ans = 3
        i =1
        flg = "b"
    else:
        ans = 3
        flg = "a"
        i =2

    while 1:


        if ls1[i]==ls2[i]:
            if flg == "a":
                flg = "b"
            else:
                ans = (ans*2)%(10**9+7)

            i += 1

        else:
            if flg == "a":
                ans = (ans*3)%(10**9+7)
            else:
                ans = (ans*2)%(10**9+7)
                flg = "a"

            i += 2
        if i >= n:
            break

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ls1 = list(input())
    ls2 = list(input())

    if ls1[0]==ls2[0]:
        ans = 3
        i =1
        flg = "b"
    else:
        ans = 6
        flg = "a"
        i =2

    while 1:

        if i >= n:
            break

        if ls1[i]==ls2[i]:
            if flg == "a":
                flg = "b"
            else:
                ans = (ans*2)%(10**9+7)

            i += 1

        else:
            if flg == "a":
                ans = (ans*3)%(10**9+7)
            else:
                ans = (ans*2)%(10**9+7)
                flg = "a"

            i += 2
        if i >= n:
            break

    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ls1 = list(input())
    ls2 = list(input())

    if ls1[0]==ls2[0]:
        ans = 3
        i =1
        flg = "b"
    else:
        ans = 3
        flg = "a"
        i =2
    
    while 1:


        if ls1[i]==ls2[i]:
            if flg == "a":
                flg = "b"
            else:
                ans = (ans*2)%(10**9+7)

            i += 1

        else:
            if flg == "a":
                ans = (ans*3)%(10**9+7)
            else:
                ans = (ans*2)%(10**9+7)
                flg = "a"
            
            i += 2
        if i >= n:
            break
    
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ls1 = list(input())
    ls2 = list(input())

    if ls1[0]==ls2[0]:
        ans = 3
        i =1
        flg = "b"
    else:
        ans = 6
        flg = "a"
        i =2

    while 1:

        if i >= n:
            break

        if ls1[i]==ls2[i]:
            if flg == "a":
                flg = "b"
            else:
                ans = (ans*2)%(10**9+7)

            i += 1

        else:
            if flg == "a":
                ans = (ans*3)%(10**9+7)
            else:
                ans = (ans*2)%(10**9+7)
                flg = "a"

            i += 2
        if i >= n:
            break

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = [input() for _ in range(n)]

l.sort(reverse=True)
print(sum(l[:k]))

Fixed submission:
n,k = map(int,input().split())
l = [int(x) for x in input().split()]

l.sort(reverse=True)
print(sum(l[:k]))
Buggy python submission (verdict: Runtime Error):
ls = list(input())
l = len(ls)
from collections import Counter

for i in range(l):
    ls.pop(-1)
    ls.pop(-1)
    c = Counter(ls)
    if all(j%2==0 for j in c.values()):
        print(len(ls))
        break
    


Fixed submission:
ls = [int(x) for x in input().split()]
print(sum(ls)-max(ls))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]


def solve(a,index,l):
    if l == len(a)+1:
        return print(-1)

    value = a[index-1]
    if value == 2:
        return print(l)
    else:
        solve(a,value,l+1)
    
solve(a,1,1)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

i = 1
f = a[0]
while i< 10**6:
    
    if f == 2:
        print(i)
        break
    elif i>n+1:
        print(-1)
        break
    else:
        f = a[f-1]
        i+=1

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
index = a.index(1)+1

def solve(a,index,l):
    if l == len(a)+1:
        return print(-1)

    value = a[index-1]
    if value == 2:
        return print(l)
    else:
        solve(a,value,l+1)
    
solve(a,index,0)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

i = 1
f = a[0]
while i< 10**6:
    
    if f == 2:
        print(i)
        break
    elif i>n+1:
        print(-1)
        break
    else:
        f = a[f-1]
        i+=1
Buggy python submission (verdict: Runtime Error):
r,g,b = map(str,input().split())

n = r+b+g
flg = "No"
if n%4 == 0:
    flg = "Yes"
    
print(flg)

Fixed submission:
r,g,b = map(str,input().split())

n = r+g+b
flg = "NO"
if int(n)%4 == 0:
    flg = "YES"
    
print(flg)
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    right,left = 0,1
    cnt = 0
    flg = 0
    while 1:
        now = ls[left]
        nex = ls[right]   
        if now<nex:
            if flg ==-1:
                cnt +=1
                flg = 0
            else:
                flg = 1
            left +=1
            right +=1
        elif nex==now:
            left +=1
            right +=1         

        else:
            if flg ==1:
                cnt += 1
                flg = 0
            else:
                flg = -1
            left +=1
            right +=1
        if right==n-1:
            cnt +=1
            break
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    if n==1:
        print(1)
    else:
        right,left = 0,1
        cnt = 0
        flg = 0
        while 1:
            now = ls[left]
            nex = ls[right]   
            if now<nex:
                if flg ==-1:
                    cnt +=1
                    flg = 0
                else:
                    flg = 1
                left +=1
                right +=1
            elif nex==now:
                left +=1
                right +=1         

            else:
                if flg ==1:
                    cnt += 1
                    flg = 0
                else:
                    flg = -1
                left +=1
                right +=1

            if right==n-1:
                cnt +=1
                break
        print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

import math
root = math.ceil(math.sqrt(n))

for i in range(n):
    if n%(root+i)==0:
        print(len(str(root+i)))
        break



Fixed submission:
n = int(input())

import math
root = math.ceil(math.sqrt(n))

for i in range(1,root+1):
    if n%i==0:
        ans = n//i
print(len(str(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

cnt = 1
for i in range(1,n+1):
    cnt *=i

print(cnt%(10**9+7))


Fixed submission:
n = int(input())

cnt = 1
for i in range(1,n+1):
    cnt = (cnt*i)%(10**9+7)

print(cnt%(10**9+7))