Harryxun/stf_run huggingface dataset:
"""
the condition is more straightforward than it looks.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcm of a list is loop: lcm(partial, new_value)
lcm(a, b) = ab / gcd(a, b)
"""

from math import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = int(round(val*lcm_ongoing/gcd(val, lcm_ongoing)))
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(int(round(lcm_of_A/value)) for value in A)
    modulo_value = int(int(10e9)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))

### FIXED CODE ###

"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from fractions import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = val*lcm_ongoing//gcd(val, lcm_ongoing)
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(lcm_of_A//value for value in A)
    modulo_value = int(int(10e8)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))
import sys

a = int(sys.stdin.readline().strip())
b = int(sys.stdin.readline().strip())
c = int(sys.stdin.readline().strip())

if a == 1:
    print("Hello World")
else:
    print(b + c)

### FIXED CODE ###

import sys

a = int(sys.stdin.readline().strip())
if a == 1:
    print("Hello World")
else:
    b = int(sys.stdin.readline().strip())
    c = int(sys.stdin.readline().strip())
    print(b + c)
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N = i_input()
    t0,a0 = 1,1

    for i in range(N):
        t1,a1 = i_map()
        f0 = t0//t1
        if t0%t1 != 0:
            f0 += 1
        f1 = a0 // a1
        if a0%a1 != -:
            f1 += 1
        f = max(f0, f1)
        t0, a0 = t1*f, a1*f
    print(t0+a0)


if __name__=="__main__":
    main()


### FIXED CODE ###

import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N = i_input()
    t0,a0 = 1,1

    for i in range(N):
        t1,a1 = i_map()
        f0 = t0//t1
        if t0%t1 != 0:
            f0 += 1
        f1 = a0 // a1
        if a0%a1 != 0:
            f1 += 1
        f = max(f0, f1)
        t0, a0 = t1*f, a1*f
    print(t0+a0)

if __name__=="__main__":
    main()
a = int(input())
b = int(input())

print(str(a*b) + " " + str(2a + 2b))

### FIXED CODE ###

z = input()
m,l = z.split()
s = int(m) * int(l)
n = int(m)*2 + int(l)*2

print("{} {}".format(str(s),str(n)))
O = input()
E = input()

ans = ""
for i in range(len(O)):
    ans += O[i]
    ans += E[i]
if len(O) > len(E):
    ans += O[-1]

print(ans)

### FIXED CODE ###

O = input()
E = input()

ans = ""
for i in range(len(E)):
    ans += O[i]
    ans += E[i]
if len(O) > len(E):
    ans += O[-1]

print(ans)
a = int(input())
l = len(str(a))

ans = 0
if l % 2 == 0:
    while l >= 1:
        ans += 10 ** (l - 1) - 1
        l -= 2
else:
    ans += a - (10 ** (l - 1) - 1)
    l -= 1
    while l >= 1:
        ans += 10 ** (l - 1) - 1
        l -= 2

print(ans)

### FIXED CODE ###

A, B, C = map(int, input().split())
if C-A+B >= 0:
    print(C-A+B)
else:
    print(int(0))
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def calc_lcs(s, t):
  dp = numpy.zeros((len(s)+1, len(t)+1))
  for i, si in enumerate(s, 1):
    for j, tj in enumerate(t, 1):
      dp[i][j] = max((dp[i-1][j-1] + (1 if si==tj else 0), dp[i-1][j], dp[i][j-1]))

  lcs = ''
  i, j = len(s), len(t)
  while i > 0 and j > 0:
    if   dp[i][j] == dp[i-1][j-1]+1:
      lcs = s[i-1] + lcs
      i -= 1
      j -= 1
    elif dp[i][j] == dp[i-1][j]:
      i -= 1
    elif dp[i][j] == dp[i][j-1]:
      j -= 1
  return lcs

def main():
  s = input().strip()
  t = input().strip()
  print(calc_lcs(s, t))


if __name__=='__main__':
  main()

### FIXED CODE ###

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

# @profile
def calc_lcs(s, t):
  dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
  # dp = numpy.zeros((len(s)+1, len(t)+1))
  for i, si in enumerate(s, 1):
    for j, tj in enumerate(t, 1):
      dp[i][j] = max((dp[i-1][j-1] + 1) if si==tj else 0, dp[i-1][j], dp[i][j-1])

  lcs = ''
  i, j = len(s), len(t)
  while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
      i -= 1
    elif dp[i][j] == dp[i][j-1]:
      j -= 1
    else:
      lcs = s[i-1] + lcs
      i -= 1
      j -= 1
  return lcs

def main():
  s = input().strip()
  t = input().strip()
  print(calc_lcs(s, t))


if __name__=='__main__':
  main()
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')



### FIXED CODE ###

S = input()
l = len(S)
OK = False
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')
n, m = map(int, input().split())

array = [int(x) for x in input().split()]
res = sorted(array)
judge = False
tmp = res.pop(0)
for i in res:
  if i%tmp != 0:
    judge = True
    break
if (len(res) == 0 and tmp != m) or res[-1] < m:
  judge = False
print("POSSIBLE" if judge else "IMPOSSIBLE")


### FIXED CODE ###

import fractions
import sys

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == 1:
    print("POSSIBLE" if max(array) == k else "IMPOSSIBLE")
    sys.exit()

res = fractions.gcd(array[0], array[1])

for i in array[2:]:
    res = fractions.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")
A, B, C, D = map(int, input().split())
import math

dc = math.floor(B/C) - math.floor((A-1)/C)
dd = math.floor(B/D) - math.floor((A-1)/D)
lcmCD = (C*D)/math.gcd(C,D)
dcd = math.floor(B/lcmCD) - math.floor((A-1)/lcmCD)

print(B-A+1 - (dc + dd - dcd))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
import fractions
 
def num_divide(p, q, r):
    if p % r == 0:
        rmin = p
    else:
        rmin = p + (r-p%r)
    rmax = q - q%r
    return (rmax-rmin)//r + 1
 
print(b - a + 1 - (num_divide(a, b, c) + num_divide(a, b, d) - num_divide(a, b, c * d // fractions.gcd(c, d))))
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
xn.append(x)
ym.append(y)
flag = 0
 
if x < y:
    for i in range(min(xn), max(ym)+1):
        if max(xn) < i and min(ym)>=i:
            print("No War")
            flag = 1
    if flag == 0:
        print("War")
else:
    print("War")

### FIXED CODE ###

# coding: utf-8
 
a, b, c = map(int, input().split())
 
x = a*10 + b
y = b*10 + c
z = c*10 + a
 
if x >= y and x >= z:
    print(x + c)
elif y >= x and y >= z:
    print(y + a)
else:
    print(z + b)
from collections import deque
h, w = map(int, input().split())
s = [input() for _ in range(h)]

INF = 1001001001
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]

def update(i, j, x):
    global dist, s, q
    if(dist[i][j] != INF): return
    dist[i][j] = x
    q.append([i, j])

res = 0
for si in range(h):
    for sj in range(w):
        if(s[si][sj] == '#'): continue
        
        dist = [[INF for _ in range(w)] for _ in range(h)]
        q = deque()
        update(si, sj, 0)
        
        while(q):
            i, j = q.popleft()
            
            for idir, jdir in zip(di, dj):
                ni = i + idir
                nj = j + jdir
                
                if(ni<0 or ni>=h or nj<0 or nj>=w): continue
                if(s[ni][nj] == '#'): continue
                
                update(ni, nj, dist[i][j]+1)
        
        for i in range(h):
            for j in range(w):
                if(dist[i][j]==INF): continue
                res = max(res, dist[i][j])
                if(res == 9): temp.append(dist)

print(res)

### FIXED CODE ###

from collections import deque
import copy

def bfs(grid, start):
    H, W = len(grid), len(grid[0])
    distance = [[-1] * W for _ in range(H)]
    queue = deque([start])
    distance[start[0]][start[1]] = 0
    while queue:
        x, y = queue.popleft()
 
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = y + j, x + i
            if 0 <= new_y < W and 0 <= new_x < H:
                if grid[new_x][new_y] == '.' and distance[new_x][new_y] == -1:
                    distance[new_x][new_y] = distance[x][y] + 1
                    queue.append((new_x, new_y))
    return max(map(max, distance))

h, w = map(int, input().split())
maze = [input() for _ in range(h)]


res = -1
for i in range(h):
    for j in range(w):
        if(maze[i][j] == '#'): continue
        tmpmaze = copy.deepcopy(maze)
        steps = bfs(tmpmaze, [i, j])
        if(steps > res):
            res = steps
print(res)
import collections
i,j = 0,0 
q = collections.deque([])
while(j < len(s)):
  while(s[j] == s[i]): j+=1
  q.append(j - i - 1)
  j = i

5 6 5 1 1 4 2 1 1 1 1 1

while(len(q) > 1):
  u,v = q.popleft(), q.popleft()
  if q: q[0] += abs(u-v)
print q[0] if q else 0

### FIXED CODE ###

import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)
N = input()
n = list(map(int,raw_input().split()))

for i in range(1,int(N)):
    v = n[i]
    j = i - 1
    while j >= 0 and v < n[j]:
        n[j+1] = n[j]
        j = j - 1
    n[j+1] = v
    print(n.replace("[","").replace(",","").replace("]",""))

### FIXED CODE ###

def insertsort(array):
    for i in range(1,len(array)):
        print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in rnage(m)]     
c = [[0]*l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] = int(a[i][k])*int(b[k][j])
for i in range(n):
    print(*c)


### FIXED CODE ###

n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])
import sys
input = sys.stdin.readline

def main():
    N,P = map(int,input().split())
    if N==1:
        print(P)
    else:
        ans = 1
        insuu = 2
        while insuu**N<=P:
            if P%(insuu**N)==0:
                ans *= insuu
                P //= insuu**N
            else:
                insuu += 1
        print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,P = map(int,input().split())
    if N==1:
        print(P)
    elif N>50:
        print(1)
    else:
        ans = 1
        insuu = 2
        while insuu**N<=P:
            if P%(insuu**N)==0:
                ans *= insuu
                P //= insuu**N
            else:
                insuu += 1
        print(ans)

if __name__ == '__main__':
    main()
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0
num_drinks = input()
for j in new:
  sum += j

for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if new_line[1] != new[new_line[0]]:
    sum -= new[new_line[0]]
    sum += new_line[1]
    


### FIXED CODE ###

num_prob = int(input())
prob = input()
new = prob.split()
sum = 0

for j in new:
  sum += int(j)

  
num_drinks = int(input())
for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if int(new_line[1]) != int(new[int(new_line[0])-1]):
    temp = sum - int(new[int(new_line[0])-1]) + int(new_line[1])
    print(temp)
  else:
    print(sum)
from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.insert(0,a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)


### FIXED CODE ###

from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.appendleft(a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)
X, N = map(int,input().split())
L = list(map(int,input().split()))

NL = []
for i in range(100):
    NL.append(i+1)

for l in L:
    NL.remove(l)

NL.append(X)
NL.sort()

LR = NL.index(X)+1
LL = NL.index(X)-1


if (NL[LR]-X) < (X-NL[LL]):
    print(NL[LR])
else:
    print(NL[LL])

### FIXED CODE ###

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

NL = []
for i in range(102):
    NL.append(i)

for l in L:
    NL.remove(l)

NL.append(X)
NL.sort()

LR = NL.index(X)+1
LL = NL.index(X)-1


if (NL[LR]-X) < (X-NL[LL]):
    print(NL[LR])
else:
    print(NL[LL])
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1

    for i in range(n):
        if num_list[i] == 'X':
            num_list[i] = '1' if i == 0 else '0'

    return ''.join(num_list)

print(ans())


### FIXED CODE ###

import math
n = int(input())
print(math.ceil(n/2))
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)

listS = []

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

for i in range(0,N-K+1):
    if prod(A[i:K+i]) < prod(A[i+1:K+i+1]):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

for i in range(0,N-K):
    if A[i] < A[i+K]:
        print("Yes")
    else:
        print("No")
S = list(input())

if S[0] == "Y" and S[1] == "A" and S[2] == "K" and S[3] == "I":
    print("Yes")
else:
    print("No")



### FIXED CODE ###

S = input()

if S[:4] == "YAKI":
    print("Yes")
else:
    print("No")
A, B, K = list(map(int, input().split()))

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

### FIXED CODE ###

A, B, K = list(map(int, input().split()))

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[(1,1),(-1,1),(1,-1),(-1,-1),(2,0),(-2,0),(0,2),(0,-2),(1,2),(-1,2),(1,-2),(-1,-2),(2,1),(-2,1),(2,-1),(-2,-1),(2,2),(-2,2),(2,-2),(-2,-2)]

visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1

q=deque()
q.append((0,CH,CW))
visit[(CH,CW)]=1

while q:
    kyori, fro_h, fro_w=q.popleft()
    visit[(fro_h, fro_w)]=1
    if fro_h==DH and fro_w==DW:
        print (kyori)
        quit()
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
                    q.appendleft((kyori,to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
                    q.append((kyori+1, to_h, to_w))

print (-1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
import math
import reduce
n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]

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

print(gc(x))

### FIXED CODE ###

def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

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

x=[abs(int(i)-xs) for i in input().split()]

ans=x[0]
for i in range(n):
    ans=gcd(ans,x[i])

print(ans)
S=list(input())
s=[]
for i in range(len(S)):
    if S[i] == "A":
        s.append("A")
    elif(S[i] == "B" and S[i+1] == "C"):
        s.append("D")
s=s+[""]
c=0
i=0
while(len(s)>i):
    if s[i]=="A" and s[i+1]=="D":
        s[i]="D"
        s[i+1]="A"
        i-=2
        c+=1
    i+=1

print(c)

### FIXED CODE ###

s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans)
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

a_c = max(A, C)
b_d = min(B, D)

if a_c - b_d:
  print(a_c - b_d)
else:
  print("0")

### FIXED CODE ###

N = input()

if N == N[::-1]:
  print('Yes')
else:
  print('No')
D,N = map(int, input().split())

if N == 100:
    print(101 ** D * n)
else:
    print(100 ** D * N)

### FIXED CODE ###

D,N = map(int, input().split())

if N == 100:
    print(100 ** D * (N+1))
else:
    print(100 ** D * N)
import copy

N=int(input())
X=list(map(int,input().split(" ")))
Y=copy.deepcopy(X)
Y.sort()
Y1=Y[:N//2]
Y2=Y[N//2:]
a=Y[N//2]
b=Y[N//2-1]
for i in X:
  if i in Y1:
    print(a)
  else:
    print(b)

### FIXED CODE ###

A,B,X=list(map(int,input().split(" ")))
if A<=X and X<=A+B:
  print("YES")
else:
  print("NO")
N = int(input())
T,A = map(int,input().split(" "))
temp = []
for i in range(N):
  temp.append(map(int,input().split(" ")))
j = 0
k = 0
flag = 0
s = []
while j < N:
  k = T - (0.006)*temp[j]
  if k >= A:
    s.append(k - A)
  else:
    s.append(A - k)
  if s[j] <= s[flag]:
    flag = j
  j = j + 1
print(flag)

### FIXED CODE ###

N = int(input())
T,A = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
j = 0
k = 0
flag = 0
s = []
while j < N:
  k = T - (0.006)*H[j]
  if k >= A:
    s.append(k - A)
  else:
    s.append(A - k)
  if s[j] <= s[flag]:
    flag = j
  j = j + 1
print(flag+1)
import numpy
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
matrix =[0]*h
for i in range(h):
    matrix[i] = [0]*w
for i in range(m):
    hi,wi = map(int,input().split())
    hight[hi-1] += 1
    width[wi-1] += 1
    matrix[hi-1][wi-1] += 1
max_vh = numpy.argmax(hight)
max_vw = numpy.argmax(width)
f = 1
for i in range(m):
    if(matrix[max_vh][i] == 0):
        f = 0
        break
 
print(hight[max_vh] + width[max_vw]-f)

# 3 2 22
# 3 2
# 1 2



### FIXED CODE ###

import sys
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
S = set()

for i in range(m):
    hi,wi = map(int,input().split())
    S.add((hi-1,wi-1))
    hight[hi-1] += 1
    width[wi-1] += 1

max_vh = max(hight)
max_vw = max(width)

max_h = [i for i in range(h) if hight[i] == max_vh]
max_w = [i for i in range(w) if width[i] == max_vw]
for i in max_h:
    for j in max_w:
        if not(i,j) in S:
            print(max_vh+max_vw)
            sys.exit()

print(max_vh+max_vw-1)
R = input()
if R < 1200:
  print("ABC")
elif R < 2800:
  print("ARC")
else:
  print("AGC")

### FIXED CODE ###

R = int(input())
if R < 1200:
  print("ABC")
elif R < 2800:
  print("ARC")
else:
  print("AGC")