Harryxun/stf_run huggingface dataset:
import sys

sys.setrecursionlimit(10**6)
input=sys.stdin.readline

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


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

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

val = [X,Y]
val_min = min(val)

val_min_sho = int(val_min/3)

X_henkan = X - 3*val_min_sho
Y_henkan = Y - 3*val_min_sho
if (X_henkan == 0 and Y_henkan == 0):
    n = (val_min_sho)*2
    n_2 = int(n/2)
    print(comb(n,n_2,10**9+7))
elif Y_henkan != 0 and (X_henkan / Y_henkan == 2):
    n = (val_min_sho)*2 + Y_henkan
    n_2 = val_min_sho
    print(comb(n,n_2,10**9+7))
elif X_henkan != 0 and (Y_henkan / X_henkan == 2):
    n = (val_min_sho)*2 + X_henkan
    n_2 = val_min_sho
    print(comb(n,n_2,10**9+7))
else:
    print(0)

### FIXED CODE ###

import itertools

N = int(input())
Town = []
for _ in range(N):
    Town.append(list(map(int, input().split())))

kyori = 0
num = 0
for v in itertools.permutations(Town, N):
    num += 1
    for i in range(N-1):
        kyori += ((v[i][0]-v[i+1][0])**2 + (v[i][1]-v[i+1][1])**2)**0.5

print(kyori/num)
import collections

n = int(input())
a = list(map(int, input().split(" ")))
q = int(input())
have_map = collections.Counter(a)
cost_map = { k:k for k in have_map.keys() }
for i in range(q):
    x, y = map(int, input().split(" "))
    have_map[y] = have_map.get(x, 0) + have_map.get(y, 0)
    have_map.pop(x, 0)

    cost = 0
    for k,v in have_map.items():
        cost += cost_map[k] * v
    print(cost)


### FIXED CODE ###



import collections

n = int(input())
a = list(map(int, input().split(" ")))
q = int(input())
have_map = collections.Counter(a)

total_cost = 0
for k,v in have_map.items():
    total_cost += k * v

for i in range(q):
    x, y = map(int, input().split(" "))
    if x in have_map:
        diff = have_map[x] * -x  + have_map[x] * y
        total_cost += diff

    have_map[y] = have_map.get(x, 0) + have_map.get(y, 0)
    have_map.pop(x, 0)

    print(total_cost)
n = int(input())
L=[]
for i in range(n):
  s,p=input()
  L.append([s,int(p),i+1])
list.sort(L,reverse=True)
for i in range(n):
  print(L[i][2])

### FIXED CODE ###

n = int(input())
L=[]
for i in range(n):
  s,p=input().split()
  L.append([s,-int(p),i+1])
list.sort(L)
for i in range(n):
  print(L[i][2])
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())])

### FIXED CODE ###

a=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
print(a[int(input())-1])
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N, M, X, Y = map(int, input().split(" "))
	X = input().split(" ")
	X = [int(s) for s in X]
	Y = input().split(" ")
	Y = [int(s) for s in Y]
	
	X.sort()
	Y.sort()
	
	if X >= Y:
		print("War")
		sys.exit()
	
	tmp = Y[0] - X[len(X)-1]
	if tmp < 2:
		print("War")
		sys.exit()
		
	for i in range(X[len(X)-1]+1, Y[0]):
		if i <= Y and X < i:
			print("No War")
			sys.exit()
	
	
	print("War")
		
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N, M, XX, YY = map(int, input().split(" "))
	X = input().split(" ")
	X = [int(s) for s in X]
	Y = input().split(" ")
	Y = [int(s) for s in Y]
	
	X.sort()
	Y.sort()
	
	if X >= Y:
		print("War")
		sys.exit()
	
	tmp = Y[0] - X[len(X)-1]
	if tmp < 1:
		print("War")
		sys.exit()
		
	for i in range(X[len(X)-1]+1, Y[0]+1):
		if i <= YY and XX < i:
			print("No War")
			sys.exit()
	
	print("War")
		
	
if __name__ == "__main__":
	main()
N, K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9 + 7

LANK = list(set(A))
LANK.sort()
LANK2 = [0] * 2000
for i, l in enumerate(LANK):
    LANK2[l] = i

LANK = [-1] * N
for i,a in enumerate(A):
    LANK[i] = LANK2[a]

back = [0] * N
for i,a in enumerate(A[::-1]):
    cnt = 0
    for j,a2 in enumerate(A[::-1]):
        if i > j and a > a2:
            cnt += 1
    back[N-1-i] = cnt
    
SUM = 0
tmp = K*(K-1) //2
tmp %= MOD

for i,a in enumerate(A):
    SUM += (LANK[i] * tmp)%MOD
    SUM += (back[i] * K)%MOD
    SUM %= MOD
print(SUM)

### FIXED CODE ###

N, k = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7

ans = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            if i > j:
                ans += k*(k-1)//2
            elif i < j:
                ans += k*(k+1)//2
            ans %= MOD

print(ans)
a,b = map(int,input().split())

if a > 9 or b > 9:
    print("-1")
else:
    num = a*b
print(num)

### FIXED CODE ###

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

if a > 9 or b > 9:
    print("-1")
else:
    num = a*b
    print(int(num))
import numpy as np
import math

def solve():
    n,w = map(int,input().split())
    w_list,v_list = [0]*n,[0]*n
    for i in range(n):
        w_list[i],v_list[i] = map(int,input().split())
    dp = [[0]*(w+5) for i in range(n+5)]
    for i in range(n):
        for j in range(w+1):
            if j-w_list[i]>=0:
                dp[i][j] = max(
                    dp[i-1][j],
                    dp[i-1][j-w_list[i]]+v_list[i]
                    )
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n-1][w])
    return 0

if __name__ == "__main__":
    solve()


### FIXED CODE ###


def solve():
    n,w = map(int,input().split())
    w_list,v_list = [0]*n,[0]*n
    for i in range(n):
        w_list[i],v_list[i] = map(int,input().split())
    dp = [[0]*(w+5) for i in range(n+5)]
    for i in range(n):
        for j in range(w+1):
            if j-w_list[i]>=0:
                dp[i][j] = max(dp[i-1][j],
                               dp[i-1][j-w_list[i]]+v_list[i])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n-1][w])
    return 0
 
if __name__ == "__main__":
    solve()
import itertools

n, m, q = map(int, input().split())
I = list(range(1, m + 1))
A = list(map(list, itertools.combinations(I, n)))
l = len(A)
ans = [0 for i in range(l)]
for _ in range(q):
    a, b, c, d = map(int, input().split())
    for i in range(l):
        if A[i][b - 1] - A[i][a - 1] == c:
            ans[i] += d
print(max(ans))

### FIXED CODE ###

import itertools

n, m, q = map(int, input().split())
I = list(range(1, m + 1))
A = list(map(list, itertools.combinations_with_replacement(I, n)))
l = len(A)
ans = [0 for i in range(l)]
for _ in range(q):
    a, b, c, d = map(int, input().split())
    for i in range(l):
        if A[i][b - 1] - A[i][a - 1] == c:
            ans[i] += d
print(max(ans))
# https://atcoder.jp/contests/abc109/tasks/abc109_c

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


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()
# https://atcoder.jp/contests/abc109/tasks/abc109_c

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


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc109/tasks/abc109_c

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


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()
import sys

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

p = X
_p = 0
k = 0

if abs(p) > K*D:
    print(abs(p)-K*D)
    sys.exit()

if p < 0:
    for i range(K):
        _p = p
        p += D
        k += 1
        if p > 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
elif p > 0:
    for i in range(K):
        _p = p
        p -= D
        k += 1
        if p < 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)


### FIXED CODE ###

import sys

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

p = X
_p = 0
k = 0

if abs(p) > K*D:
    print(abs(p)-K*D)
    sys.exit()

if p < 0:
    for i in range(K):
        _p = p
        p += D
        k += 1
        if p > 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
elif p > 0:
    for i in range(K):
        _p = p
        p -= D
        k += 1
        if p < 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)
goal = 'AKIHABARA'
s = input()
if s[-1] != "A":
    s += "A"

i = 0
j = 0
while True:
    if j == len(goal):
        break
    if s[i] == goal[j]:
        i += 1
        j += 1
    elif s[i] != goal[j]:
        j += 1
if i == len(s):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s = input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                tmp = "A"[:i] + "KIH" + "A"[:j] + "B" + "A"[:k]+ "R" + "A"[:l]
                if tmp == s:
                    print("YES")
                    exit()
print("NO")
import copy as copy
s = input()
dic={}

def func(val, n):
    if val in dic:
        return dic[val]

    if not ('1' in val):
        return n
    elif not ('0' in val):
        return n
    a=0
    b=0    
    if '01' in val:
        a = func(val.replace('01', '', 1), n+2)
    if '10' in val:
        b = func(val.replace('10', '', 1), n+2)
    
    ans=max(a, b, n)

    dic[val]=ans

    return ans

print(func(s, 0))


### FIXED CODE ###

s = input()

print(min(s.count('0'), s.count('1'))*2)
#!/usr/bin/env python3

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
grid = [list(map(int, input().split())) for _ in range(H)]

d = dict()
nums = [i for i in range(10) if i != 1]

q = [[[1], 0]]

while q:
    tmp = q.pop()
    num, cost = tmp[0], tmp[1]
    key = str(num[-1]) + "_1"
    if d.get(key):
        d[key] = min(d[key], cost)
    else:
        d[key] = cost
    if len(num) < 10:
        for n in nums:
            num_tmp = num.copy()
            if n not in set(num_tmp):
                num_tmp.append(n)
                q.append([num_tmp, cost + c[num_tmp[-1]][num_tmp[-2]]])

ans = 0
for i in range(H):
    for j in range(W):
        tmp = grid[i - 1][j - 1] 
        if tmp >= 0:
            ans += d[str(tmp) + "_1"]
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import copy

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
grid = [list(map(int, input().split())) for _ in range(H)]

d = dict()
nums = [i for i in range(10) if i != 1]
d["-1_1"] = 0

q = [[[1], 0]]

while q:
    tmp = q.pop()
    num, cost = tmp[0], tmp[1]
    key = str(num[-1]) + "_1"
    if d.get(key):
        d[key] = min(d[key], cost)
    else:
        d[key] = cost
    if len(num) < 10:
        for n in nums:
            num_tmp = copy.copy(num)
            if n not in set(num_tmp):
                num_tmp.append(n)
                q.append([num_tmp, cost + c[num_tmp[-1]][num_tmp[-2]]])

ans = 0
for i in range(H):
    for j in range(W):
        tmp = grid[i - 1][j - 1] 
        ans += d[str(tmp) + "_1"]
print(ans)
n = int(input())
kugiri = [0,26,702,18278,475254,12356630,321272406,8353082582,217180147158,5646683826134]
ans = ""

for i in range(len(kugiri)):
    if n <= kugiri[i]:
        keta = i
        break
        
n -= kugiri[i-1]

for i in range(keta):
    moji = n // 26**(keta-1)
    
    if keta == 1:
        moji -= 1
    
    ans += chr(moji+97)
    n -= moji * 26**(keta-1)
    keta -= 1
    
print(ans)

### FIXED CODE ###

n = int(input())
kugiri = [0,26,702,18278,475254,12356630,321272406,8353082582,217180147158,5646683826134,146813779479510,3817158266467286]
ans = ""

for i in range(len(kugiri)):
    if n <= kugiri[i]:
        keta = i
        break
        
n -= kugiri[i-1]

for i in range(keta):
    moji = -(-n // 26**(keta-1))
    ans += chr(moji+96)
    n -= (moji-1) * 26**(keta-1)
    keta -= 1
    
print(ans)
a, b, c = map(int, input().split())
print(len(set(a, b, c)))


### FIXED CODE ###

a, b, c = map(int, input().split())
print(len(set([a, b, c])))
A,B = map(float,input().split())
ans = A*B
if ans >= 1:
    ans = str(A*B)
    a = ans[0:len(ans)-2]
    print(int(a))
else:
    print(0)

### FIXED CODE ###

A,B = map(str,input().split())
a = int(A)
b = int(B[0])*100 + int(B[2])*10 + int(B[3])
print((a*b)//100)
N = int(intput())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))


### FIXED CODE ###

N = int(input())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))
import math
A, B = map(int, input().split())
ans = math.floor(A*B)
print(ans)

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    answer = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 0:
                continue
            else:
                if h + 1 <= H - 1 and w + 1 <= W + 1:
                    if A[h + 1][w] % 2 == 1:
                        A[h + 1][w] += 1
                        answer.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w + 1] += 1
                        answer.append([h + 1, w + 1, h + 1, w + 2])
                elif h + 1 <= H - 1:
                    A[h + 1][w] += 1
                    answer.append([h + 1, w + 1, h + 2, w + 1])
                elif w + 1 <= W - 1:
                    A[h][w + 1] += 1
                    answer.append([h + 1, w + 1, h + 1, w + 2])
                else:
                    continue
    N = len(answer)
    print(N)
    for i in range(N):
        print(*answer[i], sep=" ")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    answer = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 0:
                continue
            else:
                if h + 1 <= H - 1 and w + 1 <= W - 1:
                    if A[h + 1][w] % 2 == 1:
                        A[h + 1][w] += 1
                        answer.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w + 1] += 1
                        answer.append([h + 1, w + 1, h + 1, w + 2])
                elif h + 1 <= H - 1:
                    A[h + 1][w] += 1
                    answer.append([h + 1, w + 1, h + 2, w + 1])
                elif w + 1 <= W - 1:
                    A[h][w + 1] += 1
                    answer.append([h + 1, w + 1, h + 1, w + 2])
                else:
                    continue
    N = len(answer)
    print(N)
    for i in range(N):
        print(*answer[i], sep=" ")


if __name__ == "__main__":
    main()
x = input()
if x.isupper() == True:
  print(A)
else:
  print(a)

### FIXED CODE ###

x = str(input())
if x.isupper() == True:
  print("A")
else:
  print("a")
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
    a[i] = a[i]-(i+1)

a.sort()
if i%2==1:
    b = a[i//2]
else:
    b = (a[i//2]+a[i//2+1])//2

ans = 0
for i in range(n):
    ans += abs(a[i]-b)
print(ans)


### FIXED CODE ###

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

for i in range(n):
    a[i] = a[i]-(i+1)

a.sort()
b = (a[n//2]+a[(n-1)//2])//2

ans = 0
for i in range(n):
    ans += abs(a[i]-b)
print(ans)
import numpy as np
import math

# input

r, D, x = [int(_) for _ in input().split()]

xans = np.ones(10)

def Linear_Recursive(x, r, D, N):
    
    if N==0:
        xans = x
        return xans
    
        
    
    xans = r*Linear_Recursive(x, r, D, N-1) - D # linear eq.
    
    return xans
  
for i in range(10):
    xans[i] = round(Linear_Recursive(x, r, D, i+1))
    
    print(xans[i])
    


### FIXED CODE ###

import numpy as np
import math

N = float(input())

p = math.ceil(N/2)/N

print(p)
#
# Yet I'm feeling like
# 	There is no better place than right by your side
# 		I had a little taste
# 			And I'll only spoil the party anyway
# 				'Cause all the girls are looking fine
# 					But you're the only one on my mind

import sys
# import re
inf = float("inf")
# sys.setrecursionlimit(1000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0,-1,1,-1,1],[0,0,1,-1,1,1,-1,-1]

# import operator as op
# from functools import reduce
# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan
# from bisect import bisect_left,bisect_right,insort_left
# import numpy as np
# import queue
# from copy import deepcopy
# import random

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
result=[]
for i in range(n):
    result.append((Arr[i],i))
result.sort()
ans=[]
for i in result:
    ans.append(i[1]+1)
print(*ans)

### FIXED CODE ###

import sys
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
result=[]
for i in range(n):
  result.append((Arr[i],i+1))
result.sort()
ans=[]
for i in result:
  ans.append(i[1])
print(*ans)
import collections, sys
sys.setrecursionlimit(10**5 + 5)
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)

memo = [-1] * (N + 1)


def rec(x):
    if memo[x] == -1:
        if win_lose[x] == set():
            memo[x] = 0
        else:
            memo[x] = max(a + b for a, b in zip(
                sorted(rec(y) for y in win_lose[x])[::-1], range(1, N + 1)))
    return memo[x]


print(rec(1))
print(memo)


### FIXED CODE ###

import collections
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)

s1 = [1]
s2 = []
while s1:
    a = s1.pop()
    s2 += [a]
    for b in win_lose[a]:
        s1 += [b]
memo = [0] * (N + 1)
for x in s2[::-1]:
    if win_lose[x] == set():
        memo[x] = 0
    else:
        memo[x] = max(a + b for a, b in zip(
            sorted(memo[y] for y in win_lose[x])[::-1], range(1, N + 1)))
print(memo[1])
n, m = map(int, input().split())
PS = {}

for i in range(m):
    res = input()
    res_list = list(res.split())
    if res not in PS:
        PS[res] = 0
        PS[res] += 1
    elif res_list[1] == "WA" and PS[res_list[0]+ " AC"] >= 1:
        pass
    elif res_list[1] == "AC" and PS[res_list[0]+ " AC"] >= 1:
        pass
    else:
        PS[res] += 1


ans = 0
pn = 0
for k, v in PS.items():
    if k[-2:] == "AC":
        ans += 1
    elif k[-2:] == "WA":
        pn += 1

print(ans, pn)


### FIXED CODE ###

n, m = map(int, input().split())
PN = 0
AC_list = [0 for i in range(n)] 
WA_list = [0 for i in range(n)] 

for i in range(m):
    p, s = input().split()
    p = int(p)

    if s == "AC" and AC_list[p-1] == 0:
        PN += WA_list[p-1]
        AC_list[p-1] = 1
    
    else:
        WA_list[p-1] += 1


print(AC_list.count(1), PN)
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)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mina = max(a)
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
a.sort()
for i in range(n-1):
    mina = min(mina,gcd(a[i],a[i+1]))
print(mina)
s = input()
a = int(s)
mods = [a%2019]
for i in range(len(s)):
  a = int((a-int(s[-(i+1)]))/10)
  mods.append(a%2019)
mod_N ={}
for i in mods:
  if not i in mod_N:
    mod_N[i] = 0
  else:
    mod_N[i] += 1
ans = 0
for i in mod_N:
  ans += int(mod_N[i]*(mod_N[i]-1)/2)
print(ans)

### FIXED CODE ###

s = input()
a = 0
mods = [0]*2019
mods[a] += 1
r = 1
for i in s[::-1]:
  a = (a+int(i)*r)%2019
  r = r*10%2019
  mods[a] += 1
ans = 0
for i in mods:
  ans += i*(i-1)//2
print(ans)
a,b=map(int, input().split())
c=list(map(int, input().split())) 
 
l = [1]
tmp = 1
s = 0
for i in range(b):
    l.append(c[tmp-1])
    tmp = c[tmp-1]
    d = l.count(l[i])
    if d > 1:
        s = l[i]
        break

tmp2 = [i for i, x in enumerate(l) if x == s]
h = tmp2[0]+1
t = tmp2[1]+1
 
#print(s,h,t)
l2 = l[h-1:t-1]
#print(l2)
if s == 1:
    id = b % (t - 1)
    print(l2[id])
else:
    id = (b - h + 1) % (t - h)
    print(l2[id])

### FIXED CODE ###

a,b=map(int, input().split())
c=list(map(int, input().split())) 
 
l = [1]
f = [0]*a
f[0] += 1
tmp = 1
s = 0
for i in range(b):
    l.append(c[tmp-1])
    tmp = c[tmp-1]
    if f[tmp-1] != 0:
        s = c[tmp-1]
        t = len(l)+1
        break
    f[tmp-1] += 1

#print(l)
if a > b:
    print(l[b])
    exit()

h = l.index(s) + 1

#print(s,h,t)
l2 = l[h-1:t-1]
#print(l2)
if s == 1:
    id = b % (t - 1)
    print(l2[id])
else:
    id = (b - h + 1) % (t - h)
    print(l2[id])
import collections

N = int(input())
S = [input() for i in range(N)]

ans = collections.Counter(S)
print(len(ans))

### FIXED CODE ###

S, W = map(int, input().split())
if S <= W:
  print('unsafe')
else:
  print('safe')
n = int(input())
judge = list(input() for _ in range(n))
ac, wa, tle, re = 0
for i in judge:
  if i == 'AC':
    ac = ac + 1
  elif i == 'WA':
    wa = wa + 1
  elif i == 'TLE':
    tle = tle + 1
  elif i == 'RE':
    re = re + 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

### FIXED CODE ###

n = int(input())
judge = list(input() for _ in range(n))
ac = wa = tle = re = 0
for i in judge:
  if i == 'AC':
    ac = ac + 1
  elif i == 'WA':
    wa = wa + 1
  elif i == 'TLE':
    tle = tle + 1
  elif i == 'RE':
    re = re + 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))