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: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
k, s = map(int, input().split())
counter = 0
for x in range(k + 1):
    if x >= s:
        break
    for y in range(x, k + 1):
        z = s - x - y
        if y >= s:
            break
        if y <= z <= k:
            if x == y == z:
                counter += 1
            elif x == y or y == z:
                counter += 3
            else:
                counter += 6

print(counter)

Submission status: Wrong Answer

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

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i+1 for i in range(K)]
	for x in ListK:
		for y in ListK:
			if S - (x + y) <= K:
				ans += 1

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i for i in range(K)]
	for x in ListK:
		for y in ListK:
			for z in ListK:
				if x + y + z == S:
					ans += 1
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    if i + j > s:
      break
    if 0 <= s-(i+j) <= k:
      ans += 1
      break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import *

def nHr(n, r):
   if 0 < r:
      return factorial(n+r-1) / (factorial(r) * factorial(n-1))
   else:
      return 0

lst = input().split()
K = int(lst[0])
S = int(lst[1])

a = nHr(3, S)
b = (3 * nHr(3, S - K)) - (3 * nHr(3, S - (2*K)))

print(int(a - b))

Submission status: Wrong Answer

Solution code:
from math import *

def nHr(n, r):
   if 0 <= r:
      return factorial(n+r-1) / (factorial(r) * factorial(n-1))
   else:
      return 0

lst = input().split()
K = int(lst[0])
S = int(lst[1])

a = nHr(3, S)
b = (3 * nHr(3, S - K)) - (3 * nHr(3, S - (2*K)))

print(int(a - b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  if 'get_ipython' not in globals():  
    # 以下のコードはAtCorder提出時のみに実行される。問題の種類に応じてinputメソッドを準備する
    k, s = map(int, input().split())
  else:
    #以下のコードはColab上でのみ実行される。テスト用の入力データを書いておく
    k, s = 2, 2
    # 以下にコード本体を書く
    o = 0
    for i in range(k + 1):
      for q in range(k + 1):
        for a in range(k + 1):
          x = i 
          y = q
          z = a
          if x + y + z == s:
            o += 1
    print(o)
main()

Submission status: Wrong Answer

Solution code:
#91 B - Sum of Three Integers
K,S = map(int,input().split())

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

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

for i in range((S // 3), K + 1):
    for j in range(i + 1):
        if 0 <= S - i - j <= K:
            if i == j:
                Sum += 1
            else:
                Sum += 2

print(Sum)

Submission status: Wrong Answer

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

if K >= S:
    ans = S*3

if K*3 == S:
    ans = 1
    
else:
    a =math.floor((K*3-S)/2)
    ans = a*3

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import itertools


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

lst = [i for i in range(k+1)]


prod = itertools.product(lst, repeat=3)



ans = 0


print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!


ans = 0


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
alist = [i+j+h==S for i in range(0,K+1) for j in range(0,K+1) for h in range(0,K+1)]
print(len(alist))

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
alist = [i+j+h==S for i in range(0,K) for j in range(0,K) for h in range(0,K)]
print(len(alist))

Submission status: Wrong Answer

Solution code:
K,S=map(int, input().split())
ans = 0
x = S//3+1
for i in range(x):
  if i > K:
    break
  y = (S-i)//2+1
  for j in range(y):
    if j > K:
      break
    k = S - i - j
    if k > K:
      continue
    if i == j == k:
      ans += 1
    elif i == j or j == k:
      ans += 3
    else:
      ans += 6
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    k, s = list(map(int, input().split()))
    if k*3 == s:
        print(1)
        exit()
    else:
        print(k*3)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
ans=0
if s%3==0:
  ans+=1
for i in range(k):
  if 2*k<=s<3*k:
    ans+=3
for i in range(k-1):
  for j in range(i+1,k):
    for k in range(j+1,k+1):
      if i+j+k==s:
        ans+=6


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def LI():
    return list(map(int, input().split()))


K, S = LI()
ans = 0
for i in range(K+1):
    total = S-i
    kosu = total+1
    if total > 2*K:
        continue
    if total > K:
        kosu -= (total-K)*2
        ans += kosu
    else:
        ans += kosu
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
cnt = 0
from itertools import combinations_with_replacement as cmbr
for x, y in cmbr(range(K+1),2):
    if 0 <= S-x-y <= K:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for p in range(k+1):
    for q in range(min(k+1, s-p+1)):
        for r in range(min(k+1, s-p-q+1)):
            print(p, q, r)
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)

Submission status: Wrong Answer

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

for p in range(k+1):
    for q in range(k-p+1):
        for r in range(k-p-q+1):
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)

Submission status: Wrong Answer

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

count = 0

for p in range(k+1):
    if p > s:
        break
    for q in range(k+1):
        if p + q < s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1
                break

print(count)

Submission status: Wrong Answer

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

for i in range(k+1):
    for j in range(k+1):
        l=s-i-j
        if i+j+l==s:
            t+=1
print(t)

Submission status: Wrong Answer

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

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

print(str(answer))

Submission status: Wrong Answer

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

ans=0
for i in range(K+1):
    for j in range(K+1):
        if not S-i-j>K:
            ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# vim: fileencoding=utf-8


def main():
    k, s = map(int, input().split())
    c = 0
    for i in range(k + 1):
        for j in range(i, k + 1):
            for l in range(j, k + 1):
                if i + j + l == s:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

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

count=0

for A in range(2*K+1):
        for Z in range(K+1):
            if A+Z==S:
                count+=1

print(count*2)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
if z < y:
    x = z
    z = y
ans = 0
while 0 <= x <= y and 0<= y <=K and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
print(ans)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
if z < y:
    z = y
    x = S - y - z
ans = 0
while 0 <= x and 0<=y and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
x = y = S//3 + 1
z = S - x - y
if z < y:
    z = y
    x = S - y - z
while 0 <= x and y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
print(ans)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
ans = 0
while 0 <= y and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
x = y = S//3 + 1
z = S - x - y
if z < y:
    z = y
    x = S - y - z
while 0 <= x and y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
print(ans)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
ans = 0
while 0 <= y and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
    print(x,y,z,ans,"-")
x = y = S//3 + 1
z = S - x - y
if z < y:
    z = y
    x = S - y - z
while 0 <= x and y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    print(x,y,z,ans,"+")
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = [0] * 3
ans = 0
for i in range(k, -1, -1):
    l[0] = i
    for j in range(i, -1, -1):
        if i + j > s:
            continue
        else:
            l[1] = j
            l[2] = s - l[1] - l[0]
            if l[2] <= l[1]:
                if l[0] == l[1] == l[2]:
                    ans += 1
                elif l[0] == l[1] or l[1] == l[2]:
                    ans += 3
                else:
                    ans += 6
            l = [0] * 3
            
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for x in range(k+1):
    if x > s:
        break
    if x+k+k < s:
        continue
    for y in range(x, k+1):
        xy = x+y
        if xy > s:
            break
        if xy+k < s:
            continue
        for z in range(y, k+1):
            xyz = x+y+z
            if xyz > s:
                break
            if x==y==z:
                ans += 1
            elif x!=y!=z!=x:
                ans += 6
            else:
                ans += 3
print(ans)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ans = 0
if s <= k:
    ans = (s+2)*(s+1)/2
else:
    for i in range(k+1):
        for j in range(k+1):
            ans = ans + (0 <= s-i-j <= k)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

minz = max(0, s-2*k)
maxz = k

def f(s, k):
    if k >= s:
        return (s+1)
    else:
        return (2*k-s)+1

ans = 0
for i in range(minz, maxz+1):
    ans += f(s-i, k)

print(ans)

Submission status: Wrong Answer

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

x = k - max(0,s-2*k) + 1

print(x*(x+1)//2)

Submission status: Wrong Answer

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

for x in range(S+1):
    for y in range(S+1):
        if x+y > S:
            break
        for z in range(S+1):
            if x+y+z == S:
                ans+=1
print(ans)

Submission status: Wrong Answer

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

for x in range(S+1):
    for y in range(S+1):
        for z in range(S+1):
            if x+y+z == S:
                ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 S == x+y+z:
            count += 1

print(count)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

for i in range(K+1):
    x = i
    for j in range(K+1-i):
        y = j
        for k in range(K+1-i-j):
            z = k
            if x+y+z == S:
                n += 1

print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
ans=0
c=0
if S%3==0:
  c=S//3
for x in range(K+1):
  if 0<=S-x and S-x<=2*K:
    ans+=1
print(ans*(ans+1)//2-2*c)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
ans=0
t=S//3
for x in range(K+1):
  if 0<=S-x and S-x<=2*K:
    ans+=1
print(ans*(ans+1)//2)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
ans=0
t=S//3
for x in range(t,K+1):
  for y in range(t,K+1):
    if x+y>S:
      break
    for z in range(t,K+1):
      if x+y+z==S:
        ans+=1
      if x+y+z>S:
        break
  if x>S:
    break
print(ans)

Submission status: Wrong Answer

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

count = 0
for i in range(K+1):
    for j in range(K+1):
        if(K >= S-(i+j) >= 0):
            count += 1
            print(i, j, S-(i+j))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
splited = input().split(" ")

k = int(splited[0])
s = int(splited[1])
z = [i for i in range(k+1)]

def check_sum(p):
  l, r = 0, k
  
  while(r - l >= 1):
    i = int((r + l) / 2)
    if z[i] == p:
      return True
    elif z[i] < p:
      l = i + 1
    else:
      r = i
  return False


result = 0

for x in range(k+1):
  for y in range(k+1):
    if check_sum(s-x-y):
      result = result + 1

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

Solution code:
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

count = 0
for x in range(k+1):
  if x == s:
    count += 1
  else:
    for y in range(k+1-x):
      if x+y == s:
        count += 1
      else:
        for z in range(k+1-x-y):
          if x+y+z == s:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

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

Submission status: Wrong Answer

Solution code:
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])
print(k)
print(s)

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S :
      ans+=1

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


k = 4
s = 10

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k:
                break
            
            if n >= 0:
                ans += 1

            m -= 1
        l -= 1

print(ans)

Submission status: Wrong Answer

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = k
        
        if t_sum > 2*k:
            break
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n <= k and n > 0:
                ans += 1
                
            #     n = k
            # if l + m + n < s:
            #     break
            
            # while n >= 0:
                
            #     if l + m + n == s:
            #         ans += 1
            #     if l + m + n < s:
            #         break

                # n -= 1
            m -= 1
        l -= 1

print(ans)

Submission status: Wrong Answer

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

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

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
start = s//3
ans = 0
if s < k:
    k = s

for i in range(start,k+1):
    for j in range(start,k+1):
        for l in range(start,k+1):
            if i+j+l == s:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
start = s//3
ans = 0
for i in range(start,k+1):
    for j in range(start,k+1):
        for l in range(start,k+1):
            if i+j+l == s:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
start = k//3
ans = 0
for i in range(start,k+1):
    for j in range(start,k+1):
        for l in range(start,k+1):
            if i+j+l == s:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

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

print(r)

Submission status: Wrong Answer

Solution code:
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

for i in range(K + 1):
    for j in range(K + 1):
        if i + j <= S:
            r += 1

print(r)

Submission status: Wrong Answer

Solution code:
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 1

s3 = min(K, max(0, S - 2 * K))
s2 = min(K, max(0, S - K))
s1 = min(K, S)

while True:
    if s3 != K:
        if s2 != 0:
            s3 += 1
            s2 -= 1
            r += 1
        elif s1 != 0:
            s1 -= 1
            s2 += 1
            r += 1
        else:
            break
    elif s2 != K:
        if s1 != 0:
            s2 += 1
            s1 -= 1
            r += 1
        else:
            break
    else:
        break

print(r)

Submission status: Wrong Answer

Solution code:
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

s = min(K + 1, 3 * K - S + 1)

res = s * (s + 1) // 2

print(res)

Submission status: Wrong Answer

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

print(count)