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:
from sys import stdin
K, S = map(int, stdin.readline().rstrip().split())
l = list(i for i in range(K+1))
count = 0
for i in range(K+1):
    for j in range(K+1):
        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 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())
c=0

for l in range(k+1):
    for m in range(k+1):
        if 0<=s-l-m and s-l-m<=k:
            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):
    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())
f = 0
for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if 0 <= l <=k:
            f+=1
print(f)

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())
c = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if 0 <= z <= k:
            c += 1
        
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for q in range(k + 1):
    for w in range(k + 1):
        if 0 <= (s - q - w) <= 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):
        if 0 <= (s - (i + j)) <= k:
            count += 1
print(count)

Submission status: Accepted

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

counter = 0
# x+y+z = S,　全探索
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0<=z<=K:
            counter += 1
print(counter)

Submission status: Accepted

Solution code:
from itertools import product

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

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

Submission status: Accepted

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

l = 0

if s <= k:
  l = int((s+2)*(s+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: 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:
import numpy as np
K, S = map(int, input().split())
arrange = np.arange(K + 1)
T = S - np.add.outer(arrange, arrange)
print(((T >= 0) & (T <= K)).sum())

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())

ans = 0

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

print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

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 = map(int, input().split())

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

Submission status: Accepted

Solution code:
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

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

Submission status: Accepted

Solution code:
K,S = list(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:
import sys

num = sys.stdin.readline().split(' ')
K = int(num[0])
S = int(num[1])

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

print(counter)

Submission status: Accepted

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



    return ans

print(main())

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):
        z = S - x - y
        if 0 <= z <= K:
            res += 1
print(res)

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())
ans=0
for i in range(k+1):
    if s-i>=0:
        for j in range(min(s-i+1,k+1)):
            if s-i-j<=k and s-i-j>=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):
		if i+j <= s and i+j >= s-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 z >=0 and z <= k:
            ans += 1
        else:
            pass
        

print(ans)

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

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

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
#x+y+z=s z=s-x-y
for i in range(k+1):
    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())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
       if k >= s-i-j >= 0:
           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):
        l = s - i - j
        if 0 <= l <= k:
            ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
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 = map(int,input().split())

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

Submission status: Accepted

Solution code:
from operator import mul
from functools import reduce
def combinations_count(n, r):
    if n<r: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    K,S = map(int, input().split())
    ans = 0
    # x+y<=Sとなるように回す
    for x in range(K+1):
        for y in range(K+1):
            z = S-(x+y)
            if x+y<=S and 0<=z and z<=K: ans += 1
    print(ans)

main()

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):
        if S-(x+y)>=0 and S-(x+y)<=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 k>=z>=0:
      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 0<=s-(i+j) and s-(i+j)<=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 z>=0 and z<=k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c

    count = 0
    for i in range (0,b+1):
        for j in range(0,b+1):
            if c-(i+j)<=b and c-(i+j) >=0:
                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:
import sys
def S(): return sys.stdin.readline().rstrip()


K,S = map(int,S().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: 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)

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):
        if 0 <= s - x - y <= k:
            z = s - x - y
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
s = input().split()
k=int(s[0])
s=int(s[1])
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 = map(int, input().split())
cnt = 0
for i in range(min(k+1, s+1)):
    for j in range(min(k+1, s-i+1)):
        if s-i-j<=k:
            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):
        if 0 <= s-(x+y) <= k:
            cnt += 1




print(cnt)

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

Solution code:
def main():
    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)






if __name__ == '__main__':
    main()

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:
#2830

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

"""
0<= X<= K でXを選ぶ
このとき Y+ Z= S- X
Yの最小値は，max(0, S- X- K)
Yの最大値は，min(K, S- X)
よってY, Zの選び方はmin(K, S- X)- max(0, S- X- K)+ 1 通り．
Xについて，0<= X<= Kで足し合わせればよい．
"""
ans = 0

for i in range(K+ 1):
  Y_min = max(0, S- i- K)
  Y_max = min(K, S- i)
  if(Y_max>= Y_min):
    ans+= Y_max- Y_min+ 1
    
print(ans)

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

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

idx = 0


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

print(idx)

Submission status: Accepted

Solution code:
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    ret=0
    k,s = map(int,input().split())
    for x in range(k+1):
        for y in range(k+1):
            if 0 <= s-x-y <= k:
                ret+=1
    print(ret)
 
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:
k,s = map(int,input().split())
c=0
for i in range(k+1):
    for j in range(k+1):
         c += 1*(0 <= s - i -j <= k)
print(c)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
 
result = 0
for i in range(k+1):
    x = min(s-i, k) - max(0, s-k-i)
    if x >= 0:
        result += x + 1

print(result)

Submission status: Accepted

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

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())
ans = 0
for X in range(max(0, S-2*K), min(K, S)+1):
  for Y in range(max(0, S-X-K), min(K, S-X)+1):
    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):
    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):
        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 i in range(K+1):
  for j in range(K+1):
    if S - (i + j) <= K and S - (i + j) >= 0:
      #print(i, j, (S - (i + j)))
      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:
# coding: utf-8
# Your code here!
k, s = map(int, input().rstrip().split())
result = 0
for x in range(k+1):
    if 2*k >= s - x:
        for y in range(k+1):
            if s - x - y >= 0 and s - x - y <= k:
                result += 1

print(result)

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())

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

Submission status: Accepted

Solution code:
k,s = list(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
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(0, k+1):
    for y in range(0, k+1):
        z = s - x - y
        if z < 0 or z > k:
            continue
        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 (S- X - Y >=  0 and S - X - Y <= K):
            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):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)

Submission status: Accepted

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

ans = 0
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z >= 0 and 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):
    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):
        z = S-x-y
        if 0 <= z and 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())

ans = 0

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

print(ans)

Submission status: Accepted

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

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

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:
# B - Sum of Three Integers
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>=0 and K>=z:
            cnt+=1
print(cnt)

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().split())

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

Submission status: Accepted

Solution code:
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)

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):
        if 0<=S-x-y<=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 and z <= k:
            count += 1

print(count)

Submission status: Accepted

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n,k = cin()
    ans = 0
    for i in range(n+1):
      for j in range(n+1):
        if k-i-j>=0 and k-i-j<=(n):
          ans += 1
    print(ans)


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):
        z = S - (x + y)
        if 0 <= z and z  <= K :
            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):
        z = S - i - j
        if 0 <= z <= K:
            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):
        if 0 <= (s - i - j) <= k:
            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):
    if S - i - j <= K and 0 <= S - i - j:
      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 0 <= S - j - i <= K:
      cnt += 1
print(cnt)

Submission status: Accepted

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

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
k,s = list(map(int, input().split()))
cnt=0
minX=max(s-2*k, 0)
maxX=min(s, k)
for x in range(minX, maxX+1):
    rest=s-x
    if k>=rest:
        cnt+=rest+1
    else:
        cnt+=2*k-rest+1
    
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Solution code:
def main():
    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    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
    return ans
  
print(solve())

Submission status: Accepted

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

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

k,s=mii()

cnt=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    k, s = mi()

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

if __name__ == "__main__":
    main()