peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def divisor_listout(n,m):
    max_n = max(n,m)
    out = [1]
    for i in range(2,max_n+1):
        if n % i == 0 and m % i == 0:
              out.append(i)
    return out

n1, n2, result = map(int,input().split())
ans = divisor_listout(n1,n2)[::-1]
print(ans[result-1])
# Judge status: Wrong Answer
n=int(input())
s=input()
l=len(s);
if l<=n:
    print(s)
else:
    print(s[0:l-n-1]+"...");
# Judge status: Accepted
n, k = map(int, input().split())
x = n
ans = 1
while x >= k:
  x = x // k
  ans += 1
print(ans)
# Judge status: Wrong Answer
s=input()
l=[0]
for i in s:
    l.append(int(i))
#l=[int(i) for i in s[::-1]]
#l.append(0)
#print(l)
ans=0
for i in range(1,len(l)):
    if l[i]>5:
        l[i]=0
        l[i-1]+=1
s="0"+s
#print(l,s)
for i in range(len(s)):
    ans+=l[i]
    ans+=[l[i]-int(s[i]),9+l[i]-int(s[i])][l[i]<int(s[i])]
print(ans)
# Judge status: Accepted
N,X=map(int,input().split())
S=list(map(int,input().split()))

count=1

takasa=0
for i in range(N):
    takasa+=S[i]
    if takasa<=X:
        count+=1

print(count)
# Judge status: Accepted
s = input()
cnt=0
for i in range(len(s)//2):
    if(s[i]!=s[len(s)-i-1]): cnt+=1

print(cnt)
# Judge status: Accepted
def resolve():
    N, M = list(map(int, input().split()))
    A = list(map(lambda x: -int(x), input().split()))
    import heapq
    heapq.heapify(A)
    for i in range(M):
        v = heapq.heappop(A)
        heapq.heappush(A, v/2)
    import math
    A = list(map(lambda x: math.floor(-x), A))
    print(sum(A))
    


if '__main__' == __name__:
    resolve()
# Judge status: Accepted
NN = input().split()
N = int(NN[0])
K = int(NN[1])
LL = input().split()
list1 =[]
for i in LL:
  list1.append(int(i))
list1.sort()

total = 0
for i in range(K):
  total += list1[i]
print(total)
# Judge status: Accepted
from math import pi
a = int(input())
# # a = [int(i) for i in input().split()]

print(2*pi*a)
# Judge status: Accepted
n = int(input().replace(' ', ''))

ans = 'No'
for i in range(1000):
    if n == i ** 2:
        ans = 'Yes'
print(ans)
# Judge status: Accepted
N,A,B=map(int,input().split())
print((N//(A+B))*A+N%(A+B) if N%(A+B)<=A else (N//(A+B))*A+A)
# Judge status: Accepted
A,B = map(int,input().split())
if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')
# Judge status: Wrong Answer
n=int(input())
lst=list(map(int,input().split()))
f_ans=[]
ans_lst=[0]*n
for i in range(n):
  for j in range(n-i-1):
    if lst[j+i]>=lst[j+i+1]:
      ans_lst[i]+=1
  if ans_lst[i]<=max(ans_lst):
      break
print(ans_lst)
# Judge status: Accepted
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa = [0]
bb = [0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
c = m
ans = 0
for i in range(n+1):
    u = k - aa[i]
    for j in range(c, -1, -1):
        if bb[j] <= u:
            ans = max(ans, i+j)
            c = j
            break
print(ans)
# Judge status: Accepted
N = int(input())

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

c = 1
M = [] #（葉でない）子ノードの数の最大値
INF = 10**16
for a in A:
    c -= a
    M.append(c)
    c *= 2

    c = min(INF, c)
    
if c < 0:
    print(-1)
else:
    cnt = A[-1]
    num = A[-1]
    for a,m in zip(reversed(A[:-1]),reversed(M[:-1])):
        n = min(num, m)
        cnt += n+a
        num = n+a
    print(cnt)
# Judge status: Wrong Answer
n,k = map(int,input().split())
log = list(map(int,input().split()))
for i in range(k):
  m = max(log)
  log.remove(m)
  log += [m/2]*2
  
print(max(log))
# Judge status: Wrong Answer
a,b,c = input().split()
if a + b == c or a + c == b or b + c == a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import deque

n = int(input())
A = deque(map(int, input().split()))
B = deque()

if n%2==0:
  while(A):
    B.append(A.popleft())
    B.appendleft(A.popleft())
else:
  while(A):
    B.appendleft(A.popleft())
    if(A):
      B.append(A.popleft())

for i in range(n):
  print(B[i], end=" ")
# Judge status: Accepted
n,k = map(int,input().split())
s = []
for i in range(n):
    s.append(int(input()))
s.sort()
s.reverse()
ans = s[0]-s[-1]
for i in range(n-k+1):
    ans = min(ans,s[i]-s[i+k-1])
print(ans)
# Judge status: Wrong Answer
n = int(input()) * 3
a = list(map(int, input().split(" ")))

a.sort(reverse=True)
print(sum(a[int(n/3):int(n/3*2)]))
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, x = map(int, input().split())
  As = list(map(int, input().split()))
  cost = 0
  for i in range(n):
    if As[i] > x:
      cost += As[i] - x
      As[i] = x
  for i in range(1, n):
    if As[i] + As[i-1] > x:
      cost += (As[i] + As[i-1] - x)
      As[i] -= (As[i] + As[i-1] - x)
  print(cost)

if __name__=='__main__':
  main()
# Judge status: Accepted
from math import gcd
N=int(input())
A=list(map(int,input().split()))

L=[A[0]]
R=[A[-1]]

for i in range(1,N):
    L.append(gcd(L[-1],A[i]))
    R.append(gcd(R[-1],A[-1-i]))
R=R[::-1]
#print(L)
#print(R)

ans=1
for j in range(N):
    if j==0:
        tmp = R[1]
    elif j==N-1:
        tmp = L[N-2]
    else:
        tmp = gcd(L[j-1],R[j+1])
    #print(j,tmp)
    ans=max(ans,tmp)
    
print(ans)
# Judge status: Accepted
import fractions
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))
# Judge status: Accepted
def solve(l):
  return (l/3)**3

l = int(input())
# n, m = [int(s) for s in input().split(" ")]
print(solve(l))
# Judge status: Wrong Answer
n,l = map(int,input().split())
s = [0]*n
for i in range(n):
    s[i] = input()
s = sorted(s)
ans = []
for i in range(n):
    ans.extend(s[i])
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.buffer.readline

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

if max(A) > sum(A) - max(A):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
min = math.inf
S = input()
T = input()

len_t = len(T)
for s in range(0,len(S)-len_t+1):
    sub = S[s: s+len_t]
    diff = 0
    for i in range(len_t):
        if sub[i] != T[i]:
            diff += 1
            if diff > min:
                break
    else:
        if diff < min:
            min = diff
print(min)
# Judge status: Accepted
n=input().split()
if int(n[0])==int(n[1]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
pnt=[]
n=int(input())
for i in range(n):
  pnt.append(list(map(int,input().split())))

z=[]
w=[]

for i in pnt:
  z.append(i[0]+i[1])
  w.append(i[0]-i[1])
print(max(max(z)-min(z),max(w)-min(w)))
# Judge status: Wrong Answer
import numpy as np
n, k, q = map(int, input().split())
A = np.array([int(input()) - 1 for _ in range(q)])
score = np.zeros(n)
for i in A:
    score[i] += 1
score = k + score - 4
print(*np.where(score > 0, 'Yes', 'No'), sep='\n')
# Judge status: Wrong Answer
s = int(input())
a = []

while True:
    if s % 2 == 0:
        s = s/2
        a.append(s)
        if s ==4:
            print(len(a)+4)
            break
        else:
            True
    else:
        s = 3*s+1
        a.append(s)
        if s == 4:
            print(len(a) + 4)
            break
        else:
            True
# Judge status: Wrong Answer

def answer(N:int,K:int) -> int:
    counter = 0
    for i in range(K,N+2):
        counter += i*(N - K + 1) + 1
    return counter % (10**9 + 7)



def main():
    N,K = map(int,input().split())
    # answer()
    print(answer(N,K))

if __name__ == '__main__':
   main()
# Judge status: Accepted
n = int(input())
ls = list(map(int, input().split()))

ls.sort(reverse=True)

ans = 0

for i in range(2 * n):
    if i % 2 == 1:
        ans += ls[i]

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(str,input().split()))
b = a[::-1]
b = b[::2]
c = a[::2]
d = b+c
if n >= 2:
  print(' '.join(d))
else:
  print(a[0])
# Judge status: Accepted
S, W = map(int, input().split())
print('unsafe' if S <= W else 'safe')
# Judge status: Accepted
X,Y = map(int,input().split())
count = 1

while True:
  if X*2 <= Y:
    count +=1
    X = X*2
  else:
    break
    
print(count)
# Judge status: Accepted
import numpy as np

M = np.array(list(map(int,open(0).read().split()))).reshape(3,3)

hSum = M.sum(axis=0)
vSum = M.sum(axis=1)

f=True
for i in range(3):
  if (hSum[i]-hSum[(i+1)%3])%3!=0:
    f = False

for i in range(3):
  if (vSum[i]-vSum[(i+1)%3])%3!=0:
    f = False
    
print("Yes" if f else "No")
# Judge status: Accepted
N = int(input())
d = list(map(int, input().split()))

half_ind = int(len(d)/2)
L = sorted(d)[half_ind-1]
R = sorted(d)[half_ind]

print(R - L)
# Judge status: Accepted
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N = int(input())
Als = inpl()

count= 0
for i,item in enumerate(Als):
    if (i%2 == 0) and (item % 2 != 0):
        count += 1
print(count)
# Judge status: Accepted
#!/usr/bin/env python3

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

    h_min = H[0]
    flag = True
    for i in range(0, N):
        if H[i] - 1 >= h_min:
            H[i] = H[i] - 1
        elif H[i] < h_min:
            flag = False
            break
        h_min = H[i]
    
    if flag:
        print('Yes')
    else:
        print('No')


main()
# Judge status: Accepted
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 10**9
l = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  b=i//2
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==10**9:
    cnt=cnt1
  elif cnt!=cnt1:
    print(0)
    exit()
print((M//a+2-1)//2)
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
sum = 0
for i in range(1,114514):
  sum += A*i
  if sum%B == C:
    print("YES")
    break
  if i == 100:
    print("NO")
# Judge status: Accepted
a = int(input())
b = int(input())
print(6 - a - b)
# Judge status: Wrong Answer
S = list(input())

p = S[0]+S[2]
q = S[0]+S[-2]

flag = 0
for i in range(1,len(S)):
    if i != 2 and i != len(S)-2:
        if not S[i].islower():
            print('WA')
            exit()
    else:
        if S[i] != 'C':
            print('WA')
            exit()

if (p == 'AC' and q != 'AC') or (p != 'AC' and q == 'AC'):
    print('AC')
else:
    print('WA')
# Judge status: Wrong Answer

abc = list(input().split())
list = sorted(abc)

print("Yes" if (int(list[0])+int(list[1]))==int(list[2]) else "No")
# Judge status: Wrong Answer
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
print(x)
# Judge status: Accepted
S = input()

weather = ['Sunny', 'Cloudy', 'Rainy']

num = weather.index(S)
if num == 2:
    num = -1

print(weather[num + 1])
# Judge status: Wrong Answer
import sys

readline = sys.stdin.readline
n, k = map(int, readline().split())
A = list(map(int, readline().split()))

visited = [False] * n
visited[0] = True
l = [1]
while True:
    x = A[l[-1]-1]
    if visited[x-1]:
        break
    l.append(x)
    visited[x-1] = True
# print(x)
# print(l)
# print(l[l.index(x):])
print(l[l.index(x):][(k-l.index(x)) % len(l[l.index(x):])])
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))
AI = tuple(i + a for i, a in enumerate(A))
AJ = tuple(i - a for i, a in enumerate(A))

cai = {}
caj = {}
vali = set()
valj = set()
for ai, aj in zip(AI, AJ):
    if not ai in cai:
        cai[ai] = 0
    if not aj in caj:
        caj[aj] = 0

    cai[ai] += 1
    vali.add(ai)

    caj[aj] += 1
    valj.add(aj)

count = 0
for val in vali & valj:
    count += cai[val] * caj[val]

print(count)
# Judge status: Accepted
a,b=map(str,input().split())
ab=int(a+b)

ans="No"
for i in range(1,350):
  if i**2==ab:
    ans="Yes"
    break

print(ans)
# Judge status: Wrong Answer
N, Y = map(int, input().split())

for i in range(9):
    a = Y - i*5000
    b = N-i
    if (b*10000 - a) % 9000 != 0:
        continue
    c = (b*10000 - a) // 9000
    d = b-c

    if c < 0 or d < 0:
        continue

    if N == c+d and Y == d*10000+i*5000+c*1000:
        print(d, i, c)
        break

else:
    print(-1,-1,-1)
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
U = max(A)
L = 1


def can(x, K):
    ct = 0
    for i in range(N):
        ct += (A[i]-1)//x
    if ct <= K:
        return True
    else:
        return False


while U-L > 1:
    x = (U+L)//2
    if can(x, K):
        U = x
    else:
        L = x

print(U)
# Judge status: Accepted
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
C = []

S = sum(A2) + A1[0]

for i in range(1,N):
  C.append(S)
  S += A1[i]-A2[i-1]
  
if N != 1:
  print(max(C))
else:
  print(A1[0]+A2[0])
# Judge status: Accepted
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print("No")
elif S[0] == S[1] and S[2] == S[3]:
  print("Yes")
elif S[0] == S[2] and S[1] == S[3]:
  print("Yes")
elif S[0] == S[3] and S[1] == S[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import numpy as np

input()
a = np.array(sorted(map(int, input().split())))
print(min(sum((a - i) ** 2) for i in range(min(a), max(a) + 1)))
# Judge status: Accepted
n,a,b=map(int,input().split())
m=10**9+7
def c(k):
	x = 1
	for i in range(k):
		x=x*(n-i)*pow(i+1,m-2,m)%m
	return x
print((pow(2,n,m)-c(a)-c(b)-1)%m)
# Judge status: Wrong Answer
import itertools
N,K = map(int,input().split())
p = [int(m) for m in input().split()]

if K == 1:
    print(*p)

if K == 2:
    p2list = list(itertools.combinations(p, 2))
    print(sum(min(p2list)))
    
if K >= 3:
    p3list = list(itertools.combinations(p, 3))
    print(sum(min(p3list)))
# Judge status: Accepted
x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
# Judge status: Accepted
def main():
  N = int(input())
  o = (N % 1000)
  ans = 0 if o == 0 else 1000 - o
  print(ans)
  return

main()
# Judge status: Accepted
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 9
dp = [INF] * (H+1)
dp[0] = 0
for i in range(H):
    for j in range(N):
        idx = min(H, i+ab[j][0])
        dp[idx] = min(dp[idx], dp[i]+ab[j][1])
print(dp[-1])
# Judge status: Wrong Answer
n = int(input())
wordlist = []
for i in range(n):
    word = str(input())
    if word in wordlist:
        print('No')
        exit()
    if wordlist and wordlist[-1][-1] == word[-1]:
        print('No')
        exit()
    wordlist.append(word)
print('Yes')
# Judge status: Wrong Answer
n,d = map(int,input().split())
x = [[] for _ in range(n)]
for i in range(n):
	x[i] = list(map(int,input().split()))
#8000
ansk = 0
l = set([i**2 for i in range(100)])
for i in range(n):
	for j in range(i+1, n):
		ans = 0
		for k in range(d):
			ans += (x[i][k]-x[j][k])**2
		if ans in l:
			ansk += 1
print(ansk)
# Judge status: Accepted
a = input()
b = input()
s = ""
for i in range(len(a)+len(b)):
    s+=a[0]
    a=a[1:]
    a,b=b,a

print(s)
# Judge status: Accepted
n = int(input())
x = [0]*n
for i, v in enumerate(map(int, input().split())):
    x[v-1] = i+1
print(*x)
# Judge status: Accepted
from itertools import product
nums = [1, 2, 3, 4 ,5, 6, 7, 8, 9]
nums_set = set(i*j for i, j in product(nums, repeat=2))
n = int(input())
if n in nums_set:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
S = input()
#左から数える
W=[0]*N
w = 0
for i in range(N):
    if S[i] == "W":
        w += 1
    W[i] = w
#右から数える
E = [0]*N
e = 0
for i in range(N):
    if S[N-1-i] == "E":
        e += 1
    E[N-1-i] = e
ans = 10**9
for i in range(N):
    count = W[i] + E[i]
    ans = min(ans,count)

print(ans-1)
# Judge status: Wrong Answer
S = list(input())
a_flag = 0
c_flag = 0
c_count = 0
flag2 = 0
if S[0] == 'A':
    a_flag += 1
for i in range(2, len(S)-1):
    if S[i] == 'C' and i == 2:
        c_flag += 1
        c_count += 1
    elif S[i] == 'C':
        c_flag += 1
        c_count += 1
    elif S[i].isupper():
        flag2 += 1

if S[len(S) - 1].isupper():
    flag2 += 1
if a_flag == 1 and c_flag == 1 and flag2 == 0 and c_count == 1:
    print('AC')
else:
    print('WA')
# Judge status: Accepted
n = int(input())
p = input().split()
p = [int(x) for x in p]
c = 0
for i in range(1,n-1):
  if (p[i-1] <= p[i] and p[i] <= p[i+1]) or (p[i+1] <= p[i] and p[i] <= p[i-1]):
    c +=1
print(c)
# Judge status: Wrong Answer
s = input().split()
W = int(s[0])
H = int(s[1])

if W % 2 == 0:
    out = int((H * W) / 2)
else:
    if W % 2 == 0:
        k = int(H / 2)
    else:
        k = int(H / 2)+1
    out = int((H * (W - 1)) / 2) + k

print(int(out))
# Judge status: Accepted
N=int(input());a=10;b=0
if N&1==0:
    while a<=N:b+=N//a;a*=5
print(b)
# Judge status: Accepted
y = input()
print("YES" if y in "753" else "NO")
# Judge status: Wrong Answer
s = input()
d = {'S':0,'N':0,'E':0,'W':0}
for i in s:
    d[i] += 1
ns = d['S'] > 0 and d['N'] > 0
ew = d['E'] > 0 and d['W'] > 0
if ns and ew:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b, c = map(int, input().split())

print(a*b//2)
# Judge status: Accepted
import numpy as np
N,M = map(int,input().split())
A = (N+2)*[0]

for m in range(M):
  L,R = map(int,input().split())
  A[L]+=1
  A[R+1]-=1

A = np.cumsum(A)
print(sum(a==M for a in A))
# Judge status: Accepted
a = int(input())
a = a + a**2 +a**3
print(a)
# Judge status: Wrong Answer
n,m=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(m)]
l,r=LR[0]
ans=r-l+1
for i in range(1,m):
  if l < LR[i][0]:
    l=LR[i][0]
  if r > LR[i][1]:
    r=LR[i][1]
  ans=r-l+1
print(ans)
# Judge status: Wrong Answer
n,*ab = map(int,open(0).read().split())
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort(reverse=True)

if n%2 == 1:
    med_min = a[(n-1)//2]
    med_max = b[(n-1)//2]
    ans = med_max - med_min + 1
else:
    med_min = (a[n//2-1] + a[n//2] ) /2
    med_max = (b[n//2-1] + b[n//2] ) /2
    ans = (med_max - med_min)*2 + 1

print(ans)
# Judge status: Accepted
n, m = map(int, input().split())

ans = 0
flag = [0] * n

for _ in range(m):
    P, s = input().split(' ')
    p = int(P) - 1
    if s == 'AC':
        if flag[p] != -1:
            ans += flag[p]
            flag[p] = -1
    elif flag[p] != -1:
        flag[p] += 1

print(flag.count(-1), ans)
# Judge status: Wrong Answer
x = list(map(int,input().split()))
x.sort()
if x[2] == x[1] + x[0]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def Gauss_sum(n):
  return n*(n+1)//2
a,b=map(int,input().split())
for i in range(999):
  if Gauss_sum(i+1)-a == Gauss_sum(i+2)-b:
    print(Gauss_sum(i+1)-a)
    break
# Judge status: Accepted
A, B = map(int, input().split())
K = (A + B) // 2
if abs(A - K) == abs(K - B):
    print(K)
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
a,b,x = map(int, input().split())

ans = (b//x) - ((a-1)//x)
print(ans)
# Judge status: Wrong Answer
N = int(input())

A = []
B = []

for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()

ans = 0
before = 0

for i in range(N):
    if B[i] == 1:
        plus = 0
    else:
        plus = B[i]-(A[i]+ans)%B[i]
    ans += plus


print(ans)
# Judge status: Accepted
x=int(input())
a=100
count=0
for i in range(x):
    a=int(a*1.01)
    count+=1
    if a>=x:
        break
print(count)
# Judge status: Wrong Answer
N, M = map(int, input().split())
list = []
for i in range(N):
    list.append(input())
count = 0
for i in range(M):
    x = input()
    for j in list:
        count+=j.count(x)
print("No" if count==0 else "Yes")
# Judge status: Wrong Answer
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(0, N - 1):
    if p[i + 1] != p[i] + 1:
        count += 1

print("No") if count > 2 else print("Yes")
# Judge status: Accepted
N=int(input())
p=list(map(int,input().split()))
c=0
for i in range(N):
    if p[i] != i+1: c+=1
print('YES' if c<=2 else 'NO')
# Judge status: Accepted
from collections import Counter

n,k = map(int, input().split())
A = Counter(map(int, input().split()))

rep_n = len(A)-k

if rep_n<=0:
  print(0)
else:
  ans = 0
  for k, v in A.most_common()[::-1]:
    ans += v
    rep_n -= 1
    if rep_n==0:
      break
  print(ans)
# Judge status: Accepted
from sys import stdin

A = int(stdin.readline().rstrip())

if A%2 == 0:
    print((A/2)/A)
else:
    print((A//2 + 1)/A)
# Judge status: Wrong Answer
s = list(input())
print(min(s.count("1"),s.count("0")*2))
# Judge status: Accepted
import sys
from collections import Counter

input = sys.stdin.readline

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

counter = Counter(A)
ans = 0
for value, count in counter.items():
    if value - 1 in counter:
        count += counter[value - 1]
    if value + 1 in counter:
        count += counter[value + 1]
    ans = max(ans, count)

print(ans)
# Judge status: Accepted
#１つの整数を入力
x = int(input())

if(x >= 30):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    N = int(input())
    s = input()
    t = input()
    if s == t:
        print(N)
    else:
        count = 1
        for i in range(1,N):
            tmp = s+t[-i:]
            if s == tmp[:N] and t == tmp[-N:]:
                break
            count += 1
        print(N+count)
if __name__ == '__main__':
    main()
# Judge status: Accepted
n, m = map(int, input().split())

num = [1]*n
red = [1] + [0]*(n-1)

for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    num[x] -= 1
    num[y] += 1

    if red[x]:
        red[y] = 1
    if num[x] == 0:
        red[x] = 0

print(sum(red))
# Judge status: Wrong Answer
N = int(input())
B = list(map(int, input().split()))
A = [0] * N

A[0] = B[0]
for i in range(N - 1):
    if i + 1 > N - 2:
        A[i] = min(B[i], A[i])
        continue

    if B[i] > B[i + 1]:
        A[i] = min(B[i + 1], A[i])
        A[i + 1] = B[i + 1]
    else:
        A[i] = min(B[i], A[i])
        A[i + 1] = B[i]

A[N - 1] = B[N - 2]
print(sum(A))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
  if a[i - 1] > a[i]:
    if a[i] > a[i + 1]:
      ans += 1
  elif a[i - 1] < a[i]:
    if a[i] < a[i + 1]:
      ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
MAX = 0
for i in range(N):
    MAX = max(MAX,sum(A[0][:i+1])+sum(A[1][i:]))
print(MAX)
# Judge status: Accepted
def main():
    n=int(input())
    p=list(map(int, input().split()))
    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            count += 1
    print(count)
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,K =map(int,input().rstrip().split())
ans = [0 for _ in range(10 ** 5 + 1)]
for i in range(N):
  a,b = map(int,input().rstrip().split())
  ans[a] += b
counter = 0
c2 = 0
while counter < K:
  c2  += 1
  counter += ans[c2]
print(c2)
# Judge status: Wrong Answer
N=int(input())
print(int(N**0.5))
# Judge status: Accepted
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:
    b.append(i//2)
import fractions
l=1
for i in b:
    d=fractions.gcd(i,l)
    l=i*l//d
    if l>m:
        print(0)
        sys.exit()
for i in b:
    if (l//i)%2==0:
        print(0)
        sys.exit()
x=m//l
if x%2==0:
    print(x//2)
else:
    print(x//2+1)
# Judge status: Accepted
a,b,n=map(int,input().split())
x=min(n,b-1)
print((a*x)//b-a*(x//b))
# Judge status: Accepted
import math

A,B,C,D = map(int, input().split())

tn = math.ceil(C/B)
an = math.ceil(A/D)

if tn <= an:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pat_list = []
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      price = 500 * a + 100 * b + 50 * c
      pat_list.append(price)
print(pat_list.count(X))