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: Accepted

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

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


print(counter)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
k,s=map(int,input().split())
c=0
for x in range(k+1):
    if x + 2 * k < s:
        continue
    for y in range(k+1):
        if x + y > s:
            continue
        if x + y + k < s:
            continue
        c += 1
print(c)

Submission status: Accepted

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 and S - i - j <= K:
            count += 1
print(count)

Submission status: Accepted

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

count = 0
if k < 2 or k>2500 or s<0 or s>3*k:
    print(0)
else:
    for i in range(k+1):
        for ii in range(k+1):
            temp_z = s-i-ii
            if temp_z >= 0 and temp_z <= k:
                count = count+1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
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 z <= K and z >= 0:
            count += 1
print(str(count))

Submission status: Accepted

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

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: Accepted

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

Submission status: Accepted

Solution code:
K,S = map(int,raw_input().split())
con = 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:
                        con +=1
print con

Submission status: Accepted

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 - k and  i + j <= s :
            count += 1
            
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

rcount = 0

for i in range(K+1):
    for j in range(K+1):
        x = S - (i + j)
        if x >= 0 and x<=K:
            rcount += 1

print(rcount)

Submission status: Accepted

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

ans = 0

for X in range(K + 1):
	if X > S:
		break
	for Y in range(K + 1):
		if X + Y <= S:
			if S - (X + Y) <= K:
				ans += 1
		else:
			break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            x = k + 1
            y = k + 1
            continue
        count += (s <= x + y + k)

print(count)

Submission status: Accepted

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:
            if k >= s - (x + y):
                count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
print(sum(min(2 * K - (S - x) + 1, (S - x) + 1) for x in range(max(0, S - 2 * K), min(S, K) + 1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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
        if 0 <= z and z <= k:
            cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = [int(i) for i in input().split()]

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

Submission status: Accepted

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 and S-i-j>=0:
      ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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: Accepted

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

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

Submission status: Accepted

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 <= k:
      count += 1
    elif z < 0:
      break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
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: Accepted

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
    if z > K or z < 0:
      continue
    else:
      cnt += 1
print(cnt)

Submission status: Accepted

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

for x in range(K + 1):
    tmp1 = S - x
    if tmp1 > 2 * K:
        continue
    tmp2 = min(K, tmp1)
    for y in range(tmp2 + 1):
        z = tmp1 - y
        if z <= K:
            count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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: Accepted

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

print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))

Submission status: Accepted

Solution code:
k,s = map(int, input().rstrip().split())
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: Accepted

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: Accepted

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

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

print(cnt)

Submission status: Accepted

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 <= K:
            count += 1

print (count)

Submission status: Accepted

Solution code:
#review

def solve(k, s):
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                ans += 1
            elif z < 0:
                break
    return ans
 
 
def main():
    k, s = map(int, input().split())
    ans = solve(k, s)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
k,s = list(map(int,input().split()))
ans = 0
for i in range(k+1):
    for j in range(0,s-i+1):
        if j > k:
            break
        else:
            p = s-i-j
            if p<0:
                pass
            elif p > k:
                pass 
            else:
                ans += 1
                # print("X,Y,z = ",i,j,p," :|")

print(ans)

Submission status: Accepted

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

R = 0

for X in range(max(0, S-2*K), K+1):
    for Y in range(max(0, S-X-K), K+1):
        if X + Y <= S:
            R += 1

print(R)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

same_all = 0
same_two = 0
same_none = 0

for i in range(K, -1, -1):
    for j in range(S - i, -1, -1):
        if ( K<j or i<j):
            continue
        k = S-i-j
#         print(i,j,k)
        if (k <= K and k<=j):
            if(i == j and j == k):
                same_all += 1
            elif(i == j or i == k or k == j):
                same_two += 1
            else:
                same_none += 1


print(same_all + same_two*3 + same_none*6)

Submission status: Accepted

Solution code:
import sys
ks = list(map(int, input().split()))
k = ks[0]
s = ks[1]
ans = 0
for x in range(k+1):
  for y in range(k+1):
    if s - x - y <= k and s - x - y >=0:
      ans = ans + 1
      
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

num = 0
for x in range(K + 1):
	rest = S - x
	if 0 <= rest and rest <= K:
		num += rest + 1
	elif K < rest and rest <=2*K:
		num += 2*K + 1 - rest
print(num)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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) >= 0 and s - (i + j) <= k:
            count += 1
print(count)

Submission status: Accepted

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 and s >= i+j:
            ans+=1 
print(ans)

Submission status: Accepted

Solution code:
k, s = [int(i) for i in input().split()]

res = 0

for i in range(k+1):
    for j in range(k+1):
        temp = s - i - j
        if temp >= 0 and temp <= k:
            res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for x in range(k+1):
    for y in range(k+1):
            sub = s - x - y
            if 0<=sub and sub <k+1:
                cnt += 1







print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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 and s-(x+y) >= 0:
            count+=1
print(count)

Submission status: Accepted

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: Accepted

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

print(goukei)

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

for i in range(0,k+1):
    for j in range(0,k+1):
        x=i
        y=j
        z=s-i-j
        if 0<=z<=k:
            ans+=1
        else:
            ans+=0



print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
count = 0
if K*3 < S:
    print(count)
else:
    for i in range(K, -1, -1):
        X = i
        YZ = S - X
        for j in range(K, -1, -1):
            Y = j
            Z = YZ - Y
            if Z > K:
                continue
            elif Z < 0:
                continue
            else:
                count += 1
                #print(X,Y,Z)
print(count)

Submission status: Accepted

Solution code:
import sys

def main():
    K, S = map(int, input().split())

    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            if x+y > S:
                break

            z = S - x - y
            if z <= K:
                cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


def main():
    k, s = map(int, input().split())

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def solve(K, S):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if K >= z >= 0:
                count = count + 1
    return count


if __name__ == '__main__':
    K, S = map(int, input().split())
    print(solve(K, S))

Submission status: Accepted

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 >= 0 and Z <= K):
            # print("%d, %d, %d" % (X, Y, Z))
            ans += 1

print("%d" % ans)

Submission status: Accepted

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: Accepted

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

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

print(n)

Submission status: Accepted

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) >= 0 and s-(x+y) <= k:
            count += 1
print(count)

Submission status: Accepted

Solution code:
k, s = list(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 <= k:
			count += 1

print(count)

Submission status: Accepted

Solution code:
k, s = [int(elem) for elem in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    k=S-i-j
    if 0<=k<=K:
      count=count+1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

ans = 0

if S > 3*K:
    ans = 0
else:
    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: Accepted

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

Submission status: Accepted

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 <= k:
            count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,S = [int(i) for i in input().split()]
num = 0
for a in range(K+1):
    for b in range(K+1):
        if(S-a-b>=0 and S-a-b<= K):
            num += 1
print(num)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0,k+1):
    for j in range(0,k+1):
        x = i
        y = j
        z = s-i-j
        ##print("X=" + str(x),"Y=" + str(y),"Z="+ str(z))
        if 0<= z <= k:
          count+=1
print(count)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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: Accepted

Solution code:
k, s = map(int, input().split())
count = 0
for kx in range(0, k+1):
    for ky in range(0, k+1):
        kz = s - kx -ky
        if 0 <= kz <= k:
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    print(" ".join(a.split(",")))
    return

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

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(K: int, S: int):
    ret = 0
    for i in range(K + 1):
        for j in range(K + 1):
            if 0 <= S - (i + j) <= K:
                ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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: Accepted

Solution code:
import sys

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

ans = 0
if S == (3 * K):
    ans = 1
    print(ans)
    sys.exit()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

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: Accepted

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

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

Submission status: Accepted

Solution code:
k,s=map(int,input().split())
c=0
for l in range(s+1):
    for m in range(min(l+1,k+1)):
        if s-l<=k and l-m<=k:c+=1
        else:pass
print(c)

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
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: Accepted

Solution code:
# ABC051B - Sum of Three Integers.py
import sys
import itertools

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

n = 0
for iz in range(s // 3, k + 1):
    for iy in range((s - iz) // 2, k + 1):
        x = s - iy - iz
        if 0 <= x <= iy <= iz:
            y, z = iy, iz
            # print((x, y, z))
            n += len(set(itertools.permutations((x, y, z))))

print(n)

Submission status: Accepted

Solution code:
# Sum of Three Integers
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    for y in range(K+1):
        if x + y > S:
            continue
        if S - (x + y) <= K:
            res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

n = 0

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

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,s=map(int,input().split())
ans=0
for i in range(n+1):
  if s-i>n*2 or s-i<0:
    continue
  for j in range(n+1):
    if -1<s-i-j<n+1:
      ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

ans = 0

for x in range(K+1):

    for y in range(K+1):

        if x+y <= S and S - x - y <= K:

            ans += 1

print (ans)