Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
port sys
sys.setrecursionlimit(10**9)
 
N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))
 
 
ans = max(count)
c = 1
 
 
 
def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1
 
color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))


ans = max(count)
c = 1



def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1

color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])

Buggy python submission (verdict: Runtime Error):
N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))


ans = max(count)
c = 1



def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i not in pr:
            if c == col:
                c+=1
            x, y = sorted([i, idx])
            color[(x, y)] = c
            dfs(i, (x, y))
        c+=1

color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])




Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))


ans = max(count)
c = 1



def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1

color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])
Buggy python submission (verdict: Runtime Error):
money = [300000, 200000, 100000]
X, Y = map(int, input().split())
X -= 1; Y -= 1
ans = money[X] + money[Y]
if X + Y:
    print(ans)
else:
    print(ans + 400000)

Fixed submission:
X, Y = map(int, input().split())
syoukin = [3*10**5, 2*10**5, 1*10**5]
if X == 1 and Y == 1:
    print(10*10**5)
else:
    money = 0
    if X <= 3:
        money += syoukin[X-1]
    if Y <= 3:
        money += syoukin[Y-1]
    print(money)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
brob = 0
temp = 1
first = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        temp += 1
    else:
        if first == 0:
            first = temp
        brob += temp // 2
        temp = 1S = input()
K = int(input())
brob = 0
temp = 1
first = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        temp += 1
    else:
        if first == 0:
            first = temp
        brob += temp // 2
        temp = 1
        
brob += temp // 2
last = temp

if K == 1:
    print(brob)

else:
    if last == len(S):
        print(len(S) * K // 2)
    
    elif S[-1] != S[0]:
        print(brob * K)
    

    elif last % 2 and first % 2:
        print(brob * K + K - 1)

    else:
        print(brob * K)

        
brob += temp // 2
last = temp

if K == 1:
    print(brob)

else:
    if len(S) == 1:
        print(K // 2)
    
    elif S[-1] != S[0]:
        print(brob * K)

    elif last % 2 and first % 2:
        print(brob * K + K - 1)

    else:
        print(brob * K)


Fixed submission:
S = input()
K = int(input())
brob = 0
temp = 1
first = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        temp += 1
    else:
        if first == 0:
            first = temp
        brob += temp // 2
        temp = 1
        
brob += temp // 2
last = temp

if K == 1:
    print(brob)

else:
    if last == len(S):
        print(len(S) * K // 2)
    
    elif S[-1] != S[0]:
        print(brob * K)
    

    elif last % 2 and first % 2:
        print(brob * K + K - 1)

    else:
        print(brob * K)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    
    c = Counter(A).most_common()

    if c[0][0] == "0" and c[0][1] == N:
        print("Yes")
    elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == "0" and c[1][1] == N//3:
        print("Yes")
    elif len(c) == 3 and int(c[0][0])^int(c[1][0]) == int(c[2][0]) and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    left_smaller = [0]*N
    right_smaller = [0]*N
    for i, a in enumerate(A):
        left_smaller[i] = sum(b < a for b in A[:i])
        right_smaller[i] = sum(b < a for b in A[i+1:])

    ans = sum((l*(K)*(K-1)//2%MOD + r*(K+1)*(K)//2%MOD)%MOD for l, r in zip(left_smaller, right_smaller))%MOD
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

def f2(N, K):
    return comb(N+K-1, K-1, exact=True) % MOD

def f(N, K):
    if (N < K): return 0
    if N == 0 and K == 0: return 1
    if (K < 1): return 0
    return f2(N-K, K)


for i in range(1,K+1):
    blue = f(K, i)
    red = 0
    red += f(N-K, i-1)
    red += f(N-K, i) * 2 % MOD
    red += f(N-K, i+1) % MOD
    
    print(red * blue % MOD)

Fixed submission:
from operator import mul
from functools import reduce

N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(N, R):
    R = min(N-R, R)
    if R == 0: return 1
    over = reduce(mul, range(N, N - R, -1))
    under = reduce(mul, range(1,R + 1))
    return over // under % MOD


def f2(N, K):
    return comb(N+K-1, K-1)

def f(N, K):
    if (N < K): return 0
    if N == 0 and K == 0: return 1
    if (K < 1): return 0
    return f2(N-K, K)


for i in range(1,K+1):
    blue = f(K, i)
    red = 0
    red += f(N-K, i-1)
    red += f(N-K, i) * 2 % MOD
    red += f(N-K, i+1) % MOD
    
    print(red * blue % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

C = [[0] * 4005 for _ in range(4005)]

def init():
    C[0][0] = 1
    for i in range(4002):
        for j in range(0, i+1):
            C[i+1][j] += C[i][j]
            C[i+1][j] %= MOD
            C[i+1][j+1] += C[i][j]
            C[i+1][j+1] %= MOD
            

def comb(N, K):
    return C[N][K]

def f2(N, K):
    return comb(N+K-1, K-1)

def f(N, K):
    if (N < K): return 0
    if N == 0 and K == 0: return 1
    if (K < 1): return 0
    return f2(N-K, K)


init()

for i in range(1,K+1):
    blue = f(K, i)
    red = 0
    red += f(N-K, i-1)
    red += f(N-K, i) * 2 % MOD
    red += f(N-K, i+1) % MOD
    
    print(red * blue % MOD)

Fixed submission:
from operator import mul
from functools import reduce

N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(N, R):
    R = min(N-R, R)
    if R == 0: return 1
    over = reduce(mul, range(N, N - R, -1))
    under = reduce(mul, range(1,R + 1))
    return over // under % MOD


def f2(N, K):
    return comb(N+K-1, K-1)

def f(N, K):
    if (N < K): return 0
    if N == 0 and K == 0: return 1
    if (K < 1): return 0
    return f2(N-K, K)


for i in range(1,K+1):
    blue = f(K, i)
    red = 0
    red += f(N-K, i-1)
    red += f(N-K, i) * 2 % MOD
    red += f(N-K, i+1) % MOD
    
    print(red * blue % MOD)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split())))
Left = 0
Right = sum(W)
ans = Right

for val in W:
    Left += val
    Right -= val
    ans = min(ans, abs(Right - Left))
print(ans)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
Left = 0
Right = sum(W)
ans = Right

for val in W:
    Left += val
    Right -= val
    ans = min(ans, abs(Right - Left))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):
    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        if s in edges[key]:
            del edges[key][s]

        dfs(key, d)
    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)
for color in colors:
    print(color)



Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N = int(input())

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):

    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        if s in edges[key]:
            del edges[key][s]

        dfs(key, d)

    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)

for color in colors:
    print(color)

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

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):
    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        del edges[key][s]
        dfs(key, d)
    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)
for color in colors:
    print(color)



Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N = int(input())

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):

    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        if s in edges[key]:
            del edges[key][s]

        dfs(key, d)

    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)

for color in colors:
    print(color)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
def input():return sys.stdin.readline().strip()

def main():
    H, W = map(int, input().split())

    field = "#" * (W+2)
    field += "#" + "##".join([input() for _ in range(H)]) + "#"
    field += "#" * (W+2)

    move = [-1, 1, -(W+2), W+2]
    cost = [-1] * (H+2) * (W+2)

    def dfs(s):
        q = deque()
        enqueue = q.append
        dequeue = q.popleft

        for v in s:
            cost[v] = 0
            enqueue(v)

        while q:
            now = dequeue()
            for dx in move:
                nv = now + dx
                if field[nv] == "." and cost[nv] < 0:
                    cost[nv] = cost[now] + 1
                    enqueue(nv)
    
    starts = []
    for i in range(1, H+1):
        for j in range(1, W+1):
            now = i*(W+2) + j
            if field[now] == "#":
                starts.append(now)
    dfs(starts)

    print(max(cost))

if __name__ == "__main__":
    main()

Fixed submission:
import sys
from collections import deque
def input():return sys.stdin.readline().strip()

def main():
    H, W = map(int, input().split())

    field = "#" * (W+2)
    field += "#" + "##".join([input() for _ in range(H)]) + "#"
    field += "#" * (W+2)

    move = [-1, 1, -(W+2), W+2]
    cost = [-1] * (H+2) * (W+2)

    def dfs(s):
        q = deque()
        enqueue = q.append
        dequeue = q.popleft

        for v in s:
            cost[v] = 0
            enqueue(v)

        while q:
            now = dequeue()
            for dx in move:
                nv = now + dx
                if field[nv] == "." and cost[nv] < 0:
                    cost[nv] = cost[now] + 1
                    enqueue(nv)
    
    starts = []
    for i in range(1, H+1):
        for j in range(1, W+1):
            now = i*(W+2) + j
            if field[now] == "#":
                starts.append(now)
    dfs(starts)

    print(max(cost))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
s = set([])
def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            s.add(i)
            s.add(n // i)

for i in range(2):
    divisor(A[i])

for num in A:
    for key in s:
        if num % key == 0:
            d[key] += 1

ans = 1
for key, val in d.items():
    if val >= N - 1:
        ans = max(ans, key)

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

def ABC125gcd(x, y):
    if min(x, y) == 0:
        return max(x, y)
    else:
        return ABC125gcd(y, x % y)

L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = ABC125gcd(L[i - 1], A[i - 1])
    R[N - 1 - i] = ABC125gcd(R[N - i], A[N - i])

ans = 1
for i in range(N):
    ans = max(ans, ABC125gcd(L[i], R[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

d = {}
s = set([])
def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            s.add(i)
            s.add(n // i)

for i in range(2):
    divisor(A[i])

for num in A:
    for key in s:
        if num % key == 0:
            if key not in d:
                d[key] = 1
            else:
                d[key] += 1

ans = 1
for key, val in d.items():
    if val >= N - 1:
        ans = max(ans, key)

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

def ABC125gcd(x, y):
    if min(x, y) == 0:
        return max(x, y)
    else:
        return ABC125gcd(y, x % y)

L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = ABC125gcd(L[i - 1], A[i - 1])
    R[N - 1 - i] = ABC125gcd(R[N - i], A[N - i])

ans = 1
for i in range(N):
    ans = max(ans, ABC125gcd(L[i], R[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

d = {}
def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i not in d:
                d[i] = 1
            else:
                d[i] += 1

            rev = n // i
            if i != rev:
                if rev not in d:
                    d[rev] = 1
                else:
                    d[rev] += 1

for num in A:
    divisor(num)

ans = 1
for key, val in d.items():
    if val >= N - 1:
        ans = max(ans, key)

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

def ABC125gcd(x, y):
    if min(x, y) == 0:
        return max(x, y)
    else:
        return ABC125gcd(y, x % y)

L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = ABC125gcd(L[i - 1], A[i - 1])
    R[N - 1 - i] = ABC125gcd(R[N - i], A[N - i])

ans = 1
for i in range(N):
    ans = max(ans, ABC125gcd(L[i], R[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
S = S + "2"
chokuritsu = []
sakadachi = []
flag = S[0]
count = 1
for c in S:
    if flag != c:
        if c == "1":
            chokuritsu.append(count)
        elif c == "0":
            sakadachi.append(count)
        elif c == "2":
            if flag == "1":
                sakadachi.append(count-1)
            else:
                chokuritsu.append(count-1)

        count = 1
        flag = c
    else:
        count += 1
ans = 0
sub_ans = 0

if S[0] == "1":
    for i in range(min(K, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i]
    sub_ans += sakadachi[min(K-1, len(sakadachi)-1)]
    ans = max(ans, sub_ans)
    for i in range(len(sakadachi) - K):
        sub_ans += sakadachi[i+K] + chokuritsu[i+K-1]
        sub_ans -= sakadachi[i] + chokuritsu[i-1]
        ans = max(ans, sub_ans)

    if S[-1] == "0":
        sub_ans = chokuritsu[-1]
        for i in ragne(len(sakadachi)-1, len(sakadachi) - 1 - min(K -1, len(sakadachi)), -1):
            sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)

else:
    sub_ans = chokuritsu[0]
    for i in range(min(K - 1, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)
    sub_ans = 0
    for i in range(min(K, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i+1]
    sub_ans += sakadachi[min(K-1, len(sakadachi)-1)]

    for i in range(len(sakadachi) - K):
        sub_ans += sakadachi[i+K] + chokuritsu[i+K]
        sub_ans -= sakadachi[i] + chokuritsu[i]
        ans = max(ans, sub_ans)

    if S[-1] == "0":
        sub_ans = chokuritsu[-1]
        for i in ragne(len(sakadachi)-1, len(sakadachi) - 1 - min(K -1, len(sakadachi)), -1):
            sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)

print(ans)

Fixed submission:
N, K = map(int, input().split())
S = input()

nums = []
now = 1
seq_count = 0
for char in S:
    if char == str(now):
        seq_count += 1
    else:
        now = 1 - now
        nums.append(seq_count)
        seq_count = 1

nums.append(seq_count)

if len(nums) % 2 == 0:
    nums.append(0)

sums = [0] * (len(nums) + 1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]

ans = 0
for i in range(1, len(sums), 2):
    left = i - 1
    right = min(i + 2 * K, len(sums) - 1)
    ans = max(ans, sums[right] - sums[left])
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
print(Counter(input()).most_common()[1][1]*2)

Fixed submission:
from collections import deque
import copy
S = deque(input())
S2 = deque([])
counter = 0
while True:
    flag = True
    while True:
        if len(S) == 0:
            break
        s = S.popleft()
        if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
        
        elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
        else:
            S2.append(s)
    
    if flag:
        break
    else:
        S = copy.deepcopy(S2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
#TLE
S = input()
flag0 = False
flag1 = False
counter = 0
while True:
    idx = S.find("01")
    if idx>=0:
        S = S[:idx] + S[idx+2:]
        counter += 2
    else:
        flag0 = True
    
    idx = S.find("10")
    if idx>=0:
        S = S[:idx] + S[idx+2:]
        counter += 2
    else:
        flag1 = True

    if flag0 and flag1 :
        break
print(counter)

Fixed submission:
from collections import deque
import copy
S = deque(input())
S2 = deque([])
counter = 0
while True:
    flag = True
    while True:
        if len(S) == 0:
            break
        s = S.popleft()
        if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
        
        elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
        else:
            S2.append(s)
    
    if flag:
        break
    else:
        S = copy.deepcopy(S2)
print(counter)
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [1] * N

    def root(self, x):
        px = self.par[x]
        if px == x:
            return x
        else:
            self.par[x] = self.root(px)
            return self.par[x]

    def unite(self, x, y):
        rootx = self.root(x)
        rooty = self.root(y)
        rankx = self.rank[rootx]
        ranky = self.rank[rooty]
        if rootx == rooty:
            return 0
        elif rankx < ranky:
            self.par[rooty] = rootx
            self.rank[rootx] += ranky
            return rankx * ranky
        else:
            self.par[rootx] = rooty
            self.rank[rooty] += rankx
            return ranky * rankx 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

N, M = map(int, input().split())
tree = UnionFind(N)
li = [list(map(int, input().split())) for i in range(M)]
inconv = [0] * M
for i in range(M-1, -1, -1):
    inconv[i] = tree.unite(li[i][0]-1, li[i][1]-1)
    
temp = 0
for i in range(M):
    temp += inconv[i]
    print(temp)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [1] * N

    def root(self, x):
        px = self.par[x]
        if px == x:
            return x
        else:
            self.par[x] = self.root(px)
            return self.par[x]

    def unite(self, x, y):
        rootx = self.root(x)
        rooty = self.root(y)
        rankx = self.rank[rootx]
        ranky = self.rank[rooty]
        if rootx == rooty:
            return 0
        elif rankx < ranky:
            self.par[rooty] = rootx
            self.rank[rootx] += ranky
            return rankx * ranky
        else:
            self.par[rootx] = rooty
            self.rank[rooty] += rankx
            return ranky * rankx 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

N, M = map(int, input().split())
tree = UnionFind(N)
li = [list(map(int, input().split())) for i in range(M)]
inconv = [0] * M
for i in range(M-1, -1, -1):
    inconv[i] = tree.unite(li[i][0]-1, li[i][1]-1)
    
temp = 0
for i in range(M):
    temp += inconv[i]
    print(temp)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)

Fixed submission:
"""
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)
"""
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
g = gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = gcd(g, a)
print(g)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)

Fixed submission:
"""
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)
"""
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
g = gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = gcd(g, a)
print(g)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)

Fixed submission:
"""
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)
"""
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
g = gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = gcd(g, a)
print(g)