peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a,b = S()
num = int(a+b)
for i in range(1,1000):
    if i**2 == num:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
n,m = map(int,input().split())
canred = set()
canred.add(1)
balls = [1 for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    if x in canred:
        canred.add(y)
    balls[x-1]-=1
    balls[y-1] += 1
    if balls[x-1] == 0:
        canred.discard(x)


print(len(canred))
# Judge status: Accepted
s = input()
ss = s.split("/")
if int(ss[1]) < 5:
	print ("Heisei")
else:
	print ("TBD")
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())
c = 0
while A >= B:
  B *= 2
  c += 1
while B >= C:
  C *= 2
  c += 1
print("Yes" if c<=K else "No")
# Judge status: Wrong Answer
s = input()

if s=='AAA' or s == 'BBB':
    print('NO')
else:
    print('YES')
# Judge status: Wrong Answer
import numpy as np
n,m,k=map(int,input().split())
A=[0]+list(map(int, input().split()))
B=[0]+list(map(int, input().split()))
ans=0
a=np.cumsum(np.array(A)).tolist()
b=np.cumsum(np.array(B)).tolist()
for i in range(n+1):
    if k<a[i]:
        break
    j=m
    while b[j]>k-a[i]:
        j-=1
        ans=max(ans,i+j)
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
Ans = list(map(int, input().split()))
Ans = Ans[1:]
Ans = set(Ans)

for _ in range(N-1):
    A = list(map(int, input().split()))
    A = set(A[1:])
    Ans = Ans & A
print(len(Ans))
# Judge status: Accepted
K,S = list(map(int,input().split()))

ans = 0
for x in range(K+1):
    for y in range(K+1):
        z=S-x-y
        if z <= K and z >= 0:
            ans+=1
#             print(x,y,z)
print(ans)
# Judge status: Wrong Answer
n = int(input())
d = sorted(list(map(int, input().split())))
h = int(len(d) / 2)
ans = 0

if d[h-1] != d[h]:
    if d[h-2] != d[h-1] or d[h] != d[h+1]:
        ans = d[h] - d[h-1]

print(ans)
# Judge status: Accepted
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush


# T = int(stdin.readline())
# for i in range(T):
    #N=int(stdin.readline())
N,K=list(map(int,stdin.readline().split()))
vis=set()
for k in range(K):
    dk=int(stdin.readline())
    ar=list(map(int,stdin.readline().split()))    
    for sn in ar:
        vis.add(sn)

print(N-len(vis))
# Judge status: Accepted
a,b,c,d=map(int,input().split())
import fractions
lcm=c*d//fractions .gcd(c,d)
C=b//c-(a-1)//c
D=b//d-(a-1)//d
CD=b//lcm-(a-1)//lcm
al=b-a+1
print(al-C-D+CD)
# Judge status: Accepted
S = list(str(input()))
T = list(str(input()))

if S == T[:-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
l = []
if n == 0:
    l.append(2)
elif n == 1:
    l.append(1)
elif n >= 2:
    l = [2, 1]
    for i in range(2, n+1):
        l.append(l[i-2]+l[i-1])
print(l[-1])
# Judge status: Accepted
# p,q,rに時間を整数で入力
p,q,r = map(int,input().split())
# それぞれ要する時間のリストを作成
time = [p,q,r]
# 各時間の合計値から、地点間の最大の時間数を引く
print(sum(time)-max(time))
# Judge status: Wrong Answer
d=int(input())
if d==22:
    print('Christmas Eve Eve Eve')
elif d==23:
    print('Christmas Eve Eve')
elif d==24:
    print('Christams Eve')
else:
    print('Christams')
# Judge status: Accepted
s = input()
if    1 <=int(s[0:2]) <= 12 and 1<= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
elif  1<= int(s[2:4]) <= 12:
    print("YYMM")
elif  1<= int(s[0:2]) <= 12:
    print("MMYY")
else :
    print("NA")
# Judge status: Accepted
x=int(input())
if x==3 or x==5 or x==7:print('YES')
else:print('NO')
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
candidates = [i for i in range((A+B+C)%3*2+(A+B+C),151,6)]
for i in candidates:
    x = i/3
    if A<= x and B<= x and C<=x and ((x-A)+(x-B)+(x-C))%2==0:
        print(int((i-(A+B+C))/2))
        break
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(43):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    t = 0
    for i in range(N):
        t += S[i]
        A[i] = t
print(*A)
# Judge status: Wrong Answer
N = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(1, N+1):
    if i == p[1]:
        c += 1
if c == 0 or c == 2:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
x,y=map(int,input().split())
n=1
while 2**n<=y/x:
  n+=1
print(n)
# Judge status: Wrong Answer
N = int(input())

count_dic = {}
for i in range(N+1):
    i_tmp = i
    count = 0
    while True:
        if i == 0:
            break
        elif i_tmp % 2 == 0:
            i_tmp = i_tmp / 2
            count += 1
        else:
            break
    count_dic[i] = count

print(max(count_dic, key=count_dic.get))
# Judge status: Accepted
s = input()
x = s.count("0")
print(2 * min(x, len(s) - x))
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        ans.append(res)
        res = 0
        nh = h[i]
ans.append(res)
print(max(ans))
# Judge status: Wrong Answer
lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k = int(input())
index = 0
while True:
	if len(lun_luns) >= k:
		break
	num = lun_luns[index]
	mod = num % 10
	n = num * 10
	if mod == 9:
		lun_luns.extend([n+mod-1, n+mod])
	else:
		lun_luns.extend([n+mod-1, n+mod, n+mod+1])
	index += 1
print(lun_luns[k-1])
# Judge status: Wrong Answer
import bisect
from collections import deque
def LIS(a):
    lis = deque()
    lis.append(-1)
    for i in range(len(a)):
        index = bisect.bisect_left(lis,a[i])
        if i == 0:
            lis.appendleft(a[i])
        else:
            lis[index-1] = a[i]
    return len(lis)

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(LIS(a))

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

s = sum(A)
if s >= H: print('Yes')
else: print('No')
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    print(S[:3])

if __name__ == '__main__':
    main()
# Judge status: Accepted
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from operator import xor
from functools import reduce

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = list(it)
    x1 = reduce(xor, A)

    print(*map(lambda x: x ^ x1, A))


if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
a,b=input().split()
c = int(a+b)
for i in range(1, 101):
  if c == i*i:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
S=int(input())

MOD = 10 ** 9 + 7

if S <= 2:
  print('0')
  exit(0)
elif 3 <= S <= 5:
  print('1')
  exit(0)

s = [0] * (S+1)
s[1] = 0
s[2] = 0
s[3] = 1
s[4] = 1
s[5] = 1


def calc(n):
  tmp = 0
  for i in range(n-3,2,-1):
    tmp += s[i]%MOD
  return tmp+1

result = 0
for i in range(5,S+1):
  s[i] = calc(i)
  
print(s[S]%MOD)
# Judge status: Accepted
N = int(input())
count = 0
from math import sqrt
for i in range(1,N+1)[::-1]:
    if i%2==1:
        yakusu = 0
        for j in range(1,i+1):
            if i%j==0:
                yakusu += 1
        
        if yakusu == 8:
            count += 1
print(count)
# Judge status: Wrong Answer
x,y=map(int,input().split())
if(x%y==0 or y%x==0):
    print('-1')
else:
    for i in range(1, 1000000):
        if(x*i%y != 0):
            print(x*i)
            break
# Judge status: Accepted
import collections

N=int(input())
X=list(map(int, input().split()))
c = collections.Counter(X)

for A in range(1,N+1):
  print(c[A])
# Judge status: Accepted
x, a, b = list(map(int, input().split()))
if b-a<=x:
  if a-b>=0:
  	print('delicious')
  else:
    print('safe')
else:
  print('dangerous')
# Judge status: Wrong Answer
from collections import Counter
import sys

X = int(input())
num = []

if X == 1:
    print(1)
    sys.exit()

for j in range(1, X):
    tmp = j + 1
    lis = []
    while tmp != 1:
        for i in range(2, tmp+1):
            if tmp % i == 0:
                lis.append(i)
                tmp = tmp // i
                break
    if len(Counter(lis)) == 1 and len(lis) > 1:
        num.append(j+1)

print(max(num))
# Judge status: Accepted
N, M = map(int, input().split())
graph = dict(zip(
    list (range(1, N+1)),
    [set() for i in range(N)]
))
height=list(map(int, input().split()))

for i in range(M):
    src, dest = map(int, input().split())
    graph[src].add(dest)
    graph[dest].add(src)


count = 0
for currNode in graph:
    flag = True
    for node in graph[currNode]:
        if height[currNode-1] <= height[node-1]:
            flag = False
    
    if flag:
        count += 1


print(count)
# Judge status: Wrong Answer
a = list(map(int, input().split()))

for i in range(len(a)):
  if a[i] == 0:
    print(i)
    break
# Judge status: Accepted
# -*- coding: utf-8 -*-

N = int(input())
P = [int(i) for i in input().split()]

# 最小の値を記録していく
minimum = P[0]
count = 0

for p in P:
    if p <= minimum:
        count += 1
        minimum = p

print(count)
# Judge status: Wrong Answer
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i in range(N-2):
    for j in range(i+1,N-1):
        left = bisect.bisect_right(l_new,abs(l_new[i]-l_new[j]))
        right = bisect.bisect_left(l_new,l_new[i] + l_new[j])
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
print(count//3)
# Judge status: Accepted
# input
K, X = map(int, input().split())
R_max = -(10 ** 6)
L_max = 10 ** 6

# check
result = [X]
for R, L in zip(range(K - 1, -1, -1), range(0, K, 1)):
    result += [X - r for r in range(1, R + 1) if X - r >= R_max and X - r not in result]
    result += [X + l for l in range(1, L + 1) if X + l <= L_max and X + l not in result]

# output
result.sort()
op = ""
for res in result:
    op += str(res)
    op += " "

print(op[:-1])
# Judge status: Accepted
A, B, C = map(int, input().split())
x = max(A, B, C)
y = min(A, B, C)
z = A+B+C-(x+y)
if x % 2 == 0:
    ans = 0
else:
    ans = y*z
print(ans)
# Judge status: Wrong Answer
s = input()
s = list(s)
streak = 0
max_streak = 0
for i in s:
  if s == "R":
    streak += 1
    max_streak = max(streak, max_streak)
  else:
    streak = 0
print(streak)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
ans = 100

for i in range(n-1):
    if abs(sum(l[:i+1]) - sum(l[i+1:])) < ans:
        ans = abs(sum(l[:i+1]) - sum(l[i+1:]))
print(ans)
# Judge status: Accepted
s = input()

s_1=s[:((len(s)-1)//2)]
s_2=s[((len(s)+3)//2)-1:]
#print(s_1)
#print(s_2)

flag = True

for a in range(len(s)//2):
    if s[a] != s[-(a+1)]:
        flag =False

for a in range(len(s_1)//2):
    if s_1[a] != s_1[-(a+1)]:
        flag =False

for a in range(len(s_2)//2):
    if s_2[a] != s_2[-(a+1)]:
        flag =False

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = str(input())
if len(n) <= 2:
    print(0)
else:
    a = n[0:-2]
    tens = int(n[-2])
    need = tens*2
    ones = int(n[-1])
    if ones == 0:
        need +=0
    elif ones <= 5:
        need += 1
    else:
        need +=2
    if need <= int(a):
        print(1)
    else:
        print(0)
# Judge status: Wrong Answer
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]
dp = [10**9]*(2*10**4+1)

for h in range(H):
    for i in range(N):
        if h != 0:
            dp[h+A[i]] = min(dp[h+A[i]],dp[h]+B[i])
        else:
            dp[A[i]] = min(dp[A[i]],B[i])

ans = 10**9
for i in range(H,2*H+1):
    ans = min(ans,dp[i])

print(ans)
# Judge status: Accepted
N = int(input())
s = input()
t = input()

for i in range(0, 101):
    temp = s[:i] + t
    if temp[:N] == s:
        print(N + i)
        break
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
r, cnt = 1, 0
for i in a:
    if r == i:
        r += 1
    else:
        cnt += 1

print(cnt) if a.count(1) else print(-1)
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
s=sorted(x)
p,q=s[n//2-1],s[n//2]
for i in x:
  if i<=p:
    print(q)
  else:
    print(p)
# Judge status: Accepted
N = int(input())

if N % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math

a,b,c,k=map(int,input().split())

if k<=a+b:
    print(a)
    exit()
print(a-(k-a-b))
# Judge status: Accepted
n,k=map(int,input().split())
ps=sorted(list(map(int,input().split())))
print(sum(ps[:k]))
# Judge status: Accepted
import numpy
a,b,x=map(int,input().split())
V=a*a*b
if x<=V/2:
    y=2*x/b/a
    theta=numpy.arctan(b/y)
    print(theta*360/2/numpy.pi)
else:
    x=V-x
    y=2*x/a/a
    theta=numpy.arctan(y/a)
    print(theta*360/2/numpy.pi)
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))

p_sorted = sorted(p)

is_changed = [0 if x==y else 1 for x,y in zip(p, p_sorted)]

if sum(is_changed) <= 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(0, N):
    w = wv[i][0]
    v = wv[i][1]
    for j in range(W + 1):
        if j - w >= 0:
            dpp = dp[i][j - w] + v
            dp[i + 1][j] = max(dp[i + 1][j], dpp)    
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(max(dp[-1]))
# Judge status: Wrong Answer
def main():
    N = int(input())
    A = list(map(int, input().split()))
    perfect = [2**n for n in range(N+1)]
    for n in range(N):
        if perfect[n] <= A[n]:
            print(-1)
            break
        remain = N - n
        deleted = [2**(i+1) for i in range(remain)]
        for i in range(remain):
            perfect[n+i+1] -= deleted[i]*A[n]
    else:
        print(sum(perfect))
main()
# Judge status: Wrong Answer
n,c,k = map(int,input().split())
t = list(int(input()) for i in range(n))
t.sort()

bus = 1
leave = t[0] + k
temp = 1
ans = 0

for i in range(1,n):
    if temp == 0 or leave < t[i]:
        ans += 1
        temp = 1
        leave = t[i] + k
    else:
        bus += 1

print(ans+1)
# Judge status: Accepted
a,b,c = map(int,input().split())
m1 = max(a,b,c)
m3 = min(a,b,c)
m2 = a+b+c-m1-m3
m = m2-m3
n = m1-m2
if m%2 == 0:
  print((m+2*n)//2)
else:
  print((m+2*n+3)//2)
# Judge status: Accepted
N=int(input())
A=int(input())

if (N%500) <=A:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math

r = int(input())

l = (r*2) * math.pi

print(l)
# Judge status: Accepted
N, K = map(int,input().split())
A = 0
A = N % K
print(min(A, K - A))
# Judge status: Wrong Answer
s = list(input())
ans = 'NA'
if 12 < int(s[0]+s[1]):
    if 1<=int(s[2]+s[3]) and int(s[2]+s[3])<=12:
        ans = 'YYMM'
else:
    if 1<=int(s[0]+s[1]) and int(s[0]+s[1])<=12:
        ans = 'AMBIGUOUS'
print(ans)
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X, Y = map(int, readline().split())
    if X % Y == 0:
        print('-1')
    else:
        print(X)


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


x = 0
for a in A:
    x ^= a
ans = [x ^ a for a in A]

print(*ans)
# Judge status: Accepted
a=list(map(int,input().split()))
a.sort()
if a[0]+a[1]==a[2]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
from collections import defaultdict

s, t = sys.stdin.read().split()
n = len(s)

def main():
    correspondence = defaultdict(str)
    for i in range(n):
        if not correspondence[s[i]]:
            correspondence[s[i]] = t[i]
        else:
            if correspondence[s[i]] != t[i]:
                return 'No'

    v = correspondence.values()
    return 'Yes' if len(v) == len(set(v)) else 'No'
    
if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    L = []
    for i in range(N):
        xi, li = map(int, input().split())
        s = xi - li
        f = xi + li
        L.append((f, s))
    
    L.sort()

    ans = 0
    finish = -float("inf")
    for i in L:
        if finish <= i[1]:
            ans += 1
            finish = i[0] 

    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N,K=map(int, input().split())
ans=0
mod=10**9+7
for i in range(K,N+2):
    if i==K:
        MIN=sum(list(range(0,K)))%mod
        MAX=sum(list(range(N,N-K,-1)))%mod
    else:
        MIN+=(i-1)%mod
        MAX+=(N+1-i)%mod
    ans+=(MAX-MIN+1)%mod
    ans%=mod

print(ans)
# Judge status: Accepted
N , M = (map(int , input().split()))
tree = []
for i in range(N):
    tree.append(int(input()))
sort_tree = sorted(tree)
print(min([sort_tree[i+M-1] - sort_tree[i] for i in range(N-M+1)]))
# Judge status: Wrong Answer
n=int(input())
m=n
for i in range(1,n):
  m=n*i
  continue
print(m%(10**9+7))
# Judge status: Wrong Answer
table = list(map(int, input()))
diff_nagomi = 1000
for i in range(len(table)-2):
    diff = table[i] * 100 + table[i + 1] * 10 + table[i + 2] - 753
    if diff_nagomi > diff:
        ans = diff
print(abs(ans))
# Judge status: Wrong Answer
K,X=list(map(int,input().split(' ')))
if X>=K*500:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
_min = min(X)
_max = max(X)
_sum = 1000000000
for i in range(_min, _max+1):
    temp = 0
    for x in X:
        temp += (x - i) * (x - i)
    if temp < _sum:
        _sum = temp
print(_sum)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())

s = input()

if s.find('##',a,max(c, d)) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-2,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')
# Judge status: Accepted
N = int(input())

count = 0
for n in range(1, N+1):
  if (len(str(n)) % 2 == 1):
    count += 1

print(count)
# Judge status: Wrong Answer
def main():
    n = int(input())
    ans = 0

    e = 1
    for fac in (2, *(x * 2 + 3 for x in range(1000))):
        while n % (div := pow(fac, e)) == 0:
            n //= div
            ans += 1
            e += 1

        while n % fac == 0:
            n //= fac

        if fac * 3 > n:
            break
        e = 1

    if n != 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
m = 10 ** 9 + 7
def cmb(x,y):
    r=1
    for i in range(1,y+1):
        r=(r*(x-i+1)*pow(i,m-2,m))%m
    return r

x, y = map(int, input().split())
if (2 * x - y) % 3 == 0 and (2 * y - x) % 3 == 0:
    print(cmb(int((x + y) / 3), int((2 * y - x) / 3)))
else:
    print(0)
# Judge status: Wrong Answer
N, M, Q = map(int, input().split())
X = []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    X.append((a, b, c, d))

def calc(L):
    s = 0
    for a, b, c, d in X:
        if L[b] - L[a] == c: s += d
    return s

def rec(L):
    if len(L) == N + 1:
        return calc(L)
    ma = 0
    for i in range(L[-1], M+1):
        ma = max(ma, rec(L + [i]))
    return ma

print(rec([0]))
# Judge status: Accepted
N=int(input())
*A, = map(int,input().split())

if N==0 and A[0] == 1:
    print(1)
    exit()
if A[0] != 0:
    print(-1)
    exit()

INF = 1e18
B = [1]*(N+1)
for i,a in enumerate(A[1:],1):
    B[i] = min(INF,B[i-1]*2 - a)

ans = 0
p = 0
for i,a in enumerate(A[::-1]):
    i = N - i
    m = B[i]
    if p>2*m:
        ans = -1
        break
    p = min(m,p)+a
    ans += p

print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
list = [a, b, c]
list.sort()
if list[0] + list[1]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = int(input())

lis = list()

while True:
    if (s % 2) == 0:
        s = s / 2
        if s in lis:
            break
        lis.append(int(s))
    else:
        s = 3*s + 1
        if s in lis:
            break
        lis.append(int(s))

print(len(lis)+2)
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

dp = [0] * (n)

for i in range(n):
    if t[i] == "r":
        dp[i] = p
    elif t[i] == "s":
        dp[i] = r
    elif t[i] == "p":
        dp[i] = s

    if k <= i:
        if dp[i] == dp[i-k]:
            dp[i] = 0

print(sum(dp))
# Judge status: Accepted
from math import ceil
n,h = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
max_a = max([lst[i][0] for i in range(n)])
b = sorted(lst[i][1] for i in range(n))+[0]
for i in range(n-1,-1,-1):
    b[i] += b[i+1]
ans = 10**10
for i in range(n+1):
    hp = h-b[i]
    t = max(0, ceil(hp/max_a))
    t += n-i
    ans = min(ans, t)
print(ans)
# Judge status: Accepted
from math import gcd

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


for i in range(n-1):
  a[i+1] = gcd(a[i], a[i+1])
  
print(a[n-1])
# Judge status: Accepted
n=int(input())
t,a=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]

avg = [abs(t-hi*0.006-a) for hi in h]

print(avg.index(min(avg))+1)
# Judge status: Accepted
# H, N = [int(i) for i in input().split()]
X = int(input())
if X >= 30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-
n,k,s = map(int, input().split())

if s==10**9:
    ans = [s]*k + [1]*(n-k)
else:
    ans = [s]*k + [10**9]*(n-k)

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

m_a = []
m_b = []
for i in range(m):
  m_a_tmp, m_b_tmp = map(int, input().split())
  m_a.append(m_a_tmp)
  m_b.append(m_b_tmp)

n_n = [0 for i in range(n)]

for a,b in zip(m_a, m_b):
  n_n[a-1] += 1
  n_n[b-1] += 1

for n in n_n:
  print(n)
# Judge status: Accepted
time = list(map(int,input().split()))

time.sort()

print(time[0]+time[1])
# Judge status: Wrong Answer
s = input()
if s.count('N') == s.count('S'):
    if s.count('W') == s.count('E'):
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
import bisect
n = int(input())
*l, = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        bc = l[i]+l[j]
        ans += bisect.bisect_left(l, bc)-(j+1)

print(ans)
# Judge status: Wrong Answer
n,k,x,y=[int(input()) for _ in range(4)]
print(x*k+x*max(0,n-k))
# Judge status: Accepted
import math
N = int(input())
if N == 0:
    print(0)
    exit()
ans = ""
while N != 1:
    if N % 2 == 0:
        N //= (-2)
        ans = "0" + ans
    else:
        if N > 0:
            N //= (-2)
            N += 1
            ans = "1" + ans
        else:
            N //= (-2)
            N += 1
            ans = "1" + ans
ans = "1" + ans    
print(ans)
# Judge status: Wrong Answer
n=int(input())
p=list(map(int,input().split()))
c=0
min=2*10**5
for i in range(n):
    if (p[i]<min):
        c=c+1
    if p[i]<min:
        min=p[i]
print(c)
# Judge status: Wrong Answer
#093_A
s=input()
print('Yes' if len(set(s)) else 'No')
# Judge status: Wrong Answer
n = int(input())
a = map(int, input().split())

zero = False
minus = 0
min = -999999999999999
sum = 0
for i in a:
    if i == 0:
        zero = True
    if i < 0:
        minus += 1
        min = max(min, i)
    sum += abs(i)

if not zero and minus % 2 != 0:
    sum += min * 2

print(sum)
# Judge status: Accepted
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[(int(n/2))] - d[int(n/2)-1])
# Judge status: Accepted
n=int(input())
li = list(map(int,input().split()))

li.sort()
li.reverse()
ans=0

for (i,c)in zip(range(0,n),li):
  if i%2==0:
    ans+=c
  else:
    ans-=c

print(ans)