peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, M = map(int, input().split())
man = [[int(x) for x in input().split()] for _ in range(N)]
check = [[int(x) for x in input().split()] for _ in range(M)]

for a, b in man:
    tmp = 1000000000
    ans = 1
    for i, (c, d) in enumerate(check):
        if tmp > (abs(a-c) + abs(b-d)):
            tmp = min(tmp, abs(a-c) + abs(b-d))
    print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
import sys
input = sys.stdin.readline

# A - Two Integers
x, y = map(int, input().split())

if x % y == 0:
	print(-1)
else:
	i = 2
	
	while True:
		if (x * i) % y != 0:
			print(x * i)
			break
		else:
			i += 1
# Judge status: Accepted
N=int(input())
L=['a','b','c','d','e','f','g','h','i','j']

Ans = [L[0]]
Backup = []

for k in range(N-1):
    Backup = Ans
    Ans = [i+L[j] for i in Backup for j in range(len(set(i))+1)]

for i in Ans:
    print(i)
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[i+k-1] - h[i])
print(min(l))
# Judge status: Wrong Answer
a, b = map(int,input().split())

if b < 2*a:
  print(1)
else:
  print((b-a)//a+1)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
A.sort()
lis = []

for i in range(len(A) - 1):
    if A[i] == A[i + 1]:
        lis.append(A[i])
        A[i + 1] = 0
if len(lis) < 2:
    print(0)
else:
    print(lis[-1] * lis[-2])
# Judge status: Accepted
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if w < v and (v-w)*t >= abs(a-b):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))

x = sorted(X)
ans_1 = x[N // 2 - 1]
ans_2 = x[N // 2]

ans = []
for i in range(N):
    if X[i] <= ans_1:
        ans.append(ans_2)
    else:
        ans.append(ans_1)

print(*ans, sep="\n")
# Judge status: Accepted
a,b = map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)
# Judge status: Wrong Answer
import math

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

    minimum = 10**12
    for i in range(1,math.floor(N**0.5)):
        if(N % i == 0):
            x = i
            y = N / i

            if(minimum > x+y):
                minimum = x + y

    print(int(minimum) - 2)


if __name__ == "__main__":
    main()
# Judge status: Accepted
H, W = map(int, input().split())

if H < W:
  print(str(H)*W)
else:
  print(str(W)*H)
# Judge status: Wrong Answer
def f(n, p, a):
    if n == 1:
        if p == 0 and a[0] % 2 == 0:
            print(2)
        elif p == 0 and a[0] % 2 == 1:
            print(1)
        elif p == 1 and a[0] % 2 == 0:
            print(0)
        elif p == 1 and a[0] % 2 == 1:
            print(1)
    else:
        print(2**(n-1))

n, p = map(int, input().split())
a = list(map(int, input().split()))
f(n, p, a)
# Judge status: Accepted
h,n=map(int,input().split())
a=list(map(int,input().split()))
b=0

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

if b>=h:
  print ('Yes')
else:
  print ('No')
# Judge status: Accepted
x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0:
        print(i+1)
# Judge status: Accepted
#!/usr/bin/env python3

input()

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

total_xor = 0

for a in A:
    total_xor = total_xor^a

A = [a^total_xor for a in A]
print(' '.join(map(str, A)))
# Judge status: Accepted
h,n=map(int,input().split())
A=list(map(int,input().split()))
if(sum(A)>=h):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
mylist = list(map(int, input().split()))
s = sum(mylist)
N = len(mylist)
mean = round(s/N)
ans=0
for i in range(N):
    ans=ans+(mylist[i]-mean)*(mylist[i]-mean)
print(ans)
# Judge status: Accepted
n = int(input())
ans=n
for i in range(n+1):
  cnt=0
  t=i
  while t>0:
    cnt+=t%6
    t//=6
  s=n-i
  while s>0:
    cnt+=s%9
    s//=9
  ans = min(ans,cnt)
print(ans)
# Judge status: Accepted
import math
X = int(input())
beki = []
beki.append(1)
Xruto = math.sqrt(X)
Xruto = math.floor(Xruto)
for i in range(2, Xruto+1):
    for j in range(10):
        a = pow(i, j)
        if a <= X:
            beki.append(a)
        else:
            break
print(max(beki))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

up = down = 0

cur = a[0]
ans = 0
for x in a:
    if cur < x:
        up = 1
    elif cur > x:
        down = 1
    
    if up and down:
        ans += 1
        up = down = 0

    cur = x

print(ans+1)
# Judge status: Accepted
N,x=map(int,input().split())
A=list(map(int,input().split()))
if A[0]>x:
  ans=A[0]-x
  A[0]=x
else:
  ans=0
for i in range(1,N):
  s=A[i]+A[i-1]
  if s>x:
    ans+=(s-x)
    A[i]-=(s-x)
print(ans)
# Judge status: Accepted
a=input()
if a[-1]=='s':
  print(a+'es')
else:
  print(a+'s')
# Judge status: Accepted
lis = list(input().split())
a=lis.count(lis[0])
b=lis.count(lis[1])
c=lis.count(lis[2])
if a+b+c == 5:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s=input()

k=int(input())

cnt=0
c=""
for i in s:
    if i != "1":
        c=i
        break
    cnt+=1

if cnt > k :
    print("1")
else:
    print(c)
# Judge status: Accepted
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 40):
        div = 2 * 5**i
        ans += n // div
    print(ans)
# Judge status: Accepted
N,H=list(map(int,input().split()))
sword=[list(map(int,input().split())) for i in range(N)]
through=[i[1] for i in sword]
through.sort(reverse=True)
max_atk=max([i[0] for i in sword])
ans=0
for i in through:
   ans+=1
   if i > max_atk:
      H-=i
   else:
      H-=max_atk
   if H <= 0:
      break
import math
if 0 < H:
   ans+=math.ceil(H/max_atk)
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>=b:
    print(a)
else:
    print(a-1)
# Judge status: Accepted
def func(a,b,c,d):
  result = a * c
  if a * d > result:
    result = a * d
  if b * c > result:
    result = b * c
  if b * d > result:
    result = b * d
  return result

if __name__ == "__main__":
  inputStr = input().split()
  a = int(inputStr[0])
  b = int(inputStr[1])
  c = int(inputStr[2])
  d = int(inputStr[3])
  print(func(a,b,c,d))
# Judge status: Wrong Answer
n = int(input())
x = [int(a) for a in input().split()]
ans = 0
for i in range(101):
    res = 0
    for j in x:
        res += (j-i)**2
    if ans==0:
        ans = res
    elif ans > res:
        ans = res
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())
def prime(x):
    i = 2
    while i<=x**0.5:
        if x%i==0:
            return False
        i+=1
    return True
i=2
ans = 1
while i<=max(a**0.5,b**0.5):
    if a%i==0 and b%i==0 and prime(i):
        ans += 1
    i+=1
print(ans)
# Judge status: Accepted
s=input()
count=1
ps=s[0]
i=1
while i<len(s):
  if s[i]!=ps:
    count+=1
    ps=s[i]
    i+=1
  elif i==len(s)-1:
    break
  else:
    count+=1
    ps=s[i:i+2]
    i+=2
print(count)
# Judge status: Accepted
s=list(input())
l=len(s)
k=set(s)
if l != len(k):
    print('no')
else:
    print('yes')
# Judge status: Accepted
S = input()
S_len = len(S)
if S_len % 2 != 0:
    print("No")
else:
    set_num = int(S_len // 2)
    for i in range(set_num):
        if S[i*2] != "h" or S[i*2 +1] != "i":
            hitachi = False
            break
        else:
            hitachi = True
    if hitachi == False:
        print("No")
    elif hitachi  == True:
        print("Yes")
# Judge status: Wrong Answer
N = int(input())
cnt = 0
for a in range(1, N):
    for b in range(a, N//a):
        if a * b < N:
            if a == b:
                cnt += 1
            if a != b:
                cnt += 2
        else:
            continue
print(cnt)
# Judge status: Accepted
import math


def get_min(num_step):
    res = float("inf")
    for i in range(1, min(num_step, K)+1):
        cost = costs[num_step-i] + abs(steps[num_step] - steps[num_step-i])
        if cost < res:
            res = cost
    return res


N, K = map(int, input().split(" "))
steps = list(map(int, input().split(" ")))
costs = [None] * N
costs[0] = 0

for i in range(1, N):
    costs[i] = get_min(i)

print(costs[N-1])
# Judge status: Wrong Answer
s = input()
t = input()

# tの当てはまり判定
start_ind = "#"
for i in range(len(s)-len(t)+1):
    temp = s[i:i+len(t)]
    flag = False
    for j, x in enumerate(temp):
        if (t[j] == x or t[j] == "?"):
            flag = True
    if flag:
        start_ind = i

if start_ind == "#":
    print("UNRESTORABLE")
    exit()

x = s[:start_ind] + t + s[start_ind+len(t):]

ans = ""
for c in x:
    if c == "?":
        ans += "a"
    else:
        ans += c

print(ans)
# Judge status: Accepted
K = int(input())

a = 7
p = {}
ans = 0

while True:
    t = a % K
    ans += 1
    if t == 0:
        print(ans)
        break
    if t in p:
        print(-1)
        break
    a = 10*t + 7
    p[t] = 1
# Judge status: Wrong Answer
w,h,n=map(int, input().split())
sx,sy=0,0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        sx=max(sx,x)
    elif a==2:
        w=min(w,x)
    elif a==3:
        sy=max(sy,y)
    elif a==4:
        h=min(h,y)
print(max(0,(w-sx)*(h-sy)))
# Judge status: Accepted
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import math

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()

res = sum([math.gcd(math.gcd(a, b), c) for a in range(1,K+1) for b in range(1,K+1) for c in range(1,K+1)])
print(res)
# Judge status: Accepted
n, m = [int(x) for x in input().split()]
ans = min(n, m // 2)
ans += (m - ans * 2) // 4
print(ans)
# Judge status: Accepted
q,h,s,d=map(int,input().split())
n=int(input())

h = min(h, 2*q)
s = min(s, 2*h)

if 2*s <= d:
    print(s*n)
else:
    print((n//2)*d + (n%2)*s)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 17:43:29 2020

@author: shinba
"""

n = int(input())
s = input()
t = input()

l = 0
for i in range(n):
    if s[i:] == t[:n-i]: 
         l = n-i
         break

print(2*n-l)
# Judge status: Wrong Answer
s = list(input())
a = s[0]
cou = 1
i = 1
while i!=len(s) and i!=len(s)-1:
  if s[i]!=a:
    cou += 1
    a = s[i]
    i += 1
#    print(0,a,cou,i)
  else:
    a = "".join(s[i:i+2])
    cou += 1
    i += 2
  #  print(10,a,cou,i)

if a==s[-1] and len(a)==1:
  print(cou)
elif a=="".join(s[-2:]) and len(a)==2:
  print(cou)
else:
  print(cou+1)
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
for i in range(D):
    S = list(map(int, input().split()))
    print(S.index(max(S))+1)
# Judge status: Accepted
dic={"a":0,"b":1,"c":2}
ddic={0:"A",1:"B",2:"C"}
a=[[dic[j] for j in input()][::-1] for i in range(3)]
turn=0

while True:
    if len(a[turn])==0:
        print(ddic[turn])
        break
    po=a[turn].pop()
    turn=po
# Judge status: Accepted
N=int(input())
L=input().split()

min=int(L[0])
count=0

for i in L:
    if int(i)<=min:
        min=int(i)
        count+=1
    else:
        continue

print(count)
# Judge status: Accepted
N=int(input())
A=[int(i) for i in input().split()]
a=[1-A[0]]
if a[0]<0:
    print(-1)
    exit()
for k in range(N):
    ak=a[-1]
    a.append(2*ak-A[k+1])
    if a[-1]<0:
        print(-1)
        exit()
    if a[-1]>10**17:
        break
M=len(a)
for k in range(N,0,-1):
    if k-1<M:
        A[k-1]=A[k-1]+min(A[k],a[k-1])
    else:
        A[k-1]=A[k-1]+A[k]
print(sum(A))
# Judge status: Wrong Answer
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1:
    Ci = s.index('C')
    if (s[1:Ci] + s[Ci + 1:]).islower():
        print('AC')
else:
    print('WA')
# Judge status: Accepted
X,Y=sorted(list(map(int,input().split())))
#移動方法を(i+1,j),(i,j+1)となるようにどうにかする
if (X-abs(Y-X))%3!=0 or X*2<Y:
  print(0)
  exit(0)
n=(X-abs(Y-X))//3
X=n+abs(Y-X)
Y=n

  
mod=10**9+7
a=1
for i in range(1,X+Y+1):
  a*=i
  a%=mod
b=1
for i in range(1,X+1):
  b*=i
  b%=mod
c=1
for i in range(1,Y+1):
  c*=i
  c%=mod

print(a*pow(b,-1,mod)*pow(c,-1,mod)%mod)
# Judge status: Wrong Answer
N ,M = map(int,input().split())

if N * 2 <= M:
  S = M - (N * 2)
  print(N + S // 4)
else:
  S = M - (N * 2)
  print(N // 2)
# Judge status: Wrong Answer
n = int(input())

if n >= 1000:
    print("ABD" + str(n - 999).zfill(3))
if n <= 999:
    print("ABC" + str(n))
# Judge status: Wrong Answer
n = int(input())
s = input()

import collections

ans = 0
for i in range(n):
    l = collections.Counter(s[:i])
    r = collections.Counter(s[i:])
    cnt = min(len(l), len(r))
    #print(s[:i], s[i:], cnt)
    ans = max(ans, cnt)
print(ans)
# Judge status: Accepted
n, p = map(int, input().split())
a = [_ % 2 for _ in [int(_) for _ in input().split()]]
num_zero = 0
num_one = 0
for _ in a:
    if _ == 0:
        num_zero += 1
    else:
        num_one += 1
#print(num_zero, num_one)

ans = 0
if p == 0:
    if num_one == 0:
        ans = 2 ** n
    else:
        ans = 2 ** (n - 1)
else:
    if num_one == 0:
        ans = 0
    else:
        ans = 2 ** (n - 1)
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int, input().split())     
print("Yes" if b-a==c-b else "No")
# Judge status: Wrong Answer
a, b = map(int,input().split())

if a > b:
    print('Alice')
elif a < b:
    print('Bob')
else:
    print('Draw')
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]

m = min(A)

for i in range(N):
    if A[i] % m != 0:
        print(1)
        exit()
print(m)
# Judge status: Accepted
n=int(input())
Alist=[0]+[int(input()) for i in range(n)]

now=1
Hist={1}

for i in range(n):
    now=Alist[now]
    if now==2:
        print(i+1)
        break
    if now in Hist:
        print(-1)
        break
    Hist.add(now)
# Judge status: Wrong Answer
w,a,b = map(int,input().split())
if w+a >= b:
  print(0)
else:
	print(b-(a+w))
# Judge status: Accepted
s=input()
ans="Yes"
for i in range(4):
    if s.count(s[i])!=2:
        ans="No"
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

ans = 0
for i in range(a, b + 1):
    s = str(i)
    flag = False
    for i in range(len(s)):
        if s[i] != s[len(s) - i - 1]:
            flag = True
    if not flag:
        ans += 1
print(ans)
# Judge status: Wrong Answer
for i in range(len(str(input()))):
  print("x")
# Judge status: Wrong Answer
a, b = map(int, input().split())
if (a*b) % 2 == 0:
    print("Odd")
else:
    print("Even")
# Judge status: Accepted
s=sorted(input())
t=sorted(input())[::-1]
print('Yes' if s<t else 'No')
# Judge status: Accepted
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print((n-2)*(m-2))
# Judge status: Accepted
N,A,B,C,D=map(int,input().split())
S=input()
a=1
for i in range(A,C-2):
    if S[i]==S[i+1]=="#":
        a=0
        break
for i in range(B,D-2):
    if S[i]==S[i+1]=="#":
        a=0
        break
if C>D:
    for i in range(B-1,D):
        if S[i-1]==S[i]==S[i+1]==".":
            break
    else:
        a=0
print("Yes" if a else "No")
# Judge status: Wrong Answer
N = int(input().rstrip())
S = list(map(int,input().split()))

count = 0
for i in range(N):
  for j in range(i+1,N):
    if i != j:
      for k in range(i+2,N):
        if i !=k and j !=k: 
          if S[i] + S[j] > S[k] and S[j] + S[k] > S[i] and S[k] + S[i] > S[j] :
            print(i,j,k)
            count +=1

print(count)
# Judge status: Accepted
N,M=map(int,input().split())

K=0
X="+"
while X :
    X=min(N,M//2)
    K+=X
    N-=X
    M-=2*X

    Y=M//4
    N+=Y
    M-=2*Y

print(K)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in a:
    l[i-1]+=1
for i in l:
    print(i)
# Judge status: Wrong Answer
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1 - x):
        if x * 10000 + y * 5000 + (N - x - y) * 1000 == Y:
            print(x, y, (N - x - y))
            exit()
print("-1 - 1 - 1")
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
b=sum(l)**2
a=0
for i in range(n):
    a+=l[i]**2
print((b-a)//2%(10**9+7))
# Judge status: Accepted
x = int(input())
for i in range(1,361):
  if (x*i)%360 == 0:
    print(i)
    exit()
# Judge status: Accepted
X, A, B = list(map(int, input().split()))
if -A+B <= 0:
  print("delicious")
elif -A+B <= X:
  print("safe")
else:
  print("dangerous")
# Judge status: Wrong Answer
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
d=0
for i in range(len(lb)):
    k=la[i]-lb[i]
    if k==0:
        d+=la[i]
        la[i]=0
    elif k<0:
        d+=la[i]
        if la[i+1]>-k:
            d-=k
        else:
            d+=la[i+1]
        # la[i+1]+=k
    else:
        d+=lb[i]
        la[i]=k
print(d)
# Judge status: Accepted
n=int(input())
w = [input() for _ in range(n)]
words=[]
for i in range(n):
    s=w[i]
    if s in words:
        print("No")
        exit()
    if i == 0:
        end = s[-1]
        words.append(s)
        continue
    
    if end != s[0]:
        print("No")
        exit()
    else:
        end = s[-1]
        words.append(s)
print("Yes")
# Judge status: Accepted
n=int(input())

for i in range(int(n**0.5)+2,0,-1):
    if n%i==0:
        print(i+n//i-2)
        break
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
for a in A:
    N -= a
print(N) if N >= 0 else print(-1)
# Judge status: Accepted
a,b = map(int, input().split())
if a <= 9 and b <= 9:
    print(a * b)
else:
    print(-1)
# Judge status: Accepted
s = input()

# s = '3776'

before = s[0]
isFlg = True

for i in s[1:]:
    if before == i:
        isFlg = False

    before = i

if isFlg == False:
    print("Bad")
else:
    print("Good")
# Judge status: Wrong Answer
L = [[1, 3, 5, 7, 8, 10, 12],[4, 6, 9, 11],[2]]
x, y = map(int,input().split())
ans = True
for i in range(len(L)):
  if x in L[i] and y in L[i]:
    ans = True
if ans:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = int(input())
n_list = list(map(int,input().split()))
count = 0
for i in n_list:
    if i % 4 == 0:
        count += 1
    elif i == 2 or i == 6:
        count += 0.5
if count >= n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
P, Q, R = map(int, input().split())
print(P+Q+R-max(P,Q,R))
# Judge status: Accepted
s = list(input())

#chr(ord('a')

ans = True
if s[0] != "A":
    print("WA")
elif s[2:-1].count("C") != 1:
    print("WA")
else:
    s.remove("A")
    s.remove("C")
    if not str(s).islower():
        print("WA")
    else:
        print("AC")
# Judge status: Wrong Answer
n=int(input())
ans=1
for i in range(1,n+1):
  ans=ans*i
  if ans>1000000007:
    ans=ans%1000000007
print(ans)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
X = sorted(X)
avg = sum(X)//N
aa = []
for i in range(2):
  avg = avg + i
  a = 0
  for j in range(N):
    a += (X[j] - avg)**2
  aa.append(a)
print(min(aa))
# Judge status: Accepted
N = int(input())
A = [0] * N
B = list(map(int, input().split()))

A[0] = B[0]
A[N - 1] = B[N - 2]
for i in range(1, N -1):
    A[i] = min(B[i - 1], B[i])
print(sum(A))
# Judge status: Accepted
K = int(input())
from math import gcd

sum = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += gcd(gcd(i, j),k)

print(sum)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
cnt=0
for i in range(1,100)[::-1]:
  if a%i==0 and b%i==0:
    cnt+=1
  if cnt==k:
    print(i)
    exit()
# Judge status: Accepted
A,B,C=map(int,input().split())
for i in range(1,B+1):
    if A*i%B==C:
        print('YES')
        exit()
print('NO')
# Judge status: Wrong Answer
n=int(input());s=input()
b=0
w=s.count('.')
ans=n
for si in s:
  b+=(si=='#')
  w-=(si=='.')
  ans=min(ans,b+w)
print(ans)
# Judge status: Wrong Answer
n, l = map(int, input().split())
l1 = [0]*n
for i in range(n):
  tmp = input()
  l1[i] = ((sum([ord(c) for c in tmp]), tmp))
l2 = sorted(l1)  
r = ""
for i in range(n):
  r = r + l2[i][1]
  
print(r)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
chk = 1
bre = 0
for i in range(n):
  if a[i] == chk:
    chk += 1
  else:
    bre += 1
if chk == 1:
  print(-1)
else:
  print(bre)
# Judge status: Accepted
N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
    x[i] = abs(x[i] - X)


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


ans = x[0]
if N != 1:
    for j in range(1, N):
        ans = gcd(ans, x[j])
print(ans)
# Judge status: Accepted
s = int(input())
d = set()
i = 1
while s not in d:
    d.add(s)
    s = 3 * s + 1 if s & 1 else s // 2
    i += 1
print(i)
# Judge status: Accepted
#模範解答 tの文字列の数に絞って全探索を掛ける
S = input()
T = input()

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i: i + N]
    s_list.append(s)

answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1

    answer = min(answer, counter)

print(answer)
# Judge status: Wrong Answer
n=int(input())
temp=set()
for i in range(0,n):
  a=int(input())
  if a not in temp:
    temp.add(str(a))
  else:
    temp.remove(str(a))
print(len(temp))
# Judge status: Accepted
n = list(input())
a = int(n[0])
b = int(n[1])
c = int(n[2])
if a == 7 or b == 7 or c == 7:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = int(input())
A = sorted(map(int, input().split()))
if len(set(A)) == 1:
    print(0)
    exit()
ans = 0
used = set()
for a in A:
    if any(a % x == 0 for x in used):
        continue
    ans += 1
    used.add(a)
print(ans)
# Judge status: Wrong Answer
N,b,c=map(int,input().split())
S = input()
kaigai=0
goukei=0
for i in range(0,N):
  if S[i]=='a' and goukei<b+c:
    print("Yes")
    goukei+=1
  elif S[i]=='b':
    if goukei<b+c and kaigai<=b:
      print("Yes")
      goukei+=1
      kaigai+=1
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
from decimal import Decimal
a, b = map(Decimal, input().split())
print(int(a * b))
# Judge status: Accepted
def main():
    s = int(input())
    mod = 10**9 + 7

    dp = [0] * (s+1)
    dp[0] = 1
    for i in range(1, s+1):
        for j in range(0, (i-3)+1):
            dp[i] += dp[j]
            dp[i] %= mod
    print(dp[-1])


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
x,y=map(int,input().split())
print(1+int(math.log2(y//x)))
# Judge status: Accepted
import math
 
h,n=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=list(map(int,input().split()))
 
 
dp=[[b[0]] * (h+1) for i in range(n+1)]
for j in range(h+1):
    dp[0][j]=math.ceil(j/a[0])*b[0]
for i in range(n):
    for j in range(h+1):
        if j<a[i]: dp[i+1][j]=min(dp[i][j],b[i])
        else:dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i])
print(dp[n][h])
# Judge status: Accepted
x, y=map(int, input().split())
print(x*y)
# Judge status: Accepted
n = int(input())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x+y)
    b.append(x-y)
print(max(max(a)-min(a), max(b)-min(b)))
# Judge status: Wrong Answer
N,K=map(int,input().split())
S=input()
R=0
B=0
cnt=0
for i in range(len(S)-1):
    if S[i]=='R' and S[i+1]=='L':
        R+=1
    elif S[i]=='L' and S[i+1]=='R':
        B+=1
    elif S[i]=='L' and S[i+1]=='L':
        cnt+=1
    else:
        cnt+=1
N=len(S)
if K<R:
    print(cnt+2*K)
else:
    if K-R<1:
        print(cnt+2*R)
    else:
        print(cnt+2*R+1)
# Judge status: Wrong Answer
N,M,K=map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A+=[10**10]
B+=[10**10]
a,b = 0,0
while K >= A[a] or K >= B[b] :
    if A[a]>B[b]:
        K -= B[b]
        b+=1
    else:
        K -= A[a]
        a+=1
    #print(a,b)
        
print(a+b)
# Judge status: Accepted
# For taking integer inputs.
def inp():
    return(int(input()))


n = inp()

i = 0
while 2**i <= n:
    i += 1
if i > 0:
    i -= 1
print(2**(i))
# Judge status: Wrong Answer
from collections import deque

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

print(sum(a[n:2 * n]))