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 i in range(k + 1):
    for j in range(i + 1):
        l = s - (i + j)
        if i + j + l == s:
            if i == j == l:
                ans += 1
            elif i == j or j == l or l == i:
                ans += 3
            else:
                ans += 6
print(ans)

Submission status: Wrong Answer

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 k >K:
      break
    if j>k:
      break
    if k<0:
      break
    if i==j==k:
      M+=1
    elif i==j or j==k:
      M+=3
    else:
      M+=6
print(M)

Submission status: Wrong Answer

Solution code:
K,S = (int(_) for _ in input().split())

out = 0

for x in range(K):
    for y in range(K):
        for z in range(K):
            if x + y + z == S :
                out += 1

print(out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

X = Y = Z = 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: Wrong Answer

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

Submission status: Wrong Answer

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
      break               
print(s)

Submission status: Wrong Answer

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

s = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x +y +z ==S:
        s +=1

print(s)

Submission status: Wrong Answer

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

min_x = max(0,S-2*K)

max_x = min(S,K)

for x in range(min_x+1,max_x+1):
    print(x)

count=0
for x in range(min_x,max_x+1):
    min_y = max(0,S-x-K)
    max_y = min(S-x,K)
    
    for y in range(min_y,max_y+1):
        
        if S-x-y <0 or S-x-y >K:
            print('error')
            
        count+=1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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,s)-max(0,c-k)+1,0)

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
K,S=[int(i) for i in input().split()]
ans=0
for x in range(K+1):
    ans+=(K-x+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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 = 15

count = 0
for x in range(k+1):
    if x == s:
        count = count + 1
    if x + k < s:
        count = count
    if 2*k + x >= s:
        count = count + 1
    if s <= x + k:
        count = count + (s-x+1)

print(count)

Submission status: Wrong Answer

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 = 15

count = 0
for x in range(k+1):
    if x == s:
        count = count + 1
        break
    if x + k < s:
        count = count
    if 2*k + x >= s:
        count = count + 1
    if s <= x + k:
        count = count + (s-x+1)

print(count)

Submission status: Wrong Answer

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 = 15

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

Submission status: Wrong Answer

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 = 15

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

Submission status: Wrong Answer

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 = 15

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

Submission status: Wrong Answer

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 = 15

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

Submission status: Wrong Answer

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 = 15

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(k+1-i):
        for h in range(k+1-i-j):
            if i + j + h == s:
                ans.append([i, j, h])
                break
print(len(ans))

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
print(sum(range(S+2)))

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
print(sum(range(S+1)))

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

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(X,K+1):
        Z = S - X - Y
        if Z < Y or Z < 0:
            continue
        else:
            # print(X,Y,Z)
            if X == Y and X == Z:
                count += 1
            elif X == Y and Y != Z:
                count += 3
            elif Y == Z  and Z != X:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

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(X,min(S-X,K+1)):
        Z = S - X - Y
        if Z > K:
            continue
        else:
            if X == Y and X == Z:
                count += 1
            elif X == Y and Y != Z:
                count += 3
            elif Y == Z  and Z != X:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int,input().split())
count = 0
start = S - 2*K
for X in range(start,K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            if X+Y+Z == S:
                if X == Y and X == Z:
                    count += 1
                elif X == Y and Y != Z:
                    count += 3
                elif Y == Z  and Z != X:
                    count += 3
                else:
                    count += 6

print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
res = 0
for x in range(k+1):
  if 3 * x == s:
    res += 1
for x in range(k+1):
  for y in range(k+1):
    if x == y:
      continue
    if 2 * x + y == s:
      res += 3
for x in range(k+1):
  for y in range(k+1):
    if x == y:
      continue
    d = s - x - y
    if d != x and d != y and 0 <= d <= k:
      res += 6

print(res)

Submission status: Wrong Answer

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

count = 0

for i in range(k):
    x = i + 1
    if x < s:
        for j in range(k):
            y = j + 1
            if x + y < s:
                for l in range(k):
                    z = l + 1
                    if x + y + z == s:
                        count = count + 1
            elif x + y == s:
                count = count + 1
    elif x == s:
        count = count + 1

print(count)

Submission status: Wrong Answer

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


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

print(counter)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if(S <= K):
 ans = combinations_count(S+2, 2)
 print(ans)  
elif(K < S):
 for x in range(K+1):
  for y in range(K+1):
    z = S-x-y
    if(z <= K):
      ans += 1
 print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
K, S = map(int, input().split())
ans = 0
for i in range(K + 1):
    if S - i > 2 * K:
        continue
    if S - i > K:
        ans += 2 * K + 1 - S + i
    else:
        ans += S - i + 1
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = list(map(int, input().split()))
print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

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

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
limit, target = map(int, input().split(" "))
answer = 0
for i in range(limit + 1):
    for j in range(limit + 1):
        if target - i - j <= limit:
            answer += 1

print(answer)

Submission status: Wrong Answer

Solution code:
limit, target = map(int, input().split(" "))
answer = 0
for i in range(limit + 1):
    for j in range(limit + 1):
        if target - i - j >= 0:
            answer += 1

print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
inp = sys.stdin.readline

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
if s/k == 3:
    print(1)
elif k < s:
    print(int((1/2)*(k+1)*(k+2)))
elif k >= s:
    print(int((1/2)*(s+1)*(s+2)))

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
if s/k == 3:
    print(1)
else:
    print(int((1/2)*(k+1)*(k+2)))

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
Xm = k
Ym = k
Zm = k #使わない
count = 0
for i in range(Xm+1):
  for j in range(Ym+1):
    if s - (i+j) <= k:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# 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 and z<=k:
            print(x,y,z)
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
# 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 and z<=s:
            count+=1
print(count)

Submission status: Wrong Answer

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

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):
    for z in range(K+1-x-y):
        if(x+(x+y)+(x+y+z)==S):
          count+=3
          if(x==(x+y)==(x+y+z)):
            count-=2
          else:pass
        else:pass
print(count)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
print(K,S)
count=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if(x+y+z==S):
        #print(x,y,z)
        count+=1
      else:pass
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int,input().split())
count = 0
for x in range(0,S,1):
  for y in range(0,S,1):
    z = S - x - y
    if x+y+z == S and z <= K and y <= K and x <= K and z >= 0: #ここどうにかしたい
      count += 1
print(count)

Submission status: Wrong Answer

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

print(c)

Submission status: Wrong Answer

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

print(c)

Submission status: Wrong Answer

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

print(c)

Submission status: Wrong Answer

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


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

print(count)

Submission status: Wrong Answer

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

count=0
for x in range(k+1):
  y_z = s-x
  if y_z < 0:
    count +=0
  if 2*k < y_z:
    count += 0
  elif y_z <= 2*k:
    count += min(y_z+1,2*k-y_z+1)
        
print(count)

Submission status: Wrong Answer

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

count=0
for x in range(k+1):
  y_z = s-x
  if 2*k < y_z:
    count += 0
  elif y_z <= 2*k:
    count += min(y_z+1,2*k-y_z+1)
        
print(count)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1):
    for y in range(max(x,s-x-k),k+1):
            for z in range(max(y,s-x-y),k+1):
                    if x+y+z==s:
                        if x==y and y==z:
                            count+=1
                        else:
                            count+=3
                        break
print(count)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1):
    for y in range(max(x,s-x-k),k+1):
            for z in range(max(y,s-x-y),k+1):
                    if x+y+z==s:
                        if x==y and y==z:
                            count+=1
                        else:
                            count+=3
                        print(x,y,z)
                        break
print(count)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1):
    for y in range(x,k+1):
            for z in range(y,k+1):
                    if x+y+z==s:
                        if x==y and y==z:
                            count+=1
                        else:
                            count+=3
                        break
print(count)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
count = 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:
                        if x==y and y==z:
                            count+=1
                        else:
                            count+=3
print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
if s == 3*k or s == 0:
    print(1)
else:
    counter=0
    flag=1
    index = k
    while index > max(s//3-1, -1) and flag:
        index2 = index
        while index2 > -1 and flag:
            index3 = index2
            while index3 > -1 and flag:
                if index+index2+index3 == s:
                    if index!=index2 and index2!=index3 and index3!=index:
                        counter+=6
                    elif index == index2 and index2 == index3:
                        counter+=1
                    else:
                        counter+=3
                elif index+index2+index3 < s:
                    flag=0
                    break
                index3-=1
            index2-=1
        index-=1
    
    print(counter)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

counter = 0

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

print(counter)

Submission status: Wrong Answer

Solution code:
import itertools
print(*[[[sum(j) == S for j in [i for i in itertools.product(range(K + 1), repeat=3)]].count(True)] for S, K in zip(*[[i] for i in map(int, input().split())])][0])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ks = list(range(K+1))
l = {N:ks for N in ('XYZ')}
count = 0
while l['X']:
  x = l['X'].pop(0)
  a = S - x
  if a/2 < K:
    count += 2
  elif a/2 == K:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ks = list(range(K+1))
l = {N:ks for N in ('XYZ')}
count = 0
while l['X']:
  x = l['X'].pop(0)
  a = S - x
  if a/2 < K:
    count += 2
  elif a/2 == K:
    count += 1
    break
print(count)

Submission status: Wrong Answer

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

res = [(x,y,z) for x in range(K+1)
for y in range(K+1)
for z in range(K+1)
if x+y+z==S]

print(res)
print(len(res))

Submission status: Wrong Answer

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

#問題文よりX, Y, Zの最大値はKであるため、各値の最大値はKである
X = range(K+1)
Y = range(K+1)

#フラグ設定
flag = 0

#全探索
for x in X:
    for y in Y:
        #zの値を含めて全探索すると時間オーバーするため以下の処置を施す
        Z = range(K-(x+y)+1)
        for z in Z:
            if x+y+z==S:  #条件
                flag += 1

#出力
print(flag)

Submission status: Wrong Answer

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

count = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == K:
        count += 1
print(count)

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

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

Submission status: Wrong Answer

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

ans = 0
for x in range(k+1):
    if s - x <= k:
        ans += s-x+1
    elif s-x-k <= k:
        ans += k - s + x + k + 1
    # print(x, ans)
print(ans)

Submission status: Wrong Answer

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

ret = 0 
for X in range(K+1):
  for Y in range(X, K+1):
    Z = S - X - Y
    if Z < Y: break
    if Z >= 0 and Z <= K:
      print(X, Y, Z)
      if X == Y and Y == Z: ret += 1
      elif X != Y and Y != Z and Z != X: ret += 6
      else: ret += 3

print (ret)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

count =  0
x, y, z = 0, 0, 0

if n > s:
  n = s

for i in reversed(range(n + 1)):
  x = i
  for j in reversed(range(n + 1)):
    if x > s or s - x > 2 * n:
      break
    y = j
    for k in reversed(range(n + 1)):
      if x + y > s or s - x + y > n:
        break
      z = k
      if x + y + z == s:
        count += 1
        
print(count)

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest051-B
#  https://atcoder.jp/contests/abc051/tasks/abc051_b
def  queueAnswer(maxValue,sumNumber):
	counter = 0
	for x in range(0,maxValue+1,1):
		for y in range(0,maxValue+1,1):
			z = sumNumber-x-y
			if z <= maxValue:
				counter = counter + 1
	answer = counter
	return answer


if __name__ == '__main__':
	k,s = map(int,input().strip().split(' '))
	solution=queueAnswer(k,s)
	print(solution)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,raw_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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
ss=s//3
count=0
if(k <= ss):
    print('1')
    exit()
else:
    for i in range(k):
        count+=3
print(count)

Submission status: Wrong Answer

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