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

Submission status: Accepted

Solution code:
K, S = map(int, raw_input().split())
cnt = 0
for i in range(0, K+1):
	if S - i <= 2*K:
		for j in range(0, 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(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())
cnt=0
for i in range(s+1):
    if i>k:
        break
    cnt+= max(0,min(i+k,s)-max(s-k,i)+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:
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())
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 = map(int, input().split())

cnt = 0
for i in range(k + 1):
  for j in range(k + 1):
    if s - k <= i + j <= s:
        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 S-x-y >= 0 and 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:
# -*- coding:utf-8 -*-

line = input()
line = line.split(" ")
k, s = int(line[0]), int(line[1])
counter = 0
for x in range(s // (3*k), min(s, k)+1):
    for y in range(s // (3*k), min(s, k)+1):
        if s - (x + y) < 0:
            break
        elif s - (x + y) <= k:
            counter += 1
print(counter)

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:
def main(input_str):
    nums = list(map(int, input_str.split()))

    count = 0
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            if 0 <= nums[1]-(num_1+num_2) <= nums[0]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

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

Submission status: Accepted

Solution code:
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    K,S = (int(_) for _ in input().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):            
            if(K >= S - x - y and S - x - y >= 0):
                ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k,s = map(int,input().split())
a = ((s+1)*(s+2))//2
b = ((s-k)*(s-k+1))//2
c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2

if s <= k:
    print(a)
elif s <= k*2:
    print(a-b*3)
elif s <= k*3:
    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<=K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
k,s = list(map(int,input().split()))
ans = [1 for x in range(k+1) for y in range(k+1) if 0 <= s - (x+y) <= k]
print(len(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) >= 0 and (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 k in range(K+1):
        z=S-i-k
        if 0<=z<=K:
            count += 1

print(count)

Submission status: Accepted

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

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 i+j <= s and s <= k+i+j:
            a += 1
        else:
            pass

print(a)

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:
def sum_of_three_integers(K: int, S: int)->int:
    count = 0
    for x in range(K+1):
        for y in range(x, K+1):
            z = S - (x + y)

            if z < 0 or K < z:
                # out of range
                continue

            if z < y:
                # x <= y <= z の場合だけ考えて計算回数を減らしたい。
                break

            if x == y and y == z:
                # 全文字一緒なら 1 通り
                count += 1
            elif x == y or y == z:
                # 同じ文字が 2 つだけなら 3C1 = 3 通り
                count += 3
            else:
                # 全て違う文字なら 3P3 = 6 通り
                count += 6
    return count


if __name__ == "__main__":
    K, S = map(int, input().split())
    ans = sum_of_three_integers(K, S)
    print(ans)

Submission status: Accepted

Solution code:
k, s = [int(i) for i in 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())
c=0
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 = (int(num) for num in input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j >= s-k and i+j <= s:
            ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  x=i
  for j in range(k+1):
    y=j
    z=s-x-y
    if(0<=z and z<=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):
    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 i in range(k + 1):
    for j in range(i + 1):
        l = s - (i + j)
        if 0 <= l <= k and l <= j <= i:
            if i == j == l:
                ans += 1
            elif i == j or j == l or l == i:
                ans += 3
            else:
                ans += 6
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())

c = 0

for X in range(K+1):
    for Y in range(K+1):
        if X+Y <= S and X+Y+K >= S:
            c += 1

print(c)

Submission status: Accepted

Solution code:
# coding: utf-8
input_lines=input().split()
K = int(input_lines[0])
S = int(input_lines[1])
M=0
for i in range(K+1):
  for j in range(i,K+1):
    k =S-i-j
    if i<=j<=k<=K:
      if i==j==k:
        M+=1
      elif i==j or j==k:
        M+=3
      else:
        M+=6
print(M)

Submission status: Accepted

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

ans = 0

if K >= int(S/3):
    x = y = z = 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:
def binary_search_list(beSearched,wanted) :
    l = 0
    r = len(beSearched)

    #print("condition = {}".format(r-l))

    while r - l >= 1 :
        s = (l + r) // 2
        #print("l={} r={} s={}".format(l,r,s))
        if beSearched[s] == wanted :
            return True
        if beSearched[s] > wanted :
            r = s
        else :
            l = s + 1

    return False

K,S = (int(_) for _ in input().split())
num = [_ for _ in range(K+1)]
out = 0
for i in range(K+1):
    for j in range(i+1):
        if 0 <= S - i - j <= j :
            if i == j and j == S - i - j:
                out += 1
            elif i == j or j == S - i - j or S -i - j == i:
                out += 3
            else :
                out += 6
        #print(num[:j+1])
        #b = binary_search_list(num[:j+1],S - i - j)
        #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j))
        #if b :
            #if i == j and j == S - i - j:
                #out += 1
            #elif i == j or j == S - i - j or S -i - j == i:
                #out += 3
            #else :
                #out += 6

print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
r = k+1
print(sum(0<= s- i//r - i%r <= k for i in range(r*r)))

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 0<=s-x-y <=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:
K, S = map(int, input().split())
x,y,z = 0,0,0
ans = 0

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

Submission status: Accepted

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

print(cnt)

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

print(counter)

Submission status: Accepted

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


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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
K, S = map(int, input().split())
ans = 0

for X in range(K + 1):
    for Y in range(X, K + 1):
        Z = S - Y - X
        if Z >= Y and Z <= K:
                
            if len(set([X, Y, Z])) == 1:
                ans += 1
            elif len(set([X, Y, Z])) == 2:
                ans += 3
            else:
                ans += 6
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(K+1):
    S_temp = S - i
    for k in range(K+1):
        z = S_temp - k
        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):
        X = i
        Y = j
        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())
count = 0

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

print(count)

Submission status: Accepted

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

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):
		if S - K <= X + Y <= S:
			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:
k,s=map(int,input().split())
print(len([s-(x+y) for x in range(k+1) for y in range(k+1)if 0<=s-(x+y)<=k]))

Submission status: Accepted

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

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 a in range(K+1):
    for b in range(K+1):
        c = S - a - b
        if 0 <= c and c <= K:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k+1):
    for m in range(k+1):
        if -1 < s-(i+m)  and s-(i+m) < k+1:
            #print(i,m,s-(i+m))
            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(i, j, S-i-j, ans)
      

print(ans)

Submission status: Accepted

Solution code:
# 0≦X,Y,Z≦K
# S = x + y + z

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

Submission status: Accepted

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

cnt = 0
K += 1

#TLE CODE
'''
for x in range(K):
    for y in range(K):
        for z in range(K):
            if x + y + z == S:
                cnt += 1
'''

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

print(cnt)

Submission status: Accepted

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

cnt = 0
for x in range(k+1):
    c = s-x
    cnt += max(min(k,c)-max(0,c-k)+1,0)

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
a,b=map(int,input().split());print(sum(a>=b-s-t>=0for t in range(a+1)for s in range(a+1)))

Submission status: Accepted

Solution code:
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        if 0<=b-s-t<=a:
            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-(i+j)<=k:
      cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            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):
        if 0 <= S - (x + y) <= K:
            counter += 1
print(counter)

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:
k,s=map(int,input().split())
ctr=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-(i+j)<=k:
            ctr+=1
        else:
            pass
print(ctr)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(m)

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

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

Submission status: Accepted

Solution code:
K,S = map(int, input().split(" "))
count=0
for a in range(K+1):
    if S<a:
        break
    for b in range(K+1):
        c=S-(a+b)
        if c==0:
            count+=1
            break
        elif c>K:
            continue
        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):
        if 0 <= (S - i - j) <= 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):
        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())
cnt = 0
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=[int(z) for z in input().split(" ")]
r=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:
      r+=1

print(r)

Submission status: Accepted

Solution code:
x = y = z = 0
ans = 0

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

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:
# -*- coding: utf-8 -*-


def main():
    x = y = z = 0
    ans = 0

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

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

print(count)

Submission status: Accepted

Solution code:
#ABC051 B 14:29 - 
'''
問題
整数X,Y,Zがいずれも0以上K以下であって,かつX+Y+Z=Sであるような(X,Y,Z)の組はいくつあるか？

考察
X,Yの2つがいずれも0以上K以下であって,かつX+Y=Tであるような(X,Y)の組の数をまず考える
TがK以下であればそのような組の数はmax(0,T+1)通り
TがK+1以上であればそのような組の数はmax(0,(T+1)-2*(T-K))通り

次にTのとりうる値の範囲を考える
Z=S-TであってZは0以上K以下でなければならないからTのとりうる値の範囲は0<=S-T<=K -S<=-T<=-S+K S-K<=T<=S

したがってS-K<=T<=Sについて上記の値を足し合わせればよい
'''

K,S=map(int,input().split(' '))
ans=0
for T in range(S-K,S+1):
	if T<=K:
		ans += max(0,T+1)
	else:
		ans += max(0,(T+1)-2*(T-K))
print(ans)

Submission status: Accepted

Solution code:
K,S = map(int,input().split())
t = 0
#c = 0
for x in range(max(0,S-2*K),min(S//3+1,K+1)):
    if S-x > 2 * K:
        pass
    else:
        for y in range(max(x,S-x-K),min((S-x)//2+1,K+1)):
            #c += 1
            z = S - x - y
            if z < y:
                #print('pass')
                pass
            else:
                #print(x,y,z)
                if x == y == z:
                    t += 1
                elif x == y or y == z:
                    t += 3
                else:
                    t += 6
print(t)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 14

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

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

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

DIV = 10**9+7

K, S = ints_raw()

ans = 0 
for X in xrange(K+1):
    for Y in xrange(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):
  for j in range(K+1):
    k=S-i-j
    if 0<=k<=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 0<=S-i<=K:
    ans+=S-i+1
  elif K<S-i<=2*K:
    ans+=2*K-(S-i)+1
        
print(ans)

Submission status: Accepted

Solution code:
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (-3 * (K ** 2) + 3 * K + 6 * S * K - 2 * (S ** 2) + 2) // 2
	print(int(ans))
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

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):
        Z = S - X - Y
        if Z >= 0 and Z <= K:
            count += 1
    
print(count)

Submission status: Accepted

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

ans = 0
for X in range(K + 1):
    for Y in range(K + 1):
        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())

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

if s <= k:
    print((s + 2) * (s + 1) // 2)
else:
    ans = 0
    for x in range(k + 1):
        for y in range(min(k + 1, s - x + 1)):
            if 0 <= s - x - y <= k:
                #print(x, y, s-x-y)
                ans += 1
    print(ans)

Submission status: Accepted

Solution code:
# 入力
[K,S] = list(map(int, input().split()))

# 処理
ans = 0 # 答え
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y          # X+Y+Z = Nより
    if 0 <= Z and Z <= K:  # Zが0以上K以下ならカウント
      ans += 1
      
# 出力
print(ans)

Submission status: Accepted

Solution code:
k,s=map(int,input().split());r=k+1;print(sum(k>=s-I//r-I%r>=0for I in range(r*r)))

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        h = s- i- j
        if 0<= h <= k:
            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 and z <= K:
            counter += 1
print(counter)

Submission status: Accepted

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

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 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 = (int(i) for i in 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())
#K=5
#S=15
num=0
for X in range(K+1):
    if X>S:
        break
    for Y in range(K+1):
        Z=S-Y-X
        if 0<=Z<=K:
            
            num+=1
print(num)

Submission status: Accepted

Solution code:
K, S = map(int,input().split())
count = 0
start = max(S - 2*K, 0)

for X in range(start,K+1):
    for Y in range(start,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 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:
inr = lambda: list(map(int, input().split()))

K, S = inr()

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)