peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, k = map(int, (input().split()))
r, s, p = map(int, (input().split()))
t = input()

d = {'r': p, 's': r, 'p': s}
ans = 0

for i in range(k):
    last = ''
    j = i
    while j < n:
        if t[j] != last:
            ans += d[t[j]]
            last = t[j]
        else:
            last = ''
        j += k

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

if 1<= n <= 9:
  e = n 
  print(e)
elif 10 <= n <= 99:
  print(9)
elif 100 <= n <= 999:
  e = 9 + n - 100 + 1
  print(e)
elif 1000 <= n <= 9999:
  e = 909 
  print(e)
elif 10000 <= n <= 99999:
  e = 909 + n - 10000 + 1
  print(e)
elif n == 100000:
  print(90909)
# Judge status: Wrong Answer
color = [int(i) for i in input()]
n = len(color)
ans = 0
for i in range(n-2):
    a = color[i]
    b = color[i+1]
    c = color[i+2]
    if a==b==c:
        color[i+1] = (b+1)%2
        ans += 1
    elif a==b and a!=c:
        color[i] = (a+1)%2
        ans += 1
    elif a!=b and b==c:
        color[i+2] = (c+1)%2
        ans += 1
    else:
        continue
print(ans)
# Judge status: Wrong Answer
import math

def prime(X):
    for i in range(2,math.ceil(math.sqrt(X))+1):
        if X % i == 0:
            return False
    return True

X = int(input())
while True:
    if prime(X):
        print(X)
        break
    X = X + 1
# Judge status: Accepted
s = input()
if s[0]==s[1] and s[1]==s[2]:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a%2==0 and b%2==0 and c%2==0:
    print(0)
else:
    print(min(a*b, b*c, c*a))
# Judge status: Accepted
import fractions
A, B = [int(_) for _ in input().split()]
print(A * B // fractions.gcd(A, B))
# Judge status: Wrong Answer
s=list(input())
s[3]="8"
print(str(s))
# Judge status: Accepted
a = list(map(int, input("").split()))
k=int(input())
m=0
if a[1] >= a[0] or a[2] >= a[0]:
    if a[2] >= a[1]:
        m=2
    else:
        m=1
for i in range(k):
    a[m]=a[m]*2
print(a[0]+a[1]+a[2])
# Judge status: Accepted
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    psum = int(i/10000) + int(i/1000)%10 + int(i/100)%10 + int(i/10)%10 + i%10
    if psum >= A and psum <= B:
        ans = ans + i
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
for i in range(21):
	if b<= a*i-(i-1):
		print(i)
		break
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
A = LI()
count = collections.Counter(A)
for i in range(N):
    print(count[i+1])
# Judge status: Accepted
def resolve():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    sub = []
    ans = []
    for i in range(N):
        sub.append(T-H[i]*0.006)
    for j in range(N):
        ans.append(abs(A-sub[j]))
    print(ans.index(min(ans))+1)
resolve()
# Judge status: Accepted
n=int(input())
a=[int(input()) for _ in range(n)]
b=[0]*(n+1)
count=0
w=1
for i in range(n):
    if b[2]:
        print(count)
        exit()
    b[a[w-1]]+=1
    w=a[w-1]
    count+=1
print("-1")
# Judge status: Accepted
a, b = map(int, input().split())

total = 1
ans = 0
while total < b:
    ans += 1
    total -= 1
    total += a

print(ans)
# Judge status: Accepted
a,b,c = sorted(map(int,input().split()))
d=str(c)+str(b)
print(a+int(d))
# Judge status: Wrong Answer
X = int(input())
if X >= 30:
    print("YES")
elif X < 30:
    print("No")
# Judge status: Wrong Answer
s=input()
if s[-1]=='s':
  print(s[:-1]+'es')
elif s[-1]!='s':
  print(s[:-1]+'s')
# Judge status: Accepted
N = int(input())
L = [0] * (N+1)
L[0] = 2
L[1] = 1
for i in range(2,N+1):
  L[i] = L[i-1] + L[i-2]
print(L[N])
# Judge status: Accepted
ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
    csf.append(tuple(ma()))
for i in range(n-1):
    ans = csf[i][1] + csf[i][0]
    for j in range(i+1,n-1):
        if ans<=csf[j][1]:
            ans =csf[j][1]+csf[j][0]
        else:
            ans = ceil(ans/csf[j][2])*csf[j][2] +csf[j][0]
    print(ans)
print(0)
# Judge status: Wrong Answer
#intの場合


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

for i in range(len(huga)):
    if huga[i] == 0:
        print(huga[i])
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]

cnt = [0]*n
for i in range(n,0,-1):
  total = sum(cnt[i*k-1] for k in range(1,n//i+1))
  if total % 2 != a[i-1]:
    cnt[i-1] = 1

b = [i+1 for i in range(n) if cnt[i] > 0]

print(sum(cnt))
print(*b)
# Judge status: Accepted
import sys
import fractions

input = sys.stdin.readline


def main():
    N = int(input())
    T = []
    for _ in range(N):
        T.append(int(input()))

    ans = 1
    for t in T:
        ans = (ans * t) // fractions.gcd(ans, t)

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
K,X=map(int,input().split())
a=[]
for i in range(0,K):
  a.append(X-i)
for j in range(1,K):
  a.append(X+j)
s=sorted(a)
print(s)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
dp = [0 for _ in range(n)]
ans = 0
for i in range(n):
    if i + a[i] < n:
        dp[i+a[i]] += 1
    if 0<= i-a[i]:
        ans += dp[i-a[i]]
# print(dp)
print(ans)
# Judge status: Accepted
k,n = map(int,raw_input().split())
a = map(int,raw_input().split())
b = []
for i in range(1,len(a)):
	b.append(a[i] - a[i-1])
b.append(min(a[-1] - a[0], k - a[-1] + a[0]))
print(k - max(b))
# Judge status: Wrong Answer
N, M = map(int, input().split())
pSs = [list(map(str, input().split())) for _ in range(M)]

#%%

ACs = [False for _ in range(N)]
WAs = [0 for _ in range(N)]

for pS in pSs:
    problem = int(pS[0]) -1
    answer = pS[1]
    if ACs[problem] == True:
        continue
    else:
        if answer == "WA":
            WAs[problem] += 1
        else:
            ACs[problem] = True

print(sum(ACs), sum(WAs))
# Judge status: Accepted
a, b ,x = map(int, input().split())
ans = 0
n_a = a//x
n_b = b//x
if a%x == 0:
    ans+=1
ans += n_b - n_a
print(ans)
# Judge status: Wrong Answer
import sys
N,M=map(int,input().split())
listSC=[]  
for k in range(M):
  s,c=map(int,input().split())
  listSC+=[[s,c]]
MAX=0  
if N==1:
  for s,c in listSC:
    MAX==(MAX,c)
  if MAX==0:
    print(0)
    sys.exit()    
for i in range(10**(N-1),10**N):
  A=list(str(i))
  for k in range(M):
    if A[listSC[k][0]-1]!=str(listSC[k][1]):
      break
    if k==M-1:
      ans=i
      print(ans)
      sys.exit()
  if i==10**N-1:
    print(-1)
# Judge status: Accepted
N = int(input())
A = int(input())

if A >= (N%500):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if np.prod(A[i:K+i]) < np.prod(A[i+1:K+i+1]):
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n < k:
  p = (n-k)*y
else:
  p = 0
  
print(k*x +p)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
final=0
for i in range(n):
  final=final^a[i]
for i in range(n):
  print(final^a[i])
# Judge status: Wrong Answer
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0]
B = [0]
for i in range(N):
  A.append(A[i] + a[i])
for i in range(M):
  B.append(B[i] + b[i])
  
ans = 0
j = M
for n in range(N + 1):
  while True:
    time = A[n] + B[j]
    if time <= K or j == 0:
      ans = max(ans, n + j)
      break
    else:
      j -= 1
print(ans)
# Judge status: Accepted

import numpy as np
N = int(input())
Nd2 = int(np.ceil(N / 2))
min_total = np.inf
for i in range(1, -~Nd2):
    n = i
    n2 = N - i
    total = 0
    dig = 10
    while n:
        a, b = divmod(n, dig)
        n = a
        total += b
    while n2:
        a, b = divmod(n2, dig)
        n2 = a
        total += b
    min_total = min(min_total, total)

print(min_total)
# Judge status: Wrong Answer
import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.floor(N/i)
  ans+=(Y*(Y+1)*i)//2
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())

# 約数列挙
def enum_div(N):
    ret = []
    for i in range(1,int(N**0.5)+1):
        if N % i == 0:
            ret.append(i)
            if i**2 != N:
                ret.append(N // i)
        i += 1
    return ret

ans = 0
for i in enum_div(M):
    if i >= N:
        ans = max(ans,M // i)

print(int(ans))
# Judge status: Accepted
# abc086_b.py
A, B = map(int,input().split())
for i in range(1000):
    if (10**len(str(B)) * A + B) == i**2:
        print('Yes')
        exit()
    
print('No')
# Judge status: Accepted
N,A,B=map(int,input().split())
res=0
for i in range(1,N+1):
    s=str(i)
    sum=0
    for j in range(len(s)):
        sum+=int(s[j])
    if(A<=sum and sum<=B):
        res+=i
print(res)
# Judge status: Wrong Answer
n = int(input())
a =[int(i)  for i in input().split()]
z = sum(a)
ans = 10**20
c = 0

for i in range(n-1):
    c += a[i]
    d = z - a[i]
    if abs(c-d) < ans:
        ans = abs(c-d)
    
print(ans)
# Judge status: Accepted
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read


n,k,*p = [int(i) for i in read().split()]


p = [(1+i) for i in p]


m = a = sum(p[:k])
for i in range(k,n):
    a += p[i]
    a -= p[i-k]
    m = max(m,a)

print(m/2)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
start = max(A, C)
end = min(B, D)

ans = max(end-start, 0)
print(ans)
# Judge status: Wrong Answer
#
A,B=map(int,input().split())
#print(A,B)

if A==B:
    print("AC")
else:
    print("WA")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)

store = 0
big = 0

for i in range (0, N-1):
	if store == 1:
		store = 0
	else:
		if A[i] == A[i+1] and big == 0:
			big = A[i]
			store = 1
		elif A[i] == A[i+1]:
			print(A[i]*big)
			exit()
            
print(0)
# Judge status: Accepted
A, B, C = input().split()
if A == B == C:
    print('No')
elif A != B and C != B and A != C:
    print('No')     
else:
    print('Yes')
# Judge status: Accepted
n,k,*a=map(int,open(0).read().split())
d=[2*k]*-~n
s=1
while k:k-=1;s=a[s-1];k%=d[s]-k;d[s]=k
print(s)
# Judge status: Accepted
K = int(input())
a = [7%K]
for i in range(1, K):
  a.append((a[i-1]*10+7)%K)

isCorrect = False
for i in range(K):
  if a[i] == 0:
    print(i+1)
    isCorrect = True
    break
if not isCorrect:
  print("-1")
# Judge status: Wrong Answer
import math
N = int(input())
x = list(map(int, input().split()))
 
t = 0
min = 0

for i in range(0,N-1):
     t += x[i]/N

s = math.floor(t)
print(s)
for i in range(0,N-1):
    min += (x[i] - s) **2

print(min)
# Judge status: Accepted
if __name__ == '__main__':
  x = int(input())
  if (x == 3) or (x == 5) or (x == 7):
    print("YES")
  else:
    print("NO")
# Judge status: Wrong Answer
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 for i in range(int(input1[0]))]
root =  [input().rstrip().split(" ") for i in range(int(input1[1]))]
for i in range(int(input1[1])):
    a=int(root[i][0])-1
    b=int(root[i][1])-1
    if h[a]> h[b]:
        yoi[b] = 0
    elif h[a] < h[b]:
        yoi[a] = 0
    else:
        yoi[a] = 0
        yoi[b] = 0
print (sum(yoi))
# Judge status: Accepted
a,b,k=map(int,input().split())
n=a*b+1
ans=[0]*n
for i in range(a+1):
    for j in range(b+1):
        ans[a*j+b*i-2*i*j]=1
print("Yes" if ans[k] else "No")
# Judge status: Wrong Answer
s = input()
if s[5] != 1 and int(s[6]) >=4:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
import bisect
from collections import deque
N = int(input())
ans = deque()

for _ in range(N):
    a = int(input())
    ind = bisect.bisect_left(ans, a)
    if ind == 0:
        ans.appendleft(a)
    else:
        ans[ind-1] = a
print(len(ans))
# Judge status: Accepted
N = int(input())

ranges = [tuple(map(int,input().split())) for _ in range(N)]
A = sorted(a for a,b in ranges)
B = sorted(b for a,b in ranges)
if N % 2 == 0:
    a = A[N//2-1]+A[N//2]
    b = B[N//2-1]+B[N//2]
    print(b-a+1)
else:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)
# Judge status: Accepted
#!/usr/bin/env python3
(n, ), *s = [[*map(int, i.split())] for i in open(0)]
c = 0
for a, b in reversed(s):
    q = (a + c) % b
    c += b * (q > 0) - q
print(c)
# Judge status: Accepted
import itertools
n=int(input())
a=list(map(int,input().split()))
cumsum=[0]+list(itertools.accumulate(a))
sum_num=sum(a)
ans=10**100
for i in range(1,n):
    yen=abs(cumsum[i]-(sum_num-cumsum[i]))
    if yen<ans:
        ans=yen
print(ans)
# Judge status: Wrong Answer
x, y = map(int, input().split())
a = x + y/2
print(a)
# Judge status: Wrong Answer
n=int(input())
if n >= 30:
  print('yes')
else:
   print('No')
# Judge status: Wrong Answer
N = int(input())
N = list(str(N))
N = tuple(map(int, N))

ans = 0
flag = False
flag5 = False
for i, x in enumerate(reversed(N)):
    x = N[i]
    if flag or (flag5 and x >= 5):
        x += 1
    flag5 = False
    flag = False
    if x > 5:
        ans += (10 - x)
        flag = True
        if i == 0:
            ans += 1
    else:
        ans += x
    if x == 5:
        flag5 = True
print(ans)
# Judge status: Accepted
N = int(input())
S = set()
for i in range(N):
	S.add(input())
print(len(S))
# Judge status: Accepted
N, K = map(int, input().split())
As = list(map(int, input().split()))

lastVisit = [None] * N
now = 0
n = 0
while lastVisit[now] is None:
    lastVisit[now] = n
    now = As[now]-1
    n += 1
    if n == K:
        print(now+1)
        exit()

for _ in range((K-lastVisit[now]) % (n-lastVisit[now])):
    now = As[now]-1
print(now+1)
# Judge status: Accepted
s = sorted(list(input()))

for i in range(97, 97 + 26):
  if s.count(chr(i)) %2 != 0:
    print('No')
    exit()

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

print(((1+n)*n)//2)
# Judge status: Wrong Answer
x=int(input())
if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1899:
    print(1)
# Judge status: Wrong Answer
n = int(input())
li = list(map(int, input().split()))

li.sort(reverse=True)

check = -1
flag = 0
ans = []

for i in li:
    if len(ans) == 2:
        break
    
    if flag == 0:
        check = i
        flag = 1
        continue
    
    if check == i:
        ans.append(i)
        flag = 0
    else:
        flag = 0

if len(ans) < 2:
    print(0)
else:
    print(ans[0] * ans[1])
# 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():
    n = I()
    k = I()
    x = I()
    y = I()
    if n <= k:
        print(n*x)
    else:
        print(k*x + (n-k)*y)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c = map(int,input().split())

if (a == b and a != c) or (b == c and b != a) or (c == a and c != b) :
  print('Yes')
else :
  print('No')
# Judge status: Wrong Answer
w, a, b = map(int, input().split())

if b + w >= w + a >= b:
    print(0)
elif a + w < b:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
# Judge status: Wrong Answer
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
m = h[0]
ans = 0

for i in range(1, n):
    num = abs(a-(t-h[i]*0.006))
    if num < m:
        ans = i
        m = num

print(ans+1)
# Judge status: Wrong Answer
x = int(input())
d = x%100
c = 0
for i in [6,5,4,3,2,1]:
    c += d//i
    d = d%i
if c*100 + x%100 > x:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
n, m = input().strip().split()
if(n<m):
  for i in range(int(m)-1):
    print(n)
else:
  for i in range(int(n)-1):
    print(m)
# Judge status: Accepted
S,T = input().split()
print(T + S)
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

if a > k:
  print(str(a-k) + ' ' + str(b))
elif a <= k:
  print(str(0) +  ' ' + str(a + b -k))
# Judge status: Accepted
x, a, b = map(int, input().split())

if b-a <= 0:
    print('delicious')
elif 0 < b-a <= x:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
def inverse(n: int, mod: int) -> int:
    return pow(n, mod - 2, mod)

def cmb(n: int, m: int, mod) -> int:
    p, q = 1, 1
    for i in range(m):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * inverse(q, mod) % mod

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1
ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)
print(ans % mod)
# Judge status: Accepted
k = int(input())
s = input()

if len(s) > k:
	print(s[:k] + '...')
else:
	print(s)
# Judge status: Wrong Answer
S = input()
K = int(input())

if S[0] != 1:
  print(S[0])
else:
  print(1)
# Judge status: Wrong Answer
t = input()
rain = 0
for i in t:
  if i == 'R':
    rain +=1
print(rain)
# Judge status: Wrong Answer
from sys import stdin
N,R = [int(x) for x in stdin.readline().rstrip().split()]
print(R - (100*(10-N)))
# Judge status: Accepted
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]

    zorome_count = 0
    for d in D:
        if d[0] == d[1]:
            zorome_count += 1
        else:
            zorome_count = 0
        if zorome_count == 3:
            break

    print('Yes' if zorome_count == 3 else 'No')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
A,B=map(int,input().split())

if A>0:
  print('Positive')
elif A==0 or B==0:
  print(0)
elif A<0 and 0<B:
  print(0)
else:
  if A==B:
    print('Negative')
  elif (B-A)%2==0:
    print('Negative')
  else:
    print('Positive')
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

scoreMap = {'r': P, 'p': S, 's': R}

score = 0
for i in range(0, K):
  a, b = scoreMap[T[i]], 0
  for j in range(i+K, N, K):
    na = b + scoreMap[T[j]]
    if T[j] != T[j-K]:
      na = max(na, a + scoreMap[T[j]])
    nb = max(a, b)
    a, b = na, nb
  score += max(a, b)
print(score)
# Judge status: Wrong Answer
N=int(input())
S=N%1000
print(1000-S)
# Judge status: Accepted
*s, = input()

ans = []
for _s in s:
    if _s == "0":
        ans.append("0")
    elif _s == "1":
        ans.append("1")
    elif _s == "B" and 0 < len(ans):
        ans.pop()

print("".join(ans))
# Judge status: Wrong Answer
n = int(input())
min_sum = 99999999999999
for i in range (1, n - 1):
  first = i
  second = n - i
  first_sum = 0
  second_sum = 0
  while first > 0 :
    last_digit_first = first % 10
    first = first // 10
    first_sum += last_digit_first
    
  while second > 0 :
    last_digit_second = second % 10
    second = second // 10
    second_sum += last_digit_second
  
  if first_sum + second_sum <= min_sum :
    min_sum = first_sum + second_sum
print(min_sum)
# Judge status: Accepted
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    A = sorted(list(map(lambda x: A[x] - (x + 1), range(n))))
    b = A[n // 2]
    print(sum(list(map(lambda x: abs(x - b), A))))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c=(int(x)for x in input().split())

if a<=c<=b:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = []
flg = True
for a in A:
  i = 0
  while flg:
    if a % 2 ** i == 0:
      i += 1
    else:
      B.append(i)
      flg = False
B.sort()
print(B[0])
# Judge status: Accepted
N, K = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]

ab.sort()

id = 0
for a, b in ab:
    if id + b >= K:
        print(a)
        break
    else:
        id += b
# Judge status: Accepted
input()
A=list(map(int,input().split()))
print("APPROVED" if all(a%2!=0 or a%3==0 or a%5==0 for a in A) else "DENIED")
# Judge status: Accepted
from collections import Counter


n = int(input())
s = []
for i in range(n):
    a = list(input())
    s.append("".join(sorted(a)))

c = Counter(s)
ans = 0

for i in c.values():
    ans += i*(i-1)//2

print(ans)
# Judge status: Wrong Answer
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.append(X)
# y.append(Y)
x.sort()
y.sort()

if x[-1] >= y[0]:
    print("War")
else:
    print("No War")
# Judge status: Wrong Answer
S = input()
mod_list = [str(i * 2019) for i in range(1, 100)]

count = 0
for s in mod_list:
    ps = 0
    while True:
        temp = S[ps:].find(s)

        if temp == -1:
            break
        else:
            ps += temp + len(s) - 1
            count += 1


print(count)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())
print(max(a,b,c)*(2**k-1)+a+b+c)
# Judge status: Wrong Answer
def main():
    import fractions
    import math
    A, B = map(int, input().split())

    gcd = fractions.gcd(A, B)

    tmp = gcd
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 2):
        if tmp % i == 0:
            while(tmp % i == 0):
                tmp = tmp//i
            primes.add(i)
    if len(primes) == 0 and gcd != 1:
        primes.add(gcd)
    print(len(primes) + 1)


main()
# Judge status: Wrong Answer
a,b,c=map(int,input().split())

d=a%b
if d!=0:
  if c%d==0:
    frag="YES"
  else:
    frag="NO"
else:
  frag="NO"
print(frag)
# Judge status: Accepted
import numpy as np

N = int(input())
T,A = np.array(list(map(int,input().split())))
H = np.array(list(map(int,input().split())))

ave = T-H*0.006
dif = abs(ave - A)

print(np.where(min(dif) == dif)[0][0]+1)
# Judge status: Wrong Answer
N, M = map(int,input().split())
r = 1
l = N
for i in range(M):
    print(r,l)
    r += 1
    l -= 1
# Judge status: Wrong Answer
S = list(input())
T = list(input())
S.sort()
T.sort()

print('Yes' if S == T else 'No')
# Judge status: Wrong Answer
n = int(input())
r = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
  r[i] = [r[i][0] - r[i][1], r[i][0] + r[i][1]]
r.sort(key = lambda x:x[1])
print(r)
cur = -1001001001
ans = 0
for i in range(n):
  if cur <= r[i][0]:
    ans += 1
    cur = r[i][1]
print(ans)
# Judge status: Accepted
from collections import Counter
s=sorted(Counter(input()).values())
t=sorted(Counter(input()).values())
print("Yes" if s==t else "No")
# Judge status: Wrong Answer
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    tmp=A[x-1]+B[y-1]+c
    ans=min(ans,tmp)
print(ans)
# Judge status: Accepted
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split(" "))
    A.append(a)
    B.append(b)

ans = 0
added = 0
for a, b in zip(A[::-1], B[::-1]):
    if (a + added) % b != 0:
        ans += b - (a + added) % b
        added += b - (a + added) % b
print(ans)
# Judge status: Accepted
import numpy as np
from numba import njit

@njit
def update(a):
  n = len(a)
  b = np.zeros_like(a)
  for i,x in enumerate(a):
    l = max(0, i-x)
    r = min(n-1, i+x)
    b[l] += 1
    if r+1 < n:
      b[r+1] -= 1
  b = np.cumsum(b)
  return b

n,k = map(int, input().split())
a = np.array(list(map(int, input().split())))

for _ in range(k):
  a = update(a)
  if np.all(a==n):
    break
    
print(' '.join(map(str, a)))
# Judge status: Wrong Answer
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]

    dp = [[0] * (w + 1) for _ in range(n + 1)]

    for i in range(n):
        for j in range(w + 1):
            if j < goods[i][0] + 1:
                dp[i + 1][j] = dp[i][j]

            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - goods[i][0] + 1] + goods[i][1])

    print(dp[n][w])
    
resolve()