peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = list(input())

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i, s in enumerate(S):
    if (i + 1) % 2 == 1 and (s not in odd):
        print("No")
        exit()
    if (i + 1) % 2 == 0 and (s not in even):
        print("No")
        exit()

print("Yes")
# Judge status: Wrong Answer
N = int(input())
SP = []
for i in range(N):
  c, p = input().split()
  SP.append([i+1, c, p])
SP = sorted(SP, key=lambda x:x[2], reverse=True)
SP = sorted(SP, key=lambda x:x[1])
for s in SP:
  print(s[0])
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    A = [list(map(int,input().split())) for _ in range(N)]
    
    p = 0
    for i in reversed(range(N)):
        u,m = A[i]
        u += p
        p += (-(-u//m)*m-u)
        
    print(p)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
max_ans = sum(a)
ans = abs(a[0]-(max_ans - a[0]))
sumu = a[0]
for i in range(1,n-1):
  sumu += a[i]
  arai = max_ans - sumu
  kari = abs(sumu-arai)
  if kari < ans:
    ans = kari
print(ans)
# Judge status: Wrong Answer
import numpy as np


N, K = map(int, input().split())
A = np.array([1] + list(map(int, input().split())), np.int64)

PA = np.cumprod(A)
ans = []
f = ['No', 'Yes']

B = []
for i in range(K, N + 1):
    b = PA[i] // PA[i - K]
    B.append(int(b))

ans = [['No', 'Yes'][B[i - 1] < B[i]] for i in range(1, len(B))]

print('\n'.join(ans))
# Judge status: Accepted
N = int(input())
minval = N

for a in range(1,N):
  sum = 0
  A = a
  B = N-a
  while A > 0:
    sum += A%10
    A = int(A/10)
  while B > 0:
    sum += B%10
    B = int(B/10)
  if minval > sum:
    minval = sum

print(minval)
# Judge status: Accepted
x,a,b=map(int,input().split())
if b<=a:
    print("delicious")
elif (x+a)>=b:
    print("safe")
else:
    print("dangerous")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

MOD = 1000000007
ans = 0
powsum = 0
sumpow = 0
for i in range(N):
    powsum += A[i] 
    sumpow += (A[i]*A[i])

powsum = (powsum*powsum)
ans = ((powsum-sumpow)/2)
print(int(ans)%MOD)
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    k = I()
    for i, si in enumerate(s):
        if si != '1':
            print(si)
            sys.exit()
        if i == k-1:
            break
    print(1)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
K = int(input())
a,b = map(int,input().split())
 
ka = a/K
kb = b/K
kaama = a%K
kbama = b%K
 
 
 
if kaama == 0 or kbama == 0:
  print("OK")
  
elif (kb-ka)>=1:
  print("OK")
  
else:
  print("NG")
# Judge status: Accepted
x,y=map(int,input().split());n=0;mod=10**9+7;ans=0
if not (x+y)%3:
  n=(x+y)//3;x-=n;y-=n
  if x>=0 and y>=0:
    ans=1
    for i in range(x):ans=ans*(n-i)*pow(i+1,mod-2,mod)%mod
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

answer = (a * b) % 2

if answer == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Wrong Answer
N = int(input())
S_list = [input() for i in range(N)]
AC = S_list.count('AC')
WA = S_list.count('WA')
TLE = S_list.count('TLE')
RE = S_list.count("RE")
print('AC × {}'.format(AC))
print('WA × {}'.format(WA))
print('TLE × {}'.format(TLE))
print('RE × {}'.format(RE))
# Judge status: Accepted
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n - 2):
    for j in range(n):
        if i + j*2 < n:
            if s[i] != s[i + j]:
                if s[i] != s[i + j*2]:
                    if s[i + j] != s[i + j*2]:
                        ans -= 1
        else:
            break

print(ans)
# Judge status: Accepted
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    tmp_a, tmp_b = map(int, input().split())
    a.append(tmp_a)
    b.append(tmp_b)

v = max(a)
b.sort(reverse=True)
i = 0
while i < n and b[i] > v and h > 0:
    h -= b[i]
    i += 1

if h <= 0:
    print(i)
else:
    print(i + (h + v - 1) // v)
# Judge status: Accepted
x, k, d = map(int, input().split())

if abs(x)//d >= k:
  print(abs(abs(x) - k*d))

else:
#  a = 1
  y = abs(x)//d
  a = y + 1
#  while abs(x) - d*a >=0:
#    a += 1
  if (k-(a-1)) % 2 ==0:
    print(abs(abs(x) - (a-1)*d))
  else:
    print(abs(abs(x) - a*d))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
ans = []
flg = 0

A.sort(reverse=True)

for i in range(N-1):
  if A[i] == A[i+1] and flg == 0:
    ans.append(A[i])
    flg = 1
  else:
    flg = 0

if len(ans) > 1:
  print(ans[0]*ans[1])
else:
  print(0)
# Judge status: Accepted
import math
a, b = map(int, input().split())
ave = (a + b) / 2
print(math.ceil(ave))
# Judge status: Accepted
l,r=map(int,input().split())
a=2018
for i in range (l,min(r,l+2019)):
  for j in range(i+1,min(r+1,i+2019)):
    c= ((i%2019)*(j%2019))%2019
    if c<a:
      a=c
print(a)
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())

m=max(a,b,c)
for _ in range(k):
    m*=2

print(a+b+c+m-max(a,b,c))
# Judge status: Accepted
x, y = map(int, input().split())
ans = 0
while x<=y:
    x *= 2
    ans += 1
print(ans)
# Judge status: Accepted
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from collections import Counter

    n = int(readline())
    a = list(map(int, readline().split()))
    ans = sum(a)
    counter = Counter(a)
    q = int(readline())
    for _ in range(q):
        b, c = map(int, readline().split())
        ans += (c - b) * counter[b]
        counter[c] += counter[b]
        counter[b] = 0
        print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from itertools import groupby as g
print("YNeos"[len(list(g(input())))>2::2])
# Judge status: Wrong Answer
import math

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

if M >= 2*N:
    print(N + math.floor((M-2*N)/4))
else:
    print(N//2)
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
if a - c < d: # a-cの直通
    print("Yes")
elif a - b < d and b - c < d:
    print("Yes")
elif a == b == c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
MOD=10**9+7
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1
dp[1]=1 if 1 not in a else 0
a=sorted(list(set(range(2,n+1))-set(a)))
for i in a:
    dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[n]%MOD)
# Judge status: Accepted
N = int(input())
ans=''

for i in range(1, 99):
  if N <= 26 ** i:
    N -= 1
    for j in range(i):
      ans += chr(ord('a') + N % 26)
      N //= 26
    break
  else:
    N -= 26 ** i

print(ans[::-1]) # reversed
# Judge status: Accepted
def main():
  a = int(input())
  b = int(input())
  
  print(6-a-b)

if __name__ == '__main__':
  main()
# Judge status: Accepted
s = str(input())
a = 0
b = 0
for i in range(len(s)):
    if s[i] == '0':
        a += 1
    else:
        b += 1
print(min(a, b)*2)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p, m, cnt = 0, 0, 0
for i in range(N):
  if a[i]-b[i] >= 0:
    p += a[i]-b[i]
  else:
    m += b[i]-a[i]
    cnt += 1
    
if (2*p<=m) and (cnt<=p):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys,math,collections,itertools
input = sys.stdin.readline
cnt =1
K,A,B=list(map(int,input().split()))
if A+2<=B:#交換したほうがいい
    if A-1 >=K:#最低交換枚数に達しない
      cnt = 1+K
    else:
        cnt = A + (K-(A-1))//2*(B-A)+(K-(A-1))%2
else:
    cnt = 1+K
print(cnt)
# Judge status: Accepted
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(str(min(a,b))*max(a,b))
if __name__ == '__main__':
    do()
# Judge status: Wrong Answer
from math import ceil

n,h=map(int,input().split())
a=[]
b=[]
ans=0

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

b.sort()
b.reverse()

pin=max(a)

for i in range(n):
  p=b[i]
  if p<=pin:
    break
  ans+=1
  h-=p


ans+=h-1//pin
ans+=1


print(ans)
# Judge status: Accepted
n = int(input())
a = n-1
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    a = i+n//i-2
print(a)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))

m = max(l)
ol = list(filter(lambda x: x != m,l))
ans = "Yes" if m < sum(ol) else "No"
print(ans)
# Judge status: Accepted
S = input()
T = input()
def diff_count(A,B):
    diff = 0
    for a,b in zip(A,B):
        if a!=b:
            diff += 1
    return diff
ans = len(T)
for i in range(len(S) - len(T)+1):
    temp = S[i:i+len(T)]
    diff_num = diff_count(T,temp)
    ans = min(diff_num,ans)
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
d = dict()
for i in range(m):
    k,v = map(int,input().split())
    if k in d:
        if d[k] !=v:
            print(-1)
            exit()
    else:
        d[k] = v
res = ""
for i in (range(1,n+1)):
    if i not in d:
        d[i] = 0
    res += str(d[i])
res = int(res)
if n !=1:
    if res == 0:
        print(-1)
        exit()
print(res)
# Judge status: Accepted
N = int(input())
a = [int(input()) for i in range(N)]

push = [False] * N

ans = 0
i = 0
while True:
    ans += 1
    if a[i] == 2:
        break
    if push[i]:
        ans = -1
        break
    push[i] = True
    i = a[i] - 1

print(ans)
# Judge status: Accepted
S = input()
S = S[:-1]

def stringcounter(M):
    if len(M)%2 ==0 and M[:len(M)//2]==M[len(M)//2:]:
        return True
    else:
        return False
while True:
    if stringcounter(S)==True:
        print(len(S))
        break
    else:
        S = S[:-1]
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
l_max = max(l)
sum_l = sum(l) - l_max

if l_max < sum_l:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import Counter

N = int(input())
S = input()

C_E = Counter(S[1:])
C_W = Counter()
ans = C_E['E']

for i in range(N - 1):
    C_E[S[i + 1]] -= 1
    C_W[S[i]] += 1
    ans = min(ans, C_E['E'] + C_W['W'])
print(ans)
# Judge status: Accepted
x = int(input())
ans = (x//11)*2
if(x%11>6):
    ans += 2
elif(x%11>0):
    ans += 1

print(ans)
# Judge status: Wrong Answer
line = input()
sum = 0
for i in range(len(line)):
  sum = sum + int(line[0])
if sum % 9 == 0:
    print("yes")
else:
    print("no")
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
    if (i+1) % 2 == 1 and A[i] % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
a, b = map(int, input().split(" "))

x = "Even" if (a*b)%2 == 0 else "Odd"

print(x)
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500*i+100*j+50*k==X:
                ans+=1
print(ans)
# Judge status: Wrong Answer
s= input()
t = input()
ans = 100000000
for i in range(len(s)-len(t)):
    cnt = 0
    for j in range(len(t)):
        if t[j] !=s[i+j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)
# Judge status: Accepted
s = input().split('hi')
ans = 'Yes'
for i in s:
  if i != '':
    ans = 'No'
    break

print(ans)
# Judge status: Accepted
import math
a,b,x = map(int,input().split())
if 2*x>=(a**2)*b:
    theta = math.degrees(math.atan(2*(b-x/a**2)/a))
else:
    theta = math.degrees(math.atan((a*b**2)/(2*x)))
print(theta)
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=deque([])
for i in range(n):
    a=int(input())
    ind=bisect.bisect_right(l,a-1)
    if ind==0:
        l.appendleft(a)
    else:
        l[ind-1]=a
print(len(l))
# Judge status: Accepted
h=int(input())
w=int(input())
n=int(input())

m=max(h,w)
print(n//m+(n%m!=0))
# Judge status: Wrong Answer
a,b,t=map(int,input().split())
cnt=0
for i in range(a,t,a):
  cnt=cnt+1
print(cnt)
# Judge status: Accepted
# B - Collatz Problem
s = int(input())
a = s
S = set([s])
for i in range(2,10**6+1):
    a = a//2 if a%2==0 else 3*a+1
    if a in S:
        print(i)
        break
    S.add(a)
# Judge status: Accepted
s=input()
if 65<=ord(s)<=90:
  print("A")
else:
  print("a")
# Judge status: Accepted
A, B, K = map(int, input().split())

if A >= K:
    A -= K
else:
    K -= A
    A = 0
    if B >= K:
        B -= K
    else:
        B = 0

print(A,B)
# Judge status: Accepted
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ac = sum(s)
ans = 0
if ac % 10 != 0:
    ans = ac
else:
    for i in range(n):
        tmp = ac - s[i]
        if tmp % 10 != 0:
            ans = tmp
            break
print(ans)
# Judge status: Accepted
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,P = map(int,input().split())
A = list(map(int,input().split()))
H = [i%2 for i in A]
B = collections.Counter(H)[1]

ans = 0
for i in range(1,B//2+1):
    ans += combinations_count(B, 2*i)
C = (ans+1) * (2**(len(A)-B))
print(C if P == 0 else 2**N - C)
# Judge status: Wrong Answer
import fractions

N = int(input())
T = []
ans = 1

for i in range(0,N):
    T.append(int(input()))    

for i in range(0,N):
    ans = ans * T[i] / fractions.gcd(ans, T[i])
    
print(int(ans))
# Judge status: Accepted
S = input()
T = input()

answer = 0
for i in range(len(S)):
    if S[i] != T[i]:
        answer = answer + 1

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

myAC = [0 for n in range(N+1)]
myWA = [0 for n in range(N+1)]

ansAC = 0
ansWA = 0


for m in range(M):
    a,  b = map(str, input().split())
    a = int(a)
    if b == 'WA' and myAC[a] != 1:
        myWA[a] += 1
        
    if b == 'AC' and myAC[a] != 1:
        myAC[a] = 1
        ansWA += myWA[a]
        ansAC += 1

#print(myAC)
#print(myWA)
print(ansAC,ansWA)
# Judge status: Wrong Answer
n =input()
print('Yes' if len(set(n))==2 else 'No')
# Judge status: Accepted
d,t,s=map(int,input().split())
if d/s<=t:
  print('Yes')
else: print('No')
# Judge status: Accepted
N = int(input())
for i in range(1,10):
    if N%i == 0 and N/i <10:
        a = "Yes"
        break
    else:
        a = "No"
print(a)
# Judge status: Accepted
ans = 0
N = int(input())
L = [0] * 10**6
ans = 0
for i in range(2,10**6):
    while N%i == 0:
        N = N//i
        L[i] += 1
if N != 1:
    L[10**6 - 1] = 1
L.sort(reverse=True)
for i in range (10**6):
    if L[i] == 0:
        break
    k = 1
    while L[i] > 0:
        L[i] -= k
        if L[i] >= 0:
            k += 1
            ans += 1
print(ans)
# Judge status: Wrong Answer
from sys import stdin
n,m,k = [int(x) for x in stdin.readline().rstrip().split()]
if k > n+m:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
A, B, C = map(int, input().split())

count = 0
if A > B:
    for i in range (B, A):
        if i == C:
            count = 1
elif A < B:
    for i in range (A, B):
        if i == C:
            count = 1

if count == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
lst = []
for i in range(n):
    s, p = input().split()
    lst.append([s, int(p), i+1])

beta = sorted(lst, key=lambda x: x[1], reverse=True)
alpha = sorted(beta, key=lambda x: x[0])

for i in range(n):
    print(alpha[i][2])
# Judge status: Accepted
n,m = list(map(int, input().split()))
ps = [input().split() for _ in range(m)]

acCount = 0
penaltyCount = 0
wa = [0]*n
aced = [False]*n

for i in ps:
    ind = int(i[0])-1
    if i[1]=='WA' and not aced[ind]:
        wa[ind] += 1
    elif i[1]=='AC' and not aced[ind]:
        aced[ind] = True
        acCount += 1
        penaltyCount += wa[ind]

print(acCount, penaltyCount)
# Judge status: Wrong Answer
n = int(input())
x = list(map(int, input().split()))
xsort = sorted(x)
 
for i in range(n):
    if xsort[n//2] > x[i]:
        print(xsort[2//n])
    else:
        print(xsort[n//2-1])
# Judge status: Accepted
s = input()

ans = []
for l in s:
    if l == '0':
        ans.append('0')
    elif l == '1':
        ans.append('1')
    else:
        if ans:
            ans.pop()

print(''.join(ans))
# Judge status: Accepted
S=input()
T=input()

for i in range(len(S)):
    S=S[-1]+S[:-1]
    if T==S:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
MOD = 10 ** 9 + 7
N, M = map(int, input().split())
dp = [[0, 0] for _ in range(N + 1)]
dp[0][0] = 1
for _ in range(M):
    x = int(input())
    dp[x][1] = 1
for i in range(1, N + 1):
     if dp[i][1] == 0:
         dp[i][0] = (dp[i - 2][0] + dp[i - 1][0]) % MOD
print(dp[N][0])
# Judge status: Accepted
h, w = [int(s) for s in input().split()]
if h == 1 or w == 1:
    print(1)
    exit()
rh, rw = h%2, w%2
eh, ew = h - rh, w- rw

result = int( eh * ew //2)
if rh == 1:
    result += ew //2
if rw == 1:
    result += eh //2
if rh == rw == 1:
    result += 1

print(result)
# Judge status: Accepted
def main():
  N = int(input())
  if N % 2 != 0:
    print(0)
    exit()
  ans = 0
  i = 1
  while 2*5**i<=N:
    ans += N//(2*5**i)
    i += 1
      
  print(ans)
main()
# Judge status: Accepted
N,M=map(int,input().split())
ans=[[0]*N for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    ans[a-1][b-1]+=1
    ans[b-1][a-1]+=1

for i in range(N):
    print(sum(ans[i]))
# Judge status: Accepted
x,n = map(int,input().split())
p = set([int(x) for x in input().split()])

mn = 10**10
ans_li = []

for i in range(-200,201):
    if i not in p and abs(x - i) <= mn:
        ans_li.append(i)
        mn = abs(x - i)

for aa in ans_li:
    if abs(aa - x) == mn:
        print(aa)
        break
# Judge status: Wrong Answer
import numpy as np

N = int(raw_input())

A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

A = sorted(A)
B = sorted(B)
C = sorted(C)

num_A_on_B = 0
num_C_under_B = 0

ans = 0
for y in B:
    x = 0
    z = 0
    while x < N and A[x] <= y:
        x = x + 1
    while z < N and A[z] >= y:
        z = z + 1
    ans = ans + x*(N-z)
    
print ans
# Judge status: Wrong Answer
N=int(input())
ans=0
for i in range(N):
    if i*i<=N:
        ans=i
    else:
        break
print(ans**2)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
a = 0
for i in range(1,n):
    if p[i-1] > p[i]:
        a = a + p[i-1] - p[i]
        p[i] = p[i-1]
    else:
        p[i] = p[i]
        a = a
print(a)
# Judge status: Accepted
import re
S=input()
good = True

if S[0] != 'A':
    print('WA')
    exit()
n = 0
iC = -1
for i in range(2,len(S)-1):
    if S[i] == 'C':
        n += 1
        iC = i
if n != 1:
    print('WA')
    exit()
for i in range(1,len(S)):
    if i == iC:
        continue
    if not re.match(r'[a-z]', S[i]):
        print('WA')
        exit()

print('AC')
# Judge status: Accepted
n=int(input())
s=input()
m=int(n/2)

if n%2==0 and s[:m]==s[m:]:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

now = 1
check = [-1]*(n+1)

for i in range(k):
  if check[now] == -1:
    check[now] = i
    now = a[now]
  else:
    loop = i - check[now]
    afterloop = (k-(i-loop))%loop
    print(check.index((i-loop) + afterloop))
    exit()
print(now)
# Judge status: Accepted
n = int(input())
c = list(input())
d = sorted(c)
count = 0
for i in range(n):
    if c[i] == 'W' and d[i] == 'R':
        count+=1
print(count)
# Judge status: Wrong Answer
T = input()

ans = ""
for i in range(len(T)):
    if(T[i] == "?"):
        if(i != 0 and T[i-1] == "P"):
            ans += "D"
        elif(i != len(T)-1 and T[i+1] == "?"):
            ans += "P"
        else:
            ans += "D"
    else:
        ans += T[i]
print(ans)
# Judge status: Wrong Answer
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf') for _ in range(n)]
    dp[0] = 0
    dp[1] = abs(h[0]-h[1])
    for i in range(1, n):
        for j in range(1, min(k+1, n-i)):
            num = dp[i]+abs(h[i]-h[i+j])
            if num < dp[i+j]:
                dp[i+j] = num
    print(dp[-1])

main()
# Judge status: Wrong Answer
s = int(input())
x = [0,10**9]
y = [0,1]
tmp = 10**9
x3 = tmp - (s % tmp)
y3 = (s + x3) // tmp

print(0,0,10**9,1,x3,y3)
# Judge status: Accepted
d = int(input())

if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
if A%2==0 or B%2==0 or C%2==0:
  ans = 0
else:
  ans = int(1/max(A,B,C)*A*B*C)
print(ans)
# Judge status: Wrong Answer
S = 'SAT'
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
teihen,takasa = 0,0
check = 0
A = Counter(A)

for i,j in A.items():
  if j >= 2:
    if check == 0:
      teihen = i
      check = 1
    else:
      takasa = i
      check = 0
  elif j >= 4:
    teihen,takasa = i,i

print(teihen * takasa)
# Judge status: Wrong Answer
n = int(input())

num = [1, 2, 3, 4, 5, 6, 7, 8, 9]

ans = 0
for i in range(9):
    for j in range(9):
        if n//(num[i]) == num[j]:
            ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import collections
def main():
  N, K = map(int, input().split())
  A =list(map(int, input().split()))
  LA = list(collections.Counter(A).values())
  Ans = N-sum(LA[0:K])
  if Ans > 0:
    print(Ans)
  else:
    print(0)
main()
# Judge status: Accepted
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
#C.sort(reverse=True)
C.sort()
#2分探索を用いる
ans = 0
for i in B:
    a = bisect.bisect_left(A,i)
    b = N - bisect.bisect_right(C,i)
    ans += a*b
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

A,B = list(map(int, input().rstrip().split()))
#-----

cnt=0
for i in range(2):
  if A>=B:
    cnt += A
    A -= 1
  else:
    cnt += B
    B -= 1
  
print( cnt )
# Judge status: Accepted
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    for k in range(K, N + 2):
        a = k * (k - 1) // 2
        b = k * (2 * N - (k - 1)) // 2
        ans = (ans + (b - a + 1)) % P

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = list(input())
c = 0
a = 0
for i in range(n-1):
	if s[i] == s[i+1]:
		c += 1
i = 0
if s[-1] == 'R':
	s.append('L')
else:
	s.append('R')
print(s)
while a < k and len(s) >= 2:
	if s[0] != s[1] and s[-1] != s[-2] and s[0] == s[-1]:
		c += 2
		a += 1
	s = s[1:]

	i += 1
print(c)
# Judge status: Accepted
s = list(input())
print(s.count('1'))
# Judge status: Wrong Answer
import itertools

n = int(input())

cl = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ]
rl = itertools.product(cl[:2], repeat=n - 1)
if not rl:
    print("a")
else:
    for r in rl:
        print("".join(["a"] + list(r)))
# Judge status: Wrong Answer
import math
n = int(input())
lst = list(map(int, input().split()))

res = 0
for i in range(n):
  res += lst[i] - i
res = res/n

p = math.floor(res)
q = math.ceil(res)
o = p - 1
r = q + 1
os = ps = qs = rs =  0

for i in range(n):
  ps += abs(lst[i] - (p+i))
  qs += abs(lst[i] - (q+i))
  rs += abs(lst[i] - (r+i))
  os += abs(lst[i] - (o+i))
print(min(min(ps, qs), min(os, rs)))
# Judge status: Accepted
x, y, z = map(int, input().split())

i = 1
while True:
  if (y + z) * i + z > x:
    print(i-1)
    break
  i += 1