Problem:


Score : 300 points

Problem Statement

There are N monsters, numbered 1, 2, ..., N.

Initially, the health of Monster i is A_i.

Below, a monster with at least 1 health is called alive.

Until there is only one alive monster, the following is repeated:

A random alive monster attacks another random alive monster.

As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.

Find the minimum possible final health of the last monster alive.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the minimum possible final health of the last monster alive.

Sample Input 1

4
2 10 8 40

Sample Output 1

2

When only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.

Sample Input 2

4
5 13 8 1000000000

Sample Output 2

1

Sample Input 3

3
1000000000 1000000000 1000000000

Sample Output 3

1000000000



Sample input:
4
2 10 8 40


Sample output:
2

Submission status: Runtime Error

Solution code:
import sys
import math
input = sys.stdin.readline

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

A.sort()

ans = A[0]
for i in range(1, N):
    ans = math.gcd(ans, A[i])
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
from functools import reduce
input = sys.stdin.readline

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))

Submission status: Runtime Error

Solution code:
from math import gcd

N, *A = map(int, open(0).read().split())

ans = A[0]
for v in A[1:]:
    ans = gcd(ans, v)
    
print(ans)

Submission status: Runtime Error

Solution code:
from functions import gcd 
from functools import reduce

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

print(reduce(gcd,A))

Submission status: Runtime Error

Solution code:
import math 
from functools import reduce

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

print(reduce(math.gcd,A))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

print(reduce(gcd,A))

Submission status: Runtime Error

Solution code:
from functools import reduce

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

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

print(reduce(gcd, a))

Submission status: Runtime Error

Solution code:
def smaller(x, y):
	if x < y: return x
	return y

N = int(raw_input())
A = map(int, raw_input().split())
A.sort()
min1 = A[0]
for i in range(1, N):
	if A[i]%min != 0 and A[i]%min < min: min = A[i]%min
min2 = A[-1]
for i in range(1, N):
	if min2%A[i] == 0: min2 = A[i]
	else: min2 = min2%A[i] 
print smaller(min1, min2)

Submission status: Runtime Error

Solution code:
import math

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

g = [0] * (N + 1)
for i in range(N):
    g[i+1] = math.gcd(g[i], A[i])

print(g[-1])

Submission status: Runtime Error

Solution code:
import math

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

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

print(g)

Submission status: Runtime Error

Solution code:
import math

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

g = math.gcd(A[0], A[1])
for i in range(2, N):
    g = math.gcd(g, A[i])

print(g)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, A: "List[int]"):
    res = A[0]
    B = A[1:]
    for a in B:
        res = math.gcd(res,a)

    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, A: "List[int]"):
    res = A[0]
    for a in A[1:]:
        res = math.gcd(res,a)
    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(N: int, A: "List[int]"):
    res = A[0]
    for a in A[1:]:
        res = math.gcd(res,a)
    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(N: int, A: "List[int]"):
    print(reduce(math.gcd,A))

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

# 最大公約数が答え

import math
import functools

print(functools.reduce(math.gcd, A))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans, b;
    cin >> ans;
    for(int i = 1; i < n; ++i){
        cin >> b;
        ans = __gcd(ans,b);
    }
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
import math

N = int(input())
A = [int(i) for i in input().split()]

gcd = A[0]

for i in range(1,len(A)):
    gcd = math.gcd(gcd,A[i])

print(gcd)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

print(gcd(a))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = math.gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))

Submission status: Runtime Error

Solution code:
import math

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = math.gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[map(int,input().split()) for i in range(n)]
b=a[0]
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

for i in a:
  b=gcd(b,i)
print(b)

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in a[1:]:
	x = gcd(x,i)
print(x)

Submission status: Runtime Error

Solution code:
from math import gcd

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

g = 0
for i in a:
    g = gcd(g,i)
print(g)

Submission status: Runtime Error

Solution code:
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

init_dp = lambda v,n:[v]*(n)

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

def solution():
    N,M = input_ints()
    As = input_ints_list()
    w = [0,2,5,5,4,5,6,3,7,6]

    dp = init_dp(-1,N+1)
    dp[0] = 0
    for i in range(N+1):
        for v in As:
            if i+w[v] < N+1:
                dp[i+w[v]] = max(dp[i+w[v]],dp[i]*10+v)
    print(dp[N])
    
if __name__ == '__main__':
    solution()

Submission status: Runtime Error

Solution code:
4
2 10 8 40

Submission status: Runtime Error

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

result = A
while True:
    result = list(set(result))
    result.sort()
    if min(result) == 0:
        result.remove(0)
    tmp_min = min(result)
    result =[r % tmp_min for r in result[1:]]
    #print(result)
    if max(result) == 0:
        result.append(tmp_min)
        break
    result.append(tmp_min)
    #print(result)

print(max(result))

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import fractions

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

    # Aの要素を使って、1以上の作成可能な最も小さい値を作る。それが答え。
    # というか最大公約数が答え。

    ans = A[0]
    for i in range(1, N):
        ans = fractions.gcd(ans, A[i])
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
# C - Monsters Battle Royale
# https://atcoder.jp/contests/abc118/tasks/abc118_c

N = int(input())
A = set(map(int, raw_input().split()))

while len(A) != 1:

    # minimum number of A
    minA = min(A)

    # next round A
    nA = set(), nA.add(minA)

    for Ai in A:
        if Ai % minA != 0 and Ai != minA:
            nA.add(Ai%minA)

    # update for next round
    A = nextA

print '{}'.format( list(A)[-1])

Submission status: Runtime Error

Solution code:
def multigcd(n,arr):
  a,b=max(n,arr[0]),min(n,arr[0])
  while b!=0:
    a,b=b,a%b
  if len(arr)==1:
    return a
  else:
    return multigcd(a,arr[1:])

n=int(input())
arr=list(map(int,input().split()))
print(multigcd(arr[0],arr[1:]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))

while len(A) >= 2: #残りの数が1になったら終わり
  if A[0] == 1: break
  #余りが出る場合は、左側の数字と余りを入れ替える
  rem = A[1] % A[0] #余り
  if rem != 0: A[0], A[1] = rem, A[0]
  #余りが0の場合、そいつは下位互換なので要らない？
  else: del A[1]
  print(A)

print('出たよ'+str(A[0]))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)
 
n=int(input())
arr=list(map(int,input()))
tmp=gcd(arr[0],arr[1])
for i in range(1,n):
  tmp=gcd(tmp,arr[i])
print(tmp)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input()))
for i in range(n-1):
  tmp=gcd(arr[i],arr[i+1])
print(tmp)

Submission status: Runtime Error

Solution code:
import math
def yuk(a, b):
    ans = int(a / b)
    amari = a % b
    if amari != 0:
        ans = yuk(b, amari)
    else:
        ans = b
    return ans


N = int(input())
alst = list(map(int, input().split()))
ans = alst[0]
for i in range(1, N):
    if ans > alst[i]:
        ans = math.gcd(ans, alst[i])
    else:
        ans = math.gcd(alst[i], ans)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

input()

print(gcd_list(list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
n=int(input())
a_list=list(map(int,input().split()))
import math
answer=a_list[0]
for i in range(1,n):
    answer=math.gcd(answer,a_list[i])
print(answer)

Submission status: Runtime Error

Solution code:
import math

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

mini = min(A)
ans = min(A)
for a in A:
    amari = a%mini
    if amari != 0:
        if amari < ans:
            ans = amari            
if mini - ans == 0:
    print(ans)
else:
    print(math.gcd(mini, ans))

Submission status: Runtime Error

Solution code:
import math

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

mini = min(A)
ans = min(A)
for a in A:
    amari = a%mini
    if amari != 0:
        if amari < mini:
            ans = amari            
if mini - ans == 0:
    print(ans)
else:
    print(math.gcd(mini, ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import functools
import math
n = input()
monster = list(map(int,input().split()))

gcd = functools.reduce(math.gcd, monster)
print(gcd)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
n = input()
monster = list(map(int,input().split()))

print(gcd_list(monster))

Submission status: Runtime Error

Solution code:
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


if len(zombies) == 1:
    print(zombies[0])
else:
    print(saidai_koyakusu(zombies[0], zombies[1:]))

Submission status: Runtime Error

Solution code:
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


print(saidai_koyakusu(zombies[0], zombies[1:]))

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_arr(a):
    ans = a[0]
    for i, a_i in enumerate(a):
        ans = gcd(ans, a_i)
    return ans

print(gcd_arr(A))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)
  
N = int(input())

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

print(gcd_list(list))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
N = int(input())

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

print(gcd_list(list))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

N = int(input())
As = map(int, input().split())

print(reduce(fraction.gcd, As))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N = int(input())
As = map(int, input().split())

print(reduce(math.gcd, As))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def gcd(numbers):
    return reduce(math.gcd, numbers)

print(gcd(a))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
gcd=float('inf')
for i in range(n-1):
  gcd=min(gcd,math.gcd(a[i],a[i+1]))
print(gcd)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
print(math.gcd(a))

Submission status: Runtime Error

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

ans = min(A)
aset = set(A)
A = list(aset)

for i in range(N):
    for j in range(i+1,N):
        aset.add(A[i] % A[j])
        
Alist = list(aset)
Alist.sort()
for i in range(1,len(Alist)):
    ans = min(ans,Alist[i]-Alist[i-1])

print(ans)

Submission status: Runtime Error

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

As = sorted(A)
As = [a%As[0] if a%As[0] != 0 else As[0] for a in As]
As = sorted(As)

def judge(tmp_one, tmp_two):
    flg = 1
    
    while flg:
        if tmp_two % tmp_one == 0:
            tmp_two = tmp_one
        else:
            tmp_two = tmp_two % tmp_one
            
        if tmp_one % tmp_two == 0:
            tmp_one = twp_two
        else:
            tmp_one = tmp_one % tmp_two
        if tmp_one == tmp_two:
            flg = 0
            
        return tmp_one
tmp_one = As[0]
for i in range(1, N):
    if i == N  - 1:
        tmp_two = As[i]
    elif As[i] != As[0]:
        tmp_two = As[i]
        break
        
ans = judge(tmp_one, tmp_two)
print(ans)

Submission status: Runtime Error

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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

print(gcd(*A))

Submission status: Runtime Error

Solution code:
def del_list(a):
  x = []
  for i in a:
    if i != 0:
      x.append(i)
      
  return x



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


while True:
  mil = min(m)
  for i in range(len(m)):
    m[i] -= mil
    
  if 0 in m:
    m = del_list(m)
  
  if len(m) == 1:
    break
    
print(m)

Submission status: Runtime Error

Solution code:
from math import gcd

n = int(input())
k = list(map(int, input().split()))
ans = k[0]

for i in k:
    ans = gcd(ans, i)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def gcd(*numbers):
  return reduce(math.gcd, numbers)

print(gcd(A))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

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

print(gcd_list(A))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=math.gcd(a[0],a[1])
    del a[1]
    del a[0]
    a.append(b)
print(a[0])

Submission status: Runtime Error

Solution code:
import math

N =int(input())
lives = [int(i) for i in input().split()]
gcd_value = lives[0]

for i in range(1,len(lives)) :
    gcd_value = math.gcd(gcd_value, lives[i])

print(gcd_value)

Submission status: Runtime Error

Solution code:
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(m_val,m))
    return m_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Submission status: Runtime Error

Solution code:
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return m_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Submission status: Runtime Error

Solution code:
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return min_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Submission status: Runtime Error

Solution code:
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return min_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

input()
print(reduce(math.gcd, map(int, input().split())))

Submission status: Runtime Error

Solution code:
import math
 
N = int(input())
A = [int(i) for i in input().split()]
g = A[0]
for n in range(1,N):
    g = math.gcd(g,A[n])

print(g)

Submission status: Runtime Error

Solution code:
import math
 
N = int(input())
A = [int(i) for i in input().split()] 

 
print(math.gcd(A))

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))

ans = 10**10
for i in range(N-1):
    ans = min(ans, math.gcd(A[i],A[i+1]))
print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math
N = input()
values = [int(i) for i in input().split()] 
gcd = functools.reduce(math.gcd, values)
print(gcd)

Submission status: Runtime Error

Solution code:
import fraction
n = int(input())
a = list(map(int,input().split()))
ans = a[0]

for i in range(1,len(a)):
  ans =fraction.gcd(ans,a[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
X=list(map(int,input().split()))
x=X[0]
for i in range(1,n):
    x=math.gcd(x,X[i])

if x!=1:
    print(x)
else:
    print(1)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

print(gcdlist(A))

Submission status: Runtime Error

Solution code:
from math import gcd

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

ret = gcd(a[0], a[1])
for e in a[2:]:
    ret = gcd(ret, e)

print(ret)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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

print(reduce(gcd, a))

Submission status: Runtime Error

Solution code:
from fraction import gcd
from functools import reduce
input()
print(reduce(gcd,list(map(int,input().split()))))

Submission status: Runtime Error

Solution code:
input()
a = list(map(int, input().split()))
l = a[0]
for i in a[1:]:
    l = math.gcd(l,i)
print(i)

Submission status: Runtime Error

Solution code:
import math
import functools

input()
a = list(map(int, input().split()))
l = a[0]
for i in a[1:]:
    l = math.gcd(l,i)
print(i)

Submission status: Runtime Error

Solution code:
import math
import functools

n = int(input())
print(functools.reduce(math.gcd, list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n = int(input())
print(reduce(math.gcd, list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
n = int(input())
hp_list = list(map(int, input().split()))
i = min(hp_list)
while True:
    dividable = True
    for j in hp_list:
        if j % i != 0:
            dividable = False
    if dividable:
        break
    else:
        for j in range(2, i + 1):
            if i % j == 0:
                i /= j
                break
print(int(i))

Submission status: Runtime Error

Solution code:
n = int(input())
hp_list = list(map(int, input().split()))
i = min(hp_list)
while True:
    dividable = True
    for j in hp_list:
        if j % i != 0:
            dividable = False
    if dividable:
        break
    else:
        for j in range(2, i + 1):
            if i % j == 0:
                i /= j
                break
print(i)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A = [int(i) for i in input().split()] 

g = gcd(*A)

print(g)

Submission status: Runtime Error

Solution code:
import random
N = int(input())
A = list(map(int, input().split()))

while len(A) != 1:
    print(A)
    attack_monster = random.randint(0,10**9) % len(A)
    damage_monster = random.randint(0,10**9) % len(A)
    if attack_monster != damage_monster:
        A[damage_monster] = A[damage_monster] - A[attack_monster]
        if A[damage_monster] <= 0:
            del A[damage_monster]
print(A[0])

Submission status: Runtime Error

Solution code:
import sys
from math import gcd
input = sys.stdin.readline

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

f = A[0]
for i in range(1, N):
    f = gcd(f, A[i])
print(f)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


print(gcd_list(a_li))

Submission status: Runtime Error

Solution code:
import math

N = int(input())
A = [int(_) for _ in input().split()]
GCD = math.gcd(A[0], A[1])

for i in range(1, N-1):
    GCD = math.gcd(GCD, A[i+1])

print(GCD)

Submission status: Runtime Error

Solution code:
N = int(input())

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

#0の数がN-1になった時点で終了
#Aの中のminを割り出しそれのmodをA内でとるを繰り返す

mina = 0
while(1):
    if(len(A)==1):break
    mina = min(A)
    minaind = A.index(mina)
    delind =[]
    for i in range(0,len(A)):
        # print(A,minaind)
        if i == minaind:continue
        # print(i)
        A[i]%=mina
        if A[i] <= 0: delind.append(A.index(A[i]))
    for i in delind:
        del(A[i])

print(A[0])

Submission status: Runtime Error

Solution code:
import fraction
def monsters(li,n):
    t = temp
    for i in range(1,n-1):
        t = fraction.gcd(t,li[i+1])
    return t

n = int(input())
li_a = list(map(int,input().split()))
temp = li_a[0]
print(monsters(li_a,n))

Submission status: Runtime Error

Solution code:
import math 
def monsters(li,n):
    t = temp
    for i in range(1,n-1):
        t = math.gcd(t,li[i+1])
    return t

n = int(input())
li_a = list(map(int,input().split()))
temp = li_a[0]
print(monsters(li_a,n))

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = math.gcd(x, a[i])
print(x)

Submission status: Runtime Error

Solution code:
from fraction import gcd

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = gcd(x, a[i])
    if x == 1:
        break
print(x)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = math.gcd(x, a[i])
    if x == 1:
        break
print(x)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
monster = sorted(list(map(int, input().split())))

for i in range(1,n):
    monster[i] = math.gcd(monster[0], monster[i])

print(min(monster))

Submission status: Runtime Error

Solution code:
from math import gcd
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in range(N):
    ans = gcd(ans,A[i])
print(ans)

Submission status: Runtime Error

Solution code:
from scipy import gcd
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in range(N):
    ans = gcd(ans,A[i])
print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math
import sys
input = sys.stdin.readline

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

first_gcd = A[0]
for i in range(len(A)):
    first_gcd = math.gcd(first_gcd, A[i])

print(first_gcd)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

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

def gccd(num):
    if len(num) == 1:
        return num[0]
    else:
        return gcd(gccd(num[0:1]), gccd(num[1:]))

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

print(gccd(A))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math
import sys
input = sys.stdin.readline

def gccd(num):
    if len(num) == 1:
        return num[0]
    else:
        return math.gcd(gccd(num[0:1]), gccd(num[1:]))

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

print(gccd(A))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math
import sys
input = sys.stdin.readline

def gcd(num):
    if len(num) == 1:
        return num[0]
    else:
        return math.gcd(gcd(num[0:1]), gcd(num[1:]))

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

print(gcd(A))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math
import sys
input = sys.stdin.readline

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

def gcd(num):
    if len(num) == 1:
        return num[0]
    else:
        return math.gcd(gcd(num[0:1]), gcd(num[1:]))

print(gcd(A))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

import math

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

def gcd(num):
    if len(num) == 1:
        return num[0]
    else:
        return math.gcd(gcd(num[0:1]), gcd(num[1:]))

print(gcd(A))

Submission status: Runtime Error

Solution code:
N = int(input())
monsters = list(map(int, input().split()))
def gcd(a, b):
	if b > 0 :
      return gcd(b , a % b)
    else :
      return x
if len(monster) == 1 :
	print(monster[0])
else :
    mon = gcd(monster[0], monster[1])
    if len(monster) >= 2
    for i in range(2 , N) :
      mon = gcd(mon, monster[i])
print(mon)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

import math
from functools import reduce

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

print(reduce(math.gcd, A))

Submission status: Runtime Error

Solution code:
import math


N = int(input())
A = list(map(int, input().split()))
first_gcd = A[0]
for i in range(len(A)):
    first_gcd = math.gcd(first_gcd, A[i])
print(first_gcd)

Submission status: Runtime Error

Solution code:
import math


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_min = min(A)
del A[0]
A_min_2 = min(A)
print(math.gcd(A_min, A_min_2))

Submission status: Runtime Error

Solution code:
def get_gcf(a, b):
    x = max(a, b)
    y = min(a, b)

    result = y
    while True:
        z = x % y
        if z == 0:
            break
        x = y
        y = z

    return y

def get_min_hp(A):
    if len(A) == 2:
        return get_gcf(A[0], A[1])
    else:
        return get_gcf(A[0], get_min_hp(A[1:]))

N = int(input())
A = [i for i in list(map(int, input().split()))]

print(get_min_hp(A))

Submission status: Runtime Error

Solution code:
def get_gcf(a, b):
    x = max(a, b)
    y = min(a, b)

    result = y
    while True:
        z = x % y
        if z == 0:
            break
        x = y
        y = z

    return y

def get_min_hp(A):
    if len(A) == 2:
        return get_gcf(A[0], A[1])
    else:
        return get_gcf(A[0], get_min_hp(A[1:]))

N = int(input())
A = [i for i in map(int, input().split())]

print(get_min_hp(A))

Submission status: Runtime Error

Solution code:
n=input()

a=list(map(int,input().split()))
a.sort()
l=[]
for i in range(len(a)-1):
    l.append(a[i+1]%a[0])
    try:
        l.remove(0)
    except:
        break

l.sort()

if l[0]==False:
    print(a[0])