peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = int(input())

mod = 10 ** 9 + 7


fact = [0] * 3000
fact[0] = 1
for i in range(1, 3000):
    fact[i] = fact[i - 1] * i % mod

invfact = [0] * 3000
invfact[3000 - 1] = pow(fact[3000 - 1], mod - 2, mod)
for i in range(3000 - 1, 0, -1):
    invfact[i - 1] = invfact[i] * i % mod


def nCk(n, k):
    return fact[n] * invfact[k] * invfact[n - k] % mod


ans = 0
for n in range(1, S):
    if 3 * n > S:
        break
    ans += nCk(S - 3 * n + n - 1, n - 1)
    ans %= mod

print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())
if C>=A and C<=B :
    print('Yes')
else :
    print('No')
# Judge status: Wrong Answer
o = [input()]
e = [input()] 

for i, j in zip(o, e): print(i+j , end="")
# Judge status: Accepted
a = input()
if a[-1] == "3":
  print("bon")
elif a[-1] == "0" or a[-1] == "1" or a[-1] == "6" or a[-1] == "8":
  print("pon")
else:
  print("hon")
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()
query = [list(map(int,input().split())) for _ in range(Q)]

cum_sum = [0,0]
tmp = 0
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        tmp += 1
    cum_sum.append(tmp)
# print(cum_sum)

for q in query:
    print(cum_sum[q[1]] - cum_sum[q[0]])
# Judge status: Wrong Answer
X=int(input())
a=0
b=1
while a<X:
  a+=b
  b+=1
print(b)
# Judge status: Accepted
import sys

N,M = map(int, input().split())
X = list(map(int, input().split()))

ans = 0
if N >= M:
    print(ans)
    sys.exit()

X.sort()

L = []
for i in range(1, len(X)):
    L.append(X[i]-X[i-1])

L.sort(reverse=True)
print(X[M-1]-X[0]-sum(L[:N-1]))
# Judge status: Accepted
s=[int(i) for i in input()]
ans=0
for i in range(1,len(s)):
	ans+=s[~-i]==s[i]
	s[i]=not s[~-i]
print(ans)
# Judge status: Accepted
def main():
    S = int(input())
    dp = [0]*(S+1)
    dp[0] = 1
    dp[1] = 0
    if S >= 2:
        dp[2] = 0
    for i in range(3,S+1,1):
        for j in range(0,i-2,1):
            dp[i] += dp[j]

    return dp[S]%1000000007

print(main())
# Judge status: Wrong Answer
k,s=map(int,input().split())
count=0

for x in range(k+1):
  for y in range(k+1-x):
    z=s-x-y
    if z>=0 and z<=k:
      count+=1
print(count)
# Judge status: Accepted
N, H = map(int,input().split())
L = []
maxi = 0
for _ in range(N):
    a,b = map(int,input().split())
    maxi = max(maxi, a)
    L.append(b)
 
#L = sorted([x for x in L if x > maxi])[::-1]
L = sorted(filter(lambda x:x>maxi,L))[::-1]
throw = 0
for i in range(len(L)):
    throw += L[i]
    if throw >= H:
        print(i + 1)
        quit()
from math import ceil
print(ceil((H - throw) / maxi) + len(L))
# Judge status: Accepted
n,m = map(int,input().split())
a = [list(map(int,input().split()))for i in range(m)]

for i in range(10**n):
    tmp = str(i)
    if len(tmp) == n:
        f = True
        for s,c in a:
            if tmp[s-1] != str(c):
                f = False
                break
        if f :
            print(i)
            exit()
print(-1)
# Judge status: Accepted
fifcount = 0
sevcount = 0
s  = list(map(int, input().split()))

for i in range(3):
  if s[i] == 5:
    fifcount += 1
  elif s[i] == 7:
    sevcount += 1
if fifcount ==2 and sevcount ==1:

  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
X = int(input())
if X >= 30:
    print('yes')
else:
    print('no')
# Judge status: Accepted
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  dl = 2
  while dl < len(S):
    center = (len(S) - dl) // 2
    if S[:center] == S[center:-dl]:
      print(len(S)-dl)
      return
    dl += 2


if(__name__ == '__main__'):
  main()
# Judge status: Wrong Answer
S = list(input())
for i in range(len(S) - 1):
    if S[i:i + 2] == ["h","i"]:
        print('Yes')
        exit()
if S == ["h","i"]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
s = s.replace("dreamer", "")
s = s.replace("dream", "")
s = s.replace("erase", "")
s = s.replace("eraser", "")
if len(s) == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = input()
if s[-1] == 's':
  print(s + 'es')
else:
  print(s + 's')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = a[-1]
top = n
bottom = 0
while  top - bottom > 1:
    mid = ( top + bottom )//2
    if a[mid]*2 <= k:
        bottom = mid
    else:
        top = mid
print(k)
sa = abs(a[bottom] -(k//2))
if bottom+1 < n-1 and abs(a[bottom+1]-(k//2)) < sa:
    print(a[bottom+1])
else:
    print(bottom)
# Judge status: Accepted
c = [0 for i in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 'Yes'
for i in range(1, 3):
    if c[i][0] - c[0][0] != c[i][1] - c[0][1] or c[i][1] - c[0][1] != c[i][2] - c[0][2]:
        ans = 'No'
print(ans)
# Judge status: Accepted
h,w,n=map(int,[input() for i in range(3)])
a=max(h,w)
print((n+a-1)//a)
# Judge status: Accepted
x=list(map(int, input().split()))
if x[0]+x[1]>=x[2] and x[0]<=x[2]:
	print('YES')
else:
	print('NO')
# Judge status: Accepted
a, b, c = map(int, input().split())
list = [a, b, c]
list.sort()
if list[0] + list[1] == list[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted

n=int(input())
p=[int(x) for x in input().split()]

ps=sorted(p)
cnt=0
for i in range(len(p)):
    if p[i]!=ps[i]:
        cnt+=1
if cnt<=2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n,m = map(int,input().split())

ball = [1]*n
d={}
for i in range(1,n+1):
    d[i]=0
d[1]=1

for _ in range(m):
    x,y = map(int,input().split())

    ball[x-1]-=1
    if d[x]==1:
        if ball[x-1]==0:
            d[x]=0
        d[y]=1
    ball[y-1]+=1

cnt=0
for _ ,v in d.items():
    if v==1:
        cnt+=1


print(cnt)
# Judge status: Wrong Answer
n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))

ans=1
m_t=max(t)  
for i in range(n):
    if m_t%t[i]!=0:
        for j in range(n):
            ans*=t[j]
        print(ans)
        break
    else:
        if i==n-1:
            print(m_t)
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(min(a,b))
# Judge status: Accepted
import sys
import math
import statistics
import itertools
from collections import deque

#n=int(input())
l,r,d=map(int,input().split())
#lis=list(map(int,input().split()))
ans=0
for i in range(l,r+1):
    if i%d==0:
        ans+=1

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

s=0

for i in range(0,n):
  s+=i+1
  
print(s)
# Judge status: Accepted
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, W = [int(item) for item in input().split()]
    item = np.array([[int(item) for item in input().split()] for _ in range(N)])

    dp = np.zeros((2, W+1), dtype='int64')

    for i in range(N):
        dp[i%2 ^ 1] = dp[i % 2]
        w, v = item[i]
        np.maximum(dp[i%2][:-w] + v, dp[i%2][w:], out=dp[i%2 ^ 1][w:])
        # print(dp[i+1])
    print(dp[N%2][W])

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
X = int(input());
happy = 0;

if(X >= 500):
    n = X // 500;
    # print(n);
    happy += n * 1000;
    # print(happy);
    m = X % 500;
    if(m >= 5):
        l = m // 5;
        happy += l * 5;
    
print(happy);
# Judge status: Accepted
N,M,X,Y = map(int,input().split())
lsx = list(map(int,input().split()))+[X]
lsy = list(map(int,input().split()))+[Y]
if max(lsx) < min(lsy):
    print('No War')
else:
    print('War')
# Judge status: Wrong Answer
R = int(input())
import math
pi = math.pi
print(2 * pi * R ** 2)
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14

if a == b:
    print("Drew")
elif a > b:
    print("Alice")
else:
    print("Bob")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

p = [0]*n
t = 1
for i in a:
  p[i-1] = t
  t += 1
print(*p)
# Judge status: Accepted
#ライブラリの読み込み
import math

#入力値の格納
x = int(input())

#得点の計算
score = int((x // 500 * 1000) + (x % 500 // 5 * 5))

#表示
print(score)
# Judge status: Wrong Answer
n=int(input())
res=0
M=[[0 for _ in range(10)] for _ in range(10)]
for i in range(n):
  a=i%10
  b=int(str(i)[0])
  M[a][b]+=1
for i in range(1,10):
  for j in range(1,10):
    res+=M[i][j]*M[j][i]
    
print(res)
# Judge status: Accepted
h,w=map(int,input().split())
print(-(-(h*w)//2) if h!=1 and w!=1 else 1)
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys

N,K,*A = map(int, sys.stdin.buffer.read().split())

for _ in range(K):
  Anext = [0 for _ in range(N+1)]
  for i in range(N):
    Anext[max(0,i-A[i])] += 1
    Anext[min(N,i+A[i]+1)] -= 1
  cumsum = 0
  for i in range(N):
    cumsum += Anext[i]
    A[i] = cumsum
  if min(A)==N:
    break

print(' '.join([str(a) for a in A]))
# Judge status: Accepted
import sys
import math
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    n = int(input())

    ans = 10**n - 9**n - 9**n + 8**n
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)
# Judge status: Accepted
n = int(input())
L = list(map(int, input().split()))
idx = L.index(max(L))
sum_L = 0
for i in range(len(L)):
    if i == idx:
        pass
    else:
        sum_L += L[i]

if L[idx] < sum_L:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
A = int(input())
temp = N%500
if temp<=A:
    print("Yes")
elif temp > A:
    print("No")
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += sum(range(i,n,i))
print(ans)
# Judge status: Accepted
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b

n=int(input())
a=list(map(int,input().split()))
s=Csum(a)
su=sum(a)
b=1
c=0
for i in range(n+1):
    c+=b
    b-=a[i]
    if b<=0:
        if i==n and b==0:
            break
        print(-1)
        exit()
    b=min(b*2,su-s[i+1])
print(c)
# Judge status: Wrong Answer
a,b = input().split()
c = int(a+b)
n = 101
for i in range(n):
  if i**2 == c:
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
import collections

N, C, K = map(int, input().split())
T = collections.deque()
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
T = collections.deque(T)
#print(T)
ans = 0

while T:
    time = T[0] + K
    cnt = 0
    while T[0] <= time:
        T.popleft()
        cnt += 1
        if cnt >= C:
            break
        if not T:
            break
    ans += 1
print(ans)
# Judge status: Accepted
from collections import defaultdict

n = int(input())
alst = list(map(int, input().split()))
ans = 0
dd = defaultdict(int)
for a in alst:
    dd[a] += 1
for _, num in dd.items():
    ans += num * (num - 1) // 2
for a in alst:
    num = dd[a]
    ret = ans - num * (num - 1) // 2 + (num - 1) * (num - 2) // 2
    print(ret)
# Judge status: Accepted
from collections import Counter
n=int(input())
w=Counter(input())
for i in range(n-1):
    w &=Counter(input())
ans=""
for i,j in sorted(w.items()):
    ans +=i*j
print(ans)
# Judge status: Wrong Answer
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  print((2*N+M)//4)
  return 

main()
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
sum = 0
count = 0
for i in range(1,n+1) :
	s = str(i)
	l = len(s)
	sum = 0
	for j in range(l):
		sum += int(s[j])
	if 	sum >= a and sum <= b:
		print(i)
		count += i

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

answer = a + b
if answer % 3 == 0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
blue_cards = [input() for _ in range(n)]
m = int(input())
red_cards = Counter([input() for _ in range(m)])

sources = set(blue_cards)
blue_cards = Counter(blue_cards)

result = -1
for x in sources:
  tmp = blue_cards[x]
  
  if x in red_cards:
    tmp -= red_cards[x]
  
  result = max(result, tmp)
  
print(0 if len(blue_cards) == len(red_cards) == 1 else result)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

cnt, t = 0, 0
for i in range(1,n):
    if a[i] == a[i - 1] and t == 0:
        continue
    elif a[i] >= a[i - 1] and t >= 0:
        t = 1
    elif a[i] <= a[i - 1] and t <= 0:
        t = -1
    else:
        cnt += 1
        t = 0
else:
    cnt += 1
print(cnt)
# Judge status: Accepted
a = list(map(int, input().split()))

a = sorted(a)
if a[0] + a[1] == a[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math

a,b,x=map(int,input().split())
x/=a
half=a*b/2
if x>half:
    print(math.degrees(math.atan(2*(a*b-x)/a/a)))
else:
    print(math.degrees(math.atan(b/(2*x/b))))
# Judge status: Accepted
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
s, c = 0, 0
ans = 0
for t in T:
    if t <= s + K and c:
        c -= 1
    else:
        s = t
        c = C - 1
        ans += 1
print(ans)
# Judge status: Accepted
import math
N, M = map(int, input().split())

l = []
for i in range(1, int(math.sqrt(M))+1):
  if M % i == 0:
    l.append(i)
    if i != M//i:
      l.append(M//i)
      
l.sort(reverse=True)
for n in l:
  if n*N <= M:
    ans = n
    break
print(ans)
# Judge status: Wrong Answer
S=input()
print("Yes" if S.count("N")==S.count("S") and S.count("W")==S.count("E") else "No")
# Judge status: Wrong Answer
n = int(input())
s = input()
a = [c for c in s]
ans = 0
t1 = a.count('W')
t2 = a.count('R')
ans += (t1*t2)//n + 1
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = sorted(map(int, input().split()))
print(A[:K])
# Judge status: Accepted
def prime_factorize(n):
    ans = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        while True:
            if not n % i == 0:
                break
            ans.append(i)
            n /= i
        if n == 1:
            break
    if n != 1:
        ans.append(int(n))
    return ans

a, b = map(int, input().split())
s = set(prime_factorize(a))
t = prime_factorize(b)
ans = 1
for i in s:
    if i in t:
        ans += 1
print(ans)
# Judge status: Accepted
import bisect
N,K=map(int,input().split())
X=list(map(int,input().split()))

L=bisect.bisect_left(X,0)
Z=1 if L<N and X[L]==0 else 0
R=N-L-Z

l=max(0,L-(K-Z))
r=l+K-1
ans=10**8*4
while r<N:
    if X[l]<0<X[r]:
        tmp=min(abs(X[l]),abs(X[r]))*2 + max(abs(X[l]),abs(X[r]))
    else:
        tmp=max(abs(X[l]),abs(X[r]))
    ans=min(ans,tmp)
    l+=1
    r+=1

print(ans)
# Judge status: Wrong Answer
f=lambda:map(int,input().split())
N,X=f()
*A,=f()

c=0
for i in range(N-1):
 c+=max(0,A[i]+A[i+1]-X)
 A[i+1]=min(A[i+1],X-A[i])
print(c)
# Judge status: Accepted
def main():
    N, *AB = map(int, open(0).read().split())
    ans = 0
    for i in range(N - 1, -1, -1):
        a = AB[i * 2 + 0]
        b = AB[i * 2 + 1]
        ans += (b - a - ans) % b
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
input_arr = input().split(" ")
a = int(input_arr[0])
b = int(input_arr[1])
c = int(input_arr[2])
d = int(input_arr[3])

AC = a * c
AD = a * d
BC = b * c
BD = b * d

l = [AC, AD, BC, BD]
print(max(l))
# Judge status: Accepted
import math

H, N = list(map(int, input().split()))
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))

dp = [0]*(H+1)

dp[0] = 0

for i in range(1,H+1):
    dp_min = math.inf
    for j in range(N):
        dp_min = min(dp_min, dp[max(0,i-A[j])] + B[j])
    dp[i] = dp_min

print(dp[H])
# Judge status: Accepted
l, r=map(int,input().split())
if r-l>=2019:
    minimum=0
else:
    left,right=l%2019,r%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
# Judge status: Accepted
from math import ceil
N,H=list(map(int,input().split()))
a_max=0
b_list=[]
for _ in range(N):
    a,b=list(map(int,input().split()))
    a_max = max(a_max,a)
    b_list.append(b)
b_list = sorted(b_list,reverse=True)

ans=ceil(H/a_max)
bcount=0
for b in b_list:
    bcount+=1
    H=max(0,H-b)
    ans=min(ans,bcount+ceil(H/a_max))

print(ans)
# Judge status: Accepted
n=int(input())
if n%2==1:
    print((n+1)/(2*n))
else:
    print(n/(2*n))
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
S = float('inf')
all = sum(W)
for i in range (1,N+1):
  A = sum(W[0:i])
  s_t = abs(all - 2*A)
  if s_t < S:
    S = s_t
print(S)
# Judge status: Accepted
s = input().split()
print(s[1],end='')
print(s[0])
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
a = 0
b = sum(W)
dif = b

for i in range(N):
  a += W[i]
  b -= W[i]
  if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
    
print(dif)
# Judge status: Wrong Answer
w,s = input().split()

print("unsafe" if int(w) >= int(s)  else "safe")
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))
M = 998244353
from collections import Counter

if D[0] != 0:
    print(0)
    exit(0)

cd = Counter(D)
tmp = sorted(cd.items(), key=lambda x: x[0])

ans = 1
for kx in range(1, len(tmp)):
    __, p = tmp[kx-1]
    _, v = tmp[kx]
    ans *= p**v %M

print(ans)
# Judge status: Accepted
n=input()
l=set(list(n))
b=True
for x in l:
    if n.count(x)%2==1:b=False
if b:print("Yes")
else:print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
countUp = 0
sumA = sum(A)
minA = 2020202020 * N
for x in range(N):
    countUp += A[x]
    sumA -= A[x]
    minA = min(minA, abs(countUp - sumA))
print(minA)
# Judge status: Accepted
def main():
 s = input()
 if s == 'SUN':
     print(7)
 elif s == 'MON':
     print(6)
 elif s == 'TUE':
     print(5)
 elif s == 'WED':
     print(4)
 elif s == 'THU':
     print(3)
 elif s == 'FRI':
     print(2)
 else:
     print(1)
main()
# Judge status: Accepted
n,m,X,Y=map(int,input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
Mx=max(x)
my=min(y)
if Mx<my and Mx<Y and X<my:
  print("No War")
else:
  print("War")
# Judge status: Accepted
X=input()
Y=[0]*len(X)
#Sは0,Tは1
for i in range(len(X)):
    if X[i]=='T':
        Y[i]=1
#print(Y)

from collections import deque

Z=deque([])
for i in range(len(X)):
    c=Y[i]
    if c==0:
        Z.append(c)
    elif Z==deque([]):
        Z.append(c)
    elif Z[-1]==1:
        Z.append(c)
    else:
        Z.pop()

print(len(Z))
# Judge status: Accepted
N = 0
S = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

try:
  N = int(input())
  for i in range(N):
      result = input()
      for k in S:
          if k == result:
              S[k] += 1
except:
  pass

for k in S:
    print('%s x %d' % (k, S[k]))
# Judge status: Accepted
n = int(input())
cnt = 0
prim = [1]*(n)
for i in range(2,n):
  k = i
  while k<n:
    prim[k] += 1
    k += i
for i in range(1,n):
  tmp = n-i
  cnt += prim[tmp]
print(cnt)
# Judge status: Accepted
N = int(input())

count = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        #print("FizzBuzz")
        pass
    elif i % 3 == 0:
        #print("Fizz")
        pass
    elif i % 5 == 0:
        #print("Buzz")
        pass
    else:
        count += i
print(count)
# Judge status: Accepted
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    P=tuple(map(int,input().split()))
    Q=tuple(map(int,input().split()))

    permutations = list(itertools.permutations(range(1,n+1)))
    a = permutations.index(P)
    b = permutations.index(Q)
    print(abs(a-b))    

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
T = input()
ans =  ""
for i in range(len(T)):
    if T[i] == "P":
        ans += "P"
    elif T[i] == "D":
        ans += "D"
    elif T[i] == "?":
        if i == 0:
            ans += "D"
        else:
            if ans[i-1]== "P":
                ans += "D"
            else:
                ans += "P"
print(ans)
# Judge status: Accepted
def main():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
a,b,c = map(int, input().split())
if a == b and b == c:
    count=0
    print(count)
    sys.exit()
    
ls = [a,b,c]
ls.sort(reverse=True)
count = 0

if (ls[1]-ls[2])%2 != 0:
    ls[2] = ls[2]+1
    ls[0] = ls[0]+1
    count +=1

while ls[1] - ls[2] >= 2:
    ls[2] += 2
    count += 1

if ls[1] - ls[2] == 1:
    ls[2] += 1
    count +=1

dif = ls[0] - ls[1]
count = count + dif

print(count)
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
X = int(input())

total = 0
count = 0

for a in range(A):
  a += 1
  for b in range(B):
    b += 1
    for c in range(C):
      c += 1
      
      total = 500*a+100*b+50*c
      if total == X:
        count += 1
        
        
print(count)
# Judge status: Accepted
# D - Knapsack 1
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

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

for i in range(N):
    for j in range(W+1):
        # 選ぶ場合
        if j-w[i]>=0:
            dp[i+1][j]=dp[i][j-w[i]]+v[i]
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
print(dp[N][W])
# Judge status: Wrong Answer
A,B=map(int,input().split())
if A>8 or B>8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
import math
print(math.ceil(int(input())/111)*111)
# Judge status: Accepted
n=int(input())
s=0
for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        s+=i
print(s)
# Judge status: Wrong Answer
import math
n,m = map(int,input().split())

ans = n
m = m - 2*n
ans += math.floor(m/4)
print(ans)
# Judge status: Accepted
s = input()
bonlist = ["3"]
ponlist = ["0","1","6","8"]
if str(s)[-1] in bonlist:
  	print("bon")
elif str(s)[-1] in ponlist:
  	print("pon")
else:
  	print("hon")
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
ans=0

for i in range(60):
  x=0
  for j in range(N):
    if A[j]>>i&1: x+=1
  ans+=x*(N-x)*(2**i)
print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
while True:
    c-=b
    if c<=0:
        print("Yes")
        break
    a-=d
    if a<=0:
        print("No")
        break
# Judge status: Accepted
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        l = s - i - j
        if l >= 0 and l <= k:
            count += 1

print(count)
# Judge status: Accepted
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
    dic[a[i]] += 1
ans = 0
for k, v in dic.items():
    if k < v:
        ans += v - k
    elif v < k:
        ans += v

print(ans)
# Judge status: Accepted
def main():
    N, X, T = (int(i) for i in input().split())
    print((0--N//X)*T)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
work = [0]*n
for i in range(n):
  work[i] = list(map(int, input().split()))

work.sort()
k = 0
workable = []
heapq.heapify(workable)
ans = 0
for i in range(m):
  while k < n:
    if work[k][0] <= i+1:
      heapq.heappush(workable, -work[k][1])
      k += 1
    else:
      break
  if workable:
    ans += -heapq.heappop(workable)
print(ans)
# Judge status: Accepted
#二分探索を使った解法
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
while M != 0:
    x = bisect.bisect_left(A,A[-1]//2)
    if N-x <= M:
        M -= N-x
        for i in range(x,N):
            A[i] = A[i]//2
        A.sort()
    else:
        for i in range(N-M,N):
            A[i] = A[i]//2
        M = 0
        A.sort()

print(sum(A))
# Judge status: Wrong Answer
from itertools import combinations
def calc(a,b,l):
    if b - a ==1:
        return 1
    c =  0
    ll = []
    for i in range(b, a + 1):
        p = list(combinations(l,i))
        for j in p:
            s = sum(list(j))
            if s not in ll:
                c +=1
    return c
l = []
a,b = map(int, input().split())
for k in range(a+1):
    l.append(k)
print(calc(a, b , l))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

e = 10**18
ans = a[0]
if 0 in a:
    print(0)
    exit()

for i in range(1, n):
    ans = ans * a[i]
    if ans > e:
        print(-1)
        exit()
print(ans)
# Judge status: Wrong Answer
S = "ABC"
if S == "ABC" : 
  print("ARC")
S = "ARC"
if S == "ARC" :
  print("ABC")