peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import itertools

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 7
for combs in itertools.product([0, 1], repeat=N):
    tCA = [0] * (M + 1)
    for i, c in enumerate(combs):
        if c:
            for j in range(M + 1):
                tCA[j] += CA[i][j]
    if sum([1 for a in tCA[1:] if a >= X]) == M:
        ans = min(ans, tCA[0])
print(-1 if ans == 10 ** 7 else ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
array = [0]*(10**5+1)
for i in range(n):
    a,b = map(int,input().split())
    array[a] += b
for i in range(1,n+1):
    k -= array[i]
    if k <= 0:
        print(i)
        break
# Judge status: Accepted
N, M = map(int,input().split())
if N > M:
    N, M = M, N
if N == 1:
    if M == 1:
        ans = 1
    else:
        ans = M - 2
elif N == 2:
    ans = 0
else:
    ans = (N - 2) * (M - 2)
print(ans)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
sum=0
if k>=a:
    sum=a
    rem=k-a
else:
    sum=k
    rem=0
if rem==0:
    print(sum)
else:
    if rem>=b:
        rem=rem-b
    else:
        rem=0
        print(sum)
    if rem!=0:
        sum=sum-rem
        print(sum)
    else:
        print(sum)
# Judge status: Wrong Answer
n,k=list(map(int,input().split()))
S=input()
c,row_count=S[0],1

for s in S:
  if c != s:
    c = s
    row_count += 1

if row_count-1 <= k:
  row_count = 1
else:
  row_count -= k*2
  
print(n-row_count)
# Judge status: Accepted
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = S-x-y
    if z >= 0 and z <= K:
      ans +=1

print(ans)
# Judge status: Accepted
k=int(input())
s=input()
len_s=len(s)
if(len_s <= k):
    print(s)
else:
    print(s[:k]+"...")
# Judge status: Accepted
S = input()
cnt = 0
for i in range(len(S)):
    for j in range(len(S)):
        if i == j : pass
        elif S[i] == S[j]: cnt += 1
        else: pass
        if cnt != 0: break
    if cnt != 0 :break
    
print("yes" if cnt == 0 else "no")
# Judge status: Accepted
n = int(input())
a = [ int(x) for x in input().split() ]

cnt = [ 0 for _ in range(n) ]
for i in range(n):
    c = 0
    while True:
        if a[i] & 1:
            break
        c += 1
        a[i] //= 2
    cnt[i] = c

print(min(cnt))
# Judge status: Accepted
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
  print(a*x+b*y)
else:
  if x>=y:
    total=y*2*c
    if a*(x-y)>=2*c*(x-y):
      total+=2*c*(x-y)
    else:
      total+=a*(x-y)
  else:
    total=x*2*c
    if b*(y-x)>=c*2*(y-x):
      total+=2*c*(y-x)
    else:
      total+=b*(y-x)
  print(total)
# Judge status: Wrong Answer
N=int(input())
arr=[]
for i in range(N):
    x,y=map(int,input().split())
    arr.append([x,y])
arr1=arr.copy()
arr1.sort()
arr2=arr.copy()
arr2.sort(key=lambda x:x[1])
print(max((abs(arr1[0][0]-arr1[-1][0])+abs(arr1[0][1]-arr1[-1][1])),abs(arr2[0][0]-arr2[-1][0])+abs(arr2[0][1]-arr2[-1][1])))
# Judge status: Wrong Answer
S = input()
T = input()

if len(S) < 1:
    print("NO")
elif len(S) > 10:
    print("NO")
elif T[:-1] != S:
    print("NO")
elif set(T) - set("abcdefghijklmnopqrstuvwxyz"):
    print("NO")
else:
    print("Yes")
# Judge status: Wrong Answer
s =input()
cnt =0
a =len(s)
if a%2==0:
    a = a/2-1

else:
    a = a//2 -1
for i in range(int(a)):
    if s[i]!=s[-i-1]:
        cnt +=1
        
print(cnt)
# Judge status: Accepted
a,b = map(int, input().split())

if a%3 == 0 or b%3 ==0 or (a+b)%3 ==0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
from math import floor
A,B,N = map(int,input().split())
x = min(B-1,N)
print(floor(A*x/B)-A*floor(x/B))
# Judge status: Accepted
#!/usr/bin/env python3
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
a.reverse()
for i in range(n-1):
    a[i]-=a[i+1]
a[n-1] = 0
a.append(k-sum(a))
ans = k-max(a)
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = sorted(list(map(int,input().split())), reverse = True)
print(sum(a[::2])-sum(a[1::2]))
# Judge status: Accepted
n = int(input())
c = 0
flag = False
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        c += 1
        if c >= 3:
            flag = True
    else:
        c = 0
print('Yes' if flag else 'No')
# Judge status: Wrong Answer
import math
import fractions
A,B=map(int,input().split())
s=fractions.gcd(A,B)
t=math.floor(math.sqrt(s))+1
l=set()
if s%2==0:
  l.add(2)
  while s%2==0:
    s//=2
i=3
while i<=t:
  if s%i==0:
    l.add(s)
    while s%i==0:
      s=s//i
  i+=2
print(len(l)+1)
# Judge status: Accepted
input()
*A,=map(int,input().split())
D=[0]*(10**7)

for a in A:
    D[a-1]+=1
    D[a]+=1
    D[a+1]+=1
print(max(D))
# Judge status: Accepted
def main():
    N = int(input())
    Up = list(map(int,input().split()))
    Down = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        tmp = sum(Up[:i+1]) + sum(Down[i:])
        ans = max(ans,tmp)
    
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
s = input()

s = set(s)

if len(s) == 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
T = [1]
c = [0]*N

k = 1
st = 0
c[0] = 1
cc = 1
for i in range(N):
    k = A[k-1]
    if c[k-1] == 1:
        st = T.index(k)
        f = T[:st]
        r = T[st:]
        break

    T.append(k)
    c[k-1] += 1
    cc += 1

ff = len(f)
if K < ff:
    print(f[K])
else:
    print(r[(K-ff)%(cc-ff)])
# Judge status: Accepted
N = int(input())
table = []
for i in range(N):
    tmp = list(input().split())
    tmp[1] = int(tmp[1]) * (-1)
    tmp_table = [tmp, i+1]
    table.append(tmp_table)
table.sort()
for i in range(N):
    print(table[i][1])
# Judge status: Wrong Answer
def resolve():
    N = int(input())
    x_list = list(map(int, input().split()))

    x_min = min(x_list)
    x_max = max(x_list)
    hp_min = 10**18

    for i in range(x_min, x_max):
        tmp_hp = 0
        for j in x_list:
            tmp_hp += (j - i)**2
        if (hp_min is None) or (tmp_hp < hp_min):
            hp_min = tmp_hp

    print(hp_min)

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if K>=N:
  print(0)
else:
  H=H[K:]
  print(sum(H))
# Judge status: Accepted
l, r, d = map(int, input().split())
ans = r//d - l//d
if l%d == 0 and r%d == 0:
    ans += 1
print(ans)
# Judge status: Accepted
# ABC144 D
from math import atan2,pi

a,b,x=map(int,input().split())
if a*a*b>2*x:
    h=2*x/(a*b)
    print(90-atan2(2*x,a*b*b)*180/pi)
else:
    print(atan2((2*(a*a*b-x)),a**3)*180/pi)
# Judge status: Accepted
S = list(input())
if S[-1] == 's':
    S.append('e')
    S.append('s')
else:
    S.append('s')
strS = ''.join(S)
print(strS)
# Judge status: Accepted
N = int(input())

alpha = [chr(i) for i in range(97, 97+26)]


k=0
while N>=0:
    N -= 26**k
    k += 1

A = []
k -= 1
len_k = k
while k >= 0:
    A.append(N//(26**k))
    N %= (26**k)
    k -= 1

res = []
for i in A[-len_k:]:
    res.append(alpha[i])

print("".join(res))
# Judge status: Accepted
N, K = map(int, input().split())
A = sorted([int(input()) for _ in range(N)])

ans = 1<<60
for i in range(N-K+1):
  x = A[i+K-1] - A[i] # max-min
  ans = min(ans, x)
print(ans)
# Judge status: Accepted
k=int(input())
s=input()
if len(s)<=k:
  print(s)
else:
  print(s[:k]+"...")
# Judge status: Wrong Answer
A,B,C = map(int, input().split())

if A%2==B%2==C%2==0:
  print(0)
else:
  print(min([A*B,B*C,C*A]))
# Judge status: Wrong Answer
import heapq

n = int(input())
a = [int(input()) for _ in range(n)]
m1, m2 = heapq.nlargest(2, a)
for ai in a:
  print(ai if ai != m1 else m2)
# Judge status: Accepted
def L():
  return list(map(int, input().split()))
import math
[n,k]=L()

print(math.floor(math.log(n,k))+1)
# Judge status: Wrong Answer
de=int(input())
c=list(map(int,input().split()))
d=0
f=0
for i in range(de):
    g=sum(list(map(int,input().split())))
    if g>d:
        d=g;f=i
for i in range(d):print(f)
# Judge status: Accepted
N,K = map(int,input().split())
p = list(map(int,input().split()))

s = 0
for i in range(0,K):
    s = s + p[i]
t = s
for j in range(0,N-K):
    u = s + p[j+K] - p[j]
    if u > t:
        t = u
    s = u
print((t+K)/2)
# Judge status: Accepted
N = int(input())

ans = 0
for x in range(1, N + 1):
    n = N // x
    ans += n * (2 * x + (n - 1) * x) // 2
print(ans)
# Judge status: Accepted
N = int(input())
a = sorted(list(map(int,input().split())))

ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
  elif ans == 0:
    print(0)
    exit()
  
print(ans)
# Judge status: Wrong Answer
N, K = [int(i) for i in input().split()]

c = 0
for i in range(1, N+1):
    a = K // i
    b = 1/N*pow(0.5, a)
    c += b
print(c)
# Judge status: Accepted
L = []
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    L.append(a)
    L.append(b)
for j in range(n):
    print(L.count(j+1))
# Judge status: Wrong Answer
n=int(input())
a=[int(input()) for _ in range(n)]
ans=2
count=0
if 2 in a:
  while count<n:
    for i in range(n):
      if a[i]==ans:
        ans=i+1
        count+=1
        if i==0:
          print(count)
          exit()
        break
      elif i==n-1:
        print(-1)
        exit()

print(-1)
# Judge status: Accepted
N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2 + 1)
# Judge status: Accepted
cf = str(input())

if cf[2] == cf[3]:
	 if cf[4] == cf[5]:
	 	print("Yes")
	 else:
	 	print("No")
else:
	print("No")
# Judge status: Accepted
P, Q, R = map(int,input().split())
list = [P + Q, Q + R, R + P]
list.sort(reverse=False)

print(list[0])
# Judge status: Accepted
c = input()

print(chr(ord(c)+1))
# Judge status: Accepted
a = int(input())
b = int(input())
ans = [1,2,3]

ans.remove(a)
ans.remove(b)
print(ans[0])
# Judge status: Accepted
n,a,b  = map(int,input().split( ))
mod = 10**9+7
ans = pow(2,n,mod)
def chs(t,s):
    res = 1
    for i in range(t,t-s,-1):
        res *= i
        res %=mod
    for i in range(1,s+1):
        rev = pow(i,mod-2,mod)
        res *= rev
        res %=mod
    return res
ans -= chs(n,a)
ans -= chs(n,b)
ans -= 1
ans %=mod
print(ans)
# Judge status: Accepted
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]
li.sort()
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))
lin.sort(key=lambda x:(x[1]*(-1),x[0]))
point = lin[0][1]
for i,j in lin:
    if j == point:
        print(i)
    else:
        break
# Judge status: Wrong Answer
def main():
    num_list = list(map(int, input().split()))

    sorted(num_list, reverse=True)

    if num_list[0] -1 >= num_list[1]:
        ans = num_list[0] + num_list[0] -1
    else:
        ans = num_list[0] + num_list[1]

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, M = map(int, input().split())
if abs(N - M) > 2:
    print(0)
    quit()
MOD = 10 ** 9 + 7
fact = [0] * (max(N, M) + 1)
f = 1
for i in range(1, max(N, M) + 1):
    f = f * i % MOD
    fact[i] = f
print(((N == M) + 1) * fact[N] * fact[M] % MOD)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
count=0
suml=sum(l)
i=0
while count<suml/2:
    count+=l[i]
    i+=1
k=suml/2
a=l[i-1]
if count==k:
    print(0)
else:
    print(int(2*(min(count-k,a-count+k))))
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]

for s in S:

    print(s.index(max(s))+1)
# Judge status: Wrong Answer
N = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(N):
  if (i%2 == 1) and (arr[i]%2 == 1):
    count += 1
print(count)
# Judge status: Wrong Answer
s = list(input())
word = ""
for i in s:
  if i != "B":
    word += i
  else:
    if word != "":
      word = word.rstrip(word[-1])
    else:
      pass
print(word)
# Judge status: Accepted
x = int(input())
print((x + 1) % 2)
# Judge status: Wrong Answer
n = int(input())
x = ''
while n != 0:
  x += str(n%2)
  n = -(n//2)
  
if x == '':
  print(0)
else:
  print(x)
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split())


deg_h = 0.5 * (60 * H + M)
deg_m = 6 * M
rad_h = math.radians(deg_h)
rad_m = math.radians(deg_m)

theta = abs(rad_h - rad_m)
c2 = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(theta))
print(math.sqrt(c2))
# Judge status: Wrong Answer
N=int(input())
if N%2==0:
  print(N/2)
else:
  print(N/2+1)
# Judge status: Wrong Answer
def main():
    N, M = map(int, input().split())

    if N == 1 or M == 1:
        print(N*M-2)
        return

    if N == 2 or M == 2:
        print(N*M-4)
        return

    print((N-2)*(M-2))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

X.sort()
gap = [X[i + 1] - X[i] for i in range(M - 1)]
gap.sort()

# gapのエントリのうち大きい方からN - 1個は使わない
# 使うのは (M - 1) - (N - 1) = M - N個
print(sum(gap[0 : M - N]))
# Judge status: Accepted
num = int(input())
gou = 0
for i in range(num+1):
    if (i % 3 == 0) or (i % 5 == 0):
        gou = gou
    else:
        gou += i
print(gou)
# Judge status: Wrong Answer
n, k = map(int, input().split())
X = list(map(int, input().split()))

Xl, Xr = [0], [0]
for x in X:
    if x < 0:
        Xl.append(abs(x))
    else:
        Xr.append(x)
while len(Xl) <= k:
    Xl.append(10**9)
while len(Xr) <= k:
    Xr.append(10**9)
Xl.sort()

ans = 10**9

for i in range(k):
    ans = min(ans, Xl[i] + 2*Xr[k-i], 2*Xl[i] + Xr[k-i])

print(ans)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
if (a*b)%2==0:
    print('Odd')
else:
    print('Even')
# Judge status: Accepted
a,b=map(int,input().split())
k=b-a
print(((1+k)*k)//2-b)
# Judge status: Accepted
from itertools import accumulate
from math import gcd
N = int(input())
*A, = map(int, input().split())

L = list(accumulate(A, gcd))
R = list(accumulate(A[::-1], gcd))[::-1]

ans = max(gcd(l, r) for l, r in zip([0]+L[:-1], R[1:]+[0]))
print(ans)
# Judge status: Accepted
s = input()
print('No' if 'L' in s[::2] or 'R' in s[1::2] else 'Yes')
# Judge status: Wrong Answer
from math import sqrt
N = int(input())
sqN = int(sqrt(N))
ans = 0
for i in range(1,sqN+1):
    ans += i*(N//i)*(N//i+1)//2 
    if N % i == 0:
        j = N//i
        if j > i:
            ans += j*((N//j)*(N//j+1)//2 - 1)
ans += (N - sqN)*(sqN+1+N)//2
print(ans)
# Judge status: Accepted
n,k = input().split()
hate_num = input().split()
num = int(n)
boo = False
while(boo == False):
  dec = []
  for i in str(num):
    dec.append(i not in hate_num)
    
  if(False not in dec):
    boo = True
  num += 1
    
print(num-1)
# Judge status: Accepted
N,A,B = map(int,input().split())
a = N//(A+B)
ans = a*A
ans2 = min(N-(A+B)*a,A)
print(ans+ans2)
# Judge status: Accepted
n = int(input())
ar = list(map(int,input().split()))
l = max(ar)
if 2*l < sum(ar):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import math 
A,B,H,M = map(int,input().split())
print(( A**2 + B **2 - 2*B*A*(math.cos(math.radians(abs(30*H-6*M)))) )**0.5)
# Judge status: Accepted
## C - City Savers
N = int(input()) + 1
A = list(map(int,input().split()))
B = list(map(int,input().split())) + [0]
win = 0
remain = 0
for n in range(N):
    if A[n] < remain:
        win += A[n]
        A[n] = 0
    else:
        win += remain
        A[n] -= remain

    if A[n] < B[n]:
        win += A[n]
        remain = B[n] - A[n]
    else:
        win += B[n]
        remain = 0
print(win)
# Judge status: Accepted
H, N = input().split()
this_list = [int(x) for x in input().split()]
a = sum(this_list)
if(a>= int(H)):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = input()
if S == 'AAA' or 'BBB':
    print('No')
else:
    print('Yes')
# Judge status: Accepted
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if (a + b) == c:
  print('Yes')
elif (b + c) == a:
  print('Yes')
elif (a + c) == b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    ret = 0
    for i in range(1,N):
        ret += A[i//2]
    print(ret)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
for x in a:
  ans,dist = -1,1000000000
  for i in range(m):
    d = abs(x[0]-b[i][0])+abs(x[1]-b[i][1])
    if d < dist:
      ans, dist = i+1,d
  print(ans)
# Judge status: Accepted
n, x = map(int, input().split())
l = map(int, input().split())

d = 0
ans = 1
for li in l:
    d += li
    if d > x:
        break
    ans += 1
print(ans)
# Judge status: Accepted
def resolve():
    n=int(input())
    a=[0]*(60000)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()
# Judge status: Accepted
n, m = map(int, input().split())
inf = 0
sup = 100001
for i in range(m) :
    l, r = map(int, input().split())
    inf = max(inf, l)
    sup = min(sup, r)
if sup >= inf :
    print(sup-inf+1)
else :
    print("0")
# Judge status: Accepted
# -*- coding: utf-8 -*-

N = int(input().strip())
L_list=[int(i) for i in input().rstrip().split()]
#-----

L_list.sort()
print("Yes" if L_list[-1] < sum(L_list[:-1]) else "No")
# Judge status: Wrong Answer
K, A, B = map(int, input().split())
if A >= B or K <= A:
  print(K + 1)
else:
  print(A + ((K - A + 1) // 2) * (B - A)  + ((K - A + 1) // 2))
# Judge status: Accepted
MAX_N = 10**5+100
INF = float('inf')

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

# dp table
# dp[i] := 足場iに行くのにかかる最小のコスト
dp = [INF]*MAX_N
dp[0] = 0

for i in range(1,N):
    for j in range(1,K+1):
        if i-j>=0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, -(-heapq.heappop(a) // 2))
print(-sum(a))
# Judge status: Accepted
N, M, K = map(int, input().split())
def check():
    for i in range(M):
        P = M-2*i
        K1 = K - i*N
        if P==0:
            if K1 == 0:
                return True
            return False
        if K1%P==0 and K1//P<=N and K1//P>=0:
            return True
    return False
if check():
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a=sorted(a,reverse=True)
ans=0
for i in range(n-1):
    if i<n//2+1:
        ans+=a[i]
    else:
        ans+=a[i-n//2]

print(ans)
# Judge status: Accepted
import math

def solve():
    N = int(input())
    ans = 0
    for i in range(2, int(math.sqrt(N)) + 2):
        n = 1
        cnt = 0
        while N % i == 0:
            N //= i
            cnt += 1
            if cnt == n:
                cnt = 0
                n += 1
                ans += 1
    if N != 1:
        ans += 1
    return ans

print(solve())
# Judge status: Accepted
import math

N, D = map(int, input().split())

X = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D): 
            tmp +=(X[i][k]-X[j][k])**2
        tmp = math.sqrt(tmp)
        if (tmp.is_integer()): ans += 1
print(ans)
# Judge status: Accepted
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	s = [0]*(n+1)
	for i in range(n):
		s[i+1] = s[i] + a[i]
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, abs(s[-1] - s[i]*2))
	print(ans)
resolve()
# Judge status: Wrong Answer
x = input()
ans = len(x)
cnt = {"S":0,"T":0}
tar = "S"

for c in x:
    if c == "S" and tar == "T":
        ans -= min(cnt.values())*2
        cnt = {"S":0,"T":0}
    cnt[c] +=  1
    tar = c
else:
    if tar == "T":
        ans -= min(cnt.values())*2
        
print(ans)
# Judge status: Wrong Answer
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1-i):
    zz = i + j
    if zz > S:
      break
    for k in range(K+1-zz):
      z = i + j + k
      if z == S:
        #print(i,j,k)
        ANS+=1
      elif z >= S:
        break
print(ANS)
# Judge status: Accepted
N, M = map(int, input().split())

Pref = [[]for _ in range(N)]

City = []

for _ in range(M):
    prefecture, year = map(int, input().split())
    prefecture -= 1
    Pref[prefecture].append([_, year])

for i in range(N):
    Pref[i].sort(key=lambda x: x[1])
    for j in range(len(Pref[i])):
        s1 = str(i+1).zfill(6)
        s2 = str(j+1).zfill(6)
        Pref[i][j].append(s1+s2)
        City.append(Pref[i][j])
City.sort()
for a, b, c in City:
    print(c)
# Judge status: Accepted
N, A, B = map(int, input().split())
if A > B :
    print(0)
elif N == 1 :
    print(0 if A != B else 1)
else :
    print((B - A) * (N - 2) + 1)
# Judge status: Wrong Answer
def gusuuhantei(i):
    count = 0
    num = i
    while True:
        if num % 2 ==0 and not num == 0:
            num = num / 2
            count += 1
        else:
            break
    return count
N = int(input())
li = [0]*(N+1)
for i in range(N+1):
    li[i] = gusuuhantei(i)
Maxcount = max(li)
index = li.index(Maxcount)
print(index)
# Judge status: Wrong Answer
import heapq

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]
B = sorted(B, key = lambda x: x[1])[::-1]

heapq.heapify(A)
cnt = 0
for i in range(M):
    for _ in range(B[i][0]):  heapq.heappush(A, -max(-heapq.heappop(A), B[i][1]))
    cnt += B[i][0]
    if cnt >= N:  break
print(-sum(A))
# Judge status: Wrong Answer
alp = [chr(i) for i in range(97, 97+26)]
N = int(input())
q = N
s = ""
while True:
  q,m = divmod(q,26)
  if m == 0:
    m = 26
    if q == 1:
      q = 0
  s = alp[m - 1] + s
  if q == 0:
    break
print(s)
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        r = y - x
        print(r)
    else:
        if 0 <= y and 0 <= x:
            print(x * 2 - (x - y) + 1)
        elif y < 0 and 0 <= x:
            print(x - abs(y) + 1)
        else:
            print((x - y) + 2)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m = map(int,input().split())
if n == m == 1:
  print(1)
elif n == 1 or m == 1:
  print((n*m)-2)
else:
  print((n*m)+4-(n+m)*2)
# Judge status: Accepted
X, Y = map(int, input().split())
x, y = (X*2-Y)//3, (Y*2-X)//3
mod = 10**9+7
n = min(x, y)

factorial = [1]
for i in range(1, n+1):
    factorial.append((factorial[i-1]*i)%mod)

p_list = [(x+y)%mod]
for i in range(1, n+1):
    p_list.append((p_list[i-1]*(x+y-i))%mod)
    
if (X+Y)%3 != 0:
    print (0)
elif x < 0 or y < 0:
    print (0)
elif n == 0:
    print (1)
else:
    print (p_list[n-1]*pow(factorial[n], 10**9+5, mod)%mod)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
box=[0]*N
for i in range(N, 0,-1):
    sm = 0
    for j in range(i, N+1, i):
        sm += box[j-1]
    print(i, sm)
    box[i-1] = (sm % 2) ^ a[i-1]
print(sum(box))
print(*[i+1 for i in range(N) if box[i]])
# Judge status: Wrong Answer
n,*a=map(int,open(0).read().split())
ans=1000
num= 0
for i in range(n):
  if i == n-1:
    if a[i-1]<a[i]:
      ans += a[i]*num
  elif a[i]<a[i+1] and a[i+1]<ans:
    num = ans//a[i]
    ans = ans%a[i]
  elif a[i]<a[i+1] and a[i+1]>ans:
    continue
  elif a[i] == a[i+1]:
    continue
  else:
    ans += num*a[i]
  
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(_) for _ in input().split()]
col = [0] * n
cnt = 0
for i in range(n):
    if a[i] >= 3200:
        col[i] = 8
        cnt += 1
    else:
        col[i] = a[i] // 400
ans_min = len(set(col))
ans_max = ans_min
if cnt == n:
    ans_min = 1
    ans_max = cnt
elif cnt > 0:
    ans_min -= 1
    ans_max = ans_min + cnt
print(ans_min, ans_max)