peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
# abc057_b.py
def calc(p1, p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
    dist = 10**9
    ans = 0
    for j in range(M):
        now_dist = calc(ab[i], cd[j])
        if dist > now_dist:
            dist = now_dist
            ans = j+1
    print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
ans = 0

for i in range(1,math.ceil(math.sqrt(n))):
    for j in range(2,11):
        if i ** j > n and j > 2:
            ans = max(ans,i ** (j-1))
            break

print(ans)
# Judge status: Accepted
import math

N, D = map(int, input().split())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

d = D**2

count = 0
for i in range(N):
  x2 = x[i] ** 2
  y2 = y[i] ** 2
  if x2 > d:
    continue
  elif y2 > d:
    continue
  elif (x2 + y2) <= d:
    count += 1

print(count)
# Judge status: Accepted
import math
from decimal import Decimal
A,B = input().split()
A = int(A)
B = Decimal(B)
print(int(A*B))
# Judge status: Wrong Answer
import math

def main():
  x = int(input())
  
  total = 100
  year = 0
  
  while total < x:
    total = math.floor(total * 1.01)
    year += 1
  
  print(year)
  
  
  
main()
# Judge status: Wrong Answer
n,x=map(int,input().split())
xlist= list(map(int,input().split()))
if n == 1:
  print(abs(xlist[0]-x))
  exit()
ylist = []
for i in range(n-1):
  ylist.append(abs(xlist[i]-x))
from functools import reduce
from math import gcd
print(reduce(gcd,ylist))
# Judge status: Wrong Answer
s = input().split(" ")
n = int(s[0])
numbers = [ i for i in input() if i != " "]

for i in range(n, 10001):
  found = False
  snum = str(i)
  for num in numbers:
    if num in snum:
      found = True
      break
  
  if found == False:
     print(i)
     break
# Judge status: Accepted
a,b=map(int,input().split())
print(int(str(a)*b) if a<b else int(str(b)*a))
# Judge status: Accepted
N,K= map(int, input().split())
if N<K:
    print(min(N%K,abs(N%K-K)) )
else:
    print(min(N%K,abs(N%K-K)))
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
a.sort()
c = round(sum(a)/N)
ans = 0
for i in range(N):
    ans += (a[i]-c)**2
print(ans)
# Judge status: Accepted
A,B=map(int,input().split())
if A >=13:
    print(B)
elif A <=5:
    print(0)
else:
    print(int(B/2))
# Judge status: Accepted
A,B,C=map(int,input().split())
print((A==B and B!=C or A==C and C!=B or B==C and B!=A) and "Yes" or "No")
# Judge status: Accepted
s=input()
s=sorted(s)
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:
    print("Yes")
else:print("No")
# Judge status: Accepted
a, b = map(int, input().split())
if b >= a:
  print(a)
else:
  print(a - 1)
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
c,*l=[0]*9
for i in a:
  if i<3200: l[i//400]=1
  else: c+=1
print(max(1,sum(l)),sum(l)+c)
# Judge status: Accepted
n,k=map(int,input().split())
p=[0]+list(map(int,input().split()))
m=-1
s=0
s+=sum(p[0:k])
for i in range(len(p)-k):
    s+=p[i+k]
    s-=p[i]
    if m < s:
        m=s
print((m+k)/2)
# Judge status: Accepted
a,b,c,d = map(str,input())

n = 3
pt = []
for i in range(2 ** n):
  tmp = ["+"] * n
  for j in range(n):
    if i >> j & 1:
      tmp[j] = "-"
  pt.append(tmp)
for x in pt:
  fr = a + x[0] + b + x[1] + c+ x[2] + d 
  if eval(fr) == 7 :
    print(fr+"=7")
    exit()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(0,len(a),2):
    if a[i]%2==1:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import numpy as np

N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]

ok=np.zeros(N)
for i in range(M):
    if H[A[i][0]-1]>H[A[i][1]-1]:
        ok[A[i][0]-1]=1
        ok[A[i][1]-1]=0
    else:
        ok[A[i][1]-1]=1
        ok[A[i][0]-1]=0
print(int(np.sum(ok)))
# Judge status: Accepted
A=input()
B=input()
count=0
if A[0]==B[2]:
    if A[1]==B[1]:
        if A[2]==B[0]:
            count+=1
if count>0:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer


n = int(input())
ans = 0

for i in range(2,n,1):
    for j in range(i,n):
        if n % i*j != 0:
            #print(n,i,j,i*j)
            ans += 1

ans = ans + (n-1)


print(ans)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(n):
    for j in range(8):
        if (j*400)<=A[i]<((j+1)*400):
            B.append(j)
    if 3200<=A[i]:
        C.append(i)
print(max(len(set(B)),1),len(set(B))+len(C))
# Judge status: Accepted
n = int(input())
s = input()
x = 0
m = 0
for i in s:
    if i == 'I':
        x += 1
    else:
        x -= 1
    m = max(x, m)
print(m)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans="Yes"
s=sum(a)
if a[m-1]>=s/(4*m):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
num=input()

masu=list(map(lambda x:int(x),input().split()))

masu=[i for i in masu if i%2!=0 and (masu.index(i)+1)%2!=0]
print(len(masu))
# Judge status: Accepted
a,b,c=map(int,input().split())

if a+b+c >= 22:
  print("bust")
else:
  print("win")
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, *h = map(int, read().split())
h = sorted(h, reverse=True)
print(sum(h[k::]))
# Judge status: Accepted
n = int(input())
words = []
for i in range(n):
  words.append(input())
words_set = list(set(words))
ans = 'Yes'
if len(words) == len(words_set):
  b = words[0][-1]
  for i in range(1, n):
    if b == words[i][0]:
      b = words[i][-1]
    else:
      ans = 'No'
      break
else:
  ans = 'No'
print(ans)
# Judge status: Wrong Answer
k,n = map(int,input().split())
a = list(map(int,input().split()))
aa = a + a

for j in range(n,2*n):
    aa[j] = aa[j] + k

dis = k

for i in range((2*n)-1):
    tonari = aa[i+1]-aa[i]
    dis = min(dis,k-tonari)

print(dis)
print(aa)
# Judge status: Accepted
n = int(input())
if n > 999:
    print("ABD")
else:
    print("ABC")
# Judge status: Accepted
s = list(input())
k = int(input())
ls = list("abcdefghijklmnopqrstuvwxyz")
ls.sort(reverse=True)
ls = ["a"] + ls[:-1]
for i in range(len(s)):
    if i != len(s)-1:
        if k >= ls.index(s[i]):
            k -= ls.index(s[i])
            s[i] = "a"
        else:
            continue
    else:
        k %= 26
        s[-1] = ls[(ls.index(s[-1])-k)%26]
print("".join(s))
# Judge status: Accepted
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n))
# Judge status: Accepted
x,y = map(int, input().split())

list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]

L = [list1,list2]

ans = "No"

for i in L:
  if x in i and y in i:
    ans = "Yes"

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

count = 0
ans = False
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0

    if count == 3:
        ans = True
        break

print('Yes') if ans else print('No')
# Judge status: Accepted
# DPをとく
inf=10**10
N=int(input())
H=list(map(int,input().split()))
dp = [inf for _ in range(N)] # 足場Nまでにたどり着くときの最小コストとする
dp[0]=0
for i in range(N):
    if i+1<N:
        dp[i+1] = min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
    if i+2<N:
        dp[i+2] = min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))
print(dp[N-1])
# Judge status: Accepted
A, B, C = map(int, input().split())
print("Yes" if A <= C and C <= B or B <= C and C <= A else "No")
# Judge status: Accepted
N, M, X, Y = [int(i) for i in input().split()]
x_pos = [int(i) for i in input().split()]
y_pos = [int(i) for i in input().split()]

left, right = max(x_pos), min(y_pos)
ans = 'War'
for z in range(X + 1, Y + 1):
    if left < z <= right:
        ans = 'No War'
        break
print(ans)
# Judge status: Wrong Answer
X,Y,Z=map(int,input().split())
W=Y+Z
cnt=0
X-Z*2
while X>W:
    X-=W
    cnt+=1

print(cnt)
# Judge status: Accepted
s = str(input())
tmp = [0,0]
for i in range(len(s)):
    if s[i] == 'A':
        tmp[0] = i
        break
for i in reversed(range(len(s))):
    if s[i] == 'Z':
        tmp[1] = i
        break

print(tmp[1]-tmp[0]+1)
# Judge status: Accepted
input()

numbers = tuple(map(int, input().split(' ')))

n_4_multiples = 0
n_2_multiples = 0
n_other = 0

for n in numbers:
    if n % 4 == 0:
        n_4_multiples += 1
    elif n % 2 == 0:
        n_2_multiples += 1
    else:
        n_other += 1

if n_2_multiples > 0:
    n_other += 1

if n_other - n_4_multiples <= 1:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l+1, x+l-1))
Y.sort(key=lambda x: x[0])

cnt = 0
_, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r0 < l:
        cnt += 1
        r0 = r
print(cnt)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
count = 0
for a in A:
    if a >= S/(4*M):
        count += 1
if count >= M:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,a,b,c,d = readInts()
s = readChar()
if (a-b)*(c-d)<0:
  if "..." in s[max(a,b):] and "##" not in s[min(a,b)]:
    print("Yes")
  else:
    print("No")
else:
  if "##" not in s[min(a,b):]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
f = []

for i in range (5):
  f.append(int(input()))
  
time = 0
machi = []

for i in range (5):
  if f[i]%10 == 0:
    time += f[i]
  else:
    time += f[i] + (10-f[i]%10)
    machi.append(10-f[i]%10)
    
if len(machi) == 0:
  print(time)
else:
  print(time-max(machi))
# Judge status: Wrong Answer
n=int(input())
s=str(input())
r=s[:3]
t=s[3:]
if(r==t):
  print("Yes")
  
else:
  print("No")
# Judge status: Accepted
a,b,k = map(int,input().split())
ans=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        ans.append(i)
ans=sorted(ans,reverse=True)
print(ans[k-1])
# Judge status: Accepted
M=2019
a=i=0
d=[0]*M
p=1
for j in'0'+input()[::-1]:i=(i+int(j)*p)%M;p=p*10%M;a+=d[i];d[i]+=1
print(a)
# Judge status: Wrong Answer
N=int(input())
S = ""
while N != 0:
  if N%2==0:
    S = "0" + S
  else:
    S = "1" + S
    N -= 1
  N /= -2
print(S)
# Judge status: Wrong Answer
from collections import deque
que=deque([i for i in range(1,10)])
k=int(input())
count=0
while count!=k:
  a=que.popleft()
  count+=1
  if a%10==1:
    que.extend([10*a+1,10*a+2])
  elif a%10==9:
    que.extend([10*a+8,10*a+9])
  else:
    b=a*10+(a%10)-1
    que.extend([b,b+1,b+2])
print(a)
# Judge status: Wrong Answer
import copy

def CakesandDonuts(n):

    ans = "No"
    a = copy.copy(n)

    if n % 7 == 0 or n % 4 == 0:
        ans = "Yes"
    else:
        while a > 0:
            n -= 7
            a -= 4
            if n % 4 == 0 or a % 7 == 0:
                ans = "Yes"

    return ans

def main():
    n = int(input())
    print(CakesandDonuts(n))

if __name__ == '__main__':
    main()
# Judge status: Accepted
k = list('keyence')
s = list(input())
while len(k) > 0:
    if k[0] == s[0]:
        k.pop(0)
        s.pop(0)
    else:
        break
while len(k) > 0:
    if k[-1] == s[-1]:
        k.pop()
        s.pop()
    else:
        break
if len(k) == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
# カウンタのクリア
five_count = 0
seven_count = 0
# 5,7,5を判定
def setsu_check(x):
	global five_count, seven_count
	if x == 5:
		five_count+=1
	elif x == 7:
		seven_count+=1
# 判定関数のCALL
setsu_check(a)
setsu_check(b)
setsu_check(c)
if five_count == 2 and seven_count == 1:
	print("YES")
else:
	print("NO")
# Judge status: Wrong Answer
l, r = map(int, input().split())

x = 2018
cnt = 0
for i in range(l, r+1):
    a = i%2019
    if a == 0:
        print(0)
        exit()
    x = min(a, x)
print(x*(x+1))
# Judge status: Wrong Answer
H,N = map(int,input().split())
AB = []
 
for i in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])

dp = [[float('inf')]*(H+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0

for i in range(N):
    for j in range(H):
        dp[i+1][min(j+AB[i][0],H)] = min(dp[i][min(j+AB[i][0],H)],dp[i+1][j]+AB[i][1],dp[i+1][min(j+AB[i][0],H)])
        
print(dp[N][H])
# Judge status: Accepted
d,n=map(int, input().split())
if n == 100:
  n = 101
print(n * 100 **d)
# Judge status: Accepted
a,b,c = map(int,input().split())

if a >= b and a >= c :
    s = str(a)+str(b)
    total = int(s)+c
    print(total)

elif b >= a and b >= c:
    s = str(b)+str(a)
    total = int(s)+c
    print(total) 

elif c >= a and c >= b:
    s = str(c)+str(a)
    total = int(s)+b
    print(total)
# Judge status: Accepted
n,x = map(int, input().split())
line = list(map(int, input().split()))
line.sort()
ans = 0
for i in range(n):
  x -= line[i]
  if x < 0:
    break
  else:
    ans += 1
    
  if i == n-1 and x != 0:
    ans -= 1
print(ans)
# Judge status: Accepted
import collections

n = int(input())
d = list(map(int,input().split()))
mod = 998244353

ans = 0
c = collections.Counter(d)
if c[0] == 1 and d[0] == 0:
    ans = 1
for i in range(1,max(d)+1):
    if c[i] == 0:
        ans = 0
        break
    ans *= pow(c[i-1],c[i],mod)
    ans %= mod
print(ans%mod)
# Judge status: Wrong Answer
s = input()
a = s.index('A')
z = s.index('Z')
print(z-a+1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
# 後ろからボールの有無を決定
for i in range(n - 1, -1, -1):
    cnt = 0
    for j in range(2 * (i + 1), n + 1, i + 1):
        cnt += b[j - 1]
    # 条件と異なるならボールを投入
    if cnt % 2 != a[i]:
        b[i] = 1
m = b.count(1)
print(m)
for i in range(n):
    if b[i]:
        print(i + 1, end=' ')
# Judge status: Wrong Answer
a=sorted(input())
if a=="abc":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, b = map(str, input().split())

num1 = int(a * int(b))
num2 = int(b * int(a))

if num1 >num2:
    print(num2)

if num1 <num2:
    print(num1)
# Judge status: Wrong Answer
x = int(input())
a = []
for i in range(10**5):
  if i**2<x:
    a.append(int(i**2))
print(max(a))
# Judge status: Wrong Answer
x = int(input())
y = 0
amt = 100
while amt < x:
    amt += (amt/100)
    y += 1

print(y)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# X, Y, A, B, C = 1, 2, 2, 2, 1
# p = [2, 4]
# q = [5, 1]
# r = [3]

p.sort()
q.sort()
r.sort()
p = p[-X:]
q = q[-Y:]

d = []
d += p
d += q
d += r
d.sort()

print(sum(d[-X-Y:]))
# Judge status: Accepted
def main():
    n = list(input())
    if n.count(n[1]) >= 3 and n[1]==n[2]: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
c = []
for i in range(3):
  c.append(list(map(int, input().split())))
  
for i in range(2):
  arr1 = c[i]
  arr2 = c[i+1]
  
  d = arr1[2] - arr2[2]
  for j in range(2):
    if d != arr1[j]-arr2[j]:
      print('No')
      sys.exit(0)
  
for i in range(2):
  d = c[2][i] - c[2][i+1]
  for j in range(2):
    if d != c[j][i]-c[j][i+1]:
      print('No')
      sys.exit(0)
  
      
    
print('Yes')
# Judge status: Accepted
x = int(input())

if x >= 30:
    ans = "Yes"
else:
    ans = "No"

print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
d=max(a,b,c)
if d == a+b+c-d:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
N, K, Q = map(int, input().split())
A = (int(x) for x in sys.stdin.read().split())
score = [K - Q] * (N + 1)
for a in A:
  score[a] += 1
print("\n".join("No" if s <= 0 else "Yes" for s in score[1:]))
# Judge status: Accepted
n=int(input())
c=10**9+7
def pow_c(x,n,c):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K= (K%c)*(x%c)%c
        x = ((x%c)**2)%c
        n //= 2
    return (K%c) * (x%c) %c

k10=pow_c(10,n,c)
k9=pow_c(9,n,c)
k8=pow_c(8,n,c)
ans=(k10-2*k9+k8)%c 
print(ans)
# Judge status: Wrong Answer
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

piece = [(K+N)*arr[i]//denominator+1 for i in range(N)]
print(piece)
value = [arr[i]/piece[i] for i in range(N)]

left = K-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

print(round(max(value)))
# Judge status: Wrong Answer
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()

ans=1
mae=0
for i in range(len(s)-1):
    if mae:
        mae-=1
        continue
    if s[i]==s[i+1]:
        mae=1
        ans+=1
    else:
        ans+=1
print(ans)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    print(min(c, b // a))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
l = []
for i in range(1, int(n ** 0.5 + 1)):
    if n % i == 0:
        j = n // i
        l.append(i + j)

print(min(l) - 2)
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))

p.sort()
ans=0

for i in range(k):
  ans+=p[i]
  
print(ans)
# Judge status: Accepted
N=int(input())
cards=sorted(list(map(int,input().split())))[::-1]
A=sum(cards[::2])
B=sum(cards[1::2])
print(A-B)
# Judge status: Accepted
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = 10**20
for i in range(N-K+1):
    fst = i
    lst = i+K-1

    if X[lst]<=0:
        ans = min(ans,abs(X[fst]))
    elif X[fst]>=0:
        ans = min(ans,X[lst])
    else:
        dis = max(abs(X[fst]),X[lst])+min(abs(X[fst]),X[lst])*2
        ans = min(ans,dis)

print(ans)
# Judge status: Accepted
n = int(input())
score = 0
i = 0
ans_list = []

while score <= n:
    i += 1
    score += i
    ans_list.append(i)

ans_list.remove(score - n)
for k in range(len(ans_list)):
    print(ans_list[k])
# Judge status: Accepted
from collections import deque
n,m=map(int,input().split())
path=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  path[b].append(a)
  path[a].append(b)
q=deque()
q.append(1)
l=[-1]*(n+1)
while q:
  v=q.popleft()
  for i in path[v]:
    if l[i]==-1:
      l[i]=v
      q.append(i)
print('Yes')
for i in l[2:]:
  print(i)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]

cumulative_sum = []
cnt = 0
for i in range(n):
    cnt += a[i]
    cumulative_sum.append(cnt)

ans = abs(cumulative_sum[0] - (cumulative_sum[-1] - cumulative_sum[0]))
for i in range(n - 1):
    ans = min(abs(cumulative_sum[i] - (cumulative_sum[-1] - cumulative_sum[i])), ans)

print(ans)
# Judge status: Accepted
s = input()
s += "B"# AGCT以外の適当な文字

max_len = 0

count = 0
for i in s:
    if i in "ACGT":
        count += 1
    else:
        max_len = max(max_len,count)
        count = 0

print(max_len)
# Judge status: Accepted
s=input()
print(len(s)*'x')
# Judge status: Wrong Answer
import math
x, y = list(map(int, input().split()))
ans = int(math.log2(y/x)) + 1
print(ans)
# Judge status: Accepted
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  ans = a[0]
  for x in a:
    ans = gcd(ans, x)

  print(ans)
  return

if __name__ == "__main__":
  resolve()
# Judge status: Accepted
N = int(input())

# Nが奇数の時は2が1つもないので0
if N % 2 == 1:
    print(0)
# Nが偶数の時は5の数を数える
# N以下の2の倍数のうち
# 5の倍数の数 + 25の倍数の数 + ...
else:
    ans = 0
    for i in range(1, 50):
        ans += (N // 5 ** i) // 2

    print(ans)
# Judge status: Accepted
S = input()

for i in reversed(range(len(S))):
    tmp = S[:i]
    n = len(tmp)//2
    if tmp[:n] == tmp[n:]:
        print(len(tmp))
        break
# Judge status: Accepted
N = int(input())

s = ""

while N != 0:
    # Pythonでは負の数を割っても余りが正になる
    # -2で割ったときの"理想的な"余り(0or1になってくれる)は2で割った余りと同じ
    r = int(N % 2)
    # ここは-2
    N = (N - r) / (-2)
    s += str(int(r))

# N=0の時はから文字列が返ってきてしまう
if s == "":
    print(0)
    exit()
else:
    # reverse
    print(s[::-1])
# Judge status: Accepted
N = int(input())
nums = list(map(int, input().split()))

cnt = 0

for i in range(N):
    num = i + 1
    
    if (num % 2 == 1 and nums[i] % 2 == 1):
        cnt += 1
        

print(cnt)
# Judge status: Accepted
import numpy as np
n=int(input())
#n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

ans=np.zeros(n)

for i in range(n-1):
	tmp= a[i] -1
	ans[tmp] += 1
    
for i in range(n):
	print(int(ans[i]))
# Judge status: Accepted
a,b=map(int,input().split())
s=input()
if s[a] != '-':
    print('No')
    quit()
left=s[:a]

right=s[a+1:]
if left.isdigit()==True and right.isdigit() == True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import Counter
n = int(input())
s = input()
mod = 10**9 + 7

S = Counter(s)
a = 1
for v in S.values():
    a = a*(1+v) % mod

print(a-1)
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1))
print(dp[-1])
# Judge status: Accepted
from math import log2, ceil
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    if i >= k:
        ans += 1
    else:
        ans += pow(0.5, ceil(log2(k / i)))
print(ans / n)
# Judge status: Accepted
from sys import stdin
def main():
  readline = stdin.readline
  N = int(readline())
  L = [list(map(int, readline().split())) for _ in range(N)]
  cnt = 0
  for l in L[::-1]:
    a = l[0] + cnt
    b = l[1]
    if a % b != 0:
      cnt += b - a % b
  print(cnt)
if __name__ == "__main__":
  main()
# Judge status: Accepted
date = input()
print("2018" + date[4:])
# Judge status: Accepted
n = int(input())
a = []
b = []

for i in range(n):
    a_temp, b_temp = map(int, input().split())
    a.append(a_temp)
    b.append(b_temp)

ans = 0
a = a[::-1]
b = b[::-1]
for i in range(n):
    ans += (-(a[i] + ans)) % b[i]
print(ans)
# Judge status: Accepted
n = int(input())
def f(x):
    if n % x == 0:
        return n//x - 1
    else:
        return n//x
s = 0
for a in range(1, n):
    s += f(a)
print(s)
# Judge status: Accepted
import math
n, d = map(int, input().split())
print(math.ceil(n / (2 * d + 1)))
# Judge status: Accepted
n,k=map(int,input().split())
s=input()

if n==k:
    print(s[:k-1]+s[k-1].lower())
    
else:
    print(s[:k-1]+s[k-1].lower()+s[k:n])
# Judge status: Accepted
a,b,c,d = map(int,input().split())

if (abs(b-a) <= d and abs(c-b) <= d) or (abs(a-c) <= d):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N,K=map(int,input().split())
d=[]
A=[]
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
cnt=[0 for i in range(N)]
for i in range(K):
    for a in A[i]:
        cnt[a-1]+=1
print(cnt.count(0))
# Judge status: Accepted
n=int(input())
s=[int(input()) for _ in range(n)]

s.sort()
if sum(s)%10!=0:
    print(sum(s))
else:
    for i in range(n):
        if s[i]%10!=0:
            print(sum(s)-s[i])
            exit()
    print(0)
# Judge status: Accepted
import math
n,x,t=map(int,input().split())
ans=math.ceil(n/x)
print(ans*t)
# Judge status: Accepted
a,b,c = map(int, input().split())
print(int(b*((c+0.5)//a)))
# Judge status: Accepted
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())
s = [((ord(ch) - 65 + n) % 26) + 65 for ch in input()]
print("".join(map(chr, s)))