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:
if __name__ == '__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( z>=0 and z<=K ):
				cnt = 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 and z<=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())
# 0<=x,y,z<=k
# x+y+z=s となるxyzの組み
ans=0
for x in range(k+1):
  if s-x<0:
    break
  a=max(0,s-x+1)
  a-=max(0,(s-x-k)*2)
  ans+=max(0,a)
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):
        z = s-x-y
        if 0<=z and z<=k:
            cnt+=1

print(cnt)

Submission status: Accepted

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

print(i)

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:
def solve(K, S):
    count = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                count += 1
    return count
def main():
    K, S = map(int, input().split())
    count = solve(K, S)
    print(count)
main()

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 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 < 0:
      break
    elif z>K:
      continue
    else:
      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):
        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):
        z = S-x-y
        if 0<=z and z<=K:
            count = 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 <= k and s-x-y>=0:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
import itertools
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(i,j)
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
X = [int(e) for e in input().split()]
ans = 0
for i in range(0,X[0]+1):
    for k in range(0,X[0]+1):
        if(X[1] - (i+k))<=X[0] and X[1] - i - k >= 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-GuessTheNumber.py
#
k, s = map(int, input().split())
pattern = 0

if s == 0 or s == 1:
    print(1)
    exit()

if s <= k:
    print((s+2)*(s+1)//2)
    exit()

# elif 2*k < s <= 3*k:
#     for i in range(k+1):
#         x = k - i
#         y = k
#         z = s - x - y
#         if z <= k:
#             pattern += (y - z + 1)
#         else:
#             break

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


# for x in range(k+1):
#     x_tmp = x
#     for y in range(x_tmp, k+1):
#         y_tmp = y
#         for z in range(y_tmp, s+1-x_tmp-y_tmp):
#             if x_tmp + y_tmp + z == s:
#                 if x_tmp == y_tmp == z:
#                     pattern += 1
#                 elif x_tmp == y_tmp or x_tmp == z or y_tmp == z:
#                     pattern += 3
#                 else:
#                     pattern += 6
#                 break

print(pattern)

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 resolve():
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)):
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1
            elif i+j>s:
                break

    print(ans)

Submission status: Accepted

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

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1


    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    K, S = map(int, input().split())
    ans = 0
    for X in range(K+1):
        Y_min = max(0, S-X-K)
        Y_max = min(K, S-X)
        ans += max(0, Y_max - Y_min + 1)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    K, S = map(int, input().split())
    ans = sum((1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K))
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    K, S = map(int, input().split())
    ans = sum([1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K])
    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):
    if k >= s-i-j 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(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 = (int(x) for x in input().split())
sum_ = 0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y <= k:
        sum_ += 1
print(sum_)

Submission status: Accepted

Solution code:
k,s = [int(x) for x in 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:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
nim, mike = map(int, input().split())
    
result = 0
for X in range(0, nim + 1):
    for Y in range(0, nim + 1):
        O = mike - (X + Y)
        if 0 <= O <= nim:
            result += 1
print(result)

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

Submission status: Accepted

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

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

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())
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())
p=0
for i in range(k+1):
    for j in range(k+1):
        #print(i,j)
        if 0<= s- i - j <= k:
            p += 1
print(p)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
# 整数の入力
k, s = map(int, input().split())
# 計算
count = 0
for x in range(k+1):
    for y in range(k+1):
        if s >= x + y and s - x - y <= k:
            count += 1
        # for z in range(k+1):
        #     if x + y + z == s:
        #         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 0 <= S - i - j <= K:
            counter += 1

print(counter)

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:
import sys
in1 = sys.stdin.readlines()

#in1 = ['10 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if 0 <= S - idx1 - idx2 <= K:
            RC += 1

print(RC)

Submission status: Accepted

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    if 0 <= S-a-b <= K:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

counter = 0

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

print(counter)

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
        else:
            cnt += 0

print(cnt)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
K, S = [int(str) for str in input().strip().split()]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = map(int,input().split())
cnt = 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:
      cnt += 1
    else:
      continue

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

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:
a,b=map(int,input().split())
c=0
for l in range(a+1):
    for m in range(l,a+1):
        r=b-l-m
        if r >a:
            continue
        elif r<m:
            continue
        elif r==l==m:
            c+=1
        elif r==m:
            c+=3
        elif m==l:
            c+=3
        else:
            c+=6
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import numpy as np
if __name__ == "__main__":
    K, S = list(map(int, input().split()))
    ans = 0
    for i in range(K+1):
        for j in range(i, K+1):
            k = S - (i+j)
            if j <= k and k <= K:
                l = len(set([i,j,k]))
                if l == 3:
                    ans += 6
                elif l == 2:
                    ans += 3
                else:
                    ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

#for i in range(K+1):
#    for j in range(K+1):
#        if i+j<=S and K+i+j>=S:
#            count+=1
for i in range(K+1):
    S_rest = S-i
    if S_rest>2*K:
        continue
    if S_rest<0:
        break
    if S_rest>=K:
        count += 2*K- S_rest +1
    else:
        count += S_rest+1

print(count)

Submission status: Accepted

Solution code:
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

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

print(count)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    ans = 0
    X_max = min(S, K)
    for X in range(X_max + 1):
        Y_max = min(S - X, K)
        for Y in range(Y_max + 1):
            Z = S - (X + Y)
            if 0 <= Z <= K:
                ans += 1
            else:
                continue
    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):
  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())

count = 0
if S % 3 == 0:
    count += 1
for x in range(K):
    if 0 <= S-2*x and S-2*x <= K and x != S-2*x:
        count += 3
for x in range(K):
    for y in range(x+1,K):
        if y >= S-x-y:
            break
        elif 0 <= S-x-y and S-x-y <= K:
            count += 6

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(k+1):
    yz = s - i
    for j in range(k+1):
        if k >= yz - 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):
    x = s-i-j
    if x>=0 and x<=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+1:
                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 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:
# -*- coding: utf-8 -*-
                   
K, S = map(int, input().split())
cnt = 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:
             cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S=map(int, input().split())
s=S-2*K if S-2*K>0 else 0
e=S if S<K else K
ans=0
for Z in range(s, e+1):
  if S-Z>K:
    ans+=2*K+Z-S+1
  else:
    ans+=S-Z+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
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:
# -*- coding: utf-8 -*-
import sys

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

counter = 0

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

print(counter)

Submission status: Accepted

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

for x in range(K + 1):
    if S - x >= 0:
        for y in range(K + 1):
            if K >= S - x - y >= 0:
                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:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

k, s = inpl()
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):
    if 0 <= s - i - j <= k:
    	ans += 1
        
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,S = map(int,input().split())
ans = 0
for k in range(K+1):
    ans += max(0, min(S - k, K) - max(0, S - k - K) + 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)) & ((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 S - i - j >= 0:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 051: 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 0 <= z <= k:
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def est():
  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
  return cnt
print(est())

Submission status: Accepted

Solution code:
k,s  = list(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())
c = 0

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

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

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
I=S//3
ans=0
for i in range(K+1):
    if S-i>2*K:
        continue
    for j in range(K+1):
        z=S-i-j
        if z<=K and z>=0:
            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:
n,k=map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n+1):
    if 0<=k-i-j<=n:
      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 x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)

Submission status: Accepted

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

resolve()

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

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 0<=z<=k:
            cnt+=1

print(cnt)