Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    n=int(input())
    s=list(input())
    dict1={}
    for i in range(len(s)):
        if s[i] not in dict1:
            dict1[s[i]]=1
        else:
            dict1[s[i]]+=1
    for _ in range(n-1):
        dict2={}
        t=list(input())
        for i in range(len(t)):
            if t[i] in dict1 and dict1[t[i]]>0:
                if t[i] not in dict2:
                    dict2[t[i]]=1
                    dict1[t[i]]-=1
                else:
                    dict2[t[i]]+=1
                    dict1[t[i]]-=1
        dict1=dict2
    ans=[]
    for i in dict2:
        for _ in range(dict2[i]):
            ans.append(i)
    ans.sort()
    print(''.join(ans))
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n=int(input())
    s=list(input())
    dict1={}
    for i in range(len(s)):
        if s[i] not in dict1:
            dict1[s[i]]=1
        else:
            dict1[s[i]]+=1
    if n==1:
        s.sort()
        print(''.join(s))
        return
    for _ in range(n-1):
        dict2={}
        t=list(input())
        for i in range(len(t)):
            if t[i] in dict1 and dict1[t[i]]>0:
                if t[i] not in dict2:
                    dict2[t[i]]=1
                    dict1[t[i]]-=1
                else:
                    dict2[t[i]]+=1
                    dict1[t[i]]-=1
        dict1=dict2
    ans=[]
    for i in dict2:
        for _ in range(dict2[i]):
            ans.append(i)
    ans.sort()
    print(''.join(ans))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 

def main():
    n,m = inpm()
    x = inpl()
    y = inpl()
    N = [0 for _ in range(n-1)]
    M = [0 for _ in range(m-1)]
    cnt = n-1
    plus = 0
    for i in range(n-1):
        plus += cnt
        N[i] = plus
        N[-i-1] = plus
        cnt -= 2
        if cnt <= 0:
            break
    cnt = m-1
    plus = 0
    for i in range(m-1):
        plus += cnt
        M[i] = plus
        M[-i-1] = plus
        cnt -= 2
        if cnt <= 0:
            break
    ans = 0
    for i in range(n-1):
        for j in range(m-1):
            area = ((x[i+1]-x[i])*(y[j+1]-y[j])) % mod
            area = (area*N[i]) % mod
            area = (area*M[j]) % mod
            ans = (ans+area) % mod
    print(ans)   
    
if __name__ == "__main__":
    main()

Fixed submission:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 

def main():
    n,m = inpm()
    x = inpl()
    y = inpl()
    X = 0
    Y = 0
    cntX, cntY = n-1, m-1
    for i in range(n-1,-1,-1):
        X += x[i]*cntX
        X %= mod
        cntX -= 2
    for i in range(m-1,-1,-1):
        Y += y[i]*cntY
        Y %= mod
        cntY -= 2
    print((X*Y)%mod)


    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
for i in range(n):
    a[i],b[i] = map(int,input().split())	
cnt=0
for i in range(n):
    i=n-1-i
    while (a[i]+cnt)%b[i]!=0:
        cnt+=1
print(cnt)


Fixed submission:
n=int(input())
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
for i in range(n):
    a[i],b[i] = map(int,input().split())	
cnt=0
for i in range(n):
    i=n-1-i
    if (a[i]+cnt)%b[i]!=0:
        cnt+=b[i]-(a[i]+cnt)%b[i]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b): 
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    n=int(input())
    a=1
    b=1
    for _ in range(n):
        x,y = map(int,input().split())
        x1=x
        y1=y
        while x1<a or y1<b:
            x1+=x
            y1+=y
        a=x1
        b=y1
    print(a+b)
        

if __name__ == "__main__":
    main()


Fixed submission:
def gcd(a, b): 
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    n=int(input())
    a=1
    b=1
    for _ in range(n):
        x,y = map(int,input().split())
        n=a//x
        m=b//y
        if a%x!=0:
            n+=1
        if b%y!=0:
            m+=1
        a=max(n,m)*x
        b=max(n,m)*y
    print(a+b)
        

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int,input().split()))
check=[]
ans=0
for i in range(n):
    if [min(i+1,a[i]),max(i+1,a[i])] not in check:
        check.append([min(i+1,a[i]),max(i+1,a[i])])
    else:
        ans+=1
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
pair=[]
for i in range(n):
    if i+1 > a[i]:
        w=i+1
        i=a[i]
    else:
        w=a[i]
        i+=1
    pair.append([i,w])
pair.sort()
ans=0
for i in range(len(pair)-1):
    if pair[i]==pair[i+1]:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int,input().split()))
check=[]
ans=0
for i in range(n):
    if min(i+1,a[i])+max(i+1,a[i])*1000000 not in check:
        check.append(min(i+1,a[i])+max(i+1,a[i])*1000000)
    else:
        ans+=1
print(ans)





Fixed submission:
n=int(input())
a=list(map(int,input().split()))
pair=[]
for i in range(n):
    if i+1 > a[i]:
        w=i+1
        i=a[i]
    else:
        w=a[i]
        i+=1
    pair.append([i,w])
pair.sort()
ans=0
for i in range(len(pair)-1):
    if pair[i]==pair[i+1]:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s=list(input())
    k=inp()
    for i in range(len(s)):
        s[i]=ord(s[i])
    for i in range(len(s)):
        if i==len(s)-1:
            s[i]+=k
            if s[i]>=123:
                s[i]-=26
        elif 123-s[i]<=k:
            k-=123-s[i]
            s[i]=97
        s[i]=chr(s[i])
    print(''.join(s))



if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s=list(input())
    k=inp()
    n=len(s)
    for i in range(n):
        s[i]=ord(s[i])
    for i in range(n):
        if i==n-1:
            s[i]+=k
            if s[i]>=123:
                s[i]=(s[i]-97)%26+97
        elif s[i]==97:
            s[i]='a'
            continue
        elif 123-s[i]<=k:
            k-=123-s[i]
            s[i]=97
        s[i]=chr(s[i])
    print(''.join(s))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def b172(slist, tlist):

    ans = 0

    for s, t in slist, tlist:
        if s != t:
            ans += 1

    return ans

def main():
    slist = list(str(input()))
    tlist = list(str(input()))
    print(b172(slist, tlist))

if __name__ == '__main__':
    main()

Fixed submission:
def b172(slist, tlist):

    ans = 0

    for s, t in zip(slist, tlist):
        if s != t:
            ans += 1

    return ans

def main():
    slist = list(str(input()))
    tlist = list(str(input()))
    print(b172(slist, tlist))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def b169(n, alist):

    ans = 1
    for i in alist:
        ans *= i

    return ans if ans < 10**18 else -1

def main():
    n = int(input())
    alist = list(int(input()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Fixed submission:
def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0

    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import itertools

def c165(n, m, q, adli):

    ans = 0
    li = list(itertools.combinations_with_replacement(range(1,M+1), n))
    for i in li:
        count = 0
        for a, b, c, d in adli:
            if i[b-1] - i[a-1] == c:
                count += d
        ans = max(ans, count)

    return ans

def main():
    n, m, q = map(int, input().split())
    adli = [list(map(int, input().split()))for i in range(q)]
    print(c165(n, m, q, adli))

if __name__ == '__main__':
    main()

Fixed submission:
import itertools

def c165(n, m, q, adli):

    ans = 0
    li = list(itertools.combinations_with_replacement(range(1,m+1), n))
    for i in li:
        count = 0
        for a, b, c, d in adli:
            if i[b-1] - i[a-1] == c:
                count += d
        ans = max(ans, count)

    return ans

def main():
    n, m, q = map(int, input().split())
    adli = [list(map(int, input().split()))for i in range(q)]
    print(c165(n, m, q, adli))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def d162(n , sli):

    ans = 0

    for i in range(n - 3):
        for w in range(i + 1 , n):
            for q in range(w + 1 , n):
                if sli[i] != sli[w] and sli[i] != sli[q] and sli[w] != sli[q] and w - i != q - w:
                    ans += 1
    return ans

def main():
    n = int(input())
    sli = list(str(input()))
    print(d162(n , sli))
if __name__ == '__main__':
    main()

Fixed submission:
import bisect

def d162(n , sli):

    ans = 0
    Rli = []
    Gli = []
    Bli = []

    for i in range(n):
        if sli[i] == "R":
            Rli.append(i)
        elif sli[i] == "G":
            Gli.append(i)
        else:
            Bli.append(i)

    Rcount = len(Rli)
    Gcount = len(Gli)
    Bcount = len(Bli)
    Rli.sort()
    Gli.sort()
    Bli.sort()

    for i in range(n - 3):
        for w in range(i + 1 , n):
            if sli[i] != sli[w]:
                k = "RGB".replace(sli[i] , "").replace(sli[w] , "")
                if k == "R":
                    ans += Rcount - bisect.bisect_right(Rli , w)
                elif k == "G":
                    ans += Gcount - bisect.bisect_right(Gli , w)
                else:
                    ans += Bcount - bisect.bisect_right(Bli , w)
                if w + w - i < n and sli[w + (w - i)] == k:
                    ans -= 1

    return ans

def main():
    n = int(input())
    sli = list(str(input()))
    print(d162(n , sli))
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):

def a(n):

    return -(-n // 2)

def main():
    n = int(input())¥
    print(a(n))

if __name__ == '__main__':
    main()


Fixed submission:

def a(n):

    return -(-n // 2)

def main():
    n = int(input())
    print(a(n))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
5 5 17 6 37 17 18

25 25 289 36 1369 289 324def rally(n , xl):

    ans = 0

    aaa = round(sum(xl) / n)

    for i in range(n):
        ans += (xl[i] - aaa)**2

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    print(rally(n , xl))

if __name__ == '__main__':
    main()


Fixed submission:
def rally(n , xl):

    ans = 0

    aaa = round(sum(xl) / n)

    for i in range(n):
        ans += (xl[i] - aaa)**2

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    print(rally(n , xl))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def onlya(n , a):

    ans = "YES"

    for i in range(n):
        for w in range(i + 1 , n):
            if a[i] == a[w]:
                return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

Fixed submission:

def has_duplicates(seq):
    return len(seq) != len(set(seq))

def onlya(n , a):

    ans = "YES"

#    for i in range(n):
#        for w in range(i + 1 , n):
#            if a[i] == a[w]:
#                return "NO"

    if has_duplicates(a):
        return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def onlya(n , a):

    ans = "YES"

    for i in range(n):
        if a.count(a[i]) != 1:
            return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

Fixed submission:

def has_duplicates(seq):
    return len(seq) != len(set(seq))

def onlya(n , a):

    ans = "YES"

#    for i in range(n):
#        for w in range(i + 1 , n):
#            if a[i] == a[w]:
#                return "NO"

    if has_duplicates(a):
        return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def onlya(n , a):

    ans = "YES"

    for i in range(n):
        if a.count(a[i]) != 1:
            return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

Fixed submission:

def has_duplicates(seq):
    return len(seq) != len(set(seq))

def onlya(n , a):

    ans = "YES"

#    for i in range(n):
#        for w in range(i + 1 , n):
#            if a[i] == a[w]:
#                return "NO"

    if has_duplicates(a):
        return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def walk_on_multiplication_table(n):

    ans = 10**13
    yaku = make_divisors(n)
    yaku.sort()
    count = len(yaku)

    for i in range(int(count//2)):
        ans = min(ans, (yaku[i]+yaku[count-i-1]-2))

    if count % 2 == 0:
        return ans

    return min(ans, (yaku[int((count+1)**2)]-2))

def main():
    n = int(input())
    print(walk_on_multiplication_table(n))

if __name__ == '__main__':
    main()

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def walk_on_multiplication_table(n):

    ans = 10**13
    yaku = make_divisors(n)
    yaku.sort()
    count = len(yaku)
    for i in range(int(count//2)):
        ans = min(ans, (yaku[i]+yaku[count-i-1]-2))

    if count % 2 == 0:
        return ans
    return min(ans, (yaku[int(count//2)]*2)-2)

def main():
    n = int(input())
    print(walk_on_multiplication_table(n))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def password(n):

    return n**3
def main():
    n = list(str(input()))
    print(password(n))

if __name__ == '__main__':
    main()

Fixed submission:
def password(n):

    return n**3
def main():
    n = int(input())
    print(password(n))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def security(s):

    return "Good" if s[0] != s[1] and s[1] != s[2] and s[2] != s[3] else "Bad"
def main():
    s = list(int(input()))
    print(security(s))

if __name__ == '__main__':
    main()


Fixed submission:
def security(s):

    return "Good" if s[0] != s[1] and s[1] != s[2] and s[2] != s[3] else "Bad"
def main():
    s = list(str(input()))
    print(security(s))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def typical_stairs(n, m, ali):

    mod = 10**9+7

    dp = [0]*(n+1)
    dp[0] = 1

    for i in range(1, n+1):
        if i in ali:
            continue
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] %= mod

    return dp[i]

def main():
    n, m = map(int, input().split())
    ali = [int(input())for i in range(m)]
    print(typical_stairs(n, m, ali))

if __name__ == '__main__':
    main()

Fixed submission:
def typical_stairs(n, m, ali):

    mod = 10**9+7
    flag = [True]*(n+1)
    for i in ali:
        flag[i] = False

    dp = [0]*(n+1)
    dp[0] = 1

    for i in range(1, n+1):
        if not flag[i]:
            continue
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] %= mod

    return dp[i]

def main():
    n, m = map(int, input().split())
    ali = [int(input())for i in range(m)]
    print(typical_stairs(n, m, ali))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def typical_stairs(n, m, ali):

    mod = 10**9+7

    dp = [0]*(n+1)
    dp[0] = 1

    for i in range(1, n+1):
        if i in ali:
            continue
        dp[i] = dp[i-2] + dp[i-1]

    return dp[i]%mod

def main():
    n, m = map(int, input().split())
    ali = [int(input())for i in range(m)]
    print(typical_stairs(n, m, ali))

if __name__ == '__main__':
    main()

Fixed submission:
def typical_stairs(n, m, ali):

    mod = 10**9+7
    flag = [True]*(n+1)
    for i in ali:
        flag[i] = False

    dp = [0]*(n+1)
    dp[0] = 1

    for i in range(1, n+1):
        if not flag[i]:
            continue
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] %= mod

    return dp[i]

def main():
    n, m = map(int, input().split())
    ali = [int(input())for i in range(m)]
    print(typical_stairs(n, m, ali))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def get_ac(n, q, s, lrli):

    ans = []
    for i in lrli:
        ans.append(s[i[0]-1:i[1]].count("AC"))

    return ans

def main():
    n, q = map(int, input().split())
    s = str(input())
    lrli = [list(map(int, input().split()))for i in range(q)]
    ans = get_ac(n, q, s, lrli)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()


Fixed submission:
def get_ac(n, q, s, lrli):

    ans = []
    nli = [0]*(n+1)

    for i in range(1, n):
        if s[i] == "C" and s[i-1] == "A":
            nli[i+1] = nli[i] + 1
        else:
            nli[i+1] = nli[i]

    for i in lrli:
        ans.append(nli[i[1]]-nli[i[0]])

    return ans

def main():
    n, q = map(int, input().split())
    s = list(str(input()))
    lrli = [list(map(int, input().split()))for i in range(q)]
    ans = get_ac(n, q, s, lrli)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def get_ac(n, q, s, lrli):

    ans = []
    for i in lrli:
        ans.append(s[i[0]-1:i[1]].count("AC"))

    return ans

def main():
    n, q = map(int, input().split())
    s = str(input())
    lrli = [list(map(int, input().split()))for i in range(q)]
    ans = get_ac(n, q, s, lrli)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Fixed submission:
def get_ac(n, q, s, lrli):

    ans = []
    nli = [0]*(n+1)

    for i in range(1, n):
        if s[i] == "C" and s[i-1] == "A":
            nli[i+1] = nli[i] + 1
        else:
            nli[i+1] = nli[i]

    for i in lrli:
        ans.append(nli[i[1]]-nli[i[0]])

    return ans

def main():
    n, q = map(int, input().split())
    s = list(str(input()))
    lrli = [list(map(int, input().split()))for i in range(q)]
    ans = get_ac(n, q, s, lrli)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def kth_common_divisor(a, b, k):

    count = 0
    for i in range(max(a, b)):
        if a%i == 0 and b%i:
            count += 1
        if count == k:
            return i

def main():
    a, b, k = map(int, input().split())
    print(kth_common_divisor(a, b, k))

if __name__ == '__main__':
    main()


Fixed submission:
def kth_common_divisor(a, b, k):

    count = []
    for i in range(1, max(a, b)+1):
        if a%i == 0 and b%i == 0:
            count.append(i)

    count.sort(reverse=True)
    return count[k-1]

def main():
    a, b, k = map(int, input().split())
    print(kth_common_divisor(a, b, k))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

def gcdli(xl):
    #xlはlist
    return reduce(gcd , xl)

def monsters_battle_royale(n, al):

    ans = gcdli(al)

    return ans

def main():
    n = int(input())
    al = list(map(int, input().split()))
    print(monsters_battle_royale(n, al))

if __name__ == '__main__':
    main()

Fixed submission:
from fractions import gcd
from functools import reduce

def gcdli(xl):
    #xlはlist
    return reduce(gcd , xl)

def monsters_battle_royale(n, al):

    ans = gcdli(al)

    return ans

def main():
    n = int(input())
    al = list(map(int, input().split()))
    print(monsters_battle_royale(n, al))

if __name__ == '__main__':
    main()