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

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= 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 = map(int, input().split())

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

print(ans)

Submission status: Accepted

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

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

    print(count)

main()

Submission status: Accepted

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

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: 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(0, k+1):
    if s - i <= 2 * k:
        x = min(k, s - i) + 1
        for j in range(0, x):
            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 K>=S-(x+y)>=0:
                cnt +=1
            else:
                continue

print(cnt)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(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())
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:
K, S = map(int, input().split())
count = 0

for x in range(K + 1):
    if x > S:
        break
    for y in range(K + 1):
        z = S - (x + y)
        if z < 0:
            break
        if 0 <= z and 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):
    if x > S:
        break
    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:
k, s = map(int, input().split())

if 3*k == s:
    print(1)
    exit()

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

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

Submission status: Accepted

Solution code:
K, S = [int(item) for item in 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(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())
sum=0
for x in range(0,K+1):
    for y in range(0,K+1):
        z = S-x-y

        if z>=0 and z<=K:
            sum+=1


print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

k,s = [int(x) for x in stdin.readline().rstrip().split()]

point = 0

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

print(point)

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())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

print(r)

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

ans = 0
for x in range(K+1):
    n = 0
    if S < x:
        break
    for y in range(K+1):
        n = S - (x + y)
        if 0 <= n <= 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:
            cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

	ans = 0
	for h in range(k+1):
		for i in range(k+1):
			j = s - ( h + i )
			if k >= j >= 0:
				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):
        l=s-(x+y)
        if 0<=l<=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())
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:
k, s = [int(i) for i in 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 solve():
    K, S = map(int, input().split())
    
    lower = S - 2 * K
    if lower < 0:
        lower = 0
    
    cnt = 0
    for x in range(lower, K + 1):
        lower = S - K - x
        if lower < 0:
            lower = 0
        upper = S - x
        if upper > K:
            upper = K
        for y in range(lower, upper + 1):
            cnt += 1
    
    print(cnt)

solve()

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 0 <= z <= K:
            # print(x, y, z)
            count += 1

print(count)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K,S = MI()
    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)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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()))
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())
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())
count = 0
for x in range(k+1):
	if s - x > 2*k:
		continue
	else:
		for y in range(k+1):
			if s - x - y > k:
				continue
			elif s - x - y < 0:
				continue
			else:
				count += 1
print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
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 = input().split()
K,S = int(k),int(s)
a = 0
for x in range(K+1) :
  for y in range(K+1) :
    if 0 <= S-x-y <= K :
      a += 1
print(a)

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):
        z=s-x-y
        if z>k or z<0:
            pass
        else:
            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())
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())

result = 0

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

ans = 0

for i in range(k+1):
	for j in range(k+1):
		if i+j <= s and s-(i+j) <= k :
			#print('------')
			#print(i)
			#print(j)
			#print(s-(i+j))
			ans = 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) < 0 or S-(i+j)>K:
            cnt = cnt
        else:
            cnt += 1

print(cnt)

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 0 <= z <= K:
#             counter += 1

counter = sum([1 for x in range(K + 1) for y in range(K + 1) if 0 <= S - x - y <= K])
print(counter)

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

print(counter)

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:
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 = [int(i) for i in input().split()]
cnt = 0

for x in range(K+1):
  for y in range(K+1):
    candi_z = S - x - y 
    if 0<= candi_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):
        Z = S - i - j
        if(j>=0 and i>=0 and Z>=0 and K>=Z and S == i + j + Z):
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
# Me
def resolve(k, s):
    c = 0
    for x in range(0, k+1):
        for y in range(0, k+1):
            if 0 <= s - (x + y) <= k:
                c += 1
    return c


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
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())

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

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

Submission status: Accepted

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

c=0
for i in range(K+1):
    if(((i+2*K)>=S)):
        for j in range(K+1):
            if(((i+j)<=S)and((i+j+K)>=S)):
                c+=1        
print(c)

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().strip().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())
count=0
for x in range(K+1):
    for y in range(K+1):
        z = S - (x+y)
        if (z <= K) & (z >= 0):
            count += 1
print(count)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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:
#Sum of Three Integers
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 = n + 1
print(n)

Submission status: Accepted

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

n = 0
for x in range(k+1):
    ss = s - x
    if 0 <= ss < k:
        n += ss + 1
        #print('S', x, ss, ss + 1)
    elif k <= ss < 2*k +1:
        n += 2*k - ss + 1
        #print('L', x, ss, 2*k - ss + 1)
     
print(n)

Submission status: Accepted

Solution code:
#!python3.4.3

k, s = map(int, input().split(' '))
count = 0
for i in range(0, k+1):
    x = i
    for j in range(0, k+1):
        y = j
        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
#print(k,s)
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if z>=0 and z<=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())
count = 0
for i in range(K+1):
    for j in range(K+1):
        X = i
        Y = j
        Z = S - i - j
        if 0 <= Z <= K:
            count += 1
print(count)

Submission status: Accepted

Solution code:
def main():
  K, S = map(lambda i: int(i), 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)

main()

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 solve():
    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__':
    solve()

Submission status: Accepted

Solution code:
k, s = [int(x) for x in 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:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
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())
points=0
for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K:
      points+=1
print(points)

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

Submission status: Accepted

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


count = 0
for x in range(K+1):
    if x > S :
        break
    elif S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S:
            break
        elif S - (x+y) > K:
            continue
        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 = list(map(int,input().rstrip().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,input().split())
counter = 0
for i in range(k+1):
    rest = s-i
    for n in range(rest+1):
        if rest - n <= k and n <= k:
            counter += 1
print(counter)

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:
def examB():
    K, S = LI()
    ans = 0
    for x in range(K + 1):
        if 0 <= S - x <= K:
            ans += S - x  + 1
        elif K < S - x <= 2 * K:
            ans += K - (S - x - K) + 1
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
#        check_tmp =0
#        check_tmp =check1(x,l_s,l_k)
#        if check_tmp == 1:
#            break
#        elif check_tmp  == 2:
#            continue
        for y in range(l_k):
#            check_tmp =check2(x,y,l_s,l_k)
#            if check_tmp == 1:
#                break
#            elif check_tmp  == 2:
#                continue2
#            sum = x+y+l_k 
            sum = l_s- x-y 
            if 0<=sum and sum <= k:
#                print("x=",x,"y="   ,y) 
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))

Submission status: Accepted

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

for x in range(K + 1):
    ukou = S - x
    if (S >= x) and (ukou <= K * 2):
        y = K if K <= ukou else ukou
        z = ukou - y
        num += ((y + 1) - z)

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

k,s = (int(x) for x in input().split())
r = max(s-k,0)
count = 0
for x in range(k+1):
    for y in range(k+1):
            if r<=x+y<=s:
                count += 1
print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k:
            count += s - x  + 1
        elif k < s - x <= 2 * k:
            count += k - (s - x - k) + 1

    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k * 2:     # s - x = y + z
            for y in range(k + 1):
                if 0 <= s - x - y <= k:
                    count += 1
    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    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):
        if S-x-y >= 0 and S-x-y <= K:
            cnt += 1
print(cnt)

Submission status: Accepted

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

con = 0

for i in range(0,K + 1):
  for j in range(0,K + 1):
    X = i
    Y = j
    Z = S - X - Y
    
    if Z <= K and Z >= 0:
      con += 1
      
print(con)

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

Submission status: Accepted

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

count = 0

for i in range(k+1):
  a = i
  for j in range(k+1):
    b = j
    if a+b>s:
      break
    if s-(a+b)<=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):
        if i+j>s:
            break
        if s-(i+j)<=k:
            count+=1
            
print(count)

Submission status: Accepted

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

x=0
y=0
z=0

count=0

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

print(count)

Submission status: Accepted

Solution code:
# ABC 051: B – Sum of Three Integers
k, s = [int(s) for s in input().split()]
number = 0

for a in range(k + 1):
    for b in range(k + 1):
            if 0 <= (s - a - b) <= k:
                number += 1

print(number)

Submission status: Accepted

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

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

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):
        sumz=S-x-y
        if sumz>=0 and sumz<=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):
        sumn = S - (x + y)
        if sumn >= 0 and sumn <= K:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
#051
import sys

k, s = map(int,sys.stdin.readline().split())
cnt=0;

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

Submission status: Accepted

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

result = 0
for X in range(K + 1):
  YZ = S - X
  if 0 <= YZ <= K:
    result += YZ + 1
  elif K < YZ <= 2 * K:
    result += 2 * K + 1 - YZ
  
print(result)

Submission status: Accepted

Solution code:
k,s=map(int,input().split())
c=0
#x>=y>=z
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())
flag = 1
s = 0
for l in range(K+1):
  for m in range(K+1):
    if (0 <= S-l-m)and(S-l-m<=K):
      s = s+1
print(s)

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