Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int,input().split())
    shirube = [None]*(N+1)
    shirube[1] = (1,0)
    mmap = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        mmap[a].append(b)
        mmap[b].append(a)
    queue = deque()
    queue.appendleft((1,0))
    while queue:
        current_node, distance = queue.pop()
        for next_node in mmap[current_node]:
            new_distance = distance+1
            if shirube[next_node] is None:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
            elif shirube[next_node][1] > new_distance:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
    shirube = shirube[1::]
    if None in shirube:
        print("No")
        return
    print("Yes")
    for s in shirube[1::]:
        print(s[0])


if __name__ == '__main__':
    main()
ç

Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int,input().split())
    shirube = [None]*(N+1)
    shirube[1] = (1,0)
    mmap = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        mmap[a].append(b)
        mmap[b].append(a)
    queue = deque()
    queue.appendleft((1,0))
    while queue:
        current_node, distance = queue.pop()
        for next_node in mmap[current_node]:
            new_distance = distance+1
            if shirube[next_node] is None:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
            elif shirube[next_node][1] > new_distance:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
    shirube = shirube[1::]
    if None in shirube:
        print("No")
        return
    print("Yes")
    for s in shirube[1::]:
        print(s[0])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M,X = map(int, input().split())
    ca = []
    res = sys.maxsize
    for _ in range(N):
        ca.append(list(map(int, input().split())))
    for i in range(2 ** N):
        tmp = [0]*M
        tmpres = 0
        for j in range(N):
            if ((i >> j) & 1):
                tca = ca[M-1-j]
                tmpres += tca[0]
                for k in range(M):
                    tmp[k] += tca[1+k]
        tassei = True
        for a in tmp:
            if a < X:
                tassei = False
                break
        if tassei:
            res = min(res,tmpres)
    if res != sys.maxsize:
        print(res)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M,X = map(int, input().split())
    ca = []
    res = sys.maxsize
    for _ in range(N):
        ca.append(list(map(int, input().split())))
    for i in range(2 ** N):
        tmp = [0]*M
        tmpres = 0
        for j in range(N):
            if ((i >> j) & 1):
                tca = ca[N-1-j]
                tmpres += tca[0]
                for k in range(M):
                    tmp[k] += tca[1+k]
        tassei = True
        for a in tmp:
            if a < X:
                tassei = False
                break
        if tassei:
            res = min(res,tmpres)
    if res != sys.maxsize:
        print(res)
    else:
        print(-1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x=map(int,input().split())
h=x//500 * 1000
x%=500
h+=x//5
print(h)

Fixed submission:
x=int(input())
h=(x//500)*1000
x%=500
h+=(x//5)*5
print(h)
Buggy python submission (verdict: Runtime Error):
s=input()
a=s[:(len(s)−1)//2]
b=s[(len(s)+3)//2-1:]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
a=s[:(len(s)-1)//2]
b=s[((len(s)+3)//2-1):]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
if s==s[::-1] and s==s[:(len(s)−1)//2] and s==s[(len(s)+3)//2-1:]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
a=s[:(len(s)-1)//2]
b=s[((len(s)+3)//2-1):]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s,t = input(),input()
print(t+s)

Fixed submission:
print("".join((input().split())[::-1]))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
	print(N**3)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    print(N**3)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def apply(a,b):
  if a>b:
	return a, a-1, b
  else:
    return b, a, b-1

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)

Fixed submission:
def apply(a,b):
  if a>b:
    return (a, a-1, b)
  else:
    return (b, a, b-1)

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
SS = input()
lrq = []
for i in range(N-1):
  if SS[i] == "A" and SS[i+1] == "C":
    lrq.append(1)
  else:
    lrq.append(0)
lrq.append(0)
for _ in range(Q):
  l,r = map(int, input().split())
  l -= 1
  r -= 1
  ans = sum(lrq[l:r+1])
  if lrq[r] == 1:
    ans -= 1
  print(ans)


Fixed submission:
N,Q = map(int, input().split())
SS = input()
lrq = []
for i in range(N-1):
  if SS[i] == "A" and SS[i+1] == "C":
    lrq.append(1)
  else:
    lrq.append(0)
lrq.append(0)
lr = []
lr.append(0)
for i in range(N):
  lr.append(lr[i]+lrq[i])
for _ in range(Q):
  l,r = map(int, input().split())
  l -= 1
  r -= 1
  ans = lr[r+1]-lr[l]
  if lrq[r] == 1:
    ans -= 1
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# This file is a "Hello, world!" in Python language by CPython for wandbox.

def checkeof(s):
    l = len(s)
    #print("1"*l)
    #print("0"*l)
    if l == 0:
        return False
    if "1"*l == s or "0"*l == s:
        return False
    else:
        return True
    

def main():
    s = input()
    c = 0
    while checkeof(s):
        tmp = s.count('01')
        if tmp:
            s = s.replace("01","")
            c += tmp
        tmp = s.count('10')
        if tmp:
            s = s.replace("10","")
            c += tmp
    print(c*2)
    
    
if __name__ == '__main__':
    main()


# CPython references:
#   https://www.python.org/


Fixed submission:
s = input()
print(min(s.count("0"),s.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
import math

def solve(N, a):
	m = reduce(lambda x, y: x*y, a) // reduce(math.gcd, a) - 1
	ans = 0
	for ai in a:
		ans += m % ai
	return ans

if __name__ == '__main__':
	N = int(input())
	a = list(map(int, input().split()))
	print(solve(N,a))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
print(sum(a) - N)
Buggy python submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:s
  print("No")

Fixed submission:
N = int(input())
sn = 0
for s in str(N):
    sn += int(s)
if N % sn == 0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(n)
if N % ans == 0:
  print("Yes")
else:s
  print("No")

Fixed submission:
N = int(input())
sn = 0
for s in str(N):
    sn += int(s)
if N % sn == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split(" "))
for i in range(k):
	newa = b+c
	newb = a+c
	newc = a+b
	a = newa
	b = newb
	c = newc
if abs(a)>(10**18):
	print("Unfair")
else:
	print(a-b)

Fixed submission:
a,b,c,k = map(int, input().split(" "))
if abs(a-b)>10**18:
    print("Unfair")
if k%2==0:
    print(a-b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: x.reverse(), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked:
            ans += 1
            picked[i] = True
            break
print(ans)

Fixed submission:
from pprint import pprint
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: (x[1], x[0]), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked[i]:
            ans += 1
            picked[i] = True
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
from pprint import pprint

def solve(datas):
    ans = 0
    reds = set()
    for p in datas:
        # pprint(reds)
        if p[0] == "r":
            reds.add(p)
        else:
            if len(reds) != 0:
                partner = max(filter(lambda x: x[1][1] < p[1][1], reds), key=lambda x: x[1][1])
                # pprint(filter(lambda x: x[1][1] < p[1][1], reds))
                reds.remove(partner)
                ans += 1
    return ans

if __name__ == '__main__':
    N = int(input())
    datas = []
    for i in range(N):
        a,b = list(map(lambda x: int(x), input().split(" ")))
        datas.append(("r", (a,b)))
    for i in range(N):
        c,d = list(map(lambda x: int(x), input().split(" ")))
        datas.append(("b", (c,d)))
    # pprint(datas)
    datas.sort(key=lambda x: x[1][0]) # x座標で昇順にソート
    ans = solve(datas)
    print(ans)

Fixed submission:
from pprint import pprint
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: (x[1], x[0]), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked[i]:
            ans += 1
            picked[i] = True
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,y = list(map(lambda x: int(x), input().split(" ")))
c = 2
while x % y == 0:
  x *= c
  c += 1
print(x)

Fixed submission:
x,y = map(int, input().split(" "))
if x % y == 0:
  print(-1)
else:
  print(x)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n,k = map(int,input().split())
nums = input().split()
count_per_num = defaultdict(int)
for n in nums:
  count_per_num[n] += 1
count_per_nums = sorted(count_per_nums, key=lambda x:x[1])
ans = 0
for i in range(len(count_per_nums)-k):
  ans += count_per_nums[i]
print(ans)

Fixed submission:
from collections import defaultdict
n,k = map(int,input().split())
nums = input().split()
count_per_nums = defaultdict(int)
for n in nums:
  count_per_nums[n] += 1
count_per_nums = sorted(count_per_nums.items(), key=lambda x:x[1])
ans = 0
for i in range(len(count_per_nums)-k):
  ans += count_per_nums[i][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(lambda x: int(x), input().split(" ")))
b = list(set(a))
print(a-b)

Fixed submission:
a = list(map(lambda x: int(x), input().split(" ")))
b = list(set(a))
if a.count(b[0]) == 2:
  print(b[1])
else:
  print(b[0])
Buggy python submission (verdict: Runtime Error):
n,a = list(map(lambda x: int(x), input().split(" ")))
print(n**2-a)

Fixed submission:
n = int(input())
a = int(input())
print(n**2-a)

Buggy python submission (verdict: Runtime Error):
n,a = list(map(lambda x: int(x), input().split(" ")))
print(n**2-a)

Fixed submission:
n = int(input())
a = int(input())
print(n**2-a)
Buggy python submission (verdict: Runtime Error):
if int(input().strip(" "))%4==0:
  print("YES")
else:
  print("NO")

Fixed submission:
if int("".join(input().split(" ")))%4==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
s = list(map(lambda x: int(x), input().split(" "))).sum()
if s>=10:
  print("error")
else:
  print(s)

Fixed submission:
a,b = list(map(lambda x: int(x), input().split(" ")))
if a+b>=10:
  print("error")
else:
  print(a+b)
Buggy python submission (verdict: Runtime Error):
s = str(input()).split(" "):
if s[0][0] == s[1][-1] and s[1][0] == s[2][-1]:
  print("YES")
else:
  print("NO")

Fixed submission:
s = str(input()).split(" ")
if s[0][-1] == s[1][0] and s[1][-1] == s[2][0]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b ^ int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("LESS")
else:
  print("GREATER")

Fixed submission:
a = int(input())
b = int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("GREATER")
else:
  print("LESS")
Buggy python submission (verdict: Runtime Error):
n = int(input())
res= 0
if i in range(n)
    res += i+1
print(res)

Fixed submission:
n = int(input())
res= 0
for i in range(n):
	res += i+1
print(res)
Buggy python submission (verdict: Runtime Error):
inst = input()
buf = []
for s in inst:
  if s == "B":
    buf.pop()
  else:
    buf.append(s)
print(buf)

Fixed submission:
inst = input()
buf = []
for s in inst:
  if s == "B":
    if len(buf) != 0:
      del buf[-1]
  else:
    buf.append(s)
print("".join(buf))
Buggy python submission (verdict: Runtime Error):
n,l = list(map(int, input().split(" ")))
s = []
for i in range(n):
  s.append(input())
sort(s)
print("".join(s))

Fixed submission:
n,l = list(map(int, input().split(" ")))
s = []
for i in range(n):
  s.append(input())
s.sort()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
product = 1
for i in range(len(A)):
  product *= A[i]

if product <= 10**18:
  print(product)
else:
  print(-1)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
product = 1
if A[0]==0:
  print(0)
else:
  for i in range(len(A)):
    product *= A[i]
    if product > 10**18:
      print(-1)
      break
if product <= 10**18 and A[0]!=0:
  print(product)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
if N==1 and M==1:
  r = 0
if 0<=N and N>=1 and 2<=M:
  r = M*(M-1)//2
if 2<=N and 0<=M and M<=1:
  r = N*(N-1)//2
if 2<=N and 2<=M:
  r = (N*(N-1)+M*(M-1))//2

print(r)

Fixed submission:
N,M = map(int, input().split())
if N==1 and M==1:
  result = 0
if 0<=N and N<=1 and 2<=M:
  result = M*(M-1)//2
if 2<=N and 0<=M and M<=1:
  result = N*(N-1)//2
if 2<=N and 2<=M:
  result = (N*(N-1)+M*(M-1))//2
  
print(result)
Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  count += 1
  D += L[i]
  i += 1
  
if D <= X:
  count += 1
  
print(count)
  

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)

Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  count += 1
  D += L[i]
  i += 1
  
  
print(count)

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)

Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  D += L[i]
  i += 1
  count +=1
  
print(count)
  

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)

Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
i = 2
D = 0
count = 0

while D < X+1:
  D += L[i-1]
  i += 1
  count += 1

print(count)
  

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)

Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
i = 1
D = 0
count = 0

while D < X+1:
  D += L[i-1]
  i += 1
  count += 1

print(count)
  

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
A = list(map(int, input().split()))
x = A[:]
k = -1
for _ in range(N):
    x = x[1:] + x[:1]
    diff = sum([min(K - abs(x[i] - x[i+1]), abs(x[i] - x[i+1])) for i in range(N - 1)])
    if k == -1 or k > diff:
        k = diff
print(k)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
diff = [min(K - abs(A[i] - A[i+1]), abs(A[i] - A[i+1])) for i in range(-1, N - 1)]
diff.sort()
print(sum(diff) - diff[-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
d = list(map(int, input().split()))
P = 0

for i in range(N - 1):
    if d[i] == 0:
        continue
    for j in range(i + 1, N):
        if d[j] == 0:
            continue
        P += d[i] * d[j
print(P)

Fixed submission:
import sys
input = sys.stdin.readline
 
N = int(input())
d = list(map(int, input().split()))
P = 0
 
for i in range(N - 1):
    if d[i] == 0:
        continue
    for j in range(i + 1, N):
        if d[j] == 0:
            continue
        P += d[i] * d[j]
print(P)
Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
		A = QUICKSORT(A)
		piv = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] == piv:
				A.pop(i)
	print(A[0])

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		i = 1
		while(True):
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
				i += 1
			if i == len(A):
				break
		A = list(set(A))
	print(A[0])

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A = QUICKSORT(A)
		mini = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
		A = list(set(A))
	print(A[0])

def QUICKSORT(A):
	if len(A) < 1:
		return A
	pivot = A[0]
	left = []
	right = []
	for x in range(1, len(A)):
		if A[x] <= pivot:
			left.append(A[x])
		else:
			right.append(A[x])
	left = QUICKSORT(left)
	right = QUICKSORT(right)
	foo = [pivot]
	return left + foo + right

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		i = 1
		while(True):
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
				i += 1
			if i == len(A):
				break
		A = list(set(A))
	print(A[0])

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A = QUICKSORT(A)
		mini = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
		A = QUICKSORT(A)
		piv = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] == piv:
				A.pop(i)
	print(A[0])

def QUICKSORT(A):
	if len(A) < 1:
		return A
	pivot = A[0]
	left = []
	right = []
	for x in range(1, len(A)):
		if A[x] <= pivot:
			left.append(A[x])
		else:
			right.append(A[x])
	left = QUICKSORT(left)
	right = QUICKSORT(right)
	foo = [pivot]
	return left + foo + right

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		i = 1
		while(True):
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
				i += 1
			if i == len(A):
				break
		A = list(set(A))
	print(A[0])

if __name__ == '__main__':
	main()