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

ans = 'NO'
for i in range(1, A[1] + 1):
    if i * A[0] % A[1] == A[2]:
        ans = 'YES'
        
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int, input().split())) 
s = 0
A = Counter(a)
l = len(A)


for key, value in A.items():
    if key <= value:
        s+= value - key
    else:
        s += value

print(s)
# Judge status: Wrong Answer
s = input()
if len(set(s)) == 3:
  print('Yes')
else:
  print('NO')
# Judge status: Wrong Answer
N = int(input())
arr=[]
for i in range(N):
  arr.append(list(map(int, input().split())))

max_ind=arr[0].index(max(arr[0]))
max_sum=max(arr[0])

for i in range(1,len(arr)):
  temp=arr[i]
  temp.pop(max_ind)
  max_sum+=max(temp)
  max_ind=temp.index(max(temp))

print(max_sum)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353

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

cnt = 0
for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if l>=0 and l<=k:
            cnt += 1
print(cnt)
# Judge status: Wrong Answer
def solve(N,K,S):
    for i in range(0, K):
        print(S)
    for i in range(K+1, N):
        print(S+1)
N ,K ,S = map(int,input().split())
solve(N,K,S)
# Judge status: Accepted
x,y=map(int,input().split())
n=y//x
print(len(bin(n))-2)
# Judge status: Accepted
h,n=map(int,input().split())
dp=[10**10]*(h+1)
dp[0]=0
X=[]
for i in range(n):
    a,b=map(int,input().split())
    X.append([a,b])


for i in range(h):
    for j in range(n):
        k=min(i+X[j][0],h)
        dp[k]=min(dp[k],dp[i]+X[j][1])
print(dp[h])
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
u = sum(a) / (4*m)
l = 0
for i in a:
    if i >= u:
        l += 1
print("Yes") if l >= m else print("No")
# Judge status: Wrong Answer
N, M = map(int, input().split())
first = set()
second = set()

for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    first.add(b)
  if b == N:
    second.add(a)

if first & second:
  print("POSSIBLE")
else:
  print("IMPOSSOBLE")
# Judge status: Accepted
a, b = map(int, input().split())

print((a + b + 1) // 2)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

if abs(b-a) <= d and abs(c-b) <= d:
        print('Yes')
elif abs(a-c) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,q = map(int,input().split())
s = input()
Query = [list(map(int,input().split())) for _ in range(q)]
x = [ 0 for _ in range(n) ]
for i in range(n-1):
    if s[i:i+2] == "AC":
        x[i+1] = x[i] + 1
    else:
        x[i+1] = x[i]
for l,r in Query:
    print(x[r-1]-x[l-1])
# Judge status: Accepted
a, b = map(int, input().split())

if a < b:
    small = a
    big = b
else:
    small = b
    big = a

i = 2    
while True:
    if (small * i) % big == 0:
        print(small * i)
        break
    i += 1
# Judge status: Accepted
import itertools

S=input()
sum1=0


for i in itertools.product(["+","-"],repeat=3):
    ans=""
    for j in range(3):
        if i[j]=="+":
            ans+=S[j]+i[j]
        elif i[j]=="-":
            ans+=S[j]+"-"
    ans+=S[-1]
    sum1=eval(ans)
    if sum1==7:
        print(ans+"="+str(7))
        exit()
# Judge status: Wrong Answer
N=int(input())
x=N//2
print(x/N)
# Judge status: Accepted
N = int(input())

print(((N//2) if N%2 == 0 else (N//2)+1)/N)
# Judge status: Wrong Answer
s=2000
dp=[0]*(2001)
dp[0]=1
dp[1]=0
dp[2]=0
dp[3]=1
dp[4]=1
m=1000000007
for i in range(5,s+1):
    for j in range(3,10):
        if i>=j:
            dp[i]=(dp[i]+dp[i-j])%m
n=int(input())
print(dp[n])
# Judge status: Accepted
# ABC 135: B – 0 or 1 Swap
N = int(input())
p = [int(s) for s in input().split()]

p_sorted = sorted(p)

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

print('YES' if diff == 2 or diff == 0 else 'NO')
# Judge status: Wrong Answer
n = int(input())
xl = sorted([tuple(map(int, input().split())) for _ in range(n)])

tmp = sum(xl[0])

res = 0
for i in range(1, n):
    x, l = xl[i]
    if tmp > x-l:
        res += 1
    else:
        tmp = x+l

print(n-res)
# Judge status: Accepted
x = int(input())
x_max = 179

for i in range(1,x_max+1):
    if((360 * i) % x == 0):
        tmp = (360 * i) / x
        print(int(tmp))
        break
# Judge status: Accepted
# coding: utf-8

start_col = ["0", "1"]

s = input().rstrip()


def get_next(prev: str):
    if prev == "0":
        return "1"
    else:
        return "0"


ans = len(s)
for i in start_col:
    current = i
    cnt = 0
    for j in range(len(s)):
        if s[j] != current:
            cnt += 1
        current = get_next(current)
    ans = min(ans, cnt)

print(ans)
# Judge status: Accepted
s=input()
print(sum(a>b for a,b in zip(s,s[::-1])))
# Judge status: Accepted
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    tmp=sorted(x[p])
    for j in range(len(tmp)):
        ans[tmp[j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(m):
    print(ans[i])
# Judge status: Accepted
n,m = map(int, input().split())

ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

if n > 2:
    if m == 1:
        ans = n-2
    elif m == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)
    



print(ans)
# Judge status: Accepted
n = int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    x[i][1] = int(x[i][1])
    x[i].append(i+1)

x.sort(key= lambda a: a[1])
x.reverse()
x.sort(key= lambda b: b[0])

for i in range(n):
    print(x[i][2])
# Judge status: Accepted
n, k = map(int, input().split())

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

h.sort(reverse=True)

if len(h) >= k:
    ans = sum(h[k:])
else:
    ans = 0

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

n = len(s)
cnt = [0] * 2019
cnt[0] = 1
total = 0
ans = 0
x = 1

for i in range(n):
    total += int(s[i]) * x
    total %= 2019
    x *= 10
    x %= 2019
    ans += cnt[total]
    cnt[total] += 1

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

ans=0
if (A[1]-A[0])%2==0:
    ans=(A[1]-A[0])//2
    ans+=A[2]-A[1]
else:
    ans=(A[1]-A[0])//2+1
    ans+=A[2]+1-A[1]
    
print(ans)
# Judge status: Accepted
nums = [int(e) for e in input().split()]
if(nums[1] == 100):
    print(pow(100,nums[0])*(nums[1]+1))
else:
    print(pow(100,nums[0])*nums[1])
# Judge status: Accepted
N = int(input())
lst = []

for i in range(10):
    for j in range(10):
        lst.append(i*j)

if N in lst:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n, m = [int(x) for x in input().split()]
if n == 1 and m == 1:
    ans = 1
elif n == 1 or m == 1:
    ans = max(n, m) - 2
else:
    ans = n * m - 2 * n - 2 * m + 4
print(ans)
# Judge status: Wrong Answer
x = input()
page = int(x) // 2
print(page+1)
# Judge status: Wrong Answer
n,k=map(int,input().split())
S=input()
c=0
d=0
for i in range(n-1):
    if S[i]==S[i+1]:
        c+=1
    if S[i]!=S[i+1]:
        d+=1
print(c+2*k-1 if (d<=k and S[0]!=S[-1]) else c+2*k)
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline

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

    d = []
    for i in range(N-1):
        d.append(A[i+1] - A[i])
    d.append(K-A[-1]+A[0])
    print(K - max(d))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
mn = input().split()
ob = input().split()

n = int(mn[0])
m = int(mn[1])

votes = 0

for i in range(len(ob)):
    ob[i] = int(ob[i])
    votes += ob[i]

ob.sort()

line = votes//(4*m)

ans = 0

for i in range(m):
    if ob[-1*(i+1)] <= line:
        ans += 1

if ans == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
c = input()

if (c=='a')or(c=='i')or(c=='u')or(c=='e')or(c=='o'):
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
num=list(map(int,input().split()))
num.sort()
print('YES' if num==[5,5,7] else 'NO')
# Judge status: Accepted
S = input()

if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
S = 0

for i in a:
  S = S^i
  
ans = []

for i in a:
  ans.append(S^i)
  
print(*ans)
# Judge status: Accepted
num=str(input())
 
char=list(num)
 
if char[0]=="9":
	print("Yes")
elif char[1]=="9":
	print("Yes")
else:
	print("No")
# Judge status: Accepted
X,N=map(int, input().split())
NL=list(map(int, input().split()))
BL=[i for i in range(-1,102)]

for i in NL:
    BL.remove(i)

ANS=1000
out=1000
for i in BL:
    temp=abs(X-i)
    if ANS>temp:
        ANS=temp
        out=i
print(out)
# Judge status: Wrong Answer
import math
n,k = map(int,input().split())

lst1 = [list(map(int,input().split())) for i in range(n)]

ans = 0

x = 0
for i in range(n):
    x = max(x,lst1[i][0])

sum1 = 0
for i in range(n):
    if lst1[i][1] > x:
        sum1 += lst1[i][1]
        ans += 1

k -= sum1

print(ans + math.ceil(k/x) )
# Judge status: Wrong Answer
r, g, b = map(int, input().split())
print('Yes' if (100 * r + 10 * g + b) % 4 == 0 else 'N0')
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]

for i in range(n-1):
    if h[i+1] - h[i] == 1:
        h[i+1] = h[i+1] - 1
    elif h[i+1] - h[i] > 1:
        print("No")
        exit()
else:
    print("Yes")
# Judge status: Accepted
N = int(input())
H = tuple(map(int, input().split()))
c = m = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        c += 1
    else:
        m = c if c > m else m
        c = 0
print(max(c, m))
# Judge status: Accepted
S = input()
y, m, d = S.split('/')
ans = 'TBD'
if int(m)<=4:
    ans = 'Heisei'
print(ans)
#print(*ans, sep='\n')
# Judge status: Wrong Answer
k,x=map(int,input().split())

if x-k+1<=-1000000:
  a=-1000000
else: a=x-k+1
if x+k-1>=1000000:
  b=1000000
else:b=x+k-1

print([i for i in range(a,b+1)])
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    print(0, 0, 1, 0, 0, N)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from math import floor
n = int(input())
for i in range(1,n):
    if floor(i*1.08) == n:
        print(i)
        break
else:
    print(":(")
# Judge status: Accepted
S = input()
T = input()
S_cnt = sorted(S.count(c) for c in set(S))
T_cnt = sorted(T.count(c) for c in set(T))
print("Yes") if S_cnt == T_cnt else print("No")
# Judge status: Accepted
i = list(map(int, input().split()))
if i[0] > i[1]:
    print("safe")
else:
    print("unsafe")
# Judge status: Wrong Answer
n,*a=map(int,open(0).read().split())
ans=0
for i in range(n):
    p,a[i]=divmod(a[i],2)
    ans+=p
i=0
while i+1<n:
    if a[i]==1 and a[i+1]==1:
        ans+=1
        i+=1
    i+=1
print(ans)
# Judge status: Accepted
s = input()
n = len(s)
x = dict()
for i in range(n):
    x[s[i]] = 1
count = 0
for idx in x:
    count += 1
if count == n:
    print("yes")
else:
    print("no")
# Judge status: Accepted
s = list(input())

if s.count("a") == 1 and s.count("b") == 1 and s.count("c") == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b, k = map(int, input().split())

ma = max(a, b)
mi = min(a, b)
ans = []
if ma == mi:
    ans.append(ma)
    
for i in range(ma // 2, 0, -1):
    if ma % i == 0 and mi % i == 0:
        ans.append(i)
ans.append(1)
print(ans[k - 1])
# Judge status: Wrong Answer
S = list(input())
N = len(S)

if N % 2 == 0:
    m = int(N/2)
    LS = S[:m]
    RS = S[N:m-1:-1]
else:
    m = int((N+1)/2)
    LS = S[:m-1]
    RS = S[N:m-1:-1]

ans = 0
for i in range(m-1):
    if LS == RS:
        pass
    else:
        ans += 1
print(ans)
# Judge status: Accepted
S = sorted(input())
T = sorted(input(), reverse=True)
print("Yes" if T > S else "No")
# Judge status: Accepted
a,b,c,d = map(int,input().split())
s = [a,c]
e = [b,d]
s.sort()
e.sort()
print(max(0, e[0]-s[1]))
# Judge status: Accepted
from collections import deque

N = int(input())
amari = []

if N <= 26:
    print(chr(96+N))

else:
    while True: 
        N -= 1

        am = N % 26
        N = N // 26 
        amari.append(am)
        if N == 0:
            break

    answer = deque()
    for i in amari:
        answer.appendleft(chr(97+i))

    for i in answer:
        print(i, end='')
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 1000
    k = 0

    for i in range(N-1):
        if A[i+1] - A[i] <= 0:
            continue
        
        k += m // A[i]
        m -= k * A[i]
        m += k * A[i+1]
        k = 0

    print(m)

main()
# Judge status: Accepted
k , n = map(int, input().split())
a_list = list(map(int, input().split()))
a_last = a_list[0] + k
a_list.append(a_last)
distance = -1
for i in range(n):
    distance_btw = a_list[i + 1] - a_list[i]
    if distance_btw > distance:
        distance = distance_btw
print(k - distance)
# Judge status: Wrong Answer
x1, x2, x3, x4, x5 = input().split()

if x1 == 0:
  print(int(1))
if x2 == 0:
  print(int(2))
if x3 == 0:
  print(int(3))
if x4 == 0:
  print(int(4))
if x5 == 0:
  print(int(5))
# Judge status: Accepted
#!/usr/bin/env python3
import itertools
import math


def dist(xs, ys):
    ans = 0
    for x, y in zip(xs, ys):
        ans += (x - y) ** 2
    return math.sqrt(ans)


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

    ans = 0
    for i, j in itertools.combinations(range(N), 2):
        d = dist(Xs[i], Xs[j])
        if d == int(d):
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
l = []
for i in s:
  l.append(i)
if l[0] != "A":
  print("WA")
else:
  if len(l) == 3:
    if l[1].islower() and l[2] == "C":
      print("AC")
    else:
      print("WA")
  else:
    l.remove("A")
    if "C" not in l[1:len(l)-1]:
      print("WA")
    else:
      l.remove("C")
      s = "".join(l)
      if s.islower():
        print("AC")
      else:
        print("WA")
# Judge status: Accepted
n = input()
data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])
# Judge status: Accepted
A_mai, B_mai = map(int, input().split())
summ = A_mai + B_mai

if (A_mai % 3 == 0 or B_mai % 3 == 0 or summ % 3 == 0):
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
n,m=map(int,input().split())
h=list(map(int,input().split()))
l1=[]
l2=[]
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a>b:
    c=a
    a=b
    b=c
  k=[a,b]
  l1.append(k)
  c=a
  a=b
  b=c
  k=[a,b]
  l2.append(k)
l1.sort()
l2.sort(reverse=True)
for i in l1:
  if h[i[0]-1]<=h[i[1]-1]:
    l[i[0]-1]+=1
for i in l2:
  if h[i[0]-1]<=h[i[1]-1]:
    l[i[0]-1]+=1
print(l.count(0))
# Judge status: Accepted
from fractions import gcd

n=int(input())
a=list(map(int,input().split(' ')))
east=[0]*(n+1)
west=[0]*(n+1)
for i in range(1,n+1):
    east[i]=gcd(east[i-1],a[i-1])
    west[-i-1]=gcd(west[-i],a[-i])
ans=0
for k in range(1,n+1):
    tmp=gcd(east[k-1],west[k])
    if tmp>ans:
        ans=tmp
print(ans)
# Judge status: Accepted
X = input()
N = len(X)

cnt_s = 0
ans = N
for i in range(N):
    if X[i] == "S":
        cnt_s += 1
    else:
        if cnt_s > 0:
            ans -= 2
            cnt_s -= 1

print(ans)
# Judge status: Accepted
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
  if i%K==0:
    print('OK')
    exit(0)
print('NG')
# Judge status: Accepted
N,K,Q=map(int,input().split())

D=[0]*(N+1)
for _ in range(Q):
    D[int(input())]+=1

for i in range(1,N+1):
    if K+D[i]-Q>0:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
N = int(input())

max_count = 0
ans = 0

def div2(x, count):
    x, mod = divmod(x, 2)
    if mod != 0:
        return count
    else:
        if x == 1:
            return count+1
        return div2(x, count+1)
for x in range(1, N+1):
    count = div2(x, 0)
    
    if count > max_count:
        max_count = count
        ans = x
    
print(ans)
# Judge status: Wrong Answer


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

#A.sort()
arr = []
for i in range(1,K):
    if N % i == 0:
        arr.append(i)
#print(arr)

tmp = max(arr)
#print(tmp)
if N==K:
    tmp = N
print(N//tmp)
# Judge status: Accepted
N=int(input())

A=list(map(int,input().split()))
A=sorted(A,reverse=True)

point=0
for i in range(N-1):
    point+=A[(i+1)//2]

print(point)
# Judge status: Wrong Answer
import random
a=input()
print(a)
print(len(a))
nagasa=len(a)
num = random.randint(1,nagasa-2)-1
print(num)
numr = num+3
print(a[num:numr])
# Judge status: Accepted
A=list(map(int,input().split()))
K=int(input())
A.sort()
print(A[2]*2**K+A[1]+A[0])
# Judge status: Accepted
s = input()
a = len(s)
s_list = []
t = 3
while t <= a:
  u = abs(int(s[t-3:t])-753)
  s_list.append(u)
  t += 1
print(min(s_list))
# Judge status: Wrong Answer
import itertools
N=int(input())
LN=list(input().split(' '))
print(LN)
LN.sort(key=int)
LN_sort=list(dict.fromkeys(LN))
print(LN_sort)
cbn=list(itertools.combinations(LN_sort,3))
cnt=int(0)
for i in range(len(cbn)):
    if int(cbn[i][0])+int(cbn[i][1])>int(cbn[i][2]):
        cnt+=LN.count(cbn[i][0])*LN.count(cbn[i][1])*LN.count(cbn[i][2])

print(cnt)
# Judge status: Accepted
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
d=[0]*m
for i in range(1,m):
  d[i]=a[i]-a[i-1]
d.sort(reverse=True)
print(sum(d[n-1:]))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
num = 0
if min(a) >= 3200:
  num = 1
else:
  for i in range(8):
    for j in range(N):
      if 400*i <= a[j] and a[j] < 400*(i+1):
        num += 1
        break
num_max = num
for k in a:
  if k >= 3200 and num < min(8, N):
    num_max += 1
ans = [str(num), str(num_max)]
print(" ".join(ans))
# Judge status: Accepted
import math 
X = int(input())
yen = 100
n = 0
while yen < X:
    n = n + 1
    yen = math.floor(yen*1.01)
    if X <= yen:
        print(n)
# Judge status: Accepted
n = int(input())
m = 10**9 + 7
# ans = [0] * (n + 1)
ans = [0] * 2200
ans[0] = 1
# ans[3] = 1
# ans[4] = 1
# ans[5] = 1
for i in range(3, n + 1):
    ans[i] = ans[i - 1] + ans[i - 3]
    ans[i] %= m
    # for j in range(i - 2):
    #     ans[i] += ans[j]
    #     ans[i] %= m
print(ans[n])
# print(ans[:10])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
    if a[i] %2 == 0:
        if a[i]%3 != 0:
            if a[i]%5 != 0:
                print("DENIED")
                exit()
                
print("APPROVED")
# Judge status: Wrong Answer
# C
import numpy as np
N = int(input())
A = list(map(int,input().split()))

All_diff=[A[i]-A[j] for i,j in zip(range(N),range(N)) if i<j]   

prod=np.prod(All_diff)

if prod > 0 or prod < 0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
import numpy

N = int(input())
A, B = numpy.array([list(map(int, input().split())) for _ in range(N)]).T

A = A[::-1]
B = B[::-1]

ans = 0
for i in range(N):
    a, b = A[i], B[i]

    # need to do nothing
    if (a + ans) % b == 0:
        continue

    else:
        ans += b - (a + ans) % b

print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env pytHon3
# -*- coding: utf-8 -*-


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

    for _ in range(N):
        a, b = map(int, input().split())
        K -= b
        if K <= 0:
            break

    print(a)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
i=0
j=0
t=0
A.append(1000000001)
B.append(1000000001)
while t < K:
    if A[i]>=B[j] and t+B[j]<=K:
        t+=B[j]
        j+=1
    elif A[i]<B[j] and t+A[i]<=K:
        t+=A[i]
        i+=1
    else:
      	break
print(i+j)
# Judge status: Accepted
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(int(ans))
# Judge status: Wrong Answer
import itertools
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

dict_list = list(itertools.permutations(sorted(a), len(a)))

a_pos=0
b_pos=0
for i,dic in enumerate(dict_list):
    if list(dic) == a:
        a_pos=i
    elif list(dic) == b:
        b_pos=i

print(abs(a_pos-b_pos))
# Judge status: Wrong Answer
from collections import Counter

s = list(input())
t = list(input())

sc = Counter(s)
tc = Counter(t)

scc = sorted(sc.values())
tcc = sorted(tc.values())

if len(scc) == len(tcc):
    for i in range(len(scc)):
        if scc[i] == tcc[i]:
            continue
        else:
            print('No')
            break
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())

i = int(n/15)

print(800*(n) - 200*i)
# Judge status: Wrong Answer
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(hako.index(kari[i])+1)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
import collections as cl


def II(): 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,A,B = MI()
    oneset = A + B

    rep = N // oneset

    print(rep * A + min(N % oneset,A))


main()
# Judge status: Accepted
print(["No","Yes","Yes","No"][sum([s=="A" for s in input()])])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

alice = 0
bob = 0
for i, a in enumerate(A):
  if (i % 2 == 0):
    alice += a
  else:
    bob += a

print(alice - bob)
# Judge status: Accepted
n, k = map(int,input().split())
h = list(map(int,input().split()))
INF = float('inf')
dp = [INF] * n 
dp[0] = 0 
dp[1] = abs(h[1] - h[0])




for i in range(2,n):
    for j in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i  -j]))
        

print(dp[n - 1])
# 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 y_[0]>x_[-1]:
            print('NoWar')
else:
            print('War')
# Judge status: Accepted
h, a = map(int, input().split())
print(-(-h//a))
# Judge status: Accepted
def main():
    a, b = map(int, input().split())

    if a > 0:
        print("Positive")
        return

    if b > 0 and a <= 0:
        print("Zero")
        return

    print("Positive" if(b - a + 1) % 2 == 0 else "Negative")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
print("Yes")
print(6)
print(5)
print(5)
print(1)
print(1)
# Judge status: Accepted
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]

A=[]
B=[]
C=[]
D=[]
for i in range(N):
    A.append(x[i][0]+x[i][1])
    B.append(-x[i][0]-x[i][1])
    C.append(x[i][0]-x[i][1])
    D.append(-x[i][0]-x[i][1])

print(max(max(A)-min(A),max(B)-min(B),max(C)-min(C),max(D)-min(D)))
# Judge status: Accepted
I = input
s = I()
q = int(I())
a = [], []
i = 0
for _ in range(q):
  x = I()
  if x[0] == '1':
    i ^= 1
  else:
    f = int(x[2]) - 1
    a[i ^ f].append(x[4])
print(''.join(reversed(a[i])) + (s[::-1] if i else s) + ''.join(a[i^1]))