peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

qualified = 0
qualified_foreign = 0.
for s in S:
    if s == 'c':
        print('No')
    elif s == 'a':
        if qualified < A + B:
            print('Yes')
            qualified += 1
        else:
            print('No')
    else:
        if (qualified < A + B) & (qualified_foreign < B):
            print('Yes')
            qualified += 1
            qualified_foreign += 1
        else:
            print('No')
# Judge status: Accepted
N,K,Q = map(int,input().split())
A = {}
for i in range(1,N+1):
    A[i] = 0
for i in range(Q):
    item = int(input())
    A[item] += 1
for i in range(N):
    if Q - A[i+1] >= K:
        print("No")
    else:
        print("Yes")
# Judge status: Wrong Answer
n = int(input())
a = [input() for _ in range(n)]

max_1st = sorted(a)[-1]
max_2nd = sorted(a)[-2]
for i in range(n):
    if a[i] == max_1st:
        print(max_2nd)
    else:
        print(max_1st)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[2,1]
    for i in range(85):
        l.append(l[-2]+l[-1])
    print(l[n])
resolve()
# Judge status: Accepted
N,M=map(int,input().split())
D=[]
for i in range(1,int(M**0.5+1)):
  if M%i==0:
    D.append(i)
    D.append(M//i)
D.sort()
for j in D:
  if j >=N:
    print(M//j)
    exit()
# Judge status: Accepted
a, b, c = map(int, input().split())

if b - a == c - b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import math
h = int(input())
tmp = int(math.log2(h))
print(2**(tmp+1)-1)
# Judge status: Accepted
# coding: utf-8
# Your code here!
 
S,T = [i for i in input().split()]
A,B = [int(i) for i in input().split()]
U = input()

if S == U:
    A-=1
else:
    B-=1
print(A,B)
# Judge status: Accepted
n,k = map(int,input().split())
s = input()
happy = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        happy += 1
print(min(happy+k*2,n-1))
# Judge status: Wrong Answer
N = int(input())
p = list(map(int,input().split()))

s_p = sorted(p)

cnt = 0
for i in range(N):
    if p[i] != s_p[i]:
        cnt += 1

if cnt//2 > 1:
    print("NO")
else:
    print("YES")
# Judge status: Wrong Answer
a, b = map(int,input().split())

if a < b:
  print(a-1)
else:
  print(a)
# Judge status: Accepted
a, b = map(int, input().split())

if (a+b)%2 == 1:
  print((a+b)//2+1)
else:
  print((a+b)//2)
# Judge status: Accepted
def f(H):
    if H == 1:
        return 1
    return 2 * f(H//2) + 1


def solve():
    H = int(input())
    print(f(H))


if __name__ == "__main__":
    solve()
# Judge status: Accepted
s = input()
if 'N' in s and 'S' not in s:
    print('No')
elif 'N' not in s and 'S' in s:
    print('No')
elif 'W' in s and 'E' not in s:
    print('No')
elif 'W' not in s and 'E' in s:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
import math
x=int(input())
if 360%x==0:
    print(360//x)
else:
    print(x * 360 // math.gcd(x, 360))
# Judge status: Accepted
import fractions
a,b=map(int,input().split())
gcd=fractions.gcd(a,b)
print(a*b//gcd)
# Judge status: Accepted
import sys

def main():

    # sys.stdin = open('input156b.txt')

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

    ans = 0
    m = 1
    while n >= m:
        m *= k
        ans += 1

    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
arr = [0] * n

for i in input().split():
    i = int(i)
    arr[i - 1] += 1

for i in range(n):
    print(arr[i])
# Judge status: Accepted
S = input()
K = int(input())
one = 0

for s in S:
  if s=="1":
    one+=1
  else:
    ans = s
    break

if K<=one:
  print(1)
else:
  print(ans)
# Judge status: Accepted
from math import sqrt

N = int(input())
M = N
p=2
ans=0

while p <= sqrt(M):
  z = p
  while N % z == 0:
    N //= z
    z *= p
    ans += 1
  while N % p == 0:
    N //= p
  p+=1
if N > 1:
  ans+=1
print(ans)
# Judge status: Wrong Answer
inputs = list(map(float, input().split()))

multiple = inputs[0] * inputs[1]

multiple_str = str(multiple)
if '.' in multiple_str:
    print(multiple_str.split('.')[0])
else:
    print(multiple_str)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

d = {}
for i, ai in enumerate(a):
    l = ai + i+1
    if l in d:
        d[l] += 1
    else:
        d[l] = 1

p = 0
for i, ai in enumerate(a):
    r = i+1 - ai
    p += d.get(r, 0)

print(p)
# Judge status: Accepted
import collections

n=int(input())
s=[]
for _ in range(n):
    s.append(input())

c = collections.Counter(s)

print(len(c))
# Judge status: Accepted
n = int(input())
for i in range(10):
    if n <= i*111:
        print(i*111)
        exit()
# Judge status: Accepted
a,b,c=map(int,input().rstrip().split(' '))
if(a%2==0 or b%2==0 or c%2==0):
  print(0)
else:
  x=min(a*b,b*c,c*a)
  print(x)
# Judge status: Accepted
x, n = map(int, input().split())
p = [int(s) for s in input().split()]

min_val = 101
for i in range(102):
    if i not in p:
        if abs(i - x) < min_val:
            min_val = abs(i - x)
            ans = i
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
  if a[i-k]<a[i]:print('Yes')
  else:print('No')
# Judge status: Accepted
a,b = map(int,input().split())
print((b-a)*(b-a+1)//2-b)
# Judge status: Accepted
N = int(input())

chars = "Xabcdefghijklmnopqrstuvwxyz"
result = ""
n_1 = N

while True:
    x = n_1 % 26

    if x == 0:
        x = 26

    result += chars[x]
    n_1 -= x
    if n_1 == 0:
        break

    n_1 //= 26

print(result[::-1])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
L1 = list()
D2 = dict()
ret = 0
for i in range(len(A)):
    num1 = i + 1 - A[i]
    num2 = i + 1 + A[i]
    L1.append(num1)
    if num2 not in D2:
        D2[num2] = 1
    else:
        D2[num2] += 1
ret = 0
retlist = dict()
for l in L1:
    if l in D2.keys():
        ret += D2[l]
print(ret)
# Judge status: Wrong Answer
n = int(input())
print(800*n - 200 * n// 15)
# Judge status: Accepted
a, b = map(str, input().split())

number = [i**2 for i in range(2,317,1)]
num = int(a + b)

if num in number:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
ans = 0
flow = 0
for i in range(n):
  a = int(input())
  if a == 0:
    flow = 0
  else :
    ans += (a + flow) // 2
    flow = (a + flow) % 2
print(ans)
# Judge status: Accepted
import math
N = int(input())
print((N//11)*2+math.ceil((N%11)/6))
# Judge status: Accepted
N,P=map(int,input().split())
A=list(map(int,input().split()))

odd=0
even=0
for i in range(0,N):
    if A[i]%2==1:
        odd=odd+1
    else:
        even=even+1
if odd==0:
    if P==0:
        print(2**(even))
    else:
        print(0)
else:
    print((2**(odd-1))*(2**(even)))
# Judge status: Accepted
n,k = map(int,input().split())
enemy = list(map(int,input().split()))

enemy.sort(reverse=True)

if k >= n :
  print(0)

else:
  

  for x in range(k):
    enemy[x] = 0
  
  print(sum(enemy))
# Judge status: Accepted
n=int(input())
s=input()
t=input()
for i in range(n+1):
    if s[i:]==t[:n-i]:
        print(n+i)
        break
# Judge status: Accepted
s = input()

x = False
if 'N' in s and 'S' in s:
    x = True
if 'N' not in s and 'S' not in s:
    x = True
y = False
if 'W' in s and 'E' in s:
    y = True
if 'W' not in s and 'E' not in s:
    y = True

if x and y:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,X,Y=map(int,input().split())
d=[0]*N
for i in range(N):
    for j in range(N):
        if not i<j:
            continue
        dist=min([j-i,abs((X-1)-i)+1+abs(j-(Y-1))])
        d[dist]+=1
print(*d[1:],sep='\n')
# Judge status: Wrong Answer
num = input().split()
str = [input()]
strc = ''
flg = 0
res = ''
for i in range(int(num[0])-1):
#	print(1)
	strc = input()
	for j in range(len(str)):
		if str[j] < strc:
#			print(2)
			flg = 0
		else:
#			print(3)
			flg = j
	if flg == 0:
		str.append(strc)
	else:
		str.insert(j,strc)
for x in str:
	res += x
print(res)
# Judge status: Accepted
a,b,c=map(int,input().split())
ans=0
average=int((a+b+c)/3)
while True:
    if a%2==1 or b%2==1 or c%2==1:
        print(ans)
        exit()
    else:
        tb=int(b/2)
        tc=int(c/2)
        ta=int(a/2)
        a=tb+tc
        b=ta+tc
        c=ta+tb

        ans+=1
    if a==average and b==average and c==average:
        print(-1)
        exit()
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
S=a*b/2
print(S)
# Judge status: Accepted
n,m=map(int,input().split())
data=[]
for i in range(n):
    a,b=map(int,input().split())
    data.append([a,b])
data.sort()
buf=0
ans=0
for i in range(n):
    data_i=data[i]
    ans+=data_i[0]*data_i[1]
    buf+=data_i[1]
    if buf>=m:
        ans-=data_i[0]*(buf-m)
        break
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))
for i in range(30):
    x=2**i
    res=0
    for j in a:
        if j%x !=0:
            res=1
    if res==1:
        print(i-1)
        break
# Judge status: Accepted
from collections import Counter
N = int(input())
A = []
B = []
E = []
for i in range(N):
  l = list(input().split())
  l[1] = int(l[1])
  A.append(l)
  B.append(l[0])
  E.append(l[1])
A.sort()
C = Counter(B)
C = sorted(C.items(), key=lambda x:x[0])
cnt = 0
for c in C:
  c = c[1]
  D = reversed(A[cnt:cnt+c])
  cnt += c
  for d in D:
    print(E.index(d[1])+1)
# Judge status: Accepted
a, b = map(int, input().split())
diff = b - a
su = 0
for i in range(1, diff+1):
    su += i
print(su - b)
# Judge status: Accepted
a,b,n=map(int,input().split())

nb=n//b

#xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
#    for xb in range(nb):
#        xv=(a*xb*b+a*(b-1))//b-a*xb
#        xmax=max(xmax,xv)
    xb=nb-1
    xv=(a*xb*b+a*(b-1))//b-a*xb
    xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
L = [list(map(int, input().split())) for _ in range(M)]

res = min(a) + min(b)
for x, y, c in L:
    tres = a[x - 1] + b[y - 1] - c
    res = min(res, tres)
print(res)
# Judge status: Wrong Answer
N,x = map(int,input().split())
a = [0] + list(map(int,input().split()))
b = [0]
for i in range(1,N):
  b.append(a[i]+a[i+1])

cnt = 0  
for i in range(1,N):
  if b[i] > x:
    c = b[i] - x
    if a[i+1] >= c:
      cnt += c
      if i+1 <= N-1:
        b[i+1] -= c
    else:
      cnt += c
print(cnt)
# Judge status: Wrong Answer
capacity = []
for i in range(6):
    c = int(input())
    capacity.append(c)

stage = [capacity[0]]
ans = 0
mn = capacity[0]
for i in range(1,6):
    if capacity[i] < mn:
        ans += (mn//capacity[i]) + 1
        mn = capacity[i]
    else:
        ans += 1
print(ans)
# Judge status: Accepted
n, m = map(int,input().split())

print(n*(n-1)//2 + m*(m-1)//2)
# Judge status: Accepted
from collections import defaultdict
s=input()
dd=defaultdict(lambda: True)
for c in s:
  dd[c]=not dd[c]
for k in dd:
  if not dd[k]:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
h, n = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
max_a = max(a for a, _ in lst )
dp = [10**18 for _ in range(h+max_a)]
dp[0] = 0
for i in range(1,h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in lst)
print(min(dp[h:]))
# Judge status: Accepted
X = int(input())
n = 100
a = 0
while n < X:
    n = int(n * 1.01)
    a = a + 1
print(a)
# Judge status: Accepted
S = list(str(input()))
count = 0
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            count += 1
        elif i % 2 == 1 and j == "1":
            count += 1
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            count += 1
        elif i % 2 == 1 and j == "0":
            count += 1
print(count)
# Judge status: Accepted
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
import itertools
l=list(itertools.permutations([i for i in range(1, N+1)]))
print(abs(l.index(P)-l.index(Q)))
# Judge status: Wrong Answer
n = int(input())

if n%2 == 0:
    print(n/2)
elif n%2 == 1:
    print(n/2+1)
# Judge status: Accepted
S = input()
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
# Judge status: Wrong Answer
def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3

n = int(input())
s = [i for i in input()]
for _ in range(n-1):
    s = intersection(s, input())
s.sort()
if len(s) == 0:
    print('')
else:
    print(''.join(s))
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = 1
for i in range(k%n):
  m = a[m-1]
print(m)
# Judge status: Accepted
d,t,s = map(float,input().split())


if t >= d/s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from sys import stdin
N,Y=list(map(int,stdin.readline().strip().split()))
count=0
flag=False
if abs(N)-abs(Y)==0:
    print(1)
    exit()
if N>Y and abs(N)>abs(Y) or N>Y and N<0:
    count+=1
    N*=-1
    flag=True
YY=abs(Y)
NN=abs(N)
ans=0
if YY>NN:
    ans=YY-NN
else:
    ans=NN-YY
N+=ans
if Y==N:
    print(count+ans)
else:
    print(count+ans+1)
# Judge status: Accepted
n,m = map(int, input().split())

if n > m:
    n,m = m,n

if n==1 and m==1:
    print(1) 
elif n==1:
    print(m-2)
elif n==2 or m==2:
    print(0)
else:
    print((m-2)*(n-2))
# Judge status: Accepted
Q, H, S, D = map(int, input().split())
n = int(input())
coffee = [[Q*4, 0.25, Q], [H*2, 0.5, H], [S, 1, S], [D/2, 2, D]]
coffee_cost = sorted(coffee)
cost = 0
Qt = n
for i in range(4):
    cost += (round(Qt // coffee_cost[i][1]) * coffee_cost[i][2])
    Qt = round(Qt % coffee_cost[i][1])
    if Qt == 0:
        print(int(cost))
        exit()
# Judge status: Accepted
import math
ans = 0
n, d = map(int, input().split())
for i in range(n):
    x, y = map(int, input().split())
    distance = math.sqrt(x**2 + y**2)
    if distance <= d:
        ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
dp=[10**18]*(n+1)
dp[n]=0
for i in range(5,0,-1):
    for j in range(n,0,-1):
        if j-9**i>=0:
            dp[j-9**i]=min(dp[j-9**i],dp[j]+1)

for i in range(6,-1,-1):
    for j in range(n,0,-1):
        if j-6**i>=0:
            dp[j-6**i]=min(dp[j-6**i],dp[j]+1)
pass
print(dp[0])
# Judge status: Wrong Answer
s = input()
if s == "AAA" or "BBB" :
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
L=[int(input()) for _ in range(5)]
k=int(input())
if sum(L)<=k*5:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
S = list(input())
R = list(reversed(S))
ans = 0
for i in range(len(S)):
    if S[i] != R[i]:
        ans += 1
print(ans//2)
# Judge status: Accepted
a,b = (int(x) for x in input().split())

if (a+b)<24:
    print(a+b)
else:
    print((a+b)%24)
# Judge status: Accepted
N=int(input())
A=[0,0,0,0]
for i in range(N):
  a=input()
  if a=='AC':
    A[0]+=1
  elif a=='WA':
    A[1]+=1
  elif a=='TLE':
    A[2]+=1
  else:
    A[3]+=1
print('AC x',A[0])
print('WA x',A[1])
print('TLE x',A[2])
print('RE x',A[3])
# Judge status: Accepted
n,m,x,y = map(int,input().split())
a = max([int(i) for i in input().split()])
b = min([int(i) for i in input().split()])
if a < b and x < a+1 <= y:
  print('No War')
else:
  print('War')
# Judge status: Accepted
A, B, C = map(int, input().split())

import math

Asmall = math.floor(A/2)
Abig = A- Asmall
Bsmall = math.floor(B/2)
Bbig = B- Bsmall
Csmall = math.floor(C/2)
Cbig = C- Csmall

print(min((Cbig-Csmall)*A*B, (Abig-Asmall)*C*B, (Bbig-Bsmall)*A*C))
# Judge status: Accepted
n = int(input())

if n == 1:
    print(0)
else:
    print((n * (n-1)) // 2)
# Judge status: Wrong Answer
n = int(input())
s = input()
w = set(s)
t = 0
for i in w:
  if s.count(i) >= 2:
    t += 1
print(t)
# Judge status: Accepted
#!/usr/bin/env python3
from collections import Counter

prime_factor = []
N = int(input())
for i in range(2,int(N**0.5)+1):
    while N % i == 0:
        prime_factor.append(i)
        N /= i
if N > 1:
    prime_factor.append(N)

c = Counter(prime_factor)

cnt = 0
for k, v in c.items():
    diff = 1
    while v > 0:
        v -= diff
        if v >= 0:
            cnt += 1
        diff += 1

print(cnt)
# Judge status: Accepted
S = input()
m1 = S.count('0')
m2 = S.count('1')
print(2*min(m1,m2))
# Judge status: Accepted
c = input()
print(chr(ord(c) + 1))
# Judge status: Accepted
import math
a, b = map(int, input().split())

print(math.ceil((a + b) / 2))
# Judge status: Accepted
n = int(input())
ans = [0 for i in range(10050)]
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            f = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if f < 10050:
                ans[f] += 1
for i in range(n):
    print(ans[i+1])
# Judge status: Accepted
tH,tA,aH,aA=map(int,input().split())
print("Yes") if (aH-1)//tA+1<=(tH-1)//aA+1 else print("No")
# Judge status: Accepted
a,b = map(int, input().split())
l = [1]*999
for i in range(1, 999):
    l[i] = l[i-1] + i+1
print(l[b-a-1]-b)
# Judge status: Accepted
import numpy as np
N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
    print(M, *A)
    quit()
print(M, A[np.abs(np.array(A, dtype=np.int64) - M / 2).argmin()])
# Judge status: Accepted
x = input()
stack = []
for xx in x:
    if xx == "T":
        if len(stack) > 0:
            if stack[-1] == "S":
                stack.pop()
            else:
                stack.append(xx)
        else:
            stack.append(xx)
    else:
        stack.append(xx)

print(len(stack))
# Judge status: Accepted
X, Y = map(int, input().split())
A = (4*X-Y)/2
B = (Y-2*X)/2
if  A%1 == 0 and X >= abs(A) and A>=0:
  print('Yes')
elif B%1 == 0 and X >= abs(B) and B>=0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
def main():
    n = int(input())

    # for i in range(n-1):
    #     ans += i+1

    # print(ans)

    print(int(((n-1) * n) / 2))

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

def main():
    n, m = list(map(int, input().split(" ")))
    ans = 0
    ans += n*(n-1)/2
    ans += m*(m-1)/2
    print(int(ans))
    

if __name__ == "__main__":
    main()
# Judge status: Accepted
# C - Lamps
# imos法, 累積和

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

for _ in range(K):
    B = [0] * (N+1)
    for i, a in enumerate(A):
        left = max(0, i-a)
        right = min(i+a+1, N)
        B[left] += 1
        B[right] -= 1
    for i in range(N):
        B[i+1] += B[i]
    B.pop()
    if A == B:
        break
    else:
        A = B

print(' '.join(map(str, A)))
# Judge status: Accepted
n=int(input())
l =list(map(int,input().split()))
a = max(l)
if a < sum(l) - a:
        print('Yes')
else:
        print('No')
# Judge status: Accepted
n,k = map(int,input().split())
s = str(input())
ans = ""
for i in range(n):
  if(i==k-1):
    if(s[i]=="A"):
      ans+="a"
    elif(s[i]=="B"):
      ans+="b"
    else:
      ans+="c"
  else:
    ans+=s[i]
print(ans)
# Judge status: Accepted
mod = (10 ** 9 + 7)
tot = 1
l = [1, 0, 0]
for i in range(2000):
  nex = (tot - l[-1] - l[-2]) % mod
  tot = (tot + nex) % mod
  l.append(nex)
print(l[int(input())])
# Judge status: Wrong Answer
n,l = map(int,input().split())
s = []

for i in range(n):
    s.append(input())

sorted(s)

print(''.join(s))
# Judge status: Accepted
import fractions
n , x = map(int,input().split())
p = list(map(int,input().split()))
ans = abs(x - p[0])
for i in range(n):
    ans = fractions.gcd(ans,abs( x - p[i] ))
    
print(ans)
# Judge status: Accepted
N, M, X, Y = map(int, input().split())

x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_max = max(x_list)
y_min = min(y_list)

for Z in range(X+1,Y+1):
    if x_max < Z <= y_min:
        print('No War')
        break

else:
    print('War')
# Judge status: Accepted
def main():
	S = input()
	lst = [False] * 26

	for ch in S:
		lst[ord(ch) - ord("a")] = True

	for i in range(26):
		if lst[i] == False:
			print(chr(i + ord("a")))
			break
	else:
		print("None")

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

for i in range(N):
  if A[i]%2 ==0 and (A[i]%3==0 or A[i]%5==0):
    print('APPROVED')
  else:
    print('DENIED')
    break
  break
# Judge status: Accepted
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0

A = [0]*(n+1)

for i in range(n):
    A[i+1] = A[i] + a[i]

B = [0]*(m+1)

for i in range(m):
    B[i+1] = B[i] + b[i]

j = m

for i in range(n+1):
    if A[i] > k :
        break
    while B[j] > k-A[i]:
        j -= 1

    ans = max(ans,i+j)


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

if N == 1 and M == 1:
  print(1)
elif N == 1:
  print(M-2)
elif M == 1:
  print(N-2)
else:
  print((N-2)*(M-2))
# Judge status: Accepted
def chmin(a,b):
    if a>b: a = b
    return a
def chmax(a,b):
    if a<b: a = b
    return a
N = int(input())
h = list(map(int,input().rstrip().split(' ')))
dp = [float('INF')]*N
dp[0] = 0
for i in range(1,N):
    dp[i] = chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]))#1個前から移動
    if i>1 : dp[i] = chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]))#2個前から移動
print(dp[-1])
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(a-x)<abs(b-x):
    print('A')
else:
    print('B')
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 21:14:26 2020

@author: NEC-PCuser
"""

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

a = [0] * (10 ** 6)

for i in A:
    first_flg = True
    for j in range(i, 10 ** 6 + 1, i):
        if first_flg == True and a[j - 1] != 0:
            a[j - 1] += 1
            break
        a[j - 1] += 1
        first_flg = False


count = 0
for i in A:
    if a[i - 1] == 1:
        count+=1

print(count)
# Judge status: Accepted
import sys
input = sys.stdin.readline

X = int(input())
Num = X

while any(Num%i==0 for i in range(2,Num)):
    Num += 1

print(Num)
# Judge status: Accepted
import fractions
a, b = map(int, input().split())
common_num = fractions.gcd(a, b)
 
ans = 1
for i in range(2,int(1+common_num**0.5)):
  if common_num % i == 0:
    ans += 1
    while common_num % i == 0:
      common_num //= i
if common_num > 1:
  ans += 1
      
print(ans)
# Judge status: Wrong Answer
n = int(input())
L = list(map(int,input().split()))
M = [0]*n
for i in range(n-1):
    M[L[i]-1] +=1
print(M)
# Judge status: Accepted
A,B,K=map(int,input().split())
tmp = set(range(A,min(B+1,A+K))) | set(range(max(A, B-K+1),B+1))
[print(s) for s in sorted(tmp)]
# Judge status: Accepted
A, B, C = list(map(int, input().split()))

a = set([A, B, C])

if len(a) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x = int(input())
happiness_point=0
while x>=500:
        happiness_point+=1000
        x-=500
while x>=5:
    happiness_point+=5
    x-=5

print(happiness_point)
# Judge status: Wrong Answer
import collections

s = map(int,list(raw_input()))

count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		s[i] = 1- s[i]
		count +=1
print count
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a_ = list(reversed(a))

import fractions
l = [a[0]]
r = [a_[0]]
for i in range(n):
    l.append(fractions.gcd(l[-1], a[i]))
    r.append(fractions.gcd(r[-1], a_[i]))
#print(l)
#print(r)

s = [0]*n
for i in range(n):
    if i == 0:
        s[i] = r[n-1]
    elif i == n-1:
        s[i] = l[n-1]
    else:
        s[i] = fractions.gcd(l[i], r[n-(i+1)])
#print(s)
print(max(s))
# Judge status: Wrong Answer
#入力例は合うがWAになる

a = input()
b = input()

# if [S[0],S[1],S[2]] == [T[2],T[1],T[0]]:
if [a[2],a[1],a[0]] == [b[0],b[1],b[2]]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic.setdefault(a[i],1)
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    if b not in dic:
        dic.setdefault(b,0)
    elif c not in dic:
        dic.setdefault(c,dic[b])
    else:
        dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    print(answer)