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:

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

import math
a=math.gcd(A[0],A[1])
for i in range(2,len(A)):
	a=math.gcd(a,A[i])
print(a)

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
def gcd(x,y):
  a=max(x,y)
  b=min(x,y)
  z=a%b
  if z==0:
    return b
  else:
    gcd(z,b)
for i in range(n-1):
  A[i+1]=gcd(A[i],A[i+1])
print(A[n-1])

Submission status: Runtime Error

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

while len(A) > 1:
  min_num = min(A)
  min_index = A.index(min(A))
  for i in range(len(A)):
    if i != min_index:
      A[i] = A[i] % min_num
      if(A[i] == 0):
        A.pop(i)


print(A[0])

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcdlist(numbers):
    return reduce(math.gcd,numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdlist(a))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while ans==0:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

L=list(set(A))

while True:
  if len(L)==1:
    ans = L[0]
    break
  if min(L)==1:
    ans = 1
    break
  if sum(list(map(lambda x: x%min(L), L)))==0:
  	ans = min(L)
  g = G(L[-2], L[-1])
  L[-2] = g
  L.pop()

print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(_L):
  L = _L.copy()
  if len(L)==1:
    return L[0]
  elif min(L)==1:
    return 1
  else:
    g = G(L[-2], L[-1])
    L[-2] = g
    L.pop()
    return func(L)
print(func(list(set(A))))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  if len(L)==1:
    return L[0]
  elif min(L)==1:
    return 1
  else:
    g = G(L[-2], L[-1])
    L[-2] = g
    L.pop()
    return func(L)
print(func(list(set(A))))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  # unique_L = list(set(L))
  if len(unique_L)==1:
    return unique_L[0]
  elif min(unique_L)==1:
    return 1
  else:
    g = G(unique_L[-2], unique_L[-1])
    unique_L[-2] = g
    unique_L.pop()
    return func(unique_L)
print(func(list(set(A))))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  unique_L = list(set(L))
  if len(unique_L)==1:
    return unique_L[0]
  elif min(unique_L)==1:
    return 1
  else:
    g = G(unique_L[0], unique_L[-1])
    unique_L[0] = g
    unique_L[-1] = g
    return func(unique_L)
print(func(A))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  unique_L = list(set(L))
  if len(unique_L)==1:
    return unique_L[0]
  else:
    g = G(unique_L[0], unique_L[-1])
    unique_L[0] = g
    unique_L[-1] = g
    return func(unique_L)
print(func(A))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  unique_L = list(set(L))
  if len(unique_L)==1:
    return unique_L[0]
  else:
    g = G(unique_L[0], unique_L[1])
    unique_L[0] = g
    unique_L[1] = g
    return func(unique_L)
print(func(A))

Submission status: Runtime Error

Solution code:
from math import gcd

def solve(): 
  N = int(input().strip())
  o = 0
  for i in map(int, input().split()):
    o = gcd(o,i)
  print(o)

if __name__=="__main__":
  solve()

Submission status: Runtime Error

Solution code:
from math import gcd

N = int(input().strip())
o = 0
for i in map(int, input().split()):
	o = gcd(o,i)
print(o)

Submission status: Runtime Error

Solution code:
# -*- 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:]))

Submission status: Runtime Error

Solution code:
# -*- 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:]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

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

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

Submission status: Runtime Error

Solution code:
import numpy as np

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

print(np.gcd.reduce(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

print(gcd_list(l))

Submission status: Runtime Error

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

def gcd_list(lst):
    if len(lst)==2:
        return gcd(lst[0],lst[1])
    else:
        return gcd_list([gcd(lst[0],lst[1])]+lst[2:])

n,*h=map(int,open(0).read().split())

print(gcd_list(h))

Submission status: Runtime Error

Solution code:
while len(h)>1:
    kh=[]
    for i in range(len(h)):
        mn = min(h)
        md=h[i]%mn
        if md!=0:
            kh.append(md)
        kh.append(mn)
    h=list(set(kh))
print(mn)

Submission status: Runtime Error

Solution code:
N = int(input())
HP_list = [int(i) for i in input().split()]
while len(set(HP_list))>1:
    for i in range(0, len(set(HP_list))):
        min_HP = min(HP_list)
        if HP_list[i] > min_HP:
            HP_list[i] = HP_list%min_HP
            if HP_list[i]==0:
                HP_list[i] += min_HP
print(list(set(HP_list))[0])

Submission status: Runtime Error

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

while len(A) > 1:
  min_A = min(A)
  next_A = set([min_A])
  for i in A:
    B = i % min_A
    if B != 0:
      next_A.add(B)
  A = list(next_A)
print(A[0])

Submission status: Runtime Error

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

import math

s = []
m = a[0]

for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(n//(i+1))
s.reverse()

for i in s:
    for j in range(len(a)):
        if a[j]%i>0:
            break
    else:
        print(i)
        break

Submission status: Runtime Error

Solution code:
import fraction
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=fraction.gcd(count,i)
print(str(count))

Submission status: Runtime Error

Solution code:
import math
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=math.gcd(count,i)
print(str(count))

Submission status: Runtime Error

Solution code:
INF = 10 ** 10

def num(k):#各数字に使用するマッチ棒の本数を返す関数
    if k == 1:
        return 2
    elif k == 7:
        return 3
    elif k == 4:
        return 4
    elif k == 2 or k == 3 or k == 5:
        return 5
    elif k == 6 or k == 9:
        return 6
    elif k == 8:
        return 7

n, m = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse = True)
         
dp = [(-1) * INF] * (n+1)

dp[0] = 0

for i in range(2,n+1):
    can = []
    for x in l:
        if i-num(x)>=0:
            can.append(dp[i-num(x)]+1)
    if can == []:
        dp[i] = (-1) * INF
    else:
        dp[i] = max(can)
        
#print(dp)

anslist = [0] * dp[n]

left = n

for j in range(dp[n],0,-1):#jは桁数
    if j == 1:
        for x in l:
            if num(x) == left:
                anslist[j-1] = x
                break
    else:
        for x in l:
            if dp[left-num(x)] == j - 1:
                anslist[j-1] = x#j桁目は10^(j-1)の位
                left = left-num(x)
                break
            
    #print([j,x,left])
#print(anslist)
            
            
ans = 0

for j in range(0,dp[n]):
    ans = ans + anslist[j] * (10 ** j)

print(ans)

Submission status: Runtime Error

Solution code:
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))
jlist=[True]
cnt = 0
while(min(A) !=1 and len(set(A)) != 1):
    cnt = 0
    for i in range(N):
        if A[i] - min(A) > 0:
            A[i] = A[i] - min(A)
        print(A)
print(min(A))

Submission status: Runtime Error

Solution code:
#ABC118_C

import fraction

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

x = fraction.gcd(a[0],a[1])

if n != 2:
    for i in range(2,n):
        x = fraction.gcd(x,a[i])
        
print(x)

Submission status: Runtime Error

Solution code:
import math

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

x = math.gcd(a[0],a[1])

if n != 2:
    for i in range(2,n):
        x = math.gcd(x,a[i])
        
print(x)

Submission status: Runtime Error

Solution code:
""" AtCoder """

import math

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

ans = A[0]

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
ans=10^9
n=int(input())
a=list(map(int,input().split()))
for i in range (len(a)):
    for j in range(len(a)):
    	if ans>=math.gcd(a[j],a[i]):
            ans=math.gcd(a[j],a[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math
ans=10*9
n=int(input())
a=list(map(int,input().split()))
for i in range (len(a)):
    for j in range(len(a)):
    	if ans>=math.gcd(a[j],a[i]):
            ans=math.gcd(a[j],a[i])
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
mina = max(a)
a.sort()
for i in range(n-1):
    mina = min(mina,math.gcd(a[i],a[i+1]))
print(mina)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = input()
ls = [int(x) for x in input().split()]
ls.sort()
while len(ls) != 1:
    if ls[1] % ls[0] == 0:
        remove(ls[1])
    else:
        ls[1] = ls[1] - ls[0]
        ls.sort()

print(ls[0])

Submission status: Runtime Error

Solution code:
input()
m = sorted([int(i) for i in input().split()])
for i in m[1:]:
    if (i%m[0])!=0:
        print(1)
        end
print(m[0])

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = input()
ls = [int(x) for x in input().split()]
ls.sort()
while len(ls) != 1:
    ls[1] = ls[1] - ls[0]
    ls.remove(0)
    ls.sort()

print(ls[0])

Submission status: Runtime Error

Solution code:
import functools
import math

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

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=A[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,N):
  B=gcd(B,A[i])
prnt(B)

Submission status: Runtime Error

Solution code:
def gcd(m,n):
    while n:
        m,n = n, m%n
    return m
n = int(input())
m = map(int,input().split())
ans = m[0]
for i in range(1,n):
    ans = gcd(m[i],ans)
print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math

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

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

Submission status: Runtime Error

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

while True:
    idx = 0
    m = a[0]
    for i in range(len(a)):
        aa = a[i]
        if aa > 0 and aa < m:
            idx = i
            m = a[idx]
    count = 1
    for i in range(len(a)):
        if i != idx:
            a[i] = a[i] % m
            if a[i] == 0:
                count += 1
    if count == len(a):
        break
for aa in a:
    if aa > 0:
        print(aa)
        break

Submission status: Runtime Error

Solution code:
import math

def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(math.gcd(A[0], A[i]), d)

    print(d)


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import math

def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(math.gcd(A[0], A[1]), d)

    print(d)


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import math

def gcd(A):
    s=A[0]
    for i in A:
        s=math.gcd(s,i)
    return s

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

Submission status: Runtime Error

Solution code:
N = int(input())
L = list(map(int,inptut().split()))
while True:
  if len(L) == 1:
    print(L[0])
    quit()
  L = sorted(L)
  m = L[0]
  for i in range(1,len(L)):
    L[i] %= m
  L = list(filter(lambda x:x!=0,L))

Submission status: Runtime Error

Solution code:
import functools as f
import math
_ = int(input())
l = list(map(int, input().split()))
print(f.reduce(math.gcd, l))

Submission status: Runtime Error

Solution code:

import functools as f
import math
_ = int(input())
l = list(map(int, input().split())
print(f.reduce(math.gcd, l)

Submission status: Runtime Error

Solution code:
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue
for a in A:
  q.put(a)
x = q.get()
while not q.empty():
  y=q.get()
  if y == 0:
    break
  q.put(x % y)
  x = y
print(x)

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

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

print(reduce(lambda x,y: math.gcd(x, y), a))

Submission status: Runtime Error

Solution code:
N = int(raw_input())
health = map(int, raw_input().split())

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

def gcd_driver(lst):
	if len(lst) <= 1:
		return lst[0]

	if len(lst) > 2:
		lst[1] = gcd(lst[0], lst[1])
		return gcd_driver(lst[1:])
	
	return gcd(lst[0], lst[1])

print(gcd_driver(health))

Submission status: Runtime Error

Solution code:
N = int(raw_input())
health = map(int, raw_input().split())

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

def gcd_driver(lst):
	if len(lst) <= 1:
		return lst[0]
	if len(lst) > 2:
		lst[1] = gcd(lst[0], lst[1])
		return gcd_driver(lst[1:])
	else:
		return gcd(lst[0], lst[1])

print gcd_driver(health)

Submission status: Runtime Error

Solution code:
N = int(raw_input().split()[0])
health = map(int, raw_input().split())


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

def gcd_driver(lst):
	if len(lst) > 2:
		lst[1] = gcd(lst[0], lst[1])
		return gcd_driver(lst[1:])
	else:
		return gcd(lst[0], lst[1])

print gcd_driver(health)

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 a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)

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(math.gcd, a))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

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

print(reduce(fraction.gcd, a))

Submission status: Runtime Error

Solution code:
n=int(input())
li = list(map(int, input().split()))
li.sort()
g=li[0]
ans=1
cnt=[0]*(g+1)
for i in range(n):
  for j in range(g):
    if li[i]%(j+1)==0:
      cnt[j+1]=cnt[j+1]+1
  
for j in range(g):
  if cnt[j]==n:
    ans=j

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

n = int(input())
A = list(map(int, input().split()))
ans = gcd(*A)
print(str(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

n = int(input())
A = list(map(int, input().split()))
ans = gcd(*A)
print(str(ans))

Submission status: Runtime Error

Solution code:
from fractions import gcd
N=int(input())
list=[int(i) for i in input().split()]
print(gcd(list))

Submission status: Runtime Error

Solution code:
import sys
import collections

b=[]
n = map(int, raw_input().split())
a = map(int, raw_input().split())

while True:
    a.sort()

    if a[0]==a[-1]:
        print(a[0])
        break

    elif:
        for n, x in enumerate(a):
            n=n%a[0]
            if n!=0:
                b.append(n)
        a=[a[0]]
        a.extend(b)

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x%y)
b=list(range(N-1))
for i in range(1,N):
    b[i]=u(b[i-1],a[i])
print(int(b[N-2]))

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x&y)
b=list(range(N-1))
for i in range(1,N):
    b[i-1]=u(a[i-1],a[i])
print(int(b[N-2]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
N=input()
M=list(map(int,input().split()))
print(gcd(*M))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
def gcd(number):
    return reduce(math.gcd,number)
print(gcd(A))

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
kouyakusuu = a[0]
for i in range(N):
   

    if a[i] < kouyakusuu:
        a = a[i]
        a[i] = kouyakusuu
        kouyakusuu = a

    while a[i] % kouyakusuu != 0:
            a[i] = kouyakusuu
            kouyakusuu =  a[i] % kouyakusu
print(kouyakusuu)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
kouyakusuu = a[0]
for i in range(N):
    if a[i] >= kouyakusuu:
        while a[i] % kouyakusuu != 0:
            a[i] = kouyakusuu
            kouyakusuu =  a[i] % kouyakusu
    else:
        while kouyakusuu % a[i] != 0:
            kouyakusuu =  kouyakusuu % a[i]
print(kouyakusuu)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
kouyakusuu = a[0]
for i in range(N):
    if a[i] >= kouyakusuu:
        while a[i] % kouyakusuu != 0:
            a[i] = kouyakusuu
            kouyakusuu =  a[i] % kouyakusu
    else:
        while kouyakusuu % a[i] != 0:
            a[i] = kouyakusuu
            kouyakusuu =  kouyakusuu % a[i]
print(kouyakusuu)

Submission status: Runtime Error

Solution code:
import math

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

for i in range(n-1):
    a[i+1] = math.gcd(a[i], a[i+1])

print(a[n-1])

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a = sorted(a)
while len(a) > 1:
    for i in range(1,len(a)):
        if a[len(a)-i] % a[0] == 0:
            a.pop(len(a)-i)
        else: a[len(a)-i] %= a[0]
    a = sorted(a)
print(a[0])

Submission status: Runtime Error

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

import sys
import math

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    # 出力
    nm = lines[0].split(" ")
    n = int(nm[0])

    rows = []
    for i in range(1, 2):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, rows[0])

def solve(n, monsters):

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


    return g

def main():

    n, m, rows = parse_input()
    print("%d" % solve(n, m, rows))

if __name__ == '__main__':

    main()

Submission status: Runtime Error

Solution code:
import itertools

n=int(input())

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



def amari(a,b):
    x=max(a,b)
    y=min(a,b)
    return x%y

while len(X)>1:
    Y=list(itertools.combinations(X,2))
    Z=[]
    for i in range(len(Y)):
        z=amari(Y[i][0],Y[i][1])
        if z>0:
            Z.append(z)
    X=list(set(Z))
    
print(X[0])

Submission status: Runtime Error

Solution code:
def inpul(): return list(map(int, input().split()))

 from fractions import Fraction
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

Submission status: Runtime Error

Solution code:
def inpul(): return list(map(int, input().split()))

import math
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def inpul(): return list(map(int, input().split()))

#最大公約数
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
N = inpul()
a = inpul()

ans = gcd_list(a)

Submission status: Runtime Error

Solution code:
import fraction as math

from functools import reduce

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

input()

li = [int(i) for i in input().split(" ")]

print(gcd(*li))

Submission status: Runtime Error

Solution code:
import math

from functools import reduce

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

input()

li = [int(i) for i in input().split(" ")]

print(gcd(*li))

Submission status: Runtime Error

Solution code:
 = int(input())
mon =[int(i)for i in input().split()]

def gcd(x,y):
    if y ==0:
        return x
    else:
        return gcd(y,x%y)
mon.sort()
mini = mon[0]
for i in range(1,N):
    ans = gcd(mini,mon[i])
print(ans)

Submission status: Runtime Error

Solution code:
N =int(input())
l =[int(i)for i in input().split()]
l =sorted(l)
min =l[0]
for i,st in enumerate(l):
    st = st % min
    if st==0:
        l.pop(i)
    elif st < min:
        min = min(st,min%st)
print(min)

Submission status: Runtime Error

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

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

temp_gcm = gcm(A[0],A[1])
for i in range(2,N):
  temp_gcm = gcm(A[i],temp_gcm)
print(temp_gcm)

Submission status: Runtime Error

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

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

temp_gcm = gcm(A[0],A[1])
 for i in range(2,N):
     temp_gcm = gcm(A[i],temp_gcm)
print(temp_gcm)

Submission status: Runtime Error

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

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(A[i], A[j]))


print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

#標準入力
n=int(input())
l=list(map(int,input().split()))

l.sort()#昇順ソート
defflist=list(map(lambda x,y:x-y,l[1:],l[:-1]))
defflist.sort()
defflist=list(filter(lambda i:i>0, defflist))


anslist=[]
if(len(defflist)!=0):
    for i in l:
        if i!=defflist[0]:
            anslist.append(i%defflist[0])
        else:
            anslist.append(i)
            
    anslist=list(filter(lambda i:i>0, anslist))
    anslist.sort()
    print(anslist[0])        
else:
    print(l[0])

Submission status: Runtime Error

Solution code:
N = int(input())
L = [int(s) for s in input().split(' ')]

while len(L) > 1:
	L.sort()
    if L[-1] % L[0] == 0:
      L.pop()
    else:
      L[-1] = L[-1] % L[0]
print(L[0])

Submission status: Runtime Error

Solution code:
import math
N=int(input())
A=list(map(int,input().split()))
ans = max(A)
for a in A:
    temp_A = [temp_a for temp_a in A if temp_a != a]
    for ta in temp_A:
        gcd = math.gcd(a,ta)
        if ans > gcd:
            ans = gcd
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def mon():
    input()
    a=[int(i) for i in input().split()]
    return gcd_list(a)
print(mon())

Submission status: Runtime Error

Solution code:
import math
def mon():
    n=int(input())
    a=[int(i) for i in input().split()]
    a.sort()
    za=a[0]

    b=[i for i in a[1:] if i%za!=0]
    if b==[]:
        print(za)
        exit()

    c=[za]
    for i in b:
        c+=[i%za]

    while not len(c)==1:
        c[0]=c[0]%c[1]
        c.sort(reverse=True)
        c[0]=c[0]-c[1]
        if c[0]<=0:
            c.pop(0)

    return(c[0])


print(mon())

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a = sorted(a)
while len(a) > 1:
    for i in range(1,len(a)):
        if a[len(a)-1-i] % a[0] == 0:
            a.pop()
        else: a[len(a)-1-i] %= a[0]
    a = sorted(a)
print(a[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a = sorted(a)
while len(a) > 1:
    for i in range(1:len(a)):
        if a[len(a)-1-i] % a[0] == 0:
            a.pop()
        else: a[len(a)-1-i] %= a[0]
    a = sorted(a)
print(a[0])

Submission status: Runtime Error

Solution code:
n=input()
a=list(map(int,input().split()))
for i in range(0,len(a)):
    a[i]=a[i]%min(a)
    a.append(min(a))
    for j in range(len(a)):
        if a[j]==0:
            a.remove(a[j])
print(a[0])

Submission status: Runtime Error

Solution code:
n=input()
a=list(map(int,input().split()))
k=[0,99999999]
for i in range(0,n):
    a[i]=a[i]%min(a)
    a.append(min(a))
    for j in range(n+1):
        if a[j]==0:
            a.remove(a[j])
            n-=1
print(a[0])

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
a=[int(i) for i in input().split()]
if n==1:
  print(a[0])
else:
	x=gcd(a[0],a[1])
	i=2
	while i<n:
  		x=gcd(x,a[i])
  		i+=1
	print(x)

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    while a != b:
        if a < b:
            b = b - a
        else:
            a = a - b
    return a

def m(a):
    a.sort()
    b = []
    for i in range(len(a) // 2):
        b.append(gcd(a[i], a[i + 1]))
    return b

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(g)

Submission status: Runtime Error

Solution code:
import math


n = int(input())
a = [int(x) for x in input().split(" ")]
a.sort()
g = a[n - 1]

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


print(g)

Submission status: Runtime Error

Solution code:
import math


n = int(input())
a = [int(x) for x in input().split(" ")]
g = a.sort()[n - 1]


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


print(g)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
g = a.sort()[n - 1]

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

print(g)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
a.sort()
g = a[n - 1]

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

print(g)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
a.sort()
g = a[n - 1]

for i in range(1, n):
    g = math.gcd(g, a[i])
    
print(g)