Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=min(a)
count_min=Counter(a)[tmp]
kazu=n-count_min
if kazu%(k-1)==0:
    print(kazu//(k-1))
else:
    print(kazu//(k-1)+1)

Fixed submission:
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=min(a)
count_min=Counter(a)[tmp]
kazu=n-count_min
if kazu%(k-1)==0:
    print(kazu//(k-1))
else:
    print(kazu//(k-1)+1)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=[i for i in a if not i==min(a)]
if len(a)%(k-1)==0:
    print(len(a)//(k-1))
else:
    print(len(a)//(k-1)+1)

Fixed submission:
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=min(a)
count_min=Counter(a)[tmp]
kazu=n-count_min
if kazu%(k-1)==0:
    print(kazu//(k-1))
else:
    print(kazu//(k-1)+1)
Buggy python submission (verdict: Runtime Error):
x=int(input())
if x==1:
    print(1)
    a=True
for i in range(33):
    if a:
        break
    if i**2<x:
        pass
    else:
        print((i-1)**2)
        break

Fixed submission:
import sys
x=int(input())
a=[]
if x==0:
    print(0)
    sys.exit()
for i in range(1,33):
    for j in range(2,11):
        if i**j<=x:
            a.append(i**j)
print(max(a))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
if s[a]=="-" and (not "-"in s[:a]+s[a+1:])
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
s=input()
if s[a]=="-" and (not "-"in s[:a]+s[a+1:]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
N=input()
a=list(map(int,input().split()))
c=0
T=True
for i in a:
    if (i%2)!=0:
        print(c)
        break
    else:
        while T:
            a=list(map(lambda x:x/2,a))
            c+=1
            b=list(map(lambda x:True if x%2==0 else False,a))
            T=b[False]
print(c)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
N=input()
a=list(map(int,input().split()))
c=0
T=True
for i in a:
    if (i%2)!=0:
        print(c)
        break
    else:
        while T:
            a=list(map(lambda x:x/2,a))
            c+=1
            b=list(map(lambda x:True if x%2==0 else False,a))
            T=b[False]
        print(c)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
N=input()
a=list(map(int,input().split()))
i=0
T=True
while T:
    a=list(map(lambda x: x/2,a))
    c=list(map(lambda x : True if x%2 ==0 else False,a))    
    for k in c:
        if k==False:
            T=False
            i-=1
    i+=1
print(i)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
N=input()
a=list(map(int,input().split()))
i=0
T=True
while T:
    a=list(map(lambda x: int(x/2),a))
    i+=1
    c=list(map(lambda x : True if x%2 ==0 else False,a))    
    for k in c:
        if k==False:
            T=False
print(i)

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=input()
a=list(map(int,input().split(",")))
a=np.asarray(a)
b=0
while True:
    if all(a%2==0):
        a=a/2
        b+=1
    else:
        break
print(b)


Fixed submission:
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N=input()
a=list(map(int,input().split(",")))
a=np.asarray(a)
b=0
while True:
  if all(a%2==0):
    a=a/2
    b+=1
  else:
    break
print(b)


Fixed submission:
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())

if M - 2*N < 0:
  print N
else:
  print N + int((M - 2*N)/4)


Fixed submission:
n = input()

print 800*n - 200*(int(n/15))
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
n, m = map(int, input().split())
listL, listR = [], []

for i in range(m):
    l, r = map(int, input().split())
    listL.append(l)
    listR.append(r)

for j in range(n):
    for i in range(m):
        if not (listL[i] <= j + 1 <= listR[i]):
            break
    else:
        ans += 1


print(ans)

Fixed submission:
n, m = map(int, input().split())
l, r = 1, n

for _ in range(m):
    tmpL, tmpR = map(int, input().split())
    l = max(l, tmpL)
    r = min(r, tmpR)

print(max(0, r - l + 1))
Buggy python submission (verdict: Time Limit Exceeded):
n, sum = map(int, input().split())

for x in range(n+1):
    for y in range(n+1):
        for z in range(n+1):
            if 10000 * x + 5000 * y + 1000 * z == sum and x + y + z == n:
                break
        else:
            continue
        break
    else:
        continue
    break
else:
    x, y, z = -1, -1, -1


print("{} {} {}".format(x, y, z))

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

for x in range(n+1):
    for y in range(n+1):
        z = n - x - y        
        if 10000 * x + 5000 * y + 1000 * z == sum and z >= 0:
                break
        else:
            continue
        break
    else:
        continue
    break
else:
    x, y, z = -1, -1, -1


print("{} {} {}".format(x, y, z))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                count += 1

print(count)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if s - k <= x + y <= s:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
list = [int(x) for x in input().split()]
print(list[0] - list[1] + 1]

Fixed submission:
list = [int(x) for x in input().split()]
print(list[0] - list[1] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
sum = 0

for i in range(1, N+1):
    if (N-i) % i == 0:
        m = int((N-i) / i)
        if(m <= i):
            print(sum)
            sys.exit()
        
        sum += m


Fixed submission:
import sys

N = int(input())
sum = 0

for i in range(1, N+1):
    if (N-i) % i == 0:
        m = int((N-i) / i)
        if(m <= i):
            print(sum)
            sys.exit()
        
        sum += m
    if((N-i)/i < i):
        print(sum)
        sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
g = {}
a = int(input())
vertices = [i for i in range(1, a + 1)]
for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2]))

Q = [vertices[0]]
d = {i: False for i in vertices}
d[vertices[0]] = True
c = {}
c[vertices[0]] = 0
delta = [vertices[0]] 
while(True):
    for i in g[Q[0]]:
        if d[i[0]] == False:
            delta.append(i[0]) 
            d[i[0]] = True
            if i[1] % 2 == 0: c[i[0]] = c[Q[0]]
            else: c[i[0]] = (c[Q[0]] + 1) % 2
            Q.append(i[0])
    Q = Q[1:]
    if Q == []:
        if set(delta) == set(vertices): break
        else: Q.append(list(set(delta).intersection(set(vertices)))[0])

for i in vertices: print(c[i])

Fixed submission:
g = {}
a = int(input())
for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2]))

c = {}
d = {i: False for i in range(1, a + 1)}
c[1], d[1] = 0, True
Q = [1]
while(Q != []):
    r = Q.pop(0)
    for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2
for i in range(1, a + 1): print(c[i])

Buggy python submission (verdict: Runtime Error):
g = {}
a = int(input())
vertices = [i for i in range(1, a + 1)]
for i in range(a):
    c = [int(s) for s in input().split()] 
    print(0)

Fixed submission:
g = {}
a = int(input())
for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2]))

c = {}
d = {i: False for i in range(1, a + 1)}
c[1], d[1] = 0, True
Q = [1]
while(Q != []):
    r = Q.pop(0)
    for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2
for i in range(1, a + 1): print(c[i])
Buggy python submission (verdict: Runtime Error):
n = input()
ans = 1
while (n != 4 and n != 2 and n != 1):
  ans += 1
  if n % 2 == 0:
    n = n / 2
  else:
    n = 3 * n + 1

print(ans + 3)

Fixed submission:
n = int(input())
ans = 1
while (n != 4 and n != 2 and n != 1):
  ans += 1
  if n%2 == 0:
    n = n / 2
  else:
    n = 3 * n + 1

print(ans + 3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())

if a*b%2:
    print('Odd')
else:
    print('Even')



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

if a*b%2:
    print('Odd')
else:
    print('Even')

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

if a*b%2:
    print('Odd')
else:
    print('Even')



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

if a*b%2:
    print('Odd')
else:
    print('Even')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import math

r,g,b,n = map(int,input().split())

ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) >= 0:
            ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

import math

r,g,b,n = map(int,input().split())

ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) >= 0:
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


if n == 2:
    print(max(a))
else:
    cand = []
    for j in range(n):
        if j == 0:
            temp = a[1]
            for i in range(2,len(a)):
                temp = gcd(temp, a[i])
        else:
            temp = a[0]
            for i in range(1,len(a)):
                if i != j:
                    temp = gcd(temp, a[i])
        cand.append(temp)
    print(max(cand))


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

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

if n == 2:
    print(max(a))
else:
    list1 = make_divisors(a[0])
    list2 = make_divisors(a[1])
    list1.sort()
    list2.sort()
    flag1 = 0
    cand1 = 0
    for i in range(len(list1)):
        flag1 = 0
        for j in range(n):
            if a[j] % list1[i] != 0:
                flag1 += 1
        if flag1 <= 1:
            cand1 = list1[i]
    cand2 = 0
    for i in range(len(list2)):
        flag2 = 0
        for j in range(n):
            if a[j] % list2[i] != 0:
                flag2 += 1
        if flag2 <= 1:
            cand2 = list2[i]
    print(max(cand1,cand2))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())

needs = [n]
cnt = 0
for i in range(n):
    if s[i] == "#":
        need = 0
        cnt += 1
        for j in range(i,n):
            if s[j] == ".":
                need += 1
        needs.append(need + cnt - 1)
need = min(needs)

black = 0
for i in range(n):
    if s[i] == "#":
        black += 1

print(min(black,need))

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())

a = [0] * n

cnt = 0
for i in range(n-1,-1,-1):
    if s[i] == ".":
        cnt += 1
    a[i] = cnt

needs = [n]
cnt = 0
for i in range(n):
    if s[i] == "#":
        need = 0
        cnt += 1
        need += a[i]
        needs.append(need + cnt - 1)
need = min(needs)

black = 0
for i in range(n):
    if s[i] == "#":
        black += 1

print(min(black,need))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n,k = map(int,input().split())
s = list(input())
s = list(map(int,s))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

ss = array_count(s)

if ss[0][0] == 0:
    ss = [[1,0]] + ss

if ss[-1][0] == 1:
    ss.append([0,0])

ss_sum = []
temp = 0
for i in range(len(ss)):
    temp += ss[i][1]
    ss_sum.append(temp)

ans = -1
for i in range(len(ss_sum)):
    temp = 0
    if i % 2 == 0:
        if i + k * 2 < len(ss_sum):
            temp = ss_sum[i+k*2] - ss_sum[i]
    else:
        if i + k * 2 + 1 < len(ss_sum):
            temp = ss_sum[i+k*2+1] -  ss_sum[i]
    ans = max(temp,ans)

if k * 2 >= len(ss):
    ans = ss_sum[-1]

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

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

coin = 0
if a >= b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1
if a >= b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1

print(coin)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n,k = map(int,input().split())
s = list(input())
s = list(map(int,s))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

ss = array_count(s)

if ss[0][0] == 0:
    ss = [[1,0]] + ss

if ss[-1][0] == 1:
    ss.append([0,0])

ss_sum = []
temp = 0
for i in range(len(ss)):
    temp += ss[i][1]
    ss_sum.append(temp)

ans = -1
for i in range(len(ss_sum)):
    temp = 0
    if i % 2 == 0:
        if i + k * 2 < len(ss_sum):
            temp = ss_sum[i+k*2] - ss_sum[i]
    else:
        if i + k * 2 + 1 < len(ss_sum):
            temp = ss_sum[i+k*2+1] -  ss_sum[i]
    ans = max(temp,ans)

if k * 2 >= len(ss):
    ans = ss_sum[-1]

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

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

coin = 0
if a >= b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1
if a >= b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1

print(coin)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x,y,z,k = map(int,input().split())
a,b,c = [],[],[]
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ab = []

for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])

ab.sort()

abc = []

for i in range(min(len(ab),k)):
    for j in range(min(z,k)):
        abc.append(ab[-(i+1)] + c[j])

abc.sort()

for i in range(k):
    print(abc[-(i+1)])

Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()

cnum = []

takadaka = math.ceil(k ** 0.67)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])


Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])


Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])


Fixed submission:
# -*- coding: utf-8 -*-

a = [0]*5
n = int(input())
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

bottle = min(a[0],a[1],a[2],a[3],a[4])

time = 0

if n % bottle == 0:
    time = int(n / bottle)
else:
    time = int(n // bottle) + 1

if bottle >= n:
    print(5)
else:
    print(time+4)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

a = [0]*5
n = int(input())
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

b = [0] * 6
b[0] = n

cnt = 0
def move():
    global b,cnt
    c = b[:]
    if b[0] < a[0]:
        c[0] -= b[0]
        c[1] += b[0]
    else:
        c[0] -= a[0]
        c[1] += a[0]
    if b[1] < a[1]:
        c[1] -= b[1]
        c[2] += b[1]
    else:
        c[1] -= a[1]
        c[2] += a[1]
    if b[2] < a[2]:
        c[2] -= b[2]
        c[3] += b[2]
    else:
        c[2] -= a[2]
        c[3] += a[2]
    if b[3] < a[3]:
        c[3] -= b[3]
        c[4] += b[3]
    else:
        c[3] -= a[3]
        c[4] += a[3]
    if b[4] < a[4]:
        c[4] -= b[4]
        c[5] += b[4]
    else:
        c[4] -= a[4]
        c[5] += a[4]
    b = c[:]
    cnt += 1
    if b[5] == n:
        return True
    else:
        return False

reached = False
while(not reached):
    reached = move()

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-

a = [0]*5
n = int(input())
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

bottle = min(a[0],a[1],a[2],a[3],a[4])

time = 0

if n % bottle == 0:
    time = int(n / bottle)
else:
    time = int(n // bottle) + 1

if bottle >= n:
    print(5)
else:
    print(time+4)
Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open("C:/Users/user/Documents/python/atcoder/ABC118/import.txt","r")
sys.stdin = f

# -*- coding: utf-8 -*-

a,b = map(int,input().split())
if a % b == 0:
    print(a+b)
else:
    print(b-a)


Fixed submission:
a,b = map(int,input().split())
if b % a== 0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
a = [0] + a

print(reduce(math.gcd, a[1:]))


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

if len(a) == 1:
    ans = a[0]
else:
    ans = gcd(a[0],a[1])
    for i in range(2,n):
        ans = gcd(ans,a[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
a = [0] + a

print(reduce(math.gcd, a[1:]))

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

if len(a) == 1:
    ans = a[0]
else:
    ans = gcd(a[0],a[1])
    for i in range(2,n):
        ans = gcd(ans,a[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n,p = map(int,input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)
arr = array_count(fac)

ans = 1
for i in range(len(arr)):
    if arr[i][1] >= n:
        ans *= arr[i][0]

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

n,p = map(int,input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)

if len(fac) >= 1:
    arr = array_count(fac)

    ans = 1
    for i in range(len(arr)):
        if arr[i][1] >= n:
            ans *= arr[i][0] ** (arr[i][1] // n)

    print(ans)
else:
    print(1)