Problem p03127 (python)

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

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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))))

Buggy submission (verdict: Runtime Error):
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))))

Buggy submission (verdict: Runtime Error):
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))))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))