TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import numpy as np

N = int(input())

A = [int(i) for i in input().split()]
A = np.array(A)
print(N,A)

min_amari = min(A)
while 0==0:
  amari = A%min_amari
  amari = amari[amari!=0]
  if len(amari)==0:
    print(min_amari)
    break
  else:
    min_amari = min(amari)

import numpy as np

N = int(input())

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

min_amari = min(A)
while 0==0:
  amari = A%min_amari
  amari = amari[amari!=0]
  if len(amari)==0:
    print(min_amari)
    break
  else:
    min_amari = min(amari)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))

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


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))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import heapq

n = int(input())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

while len(A) > 1:
    print(A)
    Amax1 = heapq.heappop(A) * (-1)
    Amax2 = heapq.heappop(A) * (-1)
    pushA = Amax1 % Amax2
    if pushA == 0:
        heapq.heappush(A, Amax2 * (-1))
    else:
        heapq.heappush(A, pushA * (-1))
        heapq.heappush(A, Amax2 * (-1))

print(A[0] * (-1))

import heapq

n = int(input())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

while len(A) > 1:
    Amax1 = heapq.heappop(A) * (-1)
    Amax2 = heapq.heappop(A) * (-1)
    pushA = Amax1 % Amax2
    if pushA == 0:
        heapq.heappush(A, Amax2 * (-1))
    else:
        heapq.heappush(A, pushA * (-1))
        heapq.heappush(A, Amax2 * (-1))

print(A[0] * (-1))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a,b):
    lt,gt = sorted([a,b])
    if lt == 0:
        return gt
    else:
        return gcd(gt % lt,lt)

def q3():
    N = int(input())
    A = list(map(int,input().split()))
    assert(N == len(A))
    ret = A[0]
    for n in range(1,N):
        ret = gcd(ret,A[n])
    print(ret)

def gcd(a,b):
    lt,gt = sorted([a,b])
    if lt == 0:
        return gt
    else:
        return gcd(gt % lt,lt)

def q3():
    N = int(input())
    A = list(map(int,input().split()))
    assert(N == len(A))
    ret = A[0]
    for n in range(1,N):
        ret = gcd(ret,A[n])
    print(ret)
    
q3()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
A=[i for i in map(int,input().split())]
mini=min(A)
while mini>0:
    for i in range(len(A)):
        if A[i]!=mini:
            A[i]=A[i]%mini
    z=A.count(0)
    A=sorted(A)[z:]
    m=A[0]
    if m==1:
        break
print(A[0])

N=int(input())
A=[int for i in input().split()]
mini=min(A)
while mini>0:
    for i in range(len(A)):
        if A[i]!=mini:
            A[i]=A[i]%mini
    z=A.count(0)
    A=sorted(A)[z:]
    m=A[0]
    if m==1:
        break
    else:
        if [i%m for i in A]==[0]*len(A):
            break
print(A[0])


N = int(input())
A = [int(_) for _ in input().split()]
m = min(A)
while m > 0:
    for i in range(0,len(A)):
        if A[i] != m:
            A[i] = A[i]%m
    z = A.count(0)
    A = sorted(A)[z:]
    m = A[0]
    if m == 1:
        break
    else:
        if [_%m for _ in A] == [0]*len(A):
            break
print(m)

Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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])

import numpy as np
N = int(input())
HPs = np.array([int(i) for i in input().split()])
np.sort(HPs)
while len(HPs) > 1:
    HPs[1:] %= HPs[0]
    HPs[HPs==0] = HPs[0]
    HPs=np.unique(HPs)
print(HPs[0])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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()

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()

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()

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()

def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(m_val,i))
    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()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

L = [int(x) for x in input().split()]

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)


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

N = int(input())
L = [int(x) for x in input().split()]

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a_li = list(set(int(x) for x in input().split()))

while 1:
    res = a_li[-1]
    a_li.sort(reverse = True)
    cou = 0
    for i in a_li[:-1]:
        a_li[cou] = i % a_li[-1]
        cou += 1
        print(a_li)
    a_li = list(set(a_li))
    try:
        a_li.remove(0)
    except:
        pass
    print(a_li)
    if len(a_li) == 0:
        print(res)
        break
    if len(a_li) == 1:
        print(a_li[0])
        break


n = int(input())
a_li = list(set(int(x) for x in input().split()))

while 1:
    res = a_li[-1]
    a_li.sort(reverse = True)
    cou = 0
    for i in a_li[:-1]:
        a_li[cou] = i % a_li[-1]
        cou += 1
    a_li = list(set(a_li))
    try:
        a_li.remove(0)
    except:
        pass
    if len(a_li) == 0:
        print(res)
        break
    if len(a_li) == 1:
        print(a_li[0])
        break


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np

n = int(input())
A = np.array([int(i) for i in input().split()])

A=np.sort(A)
s=A[0]
for i in range(max([n, s])):
    c = A[0]
    A = A % c
    A[0] = c
    z=A.count(0)
    A=np.sort(A)[z:]
    for j in range(len(A)):
        if A[0] != 0:
            break
        A = np.delete(A, 0)
    if len(A) == 1:
        break
print (A[0])

import numpy as np

n = int(input())
A = np.array([int(i) for i in input().split()])

A=np.sort(A)
s=A[0]
for i in range(max([n, s])):
    c = A[0]
    A = A % c
    A[0] = c
    z=len(A) - np.count_nonzero(A)
    A=np.sort(A)[z:]
    if len(A) == 1:
        break
print (A[0])



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
_N = input()
A_list = list(map(int, input().split()))

print("{}".format(A_list))

while len(A_list) > 1:
    min_A = min(A_list)
    A_list = [min_A] + [A % min_A for A in A_list if A % min_A != 0]
    print("{}".format(A_list))

print("{}".format(A_list[0]))

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

while len(A_list) > 1:
    min_A = min(A_list)
    A_list = [min_A] + [A % min_A for A in A_list if A % min_A != 0]

print("{}".format(A_list[0]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
ai = list(map(int, input().split(' ')))
while len(ai) > 1:
    print(ai)
    ai = list(sorted(ai))
    ai_head = ai[0]
    ai = list(filter(lambda x: x != 0, map(lambda x: x%ai_head, list(ai[1:]))))
    ai.append(ai_head)
print(ai[0])

n = int(input())
ai = list(map(int, input().split(' ')))
while len(ai) > 1:
    ai = list(sorted(list(ai)))
    ai_head = ai[0]
    ai = list(filter(lambda x: x != 0, map(lambda x: x%ai_head, list(ai[1:]))))
    ai.append(ai_head)
print(ai[0])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from functools import reduce
from math import gcd
input()
Ai = list(map(int, input().strip()))
print(reduce(gcd, Ai))

from functools import reduce
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
input()
Ai = list(map(int, input().split()))
print(reduce(gcd, Ai))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N = map(int, input())
A = list(map(int, input().split()))

while len(A) >= 2:
    largest_elem = A.index(max(A))
    x = A.pop(largest_elem)
    largest_elem = A.index(max(A))
    y = A.pop(largest_elem)
    print(x, y)
    if x == 1 and y == 1:
        A.append(y)
    elif x % y == 0:
        A.append(y)
    else:
        A.append(x % y)
        A.append(y)

print(A[0])


# -*- coding: utf-8 -*-
N = map(int, input())
A = list(map(int, input().split()))

while len(A) >= 2:
    idx = A.index(min(A))
    x = A.pop(idx)
    B = list()
    for i in range(len(A)):
        if A[i] % x != 0:
            B.append(A[i] % x)
    B.append(x)
    A = B[:]

print(A[0])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
  N = int(input())
  monsters = list(map(int, input().split()))

  monsters = sorted(monsters)
  

  last = 10000
  while True:
    # print('==============================')
    
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    
    if 0 in monsters:
      monsters.remove(0)
      monsters = sorted(monsters)

    
    if len(monsters) == 2:
      last = int(abs(monsters[1] - monsters[0]))
      monsters.remove(monsters[1])

    if len(monsters) == 1:
      break
  print(last)

  

main()


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

def main():
    N = int(input())
    An = list(map(int, input().split(' ')))


    An = sorted(An)
    An = [gcd(a_n, An[0]) for a_n in An]
    print(min(An))

main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
mini = a.pop(a.index(min(a)))
semi_mini = a.pop(a.index(min(a)))
print(mini, semi_mini)
while mini > 0 and semi_mini > 0:
    if semi_mini > mini:
        semi_mini -= mini
    else:
        mini -= semi_mini
print(max(mini, semi_mini))


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


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



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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  0else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)


n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 1:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c:
      c = c_
print(c)

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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(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))))
    

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

L = np.array(list(set(A)))
mini = np.min(L)
yaku = [1]
i=2
r_mini = np.sqrt(mini)
while i<=r_mini:
  if mini%i==0:
    yaku.append(i)
  i+=1
yaku2 = list(map(lambda x: int(mini/x), yaku))
yaku = yaku[::-1]
yaku2.extend(yaku)
for y in yaku2:
  if np.sum(L%y)==0:
    ans = y
    break

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#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)

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):
    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
                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)
         
    

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

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

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))

a=sorted(a)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
c=make_divisors(a[0])
d=list(c.keys)

d=d.sorted
f=[]
for y in range(len(d))
  e=d[y]
  ch=0
  for x in range(1,n):
    if not a[x]%e==0:
      continue
    ch+=1
  if ch==n-1:
    f.append(e)
    
print(max(f))
    
      
     

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

a=sorted(a)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
c=make_divisors(a[0])


d=sorted(c)
f=[]
for y in range(len(d)):
  e=d[y]
  ch=0
  for x in range(1,n):
    if not a[x]%e==0:
      continue
    ch+=1
  if ch==n-1:
    f.append(e)
    
print(max(f))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(n,m):
  a=min(n,m)
  b=max(n,m)
  while a!=0:
    b,a=a,b%a
  return a
n=int(input())
l=list(map(int,input().split()))
ans=l[0]
for i in range(1,n):
  ans=gcd(ans,l[i])
print(ans)

def gcd(n,m):
  a=min(n,m)
  b=max(n,m)
  while a!=0:
    b,a=a,b%a
  return b
n=int(input())
l=list(map(int,input().split()))
ans=l[0]
for i in range(1,n):
  ans=gcd(ans,l[i])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else: 
    x=1
    while x>0:
        c=sorted(b)
        c[1]=c[1]-c[0]
        c=sorted(list(set(c)))
        if c[0]==1:
            x=0
        if len(c)==1:
            print(2)
            exit()
print(1)
            
    




n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else: 
    x=1
    while x>0:
        c=sorted(b)
        if c[1]%c[0]!=0:
            c[1]=c[1]%c[0]
        else:
            c[1]=c[0]
        c=sorted(list(set(c)))
        if c[0]==1:
            x=0
        if len(c)==1:
            print(2)
            exit()
print(1)
            
    




n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else: 
    x=1
    while x>0:
        c=sorted(b)
        c[1]=c[1]-c[0]
        c=sorted(list(set(c)))
        if c[0]==1:
            x=0
        if len(c)==1:
            print(2):
            exit()
print(1)
            
    



n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else:
    c=sorted(b)
    x=1
    while x>0:
        v=c[0]
        for i in range(len(c)):
            if i!=0:
                c[i]=c[i]%v
        c.removed(0)
        c=sorted(list(set(c)))
        if len(c)==1:
            print(c[0])
            exit()
        if c[0]==1:
            x=0
print(1)
            
    




n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else:
    c=sorted(b)
    x=1
    while x>0:
        v=c[0]
        for i in range(len(c)):
            if i!=0:
                c[i]=c[i]%v
        c.remove(0)
        c=sorted(list(set(c)))
        if len(c)==1:
            print(c[0])
            exit()
        if c[0]==1:
            x=0
print(1)
            
    





n=int(input())
a=list(map(int,input().split()))
b=list(set(a))   
if len(b)==1:
    print(b[0])
    exit()
else:
    c=sorted(b)
    x=1
    while x>0:
        v=c[0]
        for i in range(len(c)):
            if i!=0:
                c[i]=c[i]%v
        while 0 in c:
            c.remove(0)
        c=sorted(list(set(c)))
        if len(c)==1:
            print(c[0])
            exit()
        if c[0]==1:
            x=0
print(1)
            
    





Verdicts: Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
n=int(input())
a=list(map(int,input().split()))
print(math.gcd(a))
      

n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while x%y>0:
    x,y=y,x%y
  return y
a.sort(reverse=True)
ans=a[0]
for j in range(n-1):
  ans=gcd(ans,a[j+1])
print(ans)
  

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
		A = QUICKSORT(A)
		piv = A[0]
		for i in range(1, len(A)):
			if i >= len(A):
				continue
			if A[i] == piv:
				A.pop(i)
	print(A[0])

if __name__ == '__main__':
	main()

def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		i = 1
		while(True):
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
				i += 1
			if i == len(A):
				break
		A = list(set(A))
	print(A[0])

if __name__ == '__main__':
	main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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


def gcd(n, m):
    if n < m:
        temp = n
        n = m
        m = temp
    
    def ecd(n, m):
        if n % m == 0:
            return m
        else:
            temp = n % m
            a = ecd(m, temp)
        return a
           
    return ecd(n, m)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import fractions

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

import math
from functools import reduce

def gcd(v1, v2):
    if v1 == 0 or v2 == 0:
        return max(v1, v2)
    if v1 % v2 == 0:
        return v2
    return gcd(v2, v1%v2)

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

print(reduce(gcd, A))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a.replace(0,'')
  n=len(a)
print(a[0])

n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a=[i for i in a if not i==0]
  n=len(a)
print(a[0])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
now = A[0]
for i in range(1,N):
    now = math.gcd(A[i],now)
print(now)

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

import math

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

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

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)


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)


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

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

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

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

print(a[0])


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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])

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

  while 0 in A:
    A.remove(0)

print(A[0])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = [int(input()) for i in range(n)]

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

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

def gcd(p, q):
    if q == 0:
        return p
    else:
        return gcd(q, p % q)

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

print(g)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import random
n = int(input())
enemies = list(map(int,input().split()))
while True:
  en_at = random.randrange(len(enemies))
  while True:
    en_h = random.randrange(len(enemies))
    if en_at != en_h: break
  enemies[en_h]-=enemies[en_at]
  if enemies[en_h]<=0: enemies.pop(en_h)
  if len(enemies)==1:
    break
print(enemies[0])

import math
from functools import reduce

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

from functools import reduce

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

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))

A.sort()
stack = A[1:]
m = A[0]

while stack:
  stack = list(stack)
  l = []
  for x in stack:
    if x % m == 0:
      continue
    l.append(x % m)
  
  m = min(l)
  stack = set(l)

print(m)






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

A.sort()
stack = A[1:]
m = A[0]

while stack:
  stack = list(stack)
  l = []
  for x in stack:
    if x % m == 0:
      continue
    l.append(x % m)
  
  if not l:
    break
  l.append(m)
  m = min(l)
  stack = set(l)

print(m)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
x = a[0]
for i in range(1,n):
    x,y = max(x,a[i]),min(x,a[i])
    print(x,y)
    while y!=0:x,y=y,x%y
print(x)

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

x = a[0]
for i in range(1,n):
    x,y = max(x,a[i]),min(x,a[i])
    while y!=0:x,y=y,x%y
print(x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(input())
A = [int(x) for x in readline().rstrip().split()]
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])

import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
A = [int(x) for x in input().rstrip().split()]
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#copy code
from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
c=a[0]
for i in a:
    c=gcd(c,a)
print(c)


from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
c=a[0]
for i in a:
    c=gcd(c,a)
print(c)



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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#coding:utf-8

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

while len(a)>1:
  for i in range(1,len(a)):
    a[i] %= a[0]
  a.sort()
  while True:
    if a[0] == 0:
      a.remove(0)
    else:
      break;



#coding:utf-8

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

while len(a)>1:
  for i in range(1,len(a)):
    a[i] %= a[0]
  a.sort()
  while True:
    if a[0] == 0:
      a.remove(0)
    else:
      break;

print(a[0])

Verdicts: Wrong Answer

Accepted