Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
import time

class Node:
    def __init__(self, key = None):
        self.key = key
        self.left = None
        self.right = None

def insert(key):
    global root
    z = Node(key)
    y = None
    x = root
    while x:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right

    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "i":
            insert(int(line.split()[1]))
        else:
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))

### FIXED CODE ###

import sys

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "i":
            insert(Node(int(line.split()[1])))
        else:
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))
### BUGGY CODE ###

from math import gcd
from collections import deque
# = map(int, input().split())
N = int(input())
A = deque(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]
primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A.popleft()
  g = gcd(g, a)
  if flag:
    flag = factorization(a)
  if flag == False:
    if g == 1:
      break


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')


### FIXED CODE ###

from math import gcd

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')
### BUGGY CODE ###

N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

dp = []
init = 0

if K<=N:
  ans = set()
  for i in range(N):
    tmp,now,last = [0],i,0
    for _ in range(K):
      last += C[P[now]]
      ans.add(last)
      now=P[now]
  print(max(ans))
  exit()
ans = -10**9
for i in range(N):
  tmp,now,done = [0],i,set()
  while now not in done:
    done.add(now)
    tmp.append(tmp[-1]+C[now])
    now = P[now]
  cnt = len(done)
  tmp = tmp[1:]
  ans = max(ans,max(tmp))
  if K%cnt == 0:
    ans = max(ans, tmp[-1]*(K//cnt-1)+max(tmp))
  else:
    ans = max(ans, tmp[-1]*(K//cnt-1)+max(tmp), tmp[-1]*(K//cnt)+max(tmp[:K%cnt]))
    #print(i,ans,tmp)
print(ans)




### FIXED CODE ###

N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

if K<=N:
  ans = -10**9
  for i in range(N):
    now,last = i,0
    for _ in range(K):
      last += C[P[now]]
      ans = max(ans,last)
      now=P[now]
  print(ans)
  exit()
ans = -10**9
for i in range(N):
  tmp,now,done = [0],i,set()
  for _ in range(N+1):
  #while now not in done:
    tmp.append(tmp[-1]+C[P[now]])
    if P[now] == i:
      break
    now = P[now]
  tmp = tmp[1:]
  cnt = len(tmp)
  m = max(tmp)
  ans = max(ans,m,tmp[-1]*(K//cnt-1)+m)
  if K%cnt != 0:
    ans = max(ans, tmp[-1]*(K//cnt)+max(tmp[:K%cnt]))
    #print(i,ans,tmp)
print(ans)
### BUGGY CODE ###

X, Y = (int(i) for i in input().split())

if X % Y == 0 :
  print(-1)
else :
  i = 2
  while i < 1000000000000000000 :
    X *= i
    if X % Y != 0 :
      print(X)
      break
    else :
      i += 1

### FIXED CODE ###

X, Y = (int(i) for i in input().split())

if X % Y == 0 :
  print(-1)
else :
  i = 2
  while i < 1000000000000000000 :
    multiples = X * i
    if multiples % Y != 0 :
      print(multiples)
      break
    else :
      i += 1
### BUGGY CODE ###

import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n = int(input())
    p = []
    for _ in range(n):
        num = int(input())
        if num in p:
            del p[p.index(num)]
        else:
            p.append(num)
    print(len(p))
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    c = collections.Counter(a)
    cnt = 0
    for i in c:
        if c[i] % 2 == 1:
            cnt += 1
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

import sys
import numpy as np
from numba import njit

input = sys.stdin.buffer.readline

N = int(input())
vws = [tuple(map(int, input().split())) for _ in range(N)]

n = min(2**10, N)
vws_arr = np.array(vws, np.int32)

dp = np.zeros((n, 10**5+1), np.int32)
dp[0, vws[0][1]:] = vws[0][0]
for i in range(1, n):
    v, w = vws[i]
    dp[i] = dp[(i-1)//2]
    dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])

@njit("i4(i4[::1], i4[::1], i4, i4[::1])", cache = True)
def func(vs, ws, L, dp_):
    values = np.zeros(1 << len(vs), np.int32)
    weights = np.zeros(1 << len(vs), np.int32)
    for i in range(len(vs)):
        for bits in range(1 << len(vs)):
            if bits & (1 << i):
                values[bits] += vs[i]
                weights[bits] += ws[i]
    mask = (weights <= L)     
    return np.amax(dp_[L - weights[mask]] + values[mask])

Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V, L])
    else:
        Vs = []
        while V >= n:
            Vs.append(V)
            V = (V-1) // 2
        vs = vws_arr[Vs, 0]
        ws = vws_arr[Vs, 1]
        print(func(vs, ws, L, dp[V]))


### FIXED CODE ###

import sys
import numpy as np
from numba import njit

input = sys.stdin.buffer.readline

N = int(input())
vws = [tuple(map(int, input().split())) for _ in range(N)]

n = min(2**11, N)
vws_arr = np.array(vws, np.int32)

dp = np.zeros((n, 10**5+1), np.int32)
for i in range(n):
    v, w = vws[i]
    dp[i] = dp[(i-1)//2]
    dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])


@njit("i4(i4[::1], i4[::1], i4, i4[::1])", cache = True)
def func(vs, ws, L, dp_):
    values = np.zeros(1 << len(vs), np.int32)
    weights = np.zeros(1 << len(vs), np.int32)
    for i in range(len(vs)):
        for bits in range(1 << len(vs)):
            if bits & (1 << i):
                values[bits] += vs[i]
                weights[bits] += ws[i]
    ret = 0
    for v, w in zip(values, weights):
        if w <= L:
            ret = max(dp_[L - w] + v, ret)
    return ret

Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V, L])
    else:
        Vs = []
        while V >= n:
            Vs.append(V)
            V = (V-1) // 2
        vs = vws_arr[Vs, 0]
        ws = vws_arr[Vs, 1]
        print(func(vs, ws, L, dp[V]))
### BUGGY CODE ###

def resolve():
    n = int(input())
    s = []
    for i in range(n):
        d = input()
        if not (d in s):
            s += [d]
    print(len(s))

if __name__ == "__main__":
	resolve()

### FIXED CODE ###

def resolve():
    import sys
    input = lambda: sys.stdin.readline().rstrip()
    r = [0] * int(input())
    print(len({input() for _ in r}))

if __name__ == "__main__":
	resolve()
### BUGGY CODE ###

def binary_search_ceiling(list, element):
    i = 0
    j = len(list) - 1
    if element < list[0]:
        return None
    elif element >= list[-1]:
        return len(list) - 1
    while i <= j:
        k = (i + j) // 2
        if list[0] == element:  # k - 1が0にならないので特例
            return 0
        elif list[k - 1] < element <= list[k]:
            return k
        elif list[k] < element < list[k + 1]:
            return k + 1
        elif list[k] < element:
            i = k  # elementがk番とk+1番の間にあるかもしれないのでi = k + 1 ではなくi = k
        else:
            j = k  # 上と同様に考えてj = k

    return None


def main():
    A, B, Q = map(int, input().split())
    INF = 10 ** 11
    s_list = [-2 * INF, -INF] + [int(input()) for i in range(A)] + [INF, 2 * INF]
    t_list = [-2 * INF, -INF] + [int(input()) for i in range(B)] + [INF, 2 * INF]
    x_list = [int(input()) for i in range(Q)]

    for xi in x_list:
        ind_s = binary_search_ceiling(s_list, xi)
        ws = s_list[ind_s - 1]
        es = s_list[ind_s]

        ind_t = binary_search_ceiling(t_list, xi)
        wt = t_list[ind_t - 1]
        et = t_list[ind_t]

        dist_list = [
                     xi - min(ws, wt),
                     max(es, et) - xi,
                     xi + es - wt * 2,
                     xi + et - ws * 2,
                     (es * 2) - wt - xi,
                     (et * 2) - ws - xi
                     ]

        print(min(dist_list))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect as b


def main():
    A, B, Q = map(int, input().split())
    INF = 10 ** 11
    s_list = [-INF] + [int(input()) for i in range(A)] + [INF]
    t_list = [-INF] + [int(input()) for i in range(B)] + [INF]

    len_s = A + 1
    len_t = B + 1

    for i in range(Q):
        xi = int(input())
        ind_s = b.bisect_left(s_list, xi)
        ws = s_list[ind_s - 1]
        es = s_list[ind_s]

        ind_t = b.bisect_left(t_list, xi)
        wt = t_list[ind_t - 1]
        et = t_list[ind_t]

        dist_list = [
                     xi - min(ws, wt),
                     max(es, et) - xi,
                     xi + es - wt * 2,
                     xi + et - ws * 2,
                     (es * 2) - wt - xi,
                     (et * 2) - ws - xi
                     ]

        print(min(dist_list))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

def func(n):
    div = 0 
    for i in range(1, int(n**0.5)+1):
        if(n%i == 0):
            div += 1
            if(i != n //i):
                div += 1
    return div

def main():
    N = int(input())

    ans = 0
    for i in range(1, N+1):
        ans += i*func(i)
    print(ans)
main()

### FIXED CODE ###

N = int(input())

ans = 0

for i in range(1, N+1):
    y = N//i
    ans += ((y*(y+1))//2)*i
print(ans)
### BUGGY CODE ###

import sys

N = int(input())

cap = [int(input()) for i in range(5)]

now = [N, 0, 0, 0, 0, 0]

ans = 0

while now[5] != N:
	for i in reversed(range(5)):
		if now[i] > 0:
			if now[i] >= cap[i]:
				now[i] -= cap[i]
				now[i+1] += cap[i]
			elif now[i] < cap[i]:
				now[i+1] += now[i]
				now[i] = 0

	ans += 1

print(ans)


### FIXED CODE ###

import sys
import math

N = int(input())

cap = [int(input()) for i in range(5)]

now = [N, 0, 0, 0, 0, 0]

ans = math.ceil(float(N)/min(cap)) + 4

#while now[5] != N:
#	for i in reversed(range(5)):
#		if now[i] > 0:
#			if now[i] >= cap[i]:
##				now[i] -= cap[i]
#				now[i+1] += cap[i]
#			elif now[i] < cap[i]:
#				now[i+1] += now[i]
#				now[i] = 0
#
#	ans += 1

print(int(ans))
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j < 0:
            break
        dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]))
print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
N , K = map(int,input().split())
h = list(map(int,input().split()))
inf = float('inf')
dp = [inf] * N
if K == 1:
    ans = 0
    for i in range(N - 1):
        ans += abs(h[i + 1] - h[i])
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        min_cost = 0
    elif i == 1:
        min_cost = abs(h[1] - h[0])
    else:
        current = h[i]
        tmp_min = min(abs(current - h[i - K]) + dp[i - K] , abs(current - h[i - K + 1]) + dp[i - K + 1])
        for j in range(K - 2):
            tmp_min = min(abs(current - h[i - K + 2 + j]) + dp[i - K + 2 + j], tmp_min)
        min_cost = tmp_min
    dp[i] = min_cost
#print(dp)
print(dp[N - 1])
### BUGGY CODE ###

num=int(input())
word=str(input())
n_th = 3*10^5
for i in range(num):
	n=word[:i].count('W')+word[i+1:].count('E')
	if n_th > n:
		n_th = n
print ( n_th)


### FIXED CODE ###

num=int(input())
word=str(input())
w=[0]
e=[0]
if word[0]=='W':
	w=[1]
	e=[0]
else:
	w=[0]
	e=[1]
for i in range(1,num):
	if word[i]=='W':
		w.append(w[i-1]+1)
		e.append(e[i-1])
	else:
		w.append(w[i-1])
		e.append(e[i-1]+1)
n_th=e[num-1]
for i in range(1,num):
	n=w[i-1]+e[num-1]-e[i]
	if n_th>n:
		n_th=n

print (n_th)
### BUGGY CODE ###

N, W = map(int,input().strip().split(" "))
Vmax = 10**5
dp = [10**9+1] * (Vmax+1)
dp[0] = 0
Vtotal = 0

for _ in range(N):
    w, v = map(int, input().strip().split(" "))
    Vtotal += v
    for i in range(Vtotal-v, -1, -1):
        dp[i+v] = min(dp[i+v], dp[i]+w)

for v in range(Vtotal, -1, -1):
    if dp[v] <= W:
        print(v)
        break


### FIXED CODE ###

N, W = map(int,input().strip().split(" "))
Vmax = 10**5
dp = [10**9+1] * (Vmax+1)
dp[0] = 0
Vtotal = 0

for _ in range(N):
    w, v = map(int, input().strip().split(" "))
    Vtotal += v
    for i in range(Vtotal-v, -1, -1):
        dp[i+v] = min(dp[i+v], dp[i]+w)

for v in range(Vtotal, -1, -1):
    if dp[v] <= W:
        print(v)
        break
### BUGGY CODE ###

N,M = map(int,input().split())
graph = [0]*(N+1)
for i in range(N+1):
    graph[i]=list()
for i in range(M):#生成
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
graph[0].append(1)
for i in range(N+1):#整列
    graph[i].sort()
# print(graph)
ans = [0]*(N+1)
dis_stack = list()
dis_stack.extend(graph[0])
bef_stack = [1]
# k = 0
# print(graph)
while(len(dis_stack)!=0):
    now_watch=dis_stack.pop(0)
    next_watch = graph[now_watch]
    for spot in next_watch:
        if(spot in bef_stack):
            pass
        else:
            # print(dis_stack)
            # print(bef_stack)
            dis_stack.append(spot)
            ans[spot] = now_watch
            # print(ans)
        bef_stack.append(spot)
 
ans.pop(0)
print("Yes")
for i in range(1,len(ans)):
    print(ans[i])

    # k +=1
# 探索スタート地点を「探索候補スタック」に積む
# while スタックが空っぽになるまで
#     スタックから次の探索地点を1つ取り出す（pop）
#     「探索済みリスト」に取り出した地点を格納（ここが現在地点）
# 　　現在地点から、次に行こうと思えば行けるポイントを全部探し出す
#     for 地点 in 次に行こうと思えば行けるポイント
#         if その地点は既に「探索済みリスト」にある？
#             探索済みなので「探索候補スタック」には入れない（continue）
#         if その地点は既に「探索候補スタック」にある？（閉路があるなら可能性あり、木なら可能性なし）
#             探索予定なので「探索候補スタック」には入れない（continue）
#         未探索かつ候補にも入っていない地点なので「探索候補スタック」に追加する（append）
# print 探索済み地点

### FIXED CODE ###

N,M = map(int,input().split())
graph = [0]*(N+1)
for i in range(N+1):
    graph[i]=list()
for i in range(M):#生成
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
graph[0].append(1)
# for i in range(N+1):#整列
#     graph[i].sort()
# print(graph)
ans = [-1]*(N+1)
ans[1] = 0
dis_stack = list()
dis_stack.extend(graph[0])
bef_stack = [1]
# k = 0
# print(graph)


while dis_stack:
    now_watch=dis_stack.pop(0)
    next_watch = graph[now_watch]
    for spot in next_watch:
        if(ans[spot] != -1):
            continue            
        # print(dis_stack)
        # print(bef_stack)
        dis_stack.append(spot)
        ans[spot] = now_watch
            # print(ans)
 
ans.pop(0)
print("Yes")
for i in range(1,len(ans)):
    print(ans[i])

    # k +=1
# 探索スタート地点を「探索候補スタック」に積む
# while スタックが空っぽになるまで
#     スタックから次の探索地点を1つ取り出す（pop）
#     「探索済みリスト」に取り出した地点を格納（ここが現在地点）
# 　　現在地点から、次に行こうと思えば行けるポイントを全部探し出す
#     for 地点 in 次に行こうと思えば行けるポイント
#         if その地点は既に「探索済みリスト」にある？
#             探索済みなので「探索候補スタック」には入れない（continue）
#         if その地点は既に「探索候補スタック」にある？（閉路があるなら可能性あり、木なら可能性なし）
#             探索予定なので「探索候補スタック」には入れない（continue）
#         未探索かつ候補にも入っていない地点なので「探索候補スタック」に追加する（append）
# print 探索済み地点
### BUGGY CODE ###

from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

const = 10 ** 9 + 7
MAX = 10 ** 5 + 50

#エラトステネス
L = [1 for i in range(100101)]
L[0] = 0
L[1] = 0
plist = []
for i in range(100101):
	if L[i] == 1:
		plist.append(i)
		c = 2
		while True:
			if i * c <= 100100:
				L[i * c] = 0
				c += 1
			else:
				break

#組み合わせ、逆元前計算
fac = [0] * (MAX)
inv = [0] * (MAX)
finv = [0] * (MAX)
fac[0], fac[1] = 1, 1
inv[1] = 1
finv[0], finv[1] = 1, 1

for i in range(2, MAX):
	fac[i] = fac[i - 1] * i % const
	inv[i] = inv[const % i] * (const - (const // i)) % const
	finv[i] = finv[i - 1] * inv[i] % const

#受け取り、処理
N, M = getlist()
if M == 1:
	print(1)
else:
	D = defaultdict(int)
	while M != 1:
		for i in plist:
			if M % i == 0:
				D[i] += 1
				M = M // i
				break

	data = []
	for i in D:
		data.append(D[i])

	#計算
	ans = 1
	for i in data:
		ans *= fac[i + N - 1] * finv[i] * finv[N - 1]
		ans %= const
	print(ans)

### FIXED CODE ###

from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

const = 10 ** 9 + 7
MAX = 10 ** 5 + 50

#エラトステネス
L = [1 for i in range(100001)]
L[0] = 0
L[1] = 0
plist = []
for i in range(100001):
	if L[i] == 1:
		plist.append(i)
		c = 2
		while True:
			if i * c <= 100000:
				L[i * c] = 0
				c += 1
			else:
				break

#組み合わせ、逆元前計算
fac = [0] * (MAX)
inv = [0] * (MAX)
finv = [0] * (MAX)
fac[0], fac[1] = 1, 1
inv[1] = 1
finv[0], finv[1] = 1, 1

for i in range(2, MAX):
	fac[i] = fac[i - 1] * i % const
	inv[i] = inv[const % i] * (const - (const // i)) % const
	finv[i] = finv[i - 1] * inv[i] % const

#受け取り、処理
N, M = getlist()
if M == 1:
	print(1)
else:
	D = defaultdict(int)
	while M != 1:
		judge = "No"
		for i in plist:
			if M % i == 0:
				D[i] += 1
				M = M // i
				judge = "Yes"
				break
		if judge == "No":
			D[M] += 1
			break

	data = []
	for i in D:
		data.append(D[i])

	#計算
	ans = 1
	for i in data:
		ans *= fac[i + N - 1] * finv[i] * finv[N - 1]
		ans %= const
	print(ans)
### BUGGY CODE ###

h,n = map(int, input().split())
magic = []
INF = 10**12

for i in range(n):
    a,b = map(int, input().split())
    magic.append([a, b])

dp = [[INF for j in range(h+1)] for i in range(n+1)] #体力がjのモンスターをi番目の魔法までを使って倒せる消費魔力の最小値

for i in range(n):
    for j in range(h):
        if j+1 > magic[i][0]:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-magic[i][0]] + magic[i][1], dp[i+1][j+1-magic[i][0]] + magic[i][1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], magic[i][1])
            
print(dp[n][h])

### FIXED CODE ###

h,n = map(int, input().split())
magic = []
INF = 10**8
dp = [[INF for j in range(h+1)] for i in range(n+1)] #体力がjのモンスターをi番目の魔法までを使って倒せる消費魔力の最小値
 
for i in range(n):
    a,b = map(int, input().split())
    magic.append([a, b])
 
for i in range(n):
    for j in range(h):
        if j+1 > magic[i][0]:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-magic[i][0]] + magic[i][1], dp[i+1][j+1-magic[i][0]] + magic[i][1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], magic[i][1])
            
print(dp[n][h])
### BUGGY CODE ###


import numpy as np

def search_and_mark(recent_rooms, rooms, AB, count, count_max):
  if None not in rooms:
    return rooms

  tmp_rooms = []
  for r in recent_rooms:
    tmp = AB[np.any(AB == r, axis=1)]
    target = tmp[tmp != r]
    tmp_rooms.extend(target)
    
    for t in target:
      if rooms[t] == None:
        rooms[t] = r

  recent_rooms = list(set(tmp_rooms))
  return search_and_mark(recent_rooms, rooms, AB, count+1, count_max)

def resolve():
  N, M = map(int, input().split(" "))
  rooms = [None] * N

  AB = []
  for m in range(M):
    AB.append([int(x) - 1 for x in input().split(" ")])

  AB = np.array(AB)
  result = search_and_mark([0], rooms, AB, 1, N)

  print("Yes")
  for r in result[1:]:
    print(r + 1)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N+1))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  recent_rooms = [0]
  depth = 1
  while len(not_finished) != 0 and depth < N:
    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth
    depth += 1
    recent_rooms = list(temp_recent)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)

if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

n=int(input())
A=[]*n
A[:]=map(int,input().split())

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

ans=10**9
for i in range(n-1):
  for j in range(i+1,n):
    ans=min(ans,gcd(A[i],A[j]))
print(ans)

### FIXED CODE ###

from math import gcd
N=int(input())
A=list(map(int,input().split()))

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

print(ans)