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: Wrong Answer

Solution code:
K,S = map(int,input().split())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            V = i + j + k
            if V == S:
                ans += 1
                break
            elif V > S:
                break
    
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            comb = [i, j, m]
            sum_set.append(comb)
            break
print(len(sum_set))

Submission status: Wrong Answer

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

i=0

for l in range(k+1):
  for m in range(k+1):
    if 0<s-l-m<=k:
      i+=1
      
print(i)

Submission status: Wrong Answer

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

for i in range(K+1):
  for j in range(K+1):
    v = S-(i+j)
    if v <= K and i+j+v == S:
      ans += 1
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    if S - i < K:
        count += S - i + 1
    elif K <= S - i <= 2 * K:
        count += 2 * K - S + i + 1
    else:
        continue
print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    if S - i <= K:
        count += S - i + 1
    elif K < S - i <= 2 * K:
        count += 2 * K - S + i + 1
    else:
        continue
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
list2K = [i for i in range(2*K)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
K, S = map(int, input().split())
ans = 0
for z in range(0, min(S + 1, K + 1)):
    #print(z)
    if S - z <= 2 * K:
        x1 = min(K, S - z)
        y1 = S - z - x1

        y2 = min(K, S - z)
        x2 = S - z - y2

        ans += gcd(abs(x1 - x2), abs(y1 - y2)) + 1
        print(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
KS = list(map(int,input().split()))
sum =0
K = KS[0]
S = KS[1]
N=K+1
for i in range(N):
	if(S-i) > 2*K:
		continue
	for m in range(N):
		if(i+m) > S:
			break
		if (S -m-i) <= K:
			sum+=1
			print(i,m)
print(sum)

Submission status: Wrong Answer

Solution code:
KS = list(map(int,input().split()))
sum =0
K = KS[0]
S = KS[1]
N=K+1
for i in range(N):
	if(S-i) > 2*K:
		continue
	for m in range(N):
		if(i+m) >= S:
			break
		if (S -m-i) <= K:
			sum+=1
			print(i,m)
print(sum)

Submission status: Wrong Answer

Solution code:
KS = list(map(int,input().split()))
sum =0
N = KS[0] + 1
for i in range(N):
	for m in range(N):
		for n in range(N):
			print(i,m,n)
			if i+m+n == KS[1]:
				sum += 1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    mi = min(k, s)
    ma = max(k, s)
    for i in range(mi + 1):
        for j in range(mi + 1):
            res += int(0 == s - i - j - k)
    print(res)

Submission status: Wrong Answer

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

K+=1

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

print(count)

Submission status: Wrong Answer

Solution code:
# N^2
K, S = map(int, input().split())

K+=1

count=0
for i in range(K):
    for j in range(0, K-i):
        tmp = S - (i + j)
        if tmp>=0 and tmp<=K:
            count+=1
#             print(i,j,tmp)

print(count)

Submission status: Wrong Answer

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

K+=1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 0

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

Submission status: Wrong Answer

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


def calc_xyz(target, limit):
    xyz_list = []
    for x in range(min(limit, target) + 1):
        yz_sum = target - x
        for y in range(min(limit, yz_sum) + 1):
            z = target - x - y
            if 0 <= z <= limit:
                xyz_list.append([x, y, z])
    return xyz_list


print(calc_xyz(s, k))

Submission status: Wrong Answer

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


def calc_xyz(target, limit):
    xyz_list = []
    for x in range(min(limit, target) + 1):
        yz_sum = target - x
        for y in range(yz_sum + 1):
            z = target - y
            if 0 <= z <= limit:
                xyz_list.append([x, y, z])
    return xyz_list


print(len(calc_xyz(s, k)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for x in range(K+1):
    max_y = S - x if S - x < K else K
    for y in range(max_y + 1): 
        max_z = S - x - y if S - x -y < K else K
        for z in range(max_z):
            if (x + y + z) == S:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if i + j > s:
                break
            else:
                n = s - i - j
                if 0 <= n <= k:
                    print(i, j, n)
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
def xyz(k,s):
    if s//k == 3 :
        return 1
    if s//k < 3 :
        x = 3
    
    if s > 1 :

        if s - k <= 1 :

            x += (s//2)*3

        else:

            x += ((s//2)-(s-k-1))*3

    if s > 2 :

        if s-k <= 2 :

            if s % 2 == 1:

                x += (s//2)*3

            else:

                x += ((s//2)-1)*3

        else:

            if s % 2 == 1:

                x += ((s//2) - (s-k+2))*3

    return x

print(xyz(K,S))

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if 0<=s-i_1+i_2<=k]
print(len(result))

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if s-i_1+i_2<=k]
print(len(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(K, S):
    num=0
    for a in range(K+1):
      if S-a>=0 and S-a<=2*K:
        if S-a<=K:
          num+=S-a+1
        else:
          num+=((S-a)-K)-K+1
    return num

  
K,S=(int(x) for x in input().split())
print(f(K,S))

Submission status: Wrong Answer

Solution code:
def f(K, S):
    num=0
    for a in range(K+1):
      if S-a>=0 and S-a<=2*K:
        if S-a<=K:
          num+=S-a+1
        else:
          num+=min((S-a)-K,K)
    return num

  
K,S=(int(x) for x in input().split())
print(f(K,S))

Submission status: Wrong Answer

Solution code:
def f(K, S):
    num=0
    for a in range(K+1):
      if S-a>=0 and S-a<=2*K:
        if S-a<=K:
          num+=S-a+1
        else:
          num+=min((S-a)-K,K)+1
    return num

  
K,S=(int(x) for x in input().split())
print(f(K,S))

Submission status: Wrong Answer

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

ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        if s - (x + y) <= K and s - (x + y)>=0 :
            print(x, y, s-x-y)
            ans += 1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        if s - (x + y) <= K:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

res = 0
for x in range(K+1):
  for y in range(K+1):
    if x+y <= S:
      res += 1

print(res)

Submission status: Wrong Answer

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

count = 0

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

print(count)

Submission status: Wrong Answer

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):
            s = i + j + k
            if S < s:
                break
            elif S == s:
                ans += 1
        else:
            continue
        break

print(ans)

Submission status: Wrong Answer

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for x in range(0, k+1):
  for y in range(x, k+1):
    for z in range(y, k+1):
      if x+y+z==s:
        if x==y==z:
          ans += 1
        elif (x==y and y!=z) or (y==z and z!=x) or (z==x and x!=y):
          ans += 3
        elif x!=y!=z:
          ans += 3
print(ans)

Submission status: Wrong Answer

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

for x in range(K+1):
  if K<S-x<=2*K:
    a+=2*K-S+x+1
  elif S-x<=K:
    a+=S-x+1
  else:
    a+=0

print(a)

Submission status: Wrong Answer

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for x in range(0, k+1):
  for y in range(x, k+1):
    for z in range(y, k+1):
      if x+y+z==s:
        if x==y and y==z:
          ans += 1
        elif x==y and y!=z:
          ans += 3
        elif x!=y:
          ans += 3
      break
print(ans)

Submission status: Wrong Answer

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for x in range(0, k+1):
  for y in range(x, k+1):
    for z in range(y, k+1):
      if x+y+z==s:
        if x==y and y==z:
          ans += 1
        elif x==y and y!=z:
          ans += 2
        elif x!=y:
          ans += 3
      break
print(ans)

Submission status: Wrong Answer

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

for x in range(K+1):
  if K<S-x<=2*K:
    a+=S-x+1-2*K
  elif S-x<=K:
    a+=S-x+1
  else:
    a+=0

print(a)

Submission status: Wrong Answer

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

for x in range(K+1):
  if K<S-x<=2*K:
    a+=S-x+1-2*K
  elif S<=K:
    a+=S-x+1
  else:
    a+=0

print(a)

Submission status: Wrong Answer

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

for x in range(K+1):
  if S<=K:
    a+=S-x+1
  elif K<S-x<=2*K:
    a+=S-x+1-2*K
  else:
    a+=0

print(a)

Submission status: Wrong Answer

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

for x in range(K+1):
  if S<=K:
    a+=S-x+1-2*K
  elif K<S-x<=2*K:
    a+=S-x+1
  else:
    a+=0

print(a)

Submission status: Wrong Answer

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

counter = 0

for x in range(k+1):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        if s-x-y <= k and s-x-y >=0:
            print(x,y)
            counter += 1
                
print(counter)

Submission status: Wrong Answer

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

counter = 0

for x in range(k+1):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        if s-x-y <= k:
            counter += 1
            break
                
print(counter)

Submission status: Wrong Answer

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) <= K:
                ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
cnt = 0

l = []
l = input().split()
k = int(l[0])
s = int(l[1])

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
n=3*sum(x+y+z==s for x in range(k+1) for y in range(x,k+1) for z in range(y,k+1))
print(n-2 if s%3==0 and s//3<=k else n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
k, s = (int(x) for x in input().split())

if s < 3 or k*3 < s:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y + x <= K):
        z = 0
        while (z + y + x <= K):
            #print(x, y, z)
            if x + y + z == S:
                count += 1
            z += 1
        y += 1
    x += 1

print(count)

Submission status: Wrong Answer

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y + x <= K):
        z = 0
        while (z + y <= K):
            if x + y + z == S:
                count += 1
            z += 1
        y += 1
    x += 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys

data=input().split(' ')
data_1=int(data[0])
data_2=int(data[1])
d=0
e=0
for i in range(data_1):	
	for j in range(data_1):
         for k in range(data_1):
         	d=i+j+k
         	if d <data_2:
         		e=e+1
         	else:
         		pass
print(e)

Submission status: Wrong Answer

Solution code:
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 0 <= z <= K:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
if 0 <= s <= k:
    ans = (s+1)*(s+2)/2
    print(int(ans))
elif k < s <= 2*k:
    ans = ((s+1)*(s+2)/2) - ((s-k)*(s-k+1)/2) - (k*(k+1)/2)
    print(int(ans))
elif 2*k < s < 3*k:
    print(3)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
k,s = [int(i) for i in input().split()]
ans = 0
for a in range(k+1):
    for b in range(k+1):
        if a + b == s or (s - (a + b)) <= k:
            ans += 1
        else:
            pass
print(ans)

Submission status: Wrong Answer

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

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

      
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
 
count = 0
for x in range(K+1):
  # print("x", x)
  for y in range(K-x+1):
    # print("y" , y)
    z = K - x - y
    # print("z", z)
    if (x>=0) and (y>=0) and (z>=0):
      count += 1
      
print(count)

Submission status: Wrong Answer

Solution code:
K, S=map(int, input().split())
KK=2*K
counter=0
for x in range(K+1):
  yz=S-x
  if yz<=K:
    counter+=(yz+1)
  elif yz>KK:
    pass
  else:
    counter+=(KK-yz+1)
    
print(counter)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split());print(sum(X+Y+Z==S for X in range(K)for Y in range(K)for Z in range(K)))

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
     return P(n, r)//math.factorial(r)
if 3*K==S:
    print(1)
else:
    print(C(S+2,2))

Submission status: Wrong Answer

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

# print(K)
# print(S)

count = 0
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
		if i + j <= S:
			count += 1

print(count)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
c=0
for i in range(a[1]-2*a[0] if a[1]-2*a[0] > 0 else 0, a[0]+1):
    c += (2*a[0]-(a[1]-i)) +1 if a[0] > (2*a[0]-(a[1]-i)) else a[1] - i + 1

print(c)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for i in range(k + 1):
    # y + z = s - x, x is substituted by i,
    if k < math.ceil((s - i) / 2):
        continue
    else:
        ans += 2 * (min(k, (s - i)) - (s - i) // 2)
        if (s - i) % 2 == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
        ans += ((z>=0) or (z<=K))
print(ans)

Submission status: Wrong Answer

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

def solve_2(num):
    if num > k:
        return k - (num-k) + 1
    else:
        return num + 1
ans = 0
first = 0
#if s > 2*k:
#    first = s -2*k
while first <= k:
    if s - first < 0:
        break
    ans += solve_2(s - first)
    first += 1

print(ans)

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
k = i[0]
s = i[1]
#print("k=",k,"s=",s)
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = k-x-y
    #print("x=",x,"y=",y,"z=",z)
    if k >= z and z >=0:
        #print("clear!")
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
k = i[0]
s = i[1]
#print("k=",k,"s=",s)
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = k-x-y
    #print("x=",x,"y=",y,"z=",z)
    if x+y+z == s and z >=0:
        #print("clear!")
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
k = i[0]
s = i[1]
#print("k=",k,"s=",s)
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = k-x-y
    if x+y+z == s:
#        print("clear!")
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if z <= k and z >= 0:
                count +=1

Submission status: Wrong Answer

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
#s =int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if s >= 3*k:
            break;
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            #print(x,y,z)

print(count,flush=True)

Submission status: Wrong Answer

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
#s =int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if s >= 3*k:
            break;
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            print(x,y,z)

print(count,flush=True)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k -i +2):
      for l in range(k -i -j +4):
        if i + j + l == s:
          cnt += 1
  print(cnt)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = 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: Wrong Answer

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

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

Submission status: Wrong Answer

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

counter = 0
for c in reversed(range(k+1)):
  for b in range(k+1):
    a = s - b - c
    if a >= 0:
      counter += 1
    if a < 0:
      break
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for x in range(k+1):
    if k > s:
        break
    for y in range(k+1):
        if k > s:
            break
        for z in range(k+1):
            if k > s:
                break
            if x + y + z == s:
                ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
data = [int(x) for x in input().strip().split()]

k = data[0]
s = data[1]

answer = 0;

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
import itertools
count = 0
for pattern in itertools.product(range(K+1), repeat=2):
    #print(pattern)
    if sum(pattern) <= S:
        
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    print(x)
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        print(x,y,z)
        if (x <= k and y <= k and z <= k and y <= x and z <= x and y <= z):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)

Submission status: Wrong Answer

Solution code:
ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(k + 1)[::-1]:
    for y in range(min(x + 1, s - x))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= x and y <= z):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)