Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

factorial = [1]
for i in range(1, N):
	factorial.append(factorial[i-1] * i % mod)

def power(x, y):
	if y == 0:
		return 1
	elif y == 1:
		return x % mod
	elif y % 2 == 0:
		return power(x, int(y/2)) ** 2 % mod
	else:
		return power(x, int((y-1)/2)) ** 2 * x % mod

def C(n, r):
	return (((factorial[n] * x_inv[r]) % mod) * x_inv[n-r]) % mod

x_inv = [0] * (N)
x_inv[-1] = power(factorial[-1], mod-2)
for i in range(N-2, -1, -1):
	x_inv[i] = x_inv[i+1] * (i+1) % mod

for i in range(1, K+1):
	print((C(K-1, i-1)*C(N-K+1, i))%mod)


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

factorial = [1]
for i in range(1, N+1):
	factorial.append(factorial[i-1] * i % mod)

def power(x, y):
	if y == 0:
		return 1
	elif y == 1:
		return x % mod
	elif y % 2 == 0:
		return power(x, int(y/2)) ** 2 % mod
	else:
		return power(x, int((y-1)/2)) ** 2 * x % mod

def C(n, r):
	return (((factorial[n] * x_inv[r]) % mod) * x_inv[n-r]) % mod

x_inv = [0] * (N+1)
x_inv[-1] = power(factorial[-1], mod-2)
for i in range(N-1, -1, -1):
	x_inv[i] = x_inv[i+1] * (i+1) % mod

for i in range(1, K+1):
	if N-K >= i-1:
		print((C(K-1, i-1)*C(N-K+1, i))%mod)
	else:
		print(0)
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort(key=lambda x:(x[0], x[1]))
# print(xy)
delta = defaultdict(int)
for i in range(N):
	for j in range(N):
		if i != j:
			delta[(xy[j][0]-xy[i][0], xy[j][1]-xy[i][1])] += 1
print(1+(N-1)-max(delta.values()))

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort(key=lambda x:(x[0], x[1]))
# print(xy)
delta = defaultdict(int)
if N == 1:
	print(1)
else:
	for i in range(N):
		for j in range(N):
			if i != j:
				delta[(xy[j][0]-xy[i][0], xy[j][1]-xy[i][1])] += 1
	print(1+(N-1)-max(delta.values()))
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
BC = [LIST() for _ in range(M)]

for B, C in BC:
	for i in range(B):
		A.append(C)

A.sort(reverse=True)
print(sum(A[0:N]))


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
BC = [LIST() for _ in range(M)]
A.sort(reverse=True)
BC.sort(key=lambda x:-x[1])
# print(A)
# print(BC)
count = 0
ans = 0
while count < N:
	if BC and A[0] < BC[0][1]:  # BCからとる
		if BC[0][0] + count > N:
			ans += BC[0][1] * (N-count)
			count = N
		else:
			count += BC[0][0]
			ans += BC[0][1] * BC[0][0]
		# print(count, ans)
		BC.pop(0)
	else:
		count += 1
		ans += A.pop(0)
		# print(count, ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
uvw = [LIST() for _ in range(N-1)]
uvw.sort(key=lambda x:(x[0], x[1]))
color = [0]*N  # -1で白 1で黒を表す
searched = [0]*N  # 探索した場所に1をいれる
color[0] = -1  # 0番目のノードを白で初期化
searched[0] = 1  # 0 番目のノードは探索済み
for u, v, w in uvw:
	if searched[u-1] == 0 and searched[v-1] == 0:
		uvw.append([u, v, w])
		continue
	if searched[v-1] == 1:
		u, v = v, u
	if w % 2 == 0:
		color[v-1] = color[u-1]
		searched[v-1] = 1
	else:
		color[v-1] = color[u-1] * (-1)
		searched[v-1] = 1
	# print(searched)
# print(color)
for i in color:
	if i == -1:
		print('0')
	else:
		print('1')


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
uvw = [LIST() for _ in range(N-1)]

link_dic = defaultdict(list)

for u, v, w in uvw:
	link_dic[u-1].append((v-1, w))
	link_dic[v-1].append((u-1, w))
# print(link_dic)
searched = [0]*N
color = [0]*N
color[0] = 1
def dfs(i):
	# print(i)
	for node, w in link_dic[i]:
		if searched[node] == 1:
			continue
		else:
			if w % 2 == 0:
				color[node] = color[i]
			else:
				color[node] = color[i] * (-1)
			searched[node] = 1
			dfs(node)

dfs(0)
for i in color:
	if i == -1:
		print('0')
	else:
		print('1')
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
A = [input() for _ in range(H)]

count = [[0]*W for _ in range(H)]
q = deque([])

for i in range(H):
	for j in range(W):
		if A[i][j] == "#":
			q.append((i, j))
# print(q)

dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]

while len(q) >= 1:
	i, j = q.popleft()
	# print(i, j)
	for x, y in zip(dx, dy):
		ny = i + y
		nx = j + x
		if 0 <= nx <= W-1 and 0 <= ny <= H-1 and count[ny][nx] == 0 and A[ny][nx] != "#":
			count[ny][nx] = count[i][j] + 1
			q.append((ny, nx))

ans = 0
for i in range(H):
	ans = max(ans, max(count[i]))
# print(count)
print(ans)


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
A = [input() for _ in range(H)]

count = [[0]*W for _ in range(H)]
q = deque([])

for i in range(H):
	for j in range(W):
		if A[i][j] == "#":
			q.append((i, j))
# print(q)

dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]

while len(q) >= 1:
	i, j = q.popleft()
	# print(i, j)
	for x, y in zip(dx, dy):
		ny = i + y
		nx = j + x
		if 0 <= nx <= W-1 and 0 <= ny <= H-1 and count[ny][nx] == 0 and A[ny][nx] != "#":
			count[ny][nx] = count[i][j] + 1
			q.append((ny, nx))

ans = 0
for i in range(H):
	ans = max(ans, max(count[i]))
# print(count)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 998244353

def power(x, y):
   if y == 0:
       return 1
   elif y == 1:
       return x % mod
   elif y % 2 == 0:
       return power(x, y/2) ** 2 % mod
   else:
       return power(x, (y-1)/2) ** 2 * x % mod

N = INT()
a = [INT() for _ in range(N)]

sum_a = sum(a)
dp = [[0]*(sum_a+1) for _ in range(N+1)]
dp[0][0] = 1

dp2 = [[0]*(sum_a+1) for _ in range(N+1)]
dp2[0][0] = 1

for i, x in enumerate(a):
	for j in range(sum_a+1):
		if j+x >= sum_a+1:
			continue
		dp[i+1][j] = (dp[i+1][j] + dp[i][j]*2)%mod # 赤以外に塗り分ける
		dp[i+1][j+x] = (dp[i+1][j+x] + dp[i][j])%mod # 赤に塗り分ける
		dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j])%mod
		dp2[i+1][j+x] = (dp2[i+1][j+x] + dp2[i][j])%mod
# print(dp)
# print(dp2)
if sum_a%2 == 0:
	print((power(3, N)-3*sum([dp[N][i] for i in range(sum_a+1) if i >= sum_a//2])+3*dp2[N][sum_a//2])%mod)
else:
	print((power(3, N)-3*sum([dp[N][i] for i in range(sum_a+1) if i >= sum_a//2+1]))%mod)


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B , C = MAP()

if A<= C <= B or B<=C<=A:
	print("Yes")
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = LIST()
S = input()

# stand = []
# reverse = []
# state = None
# count = 0
# tmp = None
# for i in S:
# 	if i == "0":
# 		state = "stand"
# 	else:
# 		state = "reverse"
# 	if tmp == "stand" and state == "reverse":
# 		stand.append(count)
# 		count = 1
# 	elif tmp == "reverse" and state == "stand":
# 		reverse.append(count)
# 		count = 1
# 	else: # 状態が前と同じ
# 		count += 1
# 	tmp = state
# if state == "stand":
# 	stand.append(count)
# else:
# 	reverse.append(count)

# if "0" not in S:
# 	print(len(S))
# else:
# 	if K >= len(stand): # 全員逆立ちにできる
# 		print(len(S))
# 	else:
# 		if len(stand) > len(reverse):
# 			reverse.append(0)
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "0":
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "1":
# 			reverse.append(0)
# 		# print(stand)
# 		# print(reverse)
# 		max_ = 0
# 		for i in range(max(1, 1+len(reverse)-(K+1))):
# 			# print(reverse[i:i+K+1],stand[i:i+K])
# 			tmp = sum(reverse[i:i+K+1]+stand[i:i+K])
# 			if tmp > max_:
# 				max_ = tmp
# 		print(max_)

indexes = []
tmp = ""
for i in range(len(S)):
	if S[i] == "0":
		state = "stand"
	else:
		state = "reverse"
	if tmp != state:
		indexes.append(i)
	else: # 状態が前と同じ
		pass
	tmp = state
indexes.append(N)
ans = []
# print(indexes)
for i in range(len(indexes)):
	# print(i)
	if S[indexes[i]] == "0":
		if i+2*K >= len(indexes):
			pass
		ans.append(indexes[i+2*K]-indexes[i])
	else:
		if i+2*K+1 >= len(indexes):
			pass
		ans.append(indexes[i+2*K+1]-indexes[i])
if ans == []:
	print(len(S))
else:
	print(max(ans))

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()

print(max(A+A-1,A+B, B+B-1))
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

tmp = []
tmp.append(-1)
for i, x in enumerate(S):
	if x != "A" and x != "T" and x != "G" and x != "C":
		tmp.append(i)
# print(tmp)
tmp2 = [tmp[i+1]-tmp[i] for i in range(len(tmp)-1)]
print(max(tmp2)-1)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

tmp = []
tmp.append(-1)
for i, x in enumerate(S):
	if x != "A" and x != "T" and x != "G" and x != "C":
		tmp.append(i)
tmp.append(len(S))
# print(tmp)
tmp2 = [tmp[i+1]-tmp[i] for i in range(len(tmp)-1)]
print(max(tmp2)-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
b = [int(x) for x in input().split()]
ans = []
while len(b) > 1:
    tmp = max(b)
    flag = 0
    while flag == 0:
        if b[tmp-1] == tmp: # 数字とインデックスが一致
            ans.append(b.pop(tmp-1))
            flag = 1
        else:
            tmp -= 1
        if tmp == 0:
            flag = -1
            break
    if flag == -1:
        ans = None
        break

if ans == None or b[0] != 1:
    print(-1)
else: 
    ans.append(1)
    for i in ans[::-1]:
        print(i)


Fixed submission:
N = int(input())
b = [int(x) for x in input().split()]
ans = []
while len(b) > 1:
    tmp = max(b)
    flag = 0
    if tmp > len(b):
        ans = None
        break
    while flag == 0:
        if b[tmp-1] == tmp: # 数字とインデックスが一致
            ans.append(b.pop(tmp-1))
            flag = 1
        else:
            tmp -= 1
        if tmp == 0:
            flag = -1
            break
    if flag == -1:
        ans = None
        break

if ans == None or b[0] != 1:
    print(-1)
else: 
    ans.append(1)
    for i in ans[::-1]:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append([int(x) for x in input().split()])

money = 0
count = 0
while count < M:
    min_ = 1000000000
    index = 0
    for i in range(len(A_B)):
        if A_B[i][0] < min_:
            min_ = A_B[i][0]
            index = i
    if count+A_B[index][1] <= M:
        count += A_B[index][1]
        money += A_B[index][0] * A_B[index][1]
    else:
        money += A_B[index][0] * (M-count)
        count = M
    A_B.pop(index)
print(money)


Fixed submission:
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append([int(x) for x in input().split()])

money = 0
count = 0
A_B = sorted(A_B)
while count < M:
    if count+A_B[0][1] <= M:
        count += A_B[0][1]
        money += A_B[0][0] * A_B[0][1]
    else:
        money += A_B[0][0] * (M-count)
        count = M
    A_B.pop(0)
print(money)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append([int(x) for x in input().split()])

money = 0
count = 0
while count < M:
    min_ = 1000000
    index = None
    for i in range(len(A_B)):
        if A_B[i][0] < min_:
            min_ = A_B[i][0]
            index = i
    if count+A_B[index][1] <= M:
        count += A_B[index][1]
        money += A_B[index][1] * A_B[index][0]
    else:
        money += A_B[index][0] * (M-count)
        count = M
    A_B.pop(index)
print(money)

Fixed submission:
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append([int(x) for x in input().split()])

money = 0
count = 0
A_B = sorted(A_B)
while count < M:
    if count+A_B[0][1] <= M:
        count += A_B[0][1]
        money += A_B[0][0] * A_B[0][1]
    else:
        money += A_B[0][0] * (M-count)
        count = M
    A_B.pop(0)
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
arr = []
#for i in range(A, B+1):
#    arr.append(int(format(i, 'b')))
for i in range(A,B+1):
    arr.append(i)
for i in range(len(arr)):
    if i==0:
        ans = arr[i]
    else:
        ans = ans ^ arr[i]
print(ans)

Fixed submission:
A, B = map(int, input().split())
def f(x):
    if x % 2 == 1:
        tmp = (x + 1) / 2
        if tmp % 2 == 0:
            return 0
        else:
            return 1
    else:
        return f(x-1) ^ x
print(f(A-1)^f(B))
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
count = 0
flag = 0
j = 0
while 1:
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            S.pop(i)
            S.pop(i)
            count += 2
            break
        if i==len(S)-2:
            flag = 1
    if len(S)==0 or  len(S) == 1 or flag == 1:
        break
print(count)

Fixed submission:
S = list(input())
count_0 = 0
count_1 = 0


for i in S:
    if i == "0":
        count_0 += 1
    if i == "1":
        count_1 += 1

print(min(count_0, count_1)*2)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = math.gcd(tmp, A[i])

print(tmp)


Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = gcd(tmp, A[i])

print(tmp)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = math.gcd(tmp, A[i])

print(tmp)


Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = gcd(tmp, A[i])

print(tmp)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = math.gcd(tmp, A[i])

print(tmp)


Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = gcd(tmp, A[i])

print(tmp)