Problem:


Score : 200 points

Problem Statement

You are given two integers K and S.

Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.

How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?  

Constraints

2≤K≤2500 

0≤S≤3K 

K and S are integers.  

Input

The input is given from Standard Input in the following format:

K S

Output

Print the number of the triples of X, Y and Z that satisfy the condition.

Sample Input 1

2 2

Sample Output 1

6

There are six triples of X, Y and Z that satisfy the condition:

X = 0, Y = 0, Z = 2 

X = 0, Y = 2, Z = 0 

X = 2, Y = 0, Z = 0 

X = 0, Y = 1, Z = 1 

X = 1, Y = 0, Z = 1 

X = 1, Y = 1, Z = 0

Sample Input 2

5 15

Sample Output 2

1

The maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z.



Sample input:
2 2


Sample output:
6

Submission status: Runtime Error

Solution code:
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
print(ans)

Submission status: Runtime Error

Solution code:
K, S = [int(x) for x in input().split()]
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S-x-y =< K:
            ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
K, S = [str(x) for x in input().split()]
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S-x-y =< K:
            ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
    if x > s:
        break
    if x+k+k < s:
        continue
    for y in range(k+1):
        xy = x+y
        if xy > s:
            break
        if xy+k < s:
            continue:
        for z in range(k+1):
            xyz = x+y+z
            if xyz > s:
                break
            if xyz == s:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())
count = 0
for i in range(0,K+1):
    X = i
    for j in range(0,K+1):
        Y = j
        for k in range(0,K+1):
            Z = k
            if ( ty == S):
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
count = 0

for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            count += 1
print(count

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if 0 <= S-(i+j) <= K
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())

count = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if i+j+l = S:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())

asn=o

for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k: ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
r,g=map(int,input().split())
X=0
for i in range(g+1):
  for j in range(g+1):
    k=g-i-j
    if k>=0 and k<=n:
      X+=1
print(X)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())

ans = 0

for i in range(k+1):
    for j in range(k+1):
            l = s-i-j
            if i + j + l == s and l>=0
                 ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
#k, s = 5,15

ans = 0

for i in range(k+1):
    for j in range(k+1):
            l = s-i-j
            if i + j + l == s and l>0
                 ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
#k, s = 5,15

ans = 0

for i in range(k+1):
    for j in range(k+1):
            l = s-x-y
            if i + j + l == s and l>0
                 ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split)
#k, s = 5,15

ans = 0

for i in range(k+1):
    x = i
    for j in range(k+1):
        y = j
        for l in range(k+1):
            z = l
            if x + y + z == s:
                 ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
#k, s = 5,15

ans = 0

for i in range(k+1):
    x = i
    for j in range(k+1):
        y = j
        for l in range(k+1):
            z = l
            if x + y + z == s:
                 ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())

ans = 0

for i in range(0,K+1):
    for j in range (0,K+1):
        for k in range (0,K+1):
            if (i + j + k) == S:
                ans = ans + 1
            

print(ans)

Submission status: Runtime Error

Solution code:
k,s = map(int ,input.split())
cou = 0

for i in range(k) :
  for j in range(k):
    for h in range(k):
      if i + j + h == s:
        cou += 1
print(cou)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())

c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1-x)
    for z in range(m+1-x-y)
      if x+y+z==s:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w') 

# readline =sys.stdin.readline

# time - O(n2)
def process():
    k,s = map(int,readline().rstrip().split())
    cnt=0

    for i in range(0,k+1):
        for j in range(0,k+1):
            z = s-(i+j)
            if z>=0 and z<=k:
                cnt+=1
    
    return cnt



# for _ in range(int(readline().rstrip())):
print(process())

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
ans=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z=S:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
input=input().split(" ")
K=int(input[0])
S=int(input[1])
box=[]
for n in range(K+1):
  	box.append(n)
 
count=0
    
for xx in range(K+1):
  for yy in range(K+1):
    for zz in range(K+1):
      	t=box[xx]+box[yy]+box[zz]
        if t== S:
          	count+=1
            
print(str(count))

Submission status: Runtime Error

Solution code:
input=input().split()
K=int(input[0])
S=int(input[1])
box=[]
for n in range(K+1):
  	box.append(n)

count=0
    
for xx in range(K+1):
  for yy in range(K+1):
    for zz in range(K+1):
      	t=box[xx]+box[yy]+box[zz]
        if t== S:
          	count+=1
            
print(str(count))

Submission status: Runtime Error

Solution code:
import sys

k,s = map(int,sys.stdin.buffer.readline().split(' '))

result = 0

for x in range(k+1):
    for y in range(min(s-x+1,k+1)):
        z = s-x-y
        if z < 0: continue
        if z<=k:
            result+=1
        
print(result)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1-i):
    if s-i-j<=2500
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
K, S = map(int,input()split())

c = 0
for i in range(K+1):
  for j in range(K+1):
    z = S - i - j
    if 0 <= z and z <= K:
      c += 1
print(c)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

  
int main() {
  int k,s;
  cin >> k>>s;
 
  
  int count=0;
  for(int x=0; x<k+1; x++){
    for(int y=0; y<k+1; y++){
      for(int z=0; z<k+1; z++){
        if(x+y+z==s){
          count++;
        }
      }
    }
  }
  
  cout << count  << endl;
}

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())

flag = 0
for x in range(a + 1):

    for y in range(a + 1):

        for z in range(a + 1):

            if x + y + z ==b:
                flag +=1
print(flag)

Submission status: Runtime Error

Solution code:
a,b = [int(input())for i in range(2)]
flag = 0

for x in range(a + 1):
    for y in range(a + 1):
        for z in range(a + 1):
            if x + y + z ==b:
                flag +=1
print(flag)

Submission status: Runtime Error

Solution code:
k, s = list(map(int, input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        for n in range(k+1):
            if (i+j+n == k):
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
k, s = list(map(int, input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        if (s-i-j <= k) and (0 <= s-i-j):
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
k, s = list(map(int, input().split()))
count = 0
for i in range(2,k+1):
    for j in range(2,k+1):
        if (s-i-j <= k) and (0 <= s-i-j):
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
k,s = map(int,input().split())
f = 0
for i in range(k):
    for j in range(k):
        for l in range(k):
            if sum(i,j,l)==s:
                f+=1
print(f)

Submission status: Runtime Error

Solution code:
k,s = map(int,input().split())
f = 0
for i in range(k):
    for j in range(k):
        for l in range(k):
            if sum(i,j,k)==s:
                f+=1
print(f)

Submission status: Runtime Error

Solution code:
cnt=0
k,s=map(int,input().split())
for i in range(k+1):
    for j in range(k+1):
        if (0<=s-x-y<=k):
                cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((k+2)(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

Submission status: Runtime Error

Solution code:
k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((k+2)(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2k:
      l += 0
    elif k < s-x <= 2k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

Submission status: Runtime Error

Solution code:
k,s = map(int,input().split())
ans = 0
# 0もあるからレンジはk+1
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if z >= 0 and z <= k　#zの範囲を間違えないように注意
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())

cnt = 0
for x, y, z in range(K+1):
  if x + y + z == S:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())

cnt = 0
for x, y, z in range(K):
  if x+y+z == S:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
k,s=map(int,input())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>s-k:
      count +=1
print(count)

Submission status: Runtime Error

Solution code:
ks = list(map(int, input().split()))
k = min(ks)
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == x + y + z:
                ans += 1
            else:
                pass

print(ans)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
if 2<=K<=2500 and 0<=S<=3*K:
    Ks=[]
    wa=[]
    for i in range(K+1):
        Ks.append(i)
    X,Y,Z =Ks,Ks,Ks
    for x in X:
        if x<=S:
            X_=[]
            X_.append(x)
            for y in Y:
                if y<=S:
                    X_Y_=[]
                    X_Y_=list(X_)
                    X_Y_.append(y)
                    for z in Z:
                        if z<=S:
                            X_Y_Z_=list(X_Y_)
                            X_Y_Z_.append(z) 
                            wa_=sum(X_Y_Z_)
                            wa.append(wa_)
    for j in wa:
        if j==S:
            count+=1
    print(count)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    sys.setrecursionlimit(10 ** 6)
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num *3
    print(num)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
count = 0

for x in range(k + 1):
    x = i
    for y in range(k + 1):
        if (s - x - y >= 0 and s - x - y <= k):
            count += 1
            
print(count)

Submission status: Runtime Error

Solution code:
k, s = int(input().split())
count = 0

for i in range(k):
    x = i
    for j in range(k):
        y = j
        for l in range(k):
            z = l
            if x + y + z == s:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    if S-x<=2*K:
        for y in range(K+1):
            if S-x-y<=K:
                cout += S-x-y+1
#                 for z in range(K+1):
#                     if x+y+z==S:
#                         count += 1
print(count)

Submission status: Runtime Error

Solution code:
count= 0
#全探索は時計が切れる
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - (x +y) <= k:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
k,s=map(int,input(),split())
#k=2
#s=2
result=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:
            result+=1
            
print(result)

Submission status: Runtime Error

Solution code:
k,s=map(int,input(),split())
#k=2
#s=2
result=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:
            result+=1
            
print(result)

Submission status: Runtime Error

Solution code:
k,s=map(int,input(),split())
#k=2
#s=2
result=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:
            result+=1
            
print(result)

Submission status: Runtime Error

Solution code:
k,s=map(int,input(),split())

ans=0
for x in range(k):
    for y in range(k):
        z=S-x-y
        if 0<=s and z<=k:
            ans+=1
            
print(ans)

Submission status: Runtime Error

Solution code:
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 0<=s and z<=k:
            ans+=1
            
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
x=[0]*k
for i in range(0,k):
  x[i]=i
x.append(k)
a=int(s/3)-1
count=0
for i in range(0,len(x)):
  stemp=s-x[i]
  for j in range(0,stemp+1):
    if s-x[i]-x[j] in x:
      count=count+1
print(count)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
ans=0
z=[i for i in range(k+1)]
for x in range(k+1):
    for y in range(k+1):
        a=s-x-y
        if a<=k and z[bisect.bisect_left(z,a)]==a:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
ans=0
z=[i for i in range(k+1)]
for x in range(k+1):
    for y in range(k+1):
        a=s-x-y
        a=min(s-x-y,k)
        if z[bisect.bisect_left(z,a)]==a:
            ans+=1
        
print(ans)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    ifz>=0 andz<=2500:
      cnt+=1
        
print(cnt)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
  for y in range(K + 1):
    if S - x - y <= K:
      conut += 1
print(count)

Submission status: Runtime Error

Solution code:
k,s = map(int(),input().split())
a = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z == s:
        a += 1
        
print(a)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.extend(2*K - s_z + 1)
  else:
    ans.extend(s_z + 1)
 
print(sum(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = [None]*(K+1)
 
for i in z:
  s_z = S - i
  if s_z < 0:
    ans[i] = 0
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = 2*K - s_z + 1
  else:
    ans[i] = s_z + 1
 
print(sum(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    ans[i] = 0
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = 2*K - s_z + 1
  else:
    ans[i] = s_z + 1
 
print(sum(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

K,S=map(int,input().split())

z = list(range(K+1))
ans = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = K + 1 - (s_z - K)
  else:
    ans[i] = s_z + 1

print(sum(ans))

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
ans=0

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    for x in list(range(s_z - K,K+1)):
      y = s_z - x
      answer.append([x, y, z])

  else:
    for x in list(range(0,s_z+1)):
      y = s_z - x
      answer.append([x, y, z])

print(len(answer))

Submission status: Runtime Error

Solution code:
k, s = list(map(input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)

Submission status: Runtime Error

Solution code:
k, s = list(map(input().split()))

num = 0
for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)

Submission status: Runtime Error

Solution code:

import sys
import itertools
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 andz<=k:
            ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=0
for i in range(a+1):
  for j in range(a+1):
    z=k-(i+j)
    if 0<=z<=a:
      c+=1
print(c)

Submission status: Runtime Error

Solution code:
x,s=map(int(input().split()))
n=x+1
a=0
for i in range(n):
    for j in range(n):
        if 0<=s-(i+j)<=x:
            a+=1
print(a)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
ans = 0

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


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

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 1
print(ans)

Submission status: Runtime Error

Solution code:

K, S = map(int, input().split())

count = 0
for i in range(K+1) :
    for j in range(K+1) :
        if S < x + y :
            break
        if S - i - j <= K :
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split)
ans=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z==S:
        ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
import itertools
k, s = map(int, input().split())

#data = [i for i in range(k + 1)]
# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)
target = s / 3
ans = 0
if (target < k):
    pass
elif:
    for x in range(0, k + 1):
        #temp = s - x
        # 2なら、（０、２）（１、１）（２、０）
        for y in range(0, k + 1):
            if (0 <= s - (x + y) <= k):
                ans += 1


print(ans)

'''
ans = 0
for i in dd:
    #print(sum(i))
    if (sum(i) == s):
        ans += 1

print(ans)
'''

Submission status: Runtime Error

Solution code:
 import sys
 import copy
 sys.setrecursionlimit(1000000)
 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)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())

ans = 0
num = max(k, s)

for i in range(num+1):
  for j in range(num+1):
    res = S - (i+j)
    if res >= 0:
      ans += res+1
      
print(ans)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y
    if 0 <= Z and Z <= K
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
x <= k
y <= k
z <= k
count = 0
for e in range(s+1):
  for f in range(s+1):
    for g in range(s+1):
      if e + f + g == s:
        count =count+1
print(count)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
x <= k
y <= k
z <= k
count = 0
for x in range(s+1):
  for y in range(s+1):
    for z in range(s+1):
      if x + y + z == s:
        count =count+1
print(count)

Submission status: Runtime Error

Solution code:
K,S = (int(x) for x in input().split())
count = 0

for x in range(K+1):
    if x > S:
        break
    for y in range(K+1):
        z = s - x - y
        if 0 <= z <= K:
            count += 1
        elif x + y > S:
            break


print(count)

Submission status: Runtime Error

Solution code:
K, S = list(map(int,input().split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if X + Y + Z == S:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
print(sum(1for x in range(K+1)for y in range(K+1)if0<=S-x-y<=K))

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
res = 0
for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if Z in range(K+1)
            res += 1

print(res)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

K, S = MAP()

count = 0

for X in range(0, K+1):
	for Y in range0, (K+1):
		Z = S - X - Y
		if 0 <= Z <= K:
			count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math

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

res = 0

for x in range(k+1):
    for y in range(k+1):
        if x+y < s:
            z = s - x - y
            res += 1

print(res)

Submission status: Runtime Error

Solution code:
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    if 0<= S-i <= K:
        ans += (S-i)+1
    elif S-i <= 2K:
        a = (S-i) -K
        ans += (K-a)+1
print(ans)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0
 
for x in range(int(K)+1):
  for y in range(int(K)+1):
    z = int(S) - x - y
    if 0 <= z and z <= int(K):
    	count += 1

print(count)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0
 
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z and z <= K:
    	count = count + 1
        
print(count)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0

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

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
print(len([for X in range(K+1) for Y in range(K+1) if 0<=S-X-Y<=K]))

Submission status: Runtime Error

Solution code:
#リスト内方表記1,
K, S = map(int, input().split())
print(len([1 for X in range(K+1) for Y in range(K+1) if 0<=S-X=Y<=K]))

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
print(len[1 for X in range(K+1) for Y in range(K+1) if 0<=S-X=Y<=K])

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    if A<=(i//10)+(i%10) and (i//10)+(i%10)<=B:
        ans+=i
print(ans)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0

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

print(count)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0

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

print(count)

Submission status: Runtime Error

Solution code:
K = input()
S = input()
count = 0

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

Submission status: Runtime Error

Solution code:
k,s = int(input())
ans = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y and S-X-Y <= k:
      cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
asn=0
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        if i<j<k:
          ans+=6
        elif i<j==k or  i==j<k:
          ans+=3
        else:
          ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
k,s=map(int, input().split())

for i in range(k+1):
  for j in range(k+1):
    x = s-i-j
    if x>=0 and x<=k:
      ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
		if 0 < s- (i + j) < k:
			ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
	for j in range(k+1):
     	for k in range(k+1):
          if i + j + k ==s:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
s = int(input())

ans = 0

for x in range(k+1):
  for y in range(k+1):
    r = s - (x + y)
    if r >= 0 and r <= k:
      ans += 1

print(ans

Submission status: Runtime Error

Solution code:
k,s  = list(map(int,input().split()))
cnt = 0

def est():
  for x in range(k+1):
    for y in range(k+1):
      if s-(x+y) >=0 and s-(x+y) <= k:
        cnt += 1
  return cnt
print(est())

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n+1):
    for l in range(n+1):
if i+j+l==k:
  ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k)==S:
                count+=1
print(count)

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z=s:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
k,s = list(map(int,input().split()))
ans = 0
for i in range(k):
  for j in range(k):
    if 0 <= s-i-j <= k
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K,S = map(int, input().split())

c=0
for i in range(K+1):
  for j in range(K+1):
    if k > S-i-j:
        c+=1

print(c)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
ans=0
for i in range(S+1):
  for j in range(S+1-i):
    if 0<=i,j,S-i-j<=K:
      ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
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  0 <= z <= k:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y:
      if 0 <= Z and Z <= K:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X + Y + Z = S:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
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 k >= z >= 0:
            ans += 1
print(ans))

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
ans = 0
for x in range(k+a):
    for y in range(k+1):
        z = s-x-y
        if k >= z >= 0:
            ans += 1
print(ans))

Submission status: Runtime Error

Solution code:
ans = 0
k, s = map(int, input().split())
for x in range(k):
  for y in range(k):
    int z = s - x - y
    if 0 <= z and z <= k:
      ans += 1



print(ans)

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)
 
k, s = map(int, input().split())
if s <= k: print(comb(s+2, 2))
elif s <= 2*k: print(3*comb(s-k+2, 2))
else: print(3*comb(s-2*k+2,2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)
 
k, s = map(int, input().split())
if s <= k: print(comb(s+2, 2))
elif s <= 2*k: print(3*comb(s-k+2, 2))
else: print(3*comb(s-2k+2,2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)
 
k, s = map(int, input().split())
if s < k: print(comb(s+2, 2))
elif s < 2*k: print(3*comb(s-k+2, 2))
else: print(3*comb(s-2k+2,2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)

k, s = map(int, input().split())
if s < k: print(comb(s+2, 2))
elif s < 2k: print(3*comb(s-k+2, 2))
else: print(3*comb(s-2k+2,2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)

k, s = map(int, input().split())
print(comb(s-3k+2, 2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == r: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)
 
k, s = map(int, input().split())
print(comb(s-3k+2, 2))

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if r == 0  or n == k: return 1
  else: return comb(n-1, r) + comb(n-1, r-1)
 
k, s = map(int, input().split())
print(comb(s-3k+2, 2))