Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
c.sort()
ans = 0
for i in c:
    if K >= d:
        break
    ans += i
    d -= 1
print(ans)


Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
c.sort()
ans = 0
for i in c:
    if K >= d:
        break
    ans += i
    d -= 1
print(ans)


Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
c.sort()
e = deque(c)
ans = 0
for i in e:
    if K >= d:
        break
    ans += i
    d -= 1
print(ans)


Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
ans = 0
for i in c:
  if K >= d:
    break
  ans += i
  d -= 1
  print(c[i])
print(ans)


Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = []
d = len(b)
ans = 0
for i in b:
  c.append(a.count(i))
c.sort()
for i in c:
  if K >= d:
    break
  ans += i
  d -= 1
print(ans)
  
  


Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
  b = int(input())
  if b in a:
    del a[a.index(b)]
  else:
    a.append(b)
print(len(a))

Fixed submission:
N = int(input())
a =set([])
for i in range(N):
  b = int(input())
  if b in a:
    a.remove(b)
  else:
    a.add(b)
print(len(a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 1:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
  elif li[-1] != li[-2] or  a != 0 and a == li[-1]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Fixed submission:
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 2:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
    del li[-1]
  elif li[-1] != li[-2]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
for i in range(N):
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
  elif li[-1] != li[-2] or  a != 0 and a == li[-1]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Fixed submission:
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 2:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
    del li[-1]
  elif li[-1] != li[-2]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = input().split()
ans = []
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            ans.append(li[i])
        if i % 2 == 1:
            ans.insert(0,li[i])
else:
    for i in range(N):
        if i % 2 == 0:
            ans.insert(0,li[i])
        if i % 2 == 1:
            ans.append(li[i])
for i in range(N):
    print(ans[i],end=' ')

Fixed submission:
from collections import deque

N = int(input())
li = input().split()
ans = deque()
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            ans.append(li[i])
        elif i % 2 == 1:
            ans.appendleft(li[i])
else:
    for i in range(N):
        if i % 2 == 0:
            ans.appendleft(li[i])
        elif i % 2 == 1:
            ans.append(li[i])
for i in range(N):
    print(ans[i],end=' ')
Buggy python submission (verdict: Runtime Error):
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

Fixed submission:
N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j] = li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = (N // 11) * 2
if N%11 == 0:
    ans = ans
elif N%0 != 0 and N%11 <= 6:
    ans += 1
else:
    ans += 2
print(ans)

Fixed submission:
N = int(input())
ans = (N // 11) * 2
if N%11 == 0:
    ans = ans
elif N%11 != 0 and N%11 <= 6:
    ans += 1
else:
    ans += 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

# 最小公倍数を求める
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

BASE = 10**9 + 7

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

num = lcm(A)
ans = 0
for i in range(N):
    ans += num // A[i]
    ans %= BASE

print(ans)

Fixed submission:
from fractions import gcd
from functools import reduce

# 最小公倍数を求める
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

BASE = 10**9 + 7

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

num = lcm(A)
ans = 0
for i in range(N):
    ans += num // A[i]
    # ans %= BASE

print(ans%BASE)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
if (x <= 2):
    print(2)
    exit()
prime_list = [2]
for num in range(3,10**5,2):
    if all(num % prime != 0 for prime in prime_list):
        prime_list.append(num)
        if (num >= x):
            print(num)
            exit()

Fixed submission:
import math
x = int(input())
if (x <= 2):
    print(2)
    exit()
ans = 100003
if (x%2 == 0):
    x += 1
for num in range(x, 10**5, 2):
    flag = True
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if(num % i == 0):
            flag = False
            break
    if(flag):
        ans = num
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
prime_list = [2]
for num in range(3,10**5,2):
    if all(num % prime != 0 for prime in prime_list):
        prime_list.append(num)
        if (num >= x):
            print(num)
            exit()
print(100003)

Fixed submission:
import math
x = int(input())
if (x <= 2):
    print(2)
    exit()
ans = 100003
if (x%2 == 0):
    x += 1
for num in range(x, 10**5, 2):
    flag = True
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if(num % i == 0):
            flag = False
            break
    if(flag):
        ans = num
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
if(sum(a) > 21)
  print('bust')
else
  print('win')

Fixed submission:
a,b,c = map(int, input().split())
if a+b+c >= 22:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Runtime Error):
s = input()

res = 0
for i in range(len(s)//2):
  if(s[i] != s[-i-1])
    res++

print(res)

Fixed submission:
s = input()

res = 0
for i in range(len(s)//2):
  if(s[i] != s[-i-1]):
    res += 1

print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        sub.append(s[i:j])
sub = sorted(list(set(sub)))
print(sub[k-1])

Fixed submission:
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i+1, min(i+6, len(s)+1)):
        sub.append(s[i:j])
sub = sorted(list(set(sub)))
print(sub[k-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
x = sorted(X)
m1 = x[N//2]
m2 = x[N//2-1]
for i in X:
    print(m1 if i < m else m2)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
x = sorted(X)
m1 = x[N//2]
m2 = x[N//2-1]
for i in X:
    print(m1 if i < m1 else m2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b, c = [], [], []
for i in range(n):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])
    if(ab[0] > ab[1]):
        c.append(ab[1])
if(len(c) == 0):
    print(0)
else:
    sort.c()
    print(sum(a) - c[0])

Fixed submission:
n = int(input())
a, b, c = [], [], []
for i in range(n):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])
    if(ab[0] > ab[1]):
        c.append(ab[1])
if(len(c) == 0):
    print(0)
else:
    print(sum(a) - min(c))
Buggy python submission (verdict: Runtime Error):
s = input()
if(len(s) == 0):
    print('a')
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(True):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())


Fixed submission:
s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(s):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())
print(-1)

Buggy python submission (verdict: Runtime Error):
s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(True):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())


Fixed submission:
s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(s):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())
print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n+1):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")

Fixed submission:
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())-1
a, b = 2, 1
if(n==0):
    print(2)
elif(n==1):
    print(1)
while(n):
    c = a + b
    a = b
    b = c
    n -= 1
print(c)

Fixed submission:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    l.append(l[i-2]+l[i-1])
print(l[n])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    c = input()
    if(c in a):
        a.remove(c)
    else:
        a.append(c)
print(len(a))

Fixed submission:
n = int(input())
dict = {}
ans = 0
for i in range(n):
    c = input()
    if(c in dict):
        dict[c] += 1
    else:
        dict[c] = 1
for i in dict:
    ans += dict[i] % 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab, c, d = [], [], []
for i in range(m):
    ab.append(list(map(int, input().split())))
for i in range(m):
    if(ab[i][0] == n):
        c.append(ab[i][1])
    elif(ab[i][1] == n):
        c.append(ab[i][0])
    elif(ab[i][0] == 1):
        d.append(ab[i][1])
    elif(ab[i][1] == 1):
        d.append(ab[i][0])
for i in c:
    if(i in d):
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Fixed submission:
n, m = map(int, input().split())
ab, c, d = [], set(), set()
for i in range(m):
    ab.append(list(map(int, input().split())))
for i in range(m):
    if(ab[i][0] == n):
        c.add(ab[i][1])
    elif(ab[i][1] == n):
        c.add(ab[i][0])
    elif(ab[i][0] == 1):
        d.add(ab[i][1])
    elif(ab[i][1] == 1):
        d.add(ab[i][0])
if(c & d):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
    b.append(str(i))
    b = b[::-1]
print(' '.join(b))

Fixed submission:
n = int(input())
a = list(map(str, input().split()))
b = a[::-2] + a[len(a)%2::2]
print(' '.join(b))
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
print('#'*w)
for i in range(w):
    print('#'+input()+'#')
print('#'*w)


Fixed submission:
h, w = map(int, input().split())
s = []
s.append('#'*(w+2))
for i in range(h):
    s.append('#'+input()+'#')
s.append('#'*(w+2))
for i in range(h+2):
    print(s[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    c.extend([a]*b)
print(sorted(c)[k-1])


Fixed submission:
n, k = map(int, input().split())
ab = []
count = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
for i in range(k):
    count += ab[i][1]
    if(count >= k):
        print(ab[i][0])
        break
Buggy python submission (verdict: Time Limit Exceeded):
x = input()
while('ST' in x):
    x = x.replace('ST', '')
print(len(x))

Fixed submission:
x = input()
s, t = 0, 0
for c in x:
    if(c == 'S'):
        s += 1
    else:
        if(s):
            s -= 1
        else:
            t += 1
print(t*2)
Buggy python submission (verdict: Runtime Error):
import fractions
import math

n,m = map(int,input().split())
A=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        flag=1

num=A[0]//2
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            num=0
            break
    print(math.ceil(m//num/2))



Fixed submission:
import fractions
import math

n,m = map(int,input().split())
A=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        exit()

l = 1
for i in A:
    l = l * i//2 // fractions.gcd(l, i//2)
 
print((m // l + 1) // 2)

"""
num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))
"""

Buggy python submission (verdict: Runtime Error):
import fractions
import math

n,m = map(int,input().split())
A=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def chk(i):
    cnt=0
    while True:
        if i%2==1:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        flag=1

num=A[0]//2
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            num=0
            break
print(math.ceil(m//num/2))



Fixed submission:
import fractions
import math

n,m = map(int,input().split())
A=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        exit()

l = 1
for i in A:
    l = l * i//2 // fractions.gcd(l, i//2)
 
print((m // l + 1) // 2)

"""
num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))
"""
Buggy python submission (verdict: Runtime Error):
import collections
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


n=int(input())

arr=[]
for i in range(n):
    a,b=(map(int, input().split()))
    arr.append([a,b])
arr=sorted(arr, key=lambda x: x[1], reverse=True)
arr=sorted(arr, key=lambda x: x[0])

tmparr=[]
for num in range(len(arr)-1):
    #print(num)
    #tmparr=[]
    #for nn,i in enumerate(arr):
    for nn,i in enumerate(arr[num+1:]):
        #if nn==num:
        #    continue
        g=gcd(arr[num][0]-i[0],arr[num][1]-i[1])
        tmparr.append(((arr[num][0]-i[0]),(arr[num][1]-i[1])))
        #print(tmparr)
    #print(tmparr)
#print(set(tmparr))
c = collections.Counter(tmparr)
print(n-c.most_common()[0][1])


Fixed submission:
import collections

n=int(input())

if n==1:
    a,b=(map(int, input().split()))
    print(1)
else:

    arr=[]
    for i in range(n):
        a,b=(map(int, input().split()))
        arr.append([a,b])
    arr=sorted(arr, key=lambda x: x[1], reverse=True)
    arr=sorted(arr, key=lambda x: x[0])
    
    tmparr=[]
    for num in range(len(arr)-1):
        #print(num)
        #tmparr=[]
        #for nn,i in enumerate(arr):
        for nn,i in enumerate(arr[num+1:]):
            #if nn==num:
            #    continue
            #g=gcd(arr[num][0]-i[0],arr[num][1]-i[1])
            tmparr.append(((arr[num][0]-i[0]),(arr[num][1]-i[1])))
            #print(tmparr)
        #print(tmparr)
    #print(set(tmparr))
    c = collections.Counter(tmparr)
    print(n-c.most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)


Fixed submission:
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

targetnum=999
minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)
Buggy python submission (verdict: Runtime Error):
n=int(input())
#for i in range(n):
if n>2:
    A=list(set(list(map(int, input().split(" ")))))
else:
    A=list(map(int, input().split(" ")))

A.sort()
t1=A[0]
t2=A[1]

while t1!=t2:
    #print(t1)
    if t1>t2:
        t1=t1-t2
    else:
        t2=t2-t1

print(t1)

Fixed submission:
n=int(input())
tmp=list(map(int, input().split(" ")))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

a=max(tmp)
for i in tmp:
    a=gcd(a,i)

print(a)

Buggy python submission (verdict: Runtime Error):
n=int(input())
#for i in range(n):
A=list(set(list(map(int, input().split(" ")))))

A.sort()
t1=A[0]
t2=A[1]

while t1!=t2:
    #print(t1)
    if t1>t2:
        t1=t1-t2
    else:
        t2=t2-t1

print(t1)

Fixed submission:
n=int(input())
tmp=list(map(int, input().split(" ")))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

a=max(tmp)
for i in tmp:
    a=gcd(a,i)

print(a)
Buggy python submission (verdict: Runtime Error):
import pandas as pd
n=int(input())
O=[]
#A=[]
#B=[]
for i in range(n):
    a,b=map(int, input().split(" "))
    O.append([2*a-b,a,b])
  
O=sorted(O, key=lambda x: x[0])[::-1]
#print(O)

count=0
for num in range(n):
    if num%2==0:
        count+=O[num][1]
    else:
        count-=O[num][2]

print(count)


Fixed submission:
#import pandas as pd
n=int(input())
O=[]
#A=[]
#B=[]
for i in range(n):
    a,b=map(int, input().split(" "))
    O.append([a+b,a,b])
  
#O=sorted(O, key=lambda x: (x[0],x[1]))[::-1]
O=sorted(O, key=lambda x: (x[0]))[::-1]
#print(O)

count=0
for num in range(n):
    if num%2==0:
        count+=O[num][1]
    else:
        count-=O[num][2]

print(count)

Buggy python submission (verdict: Runtime Error):
import pandas as pd
n=int(input())
O=[]
A=[]
B=[]
for i in range(n):
    a,b=map(int, input().split(" "))
    O.append(a+a-b)
    A.append(a)
    B.append(b)

tmp=pd.DataFrame()
tmp["o"]=O
tmp["b"]=A
tmp["c"]=B

tmp=tmp.sort_values(by="o",ascending=False)

count=0
for num,(i,j) in enumerate(zip(tmp["b"].values,tmp["c"].values)):
    if num%2==0:
        count+=i
    else:
        count-=j
print(count)



Fixed submission:
#import pandas as pd
n=int(input())
O=[]
#A=[]
#B=[]
for i in range(n):
    a,b=map(int, input().split(" "))
    O.append([a+b,a,b])
  
#O=sorted(O, key=lambda x: (x[0],x[1]))[::-1]
O=sorted(O, key=lambda x: (x[0]))[::-1]
#print(O)

count=0
for num in range(n):
    if num%2==0:
        count+=O[num][1]
    else:
        count-=O[num][2]

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().split()))
#dpテーブルの初期化
#最小化問題
dp=[10*18]*n
dp[0]=0

for i in range(1,n):
    tmpmin=9999999999999999999999
    for j in range(k): 
        if i-j-1<0:
            break
        ans=dp[i-j-1]+abs(A[i]-A[i-j-1])
        if tmpmin>ans:
            tmpmin=ans

    dp[i]=tmpmin
print(dp[-1])

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
#dpテーブルの初期化
#最小化問題
dp=[10*18]*n
dp[0]=0

for i in range(1,n):
    tmpmin=9999999999999999999999
    for j in range(k): 
        if i-j-1<0:
            break
        ans=dp[i-j-1]+abs(A[i]-A[i-j-1])
        if tmpmin>ans:
            tmpmin=ans

    dp[i]=tmpmin
print(dp[-1])