peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()] 

total = sum(A)
node = 1
ans = 0
for i in range(N+1):
  ans += node
  total -= A[i]
  #print(node, total)
  node = min(total, (node - A[i]) * 2)
  
  if node < 0:
    print(-1)
    exit()
      
print(ans)
# Judge status: Accepted
import sys
c=[list(map(int,l.split())) for l in sys.stdin.read().splitlines()]
for i in range(2):
  c[2-i]=[x-y for x, y in zip(c[2-i],c[1-i])]
for i in range(2):
  for j in range(3):
    c[j][2-i]-=c[j][1-i]

if c[1][1:]==c[2][1:]==[0,0]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import math
X = int(input())

sq = int(math.sqrt(X))
m = 1
for b in range(2, sq+1):  # ここで2が1になると1のp乗となり永遠にループが回り続ける
    p = 2
    tmp = b ** p
    while tmp <= X:
        m = max(tmp, m)
        p += 1
        tmp = b ** p
print(m)
# Judge status: Wrong Answer
a,b=input().split()
a = int(a)
b = int(float(b)*100)
ans = a*b
from math import gcd
n = 100
g = gcd(ans,n)
while g != 1:
    ans //= g
    n //= g
    g = gcd(ans,n)
print(ans//n)
# Judge status: Accepted
N = int(input())
ans = [0]*(1+N)

for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            v = x*x+y*y+z*z+x*y+y*z+z*x
            
            if v<=N:
                ans[v] += 1

for i in range(1, N+1):
    print(ans[i])
# Judge status: Accepted
n=int(input())
ans=100000
for a in range(1,n):##正
    b=n-a
    suma=sum(list(map(int, list(str(a)))))
    sumb=sum(list(map(int, list(str(b)))))
    
    ans=min(ans,sumb+suma)
print(ans)
# Judge status: Wrong Answer
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
s = ""
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print(f"AC × {ac}\nWA × {wa}\nTLE × {tle}\nRE × {re}")
# Judge status: Accepted
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    return g1[r]*g2[r]%mod


mod=10**9+7
n,a,b=map(int,input().split())
k=max(a,b)
g1=[1,n]
g2=[1,1]
inverse=[0,1]

for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):
    i=i+2
    g1.append((g1[-1]*j)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

N=pow(2,n,mod)-1
print((N-cmb(n,b,mod)-cmb(n,a,mod))%mod)
# Judge status: Accepted
def solve(sa, sb, sc):
    S = {'a': sa, 'b': sb, 'c': sc}
    C = {'a': 0, 'b': 0, 'c': 0}
    turn = 'a'
    while True:
        if C[turn] == len(S[turn]):
            return turn.upper()
        C[turn] += 1
        turn = S[turn][C[turn] - 1]

_sa, _sb, _sc = [input() for _ in range(3)]
print(solve(_sa, _sb, _sc))
# Judge status: Wrong Answer
n = int(input().strip())
a = list(map(int, input().split()))
reps = []

a.sort()
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        reps.append(a[i])
reps = list(set(reps))
reps.sort(reverse=True)
if len(reps) < 2:
    print(0)
else:
    print(reps[0] * reps[1])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 1
if A.count(0) >= 1:
    print(0)
    exit()
for i in A:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
# Judge status: Accepted
import sys
import itertools

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    B = list(itertools.accumulate(A, initial=0))
    s = 0
    ans = 10 ** 12
    for i in range(N - 1, 0, -1):
        s += A[i]
        ans = min(ans, abs(s - B[i]))

    return ans


print(solve())
# Judge status: Accepted
x = int(input())

pow_li = [pow(i,5) for i in range(1000)]

for i in range(1000):
    for j in range(1000):
        if pow_li[i]-pow_li[j]==x:
            print(i,j);exit()
        elif pow_li[i]+pow_li[j]==x:
            print(i,-j);exit()
# Judge status: Accepted
a=sorted(input())
b=sorted(input())[::-1]

if a<b: 
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int,input().split())
s= input()
if s[0:a].count("-") ==0 and s[a]=="-" and s[a+1:a+b+1].count("-")==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c = map(int, input().split())
    if a + b >= c: print("Yes")
    else: print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
min = p[0]

for i in range(n):
    if p[i] <= min:
        min = p[i]
        ans += 1

print(ans)
# Judge status: Accepted
l = list(list(map(int,input().split())) for i in range(3))
first = l[0][0]-l[0][1]
second = l[0][1]-l[0][2]
first1 = l[0][0]-l[1][0]
second2 = l[1][0]-l[2][0]

for k in range(3):
    if (l[k][0]-l[k][1] != first or l[k][1]-l[k][2] != second):
        print("No")
        exit()
for j in range(3):
    if (l[0][k]-l[1][k] != first1  or l[1][k]-l[2][k] != second2):
        print("No")
        exit()     
print("Yes")
# Judge status: Accepted
N = int(input())
S = input()
C = set(list(S))
ans = 0

for i in range(1,N):
  A = 0
  X = S[:i]
  Y = S[i:]
  for j in C:
    if j in X and j in Y:
      A += 1
  ans = max(ans,A)
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

ans = 0
if N==1 and M==1:
    ans = 1
elif N==1:
    ans = max(0, M-2)
elif M == 1:
    ans = max(0, N-2)
elif N==2 or M==2:
    ans = 0
else:
    ans = (M-2)*(N-2)
print(ans)
# Judge status: Wrong Answer
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a2_tot = sum(a2)

if n == 1:
  cnt = a1[0]+a2[0]
else:
  l = []
  for i in range(n):
    x = 0
    for j in range(i):
      x += a1[j]
      x -= a2[j-1]
    x += a2_tot + a2[-1]
    l.append(x)
  cnt = max(l)
  
print(cnt)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
d = a + b + c
print('Yes' if d % 3 == 0 else 'No')
# Judge status: Accepted
n = int(input())

xmin = int(n/1.08)
xmax = int((n+1)/1.08)


if n%27 == 0:
  print(xmax)
elif (n+1)%27 == 0:
  print(":(")
elif xmin == xmax:
  print(":(")
else:
  print(xmax)
# Judge status: Accepted
a,b=map(int,input().split())
if a>=13:
  print(b)
  
elif a>=6 and a<=12:
  print(b//2)
  
else:
  print(0)
# Judge status: Accepted
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)

if n <= k:
    print(0)
    exit()
del h[0:k]
print(sum(h))
# Judge status: Accepted
from fractions import gcd
import math
A, B = map(int, input().split())
AB = gcd(A, B)

def prime_factorize(n) :
    res = []
    for i in range(2, int(math.sqrt(n))+1) :
        if n%i == 0 :
            ex = 0
            while (n%i == 0) :
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1 :
        res.append([n, 1])
    return res

print(len(prime_factorize(AB))+1)
# Judge status: Accepted
a = input().split()
print(a[2] + " " + a[0] + " " + a[1])
# Judge status: Accepted
# -*- coding: utf-8 -*-
# A - Restaurant
# 標準入力の取得
N = int(input())

# 求解
x = 800 * N
y = (N//15) * 200
print(x - y)
# Judge status: Wrong Answer
a,b = map(int, input().split())
print("Possible" if (a+b)%3 == 0 else "Impossible")
# Judge status: Accepted
d, t, s = map(int, input().split())

if (s * t >= d):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
D, N = map(int, input().split())

if D == 0:
  if N == 100:
    print(N+1)
  else:
    print(N)
elif D == 1:
  if N == 100:
    print(100 * N+1)
  else:
    print(100 * N)
else:
  if N == 100:
    print(10000 * N+1)
  else:
    print(10000 * N)
# Judge status: Accepted
x, y = map(int, input().split())

left = 0
right = 10**5
maxi = y//x
while left+1 < right:
    mid = (left+right)//2
    now = 2**mid
    if now > maxi:
        right = mid
    else:
        left = mid

print(left+1)
# Judge status: Wrong Answer
import sys
X = int(input())

while(True):
  flg = True
  if X%2 == 0:
    X += 1
    continue
    
  for i in range(3,X):
    if X%i == 0:
      flg = False
      
  if flg:
    print(X)
    sys.exit()

  X += 2
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print("Yes" if c <= (a + b) * 2 else "No")
# Judge status: Accepted
S, C = map(int, input().split(' '))

scc = min(S, C // 2)

C -= scc * 2

print(scc + C // 4)
# Judge status: Accepted
import math
N,D=map(int,input().split())
print(math.ceil(N/(2*D+1)))
# Judge status: Accepted
ls = list(map(int, input().split()))
ls.sort()
print(ls[0] + ls[1])
# Judge status: Wrong Answer
S=input()
x=dict()
for i in range(len(S)):
    s=S[i]
    if s in x:
        x[s]+=1
    else:
        x[s]=1
l=[]
cnt=0
for idx in x:
    l.append(x[idx])
    cnt+=1
if cnt!=3:
    print("NO")
    exit()
l.sort()
x=l[0]
y=l[1]
z=l[2]
y=y-x
z=z-x
if y>1 or z>1:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())  # 入力

if a % k == 0:
    print('OK')
elif b % k == 0:
    print('OK')
elif (int(a / k) + 1) * k < b:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
A, B, C, X = [int(input()) for i in range(4)]
count=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c==X:
        count+=1
print(count)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum([a[i*2+1] for i in range(n)]))
# Judge status: Accepted
import math
N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    num_success = max(0,math.ceil(math.log2(K / i)))
    ans += (1 / 2) ** num_success
   
print(ans / N)
# Judge status: Accepted
print('YES' if int(input())==len(set(input().split())) else 'NO')
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())

i = 0
j = 0
if H > W:
    while i < N:
        j = j + 1
        i = (H * j) + i
elif H < W:
    while i < N:
        j = j + 1
        i = (W * j) + i
else:
    while i < N:
        j = j + 1
        i = (H * j) + i
print(j)
# Judge status: Accepted
n = int(input())
line1 = list(map(int,input().split()))
line2 = list(map(int,input().split()))
sum1 = sum(line1)
sum2 = sum(line2)
count1 = 0
count2 = 0
box = []
for i in range(0,n):
  count1 += line1[i]
  count2 += line2[i]
  totalgap = count2 - line2[i] +sum1 - count1
  box.append(totalgap)
print(sum1 + sum2 - min(box))
# Judge status: Accepted
N = int(input())
for i in range(7):
  if 2 ** i <= N < 2 ** (i + 1):
    print(2 ** i)
    exit()
# Judge status: Wrong Answer
S=input()
ans=5*len(S)
ans-=abs(5-int(S[0]))
pre=int(S[0])
flag=True
for i in range(1, len(S)):
    cur=int(S[i])
    ans-=abs(cur-5)
    if flag:
        if pre<=4 and cur>=6 or pre>=6 and cur<=4:
            ans+=1
            flag=False
    else:
        flag=True
    pre=cur
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
a = list(map(int,input().split()))
# if m == 1:
#     print(0)
#     exit()
a.sort()
# print(a)
b = []
for i in range(m-1):
    b.append(abs(a[i+1]-a[i]))
b.sort()
b.reverse()
# print(b)
ans = sum(b)-sum(b[0:n-1])
print(ans)
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))

p = sum(w)
sm = 0
for x in w:
  sm += x
  if sm*2 > p:
    print(min(sm*2-p, p-sm*2+x*2))
    break
# Judge status: Accepted
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    n -= 1
    now = ['a']
    for _ in range(n):
        next = []
        for S in now:
            d = ord(max(S)) - ord('a')
            for i in range(d+2):
                next.append(S + chr(i + ord('a')))
        now = next

    now.sort()
    for S in now:
        print(S)
resolve()
# Judge status: Wrong Answer
import math
p, q = map(int, input().split())
distance = math.sqrt(((p)**2)+((q)**2))

print(distance)
# Judge status: Accepted
n,k = map(int,input().split())

h = [0]*n

for i in range(n):

    h[i] = int(input())

h.sort()

ans = float('inf')

for i in range(n-k+1):

    ans = min(ans,abs(h[i+k-1]-h[i]))

print(ans)
# Judge status: Accepted
S = input()
YMD = S.split('/')
MD = int(''.join(YMD[1:]))

ans = 'Heisei' if MD <= 430 else 'TBD'
print(ans)
# Judge status: Wrong Answer
S = input()
ss = str()
for s in S:
  if not s in ss:
    ss = ss + s
  if len(ss)==3:
    print (ss)
    break
# Judge status: Accepted
x, m, d = map(int, input().split())
x = abs(x)
mn = float('inf')
if x // d > m:
    mn = x-m*d
else:
    m -= x//d
    if m % 2 == 0:
        mn = x %d
    else:
        mn = abs(x%d -d)
print(mn)
# Judge status: Accepted
S = input()
N = len(S)

# 1,3,...文字目が'R'でも'U'でも'D'でもない、または、2,4,...文字目が'L'でも'U'でも'D'でもないとき、'No'を出力する
ans = 'Yes'
for i in range(N):
  if (i % 2 == 0 and S[i] != 'R' and S[i] != 'U' and S[i] != 'D') or (i % 2 == 1 and S[i] != 'L' and S[i] != 'U' and S[i] != 'D'):
    ans = 'No'
    break
    
print(ans)
# Judge status: Accepted
from fractions import gcd
a,b = map(int, input().split())
print((a*b)//gcd(a,b))
# Judge status: Accepted
import sys, random
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
    # t, a, b = map(int, input().split())
    t = 1
    
    
    for _ in range(1, t+1):
        # print("Case #{}: ".format(_), end = '')
        
        a, b = [input().strip() for i in range(2)]
        
        if(a == b[:len(a)]):
            print("Yes")
        else:
            print("No")
        
        
main()
# Judge status: Accepted
n = int(input())
S = [''.join(sorted(input())) for _ in range(n)]
cnt = 0
dic = {}
for s in S:
    if s in dic.keys():
        cnt += dic[s]
        dic[s] += 1
    else:
        dic[s] = 1
print(cnt)
# Judge status: Wrong Answer
X,Y = list(map(int,input().split()))
A = Y//X
B = A//2
num = 0
ans = 0
for i in range(1,10000000):
    num += 2**i
    if num > B:
        ans = i+1
        break
if X*(2**ans) <= Y:
    ans += 1
print(ans)
# Judge status: Accepted
n, d = map(int, input().split())
c = 2 * d + 1
print((n + c - 1) // c)
# Judge status: Accepted
s = str(input())
a,b,c = 0,0,0

for i in s:
    if i == "a":
        a += 1
    if i == "b":
        b += 1
    if i == "c":
        c += 1

if a == 1 and b == 1 and c == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
x = 1000
z = 0

if a == sorted(a,reverse=True):
    print(x)

else:
    for i in range(n-1):
        if a[i] <= a[i+1]:
            y = x//a[i]
            x = x -y*a[i]
            z = z+y
        elif a[i] > a[i+1]:
            x = z*a[i]+x
            z = 0
    x = x + z*a[n-1]
    print(x)
# Judge status: Wrong Answer
import numpy as np

n = int(input())

a = list(map(int, input().split()))
a = np.array(a)
a -= np.array(range(1,n+1))

b = int(np.floor(np.mean(a)))

ans = min(int(np.sum(abs(a-b))), int(np.sum(abs(a-b-1))), int(np.sum(abs(a-b+1))))

print(ans)
# Judge status: Wrong Answer
HPa,ATa,HPb,ATb=map(int,input().split())
flag = False
for i in range(0,HPa,ATb):
  if HPb < 0:
    flag = True
  HPb = HPb - ATa
if flag:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

t=sum(a)
m=10**9
flag=0
for i in range(len(a)-1):
    t-=2*a[i]
    if t<=0 :
        if i==0:
            print(abs(t))
            flag = 1
            break
        else:
            print(min(abs(t+2*a[i]),abs(t)))
            flag=1
            break
if flag==0:
    print(t)
# Judge status: Accepted
A,B=map(int, input().split())
if A > 8 or B > 8 :
    print (":(")
else :
    print ( "Yay!")
# Judge status: Wrong Answer
N, K = map(int, input().split(' '))
H = sorted(map(int, input().split(' ')))
if(K >= N):
    print(0)
    exit(0)
for j in range(K):
    H[K - j - 1] = 0
print(sum(H))
# Judge status: Accepted
# r:グー　s:ちょき　p:パー
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
point = {"r":p, "s":r, "p":s}
d = {"r":"p", "s":"r", "p":"s"}

janken = []
score = 0
for i in range(n):
  if len(janken) < k or d[t[i]]!=janken[-k]:
    score += point[t[i]]
    janken.append(d[t[i]])
  else:
    janken.append("")
print(score)
# Judge status: Accepted
W, H, x, y = list(map(int, input().split()))

area = W * H / 2

checker = 0

if(x == W / 2 and y == H / 2):
    checker = 1

print(area, checker)
# Judge status: Wrong Answer

if __name__ == '__main__':
  
  S = input()
  comp_num = 753
  temp = 0
  for i in range(0, len(S)-2):
    temp = int (S[i]+S[i+1]+S[i+2])
    min = abs(comp_num - temp)
    if temp <= min:
      temp = min
  print(min)
# Judge status: Accepted
# ABC126A

n, k = map(int, input().split())
s = input()
a = list(s)
a[k-1] = a[k - 1].lower()
print(''.join(a))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
print(len([0 for i in range(N) for j in range(i + A[i], N) if j - 1 == A[i] + A[j]]))
# Judge status: Wrong Answer
a = int(input())
lis = list(map(int, input().split()))
for i in range(a):
  if lis[i]%2 == 0:
    lis[i] = lis[i]/2
  else:
    break
print(i)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(N - K):
        if A[i] < A[i + K]:
            print("Yes")
        else:
            print("No")  
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    x, k, d = map(int, input().split())
    y = abs(x) // d
    if y == k:
        print(abs(x) % d)
    elif y < k:
        if (k-y) % 2 == 0:
            print(abs(x) % d)
        else:
            print(min(abs(abs(x) % d - d), abs(abs(x) % d + d)))
    else:
        print(min(abs(abs(x)-d*k), abs(abs(x)+d*k)))




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


import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
from string import ascii_lowercase
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------


n = int(input())
S = []
for i in range(n):
    S.append(input().strip())

cmap = defaultdict(lambda :INF)

for s in S:
    for alpha in ascii_lowercase:
        cnt = s.count(alpha)
        cmap[alpha] = min(cnt, cmap[alpha])

ans = ''
for k, v in cmap.items():
    ans += k * v

print(ans)
# Judge status: Accepted
import numpy as np
import math
N,K = map(int, input().split()) 
Logs = np.array([int(x) for x in input().split()])
ave = sum(Logs)/(N+K)
cut = np.array([max(1,int(x/ave)) for x in Logs])
chip = Logs/cut
chip=np.sort(chip)[::-1]
print(math.ceil(chip[N+K-sum(cut)]))
# Judge status: Accepted
from collections import Counter
N = int(input())
x = []
for _ in range(N):
    x.append(input())
c = Counter(x)
print("AC x {}".format(c["AC"]))
print("WA x {}".format(c["WA"]))
print("TLE x {}".format(c["TLE"]))
print("RE x {}".format(c["RE"]))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    ans=1
    if 0 in l:
        print(0)
    else:
        for i in l:
            ans*=i
            if ans>10**18:
                ans=-1
                break
        print(ans)
resolve()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a_dict = {}
s = sum(a)

for ai in a:
  if a_dict.get(ai):
    a_dict[ai] += 1
  else:
    a_dict[ai] = 1

q = int(input())
for _ in range(q):
  b, c = map(int, input().split())
  x = a_dict.get(b, 0)
  s += (c - b) * x
  if a_dict.get(c):
    a_dict[c] += x
  else:
    a_dict[c] = x
  a_dict[b] = 0
  print(s)
# Judge status: Accepted
s = input()
for i in range(2 if len(s) % 2 == 0 else 1, len(s), 2):
    t = s[:-i]
    mid = len(t) // 2
    if t[:mid] == t[mid:]:
        print(len(t))
        break
# Judge status: Wrong Answer
a, b = map(int,input().split())
v = ""
if a == b:
    v = "Draw"
elif a == 1 or a > b:
    v = "Alice"
elif b == 1 or a < b:
    v = "Bob"
print(v)
# Judge status: Accepted
x = int(input())

if 400 <= x <= 599:
    print(8)
if 600 <= x <= 799:
    print(7)
if 800 <= x <= 999:
    print(6)
if 1000 <= x <= 1199:
    print(5)
if 1200 <= x <= 1399:
    print(4)
if 1400 <= x <= 1599:
    print(3)
if 1600 <= x <= 1799:
    print(2)
if 1800 <= x <= 1999:
    print(1)
# Judge status: Accepted
import sys
x,y = [int(x) for x in input().split()]
mod = 10**9+7
if (x+y)%3!=0:
    print(0)
    sys.exit()
n = (2*y-x)//3
m = (2*x-y)//3
if n<0 or m<0:
    print(0)
    sys.exit()

a = 1
for i in range(m+1,n+m+1):
    a = a * i % mod
b = 1
for i in range(1,n+1):
    b = b * i % mod
b = pow(b,mod-2,mod)
print(a*b%mod)
# Judge status: Accepted
from collections import Counter


def main():
    S = input()

    c = Counter(S)

    if len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,we =I()
v=[0]*(n+1);w=[0]*(n+1)
dp=[[0]*(we+1) for i in range(n+1)]
for i in range(1,n+1):
	w[i],v[i] = I()
v=[x for _,x in sorted(zip(w,v))]
w.sort()
for i in range(1,n+1):
	for j in range(w[i],we+1):
		st = dp[i-1][j]
		dt=0
		if w[i]<=j:
			dt=v[i]+dp[i-1][j-w[i]]
		dp[i][j] = max(st,dt)
print(dp[n][we])
# Judge status: Accepted
def MI():return map(int,input().split())
N,M=MI()
sc=[]
for i in range(M):
    x,y=MI()
    sc.append((x,y))
for i in range(0,10**3):
    h=str(i)
    if len(h)==N:
        if all([h[s-1]==str(c) for (s,c) in sc]):
            print(i)
            exit()
print(-1)
# Judge status: Accepted
A, B = map(int,input().split())
import fractions
print(A * B // fractions.gcd(A, B))
# Judge status: Accepted
k, x = map(int, input().split())
l = x - k + 1
r = x + k - 1
if l < -1000000:
  l = -1000000
if r > 1000000:
  r = 1000000

for i in range(l, r+1):
  print(i, end=" ")
# Judge status: Wrong Answer
a,b,c = map(int,input().split(' '))
x = a%b
ans = 'No'
i = 1
while i*x <= c:
    if i*x == c:
        ans = 'Yes'
        break
    i += 1
print(ans)
# Judge status: Accepted
a, v= map(int,input().split())
b, w= map(int,input().split())
t = int(input())
if b < a:
    a*=-1
    b*=-1
if a+v*t >= b+w*t:
    print('YES')
else:
    print('NO')
# Judge status: Accepted

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

ans = list(map(ord, S))
for i in range(len(ans)):
    ans[i] = ans[i] + N
    if ans[i] > ord("Z"):
        ans[i] = ans[i] - 26

for ans in ans:
    print("".join(chr(ans)), end="")
# Judge status: Accepted
a,b=[int(i) for i in input().split()]


if a+b<24:
    print(a+b)
else:
    print(a+b-24)
# Judge status: Wrong Answer
n = int(input())
pVal = 1
idx = 0
res = []
total = 0

while(26 * pVal + total < n):
  n -= pVal
  total += 26 * pVal
  pVal *= 26
  res.append('a')

res.append('a')
n -= pVal

while(n > 0):
  put = n//pVal
  if(put > 0):
    res[idx] = chr(put + 97)

  idx += 1
  n -= put * pVal
  pVal /= 26
  pVal = int(pVal)

print(str.join('', res))
# Judge status: Accepted
H, N = map(int, input().split())
A = map(int, input().split())

attack = sum(A)
if H <= attack:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = str(input())
T = str(input())

if T[:-1] == S:
  print('Yes')
  
else:
  print('No')
# Judge status: Accepted
n = int(input())
s = {}
for i in range(n):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
s = sorted(s.items(), key=lambda x:x[1], reverse=True)
vmax = s[0][1]
ans = []
for si in s:
  if si[1] == vmax:
    ans.append(si[0])
  else:
    break
ans.sort()
for a in ans:
  print(a)
# Judge status: Wrong Answer
ps = list(map(int, input().split()))

print(max([p+q for p in ps for q in ps]))
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x, y, c = [], [], []
for i in range(M):
    x2, y2, c2 = map(int, input().split())
    x.append(x2)
    y.append(y2)
    c.append(c2)

a.sort()
b.sort()
no_ticket = a[0] + b[0]

ticket = 10**5
for i in range(M):
    ticket2 = a[x[i]-1] + b[y[i]-1] - c[i]
    ticket = min(ticket, ticket2)

print(min(no_ticket, ticket))