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:
import sys
import string
import time


def input():
    return sys.stdin.readline().rstrip()


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


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


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10 ** 6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    K, S = MI()
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = x + y - S
            if 0 <= z & z <= K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

print(i)

Submission status: Wrong Answer

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

ans = {}
perm = 0
x_list = list(range(K+1))
y_list = list(range(K+1))

for x in x_list:
    for y in y_list:
        #print(x, y, S-x-y)
        cand = "".join(sorted([str(x), str(y), str(S-x-y)]))
        if S-x-y in range(K+1) and not(cand in ans.keys()):
            if x == y == S-x-y:
                perm = 1
            elif x == y or y == S-x-y or x == S-x-y:
                perm = 3
            else:
                perm = 6
            #print(cand)
            ans[cand] = perm

print(sum(ans.values()))

Submission status: Wrong Answer

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

ans = {}
perm = 0
x_list = list(range(K+1))
y_list = list(range(K+1))

for x in x_list:
    for y in y_list:
        #print(x, y, S-x-y)
        if x == y == S-x-y:
            perm = 1
        elif x == y or y == S-x-y or x == S-x-y:
            perm = 3
        else:
            perm = 6
        cand = "".join(sorted([str(x), str(y), str(S-x-y)]))
        if S-x-y in range(K+1) and not(cand in ans.keys()):
            #print(cand)
            ans[cand] = perm

print(sum(ans.values()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = 2
S = 2
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: Wrong Answer

Solution code:
K = 2
S = 2
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: Wrong Answer

Solution code:
K = 2
S = 2
count = 0

for x in range(K):
  for y in range(K):
    z = S - x - y
    if 0 <= z and z <= K:
    	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(X,K+1):
		for Z in range(Y,K+1):
			if X+Y+Z==S:
				if X==0 and Y==0:
					ans=ans+3
				elif X==0:
					ans=ans+3
				else:
					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(1,K+1):
    for z in range(1,K+1):
      if x + y + z == S:
        count = 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(1,K+1):
    for z in range(1,K+1):
      print(x,y,z,x+y+z,S)
      if x + y + z == S:
        count = count + 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if s % 3 == 0:
    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+1, k+1):
        z = s - x - y
        l = {x, y, z}
        if 0 <= z <= k:
            if len(l) == 3:
                ans += 6
            elif len(l) == 2:
                ans += 3
            else:
                ans += 1

if s % 3 == 0:
    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())
ans = 0

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

print(ans)

Submission status: Wrong Answer

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
            else:
                break

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

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

Submission status: Wrong Answer

Solution code:
import bisect

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

p=[]
for i in range(k+1):
    p.append(i)
    
pp=[]
for i in p:
    for j in p:
        pp.append(i+j)
pp.sort()

ans=0
for x in pp:
    if pp[bisect.bisect_right(pp,s-x)-1]==s-x:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 <= 5 and z <= 5:
            if s == y+z+i:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def main():
    S, K = 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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
in1 = sys.stdin.readlines()

#in1 = ['5 15']

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

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

print(RC)

Submission status: Wrong Answer

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 = K - i - ii
        if 0<=z and z<=K and (x+y+z)==S:
            counter += 1

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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:
            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 3*x == S:
        ans += 1

#二つ同じ
for x in range(K+1):
    for y in range(x+1, K+1):
        if 2*x + y == S or x + 2*y == S:
            ans += 3

#全て違う
for x in range(K+1):
    for y in range(x+1, K+1):
        for z in range(y+1, K+1):
            if x+y+z == S:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 (s-x-y)>y:
            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: Wrong Answer

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 s-x-y <= k:
            count += (s-x-y*2)*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: Wrong Answer

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+1):
        for z in range(y+2, k+1):
            if x+y+z == s:
                count += 6
    for z in range(temp, k+1):
        if x*2 + z == s:
            if x == z:
                count += 1
            else:
                count += 3
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 i + j <= s:
            ans += 1
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
x=input().split(" ")
k=int(x[0])
s=int(x[1])
sum=0
for i in range(k+1):
    if s-i<=k*2 and s-i>=k:
        sum+=k*2-s+i+1
    elif s-i<k:
        sum+=s-i+1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
temp=0

k,s=map(int,input().split())
if 3*k<s: print(0)
else: 
  for a in range(s-2*k,k+1):
    temp+=2*k-(s-a)+1

print(temp)

Submission status: Wrong Answer

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  k,s = map(int,input().split())
  ans = 0
  for i in range(k):
    for j in range(k):
      z = s - i - j
      if 0 <= z <= k:
        ans += 1
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7
def main():
  k,s = map(int,input().split())
  a_1 = 3 * k
  a_2 = a_1 - s
  if a_2 == 0:
    print(1)
    exit()
  ans = math.factorial(a_2)// (math.factorial(a_2-2) * math.factorial(2))
  print(ans)
  
if __name__ == '__main__':
  main()

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

print(ans)

Submission status: Wrong Answer

Solution code:
x = list(map(int,input().split()))
count=0
for a in range(0,x[0]+1):
    print(a)
    for b in range(0,x[0]+1):
        for c in range(0,x[0]+1):
            if(a+b+c==x[1]):
                count+=1
print(count)

Submission status: Wrong Answer

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

k, s = map(int, input().split())
cnt = 0
max_v = max(2 * (k + 2), s + 1)
memo = [0] * max_v
for i in range(k + 1):
  for j in range(k + 1):
    v = i + j
    if v > s:
      break
    memo[v] += 1
for i in range(k + 1):
  for j in range(max_v):
    v = i + j
    if v > s:
      break
    elif v == s:
      cnt += memo[j]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(Y)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

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

    for y in range(a//2, -1, -1):
        z = a - y
        if z == k:
            count += 1
        elif z > k:
            break

print(count)

Submission status: Wrong Answer

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

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

    for y in range(a//2, -1, -1):
        z = a - y
        if z == k:
            count += 1
        else:
            break

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
x = S if K>S else K

ans = 0
for i in range(x+1):
  x1 = S-i
  for j in range((K if x1>K else x1)+1):
    x2 = S-i-j
    for k in range((K if x2>K else x2)+1):
      if i+j+k==S:
        print("{} {} {}".format(i,j,k))
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
x = S if K>S else K

print(3+sum(range(3,3+(x-1))))

Submission status: Wrong Answer

Solution code:
#from scipy.misc import comb

K, S = map(int, input().split())
x = S if K>S else K

#a = comb(3*K, S, exact=True)
#print(a)

ans = 0
for i in range(x+1):
  for j in range(x-i+1):
    for k in range(x-i-j+1):
      if i+j+k==S:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#from scipy.misc import comb

K, S = map(int, input().split())
x = S if K>S else K

#a = comb(3*K, S, exact=True)
#print(a)

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

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

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

K = KS[0]
S = KS[1]
T = 0
combination_number = 0

for X in range(0,K+1):
    T = S-X
    if((T > 2*K)or(T < 0)):
        pass
    elif((T <= 2* K)and(T> K)):
        combination_number = combination_number + 1
    else:
        combination_number = combination_number + T + 1

print(combination_number)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s3 = s // 3
m = max(k, s3)
for x in range(0, m + 1):
    print(x)
    for y in range(0, m + 1):
        ad = s - x - y
        if ad <= k and ad >= 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

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

s3 = s // 3
m = min(k, s3)
for x in range(m, 0, -1):
    print(x)
    for y in range(m, 0, -1):
        for z in range(s - x - y, 0, -1):
            xyz = x + y + z
            if x + y + z == s:
                ans += 1
            elif xyz < s:
                break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(cnt)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x=0
j=0

for j in range(k+1):
	if s-j<=k:
		x=x+s-j+1
	elif (s-j)<=2*k:
		x=x+(2*k-(s-j)+1)

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement
import bisect

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

ans = 0
# for v in combinations_with_replacement(range(k + 1), 3):
#     if sum(v) == s:
#         leng = len(set(v))
#         if leng == 1 or leng == 3:
#             ans += 1
#         else:
#             ans += 3

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                print([v, x, hoge])
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1

            # leng = len(set([v, x, hoge]))
            # if leng == 1 or leng == 3:
            #     ans += 1
            # else:
            #     ans += 3

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement


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

ans = 0
for v in combinations_with_replacement(range(k + 1), 3):
    if sum(v) == s:
        leng = len(set(v))
        if leng == 1 or leng == 3:
            ans += 1
        else:
            ans += 3

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
K, S = map(int, input().split())
table = [0] * (2 * K + 1)
for x in range(K + 1):
  for y in range(K + 1):
    table[x + y] += 1
res = 0
#print(table)
for z in range(S - K, min(2 * K + 1, S + 1)): res += table[z]
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
K, S = map(int, input().split())
table = [0] * (2 * K + 1)
for x in range(K + 1):
  for y in range(K + 1):
    table[x + y] += 1
res = 0
#print(table)
for z in range(S - K, 2 * K + 1): res += table[z]
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = list(range(0,k + 1))

import itertools
ans = 0
for v in itertools.combinations_with_replacement(n, 3):
  if sum(list(v)) == s:
    if v[0] == v[1] == v[2]:
      ans += 1
    elif v[0] == v[1] or v[0] == v[2] or v[1] == v[2]:
      ans += 3
    else:
      ans += 3

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(X,K+1):
        Z = S - X - Y
        if Y <= Z <= K:
            if X == Y == Z:
                ans += 1
            else:
                ans += 3
                

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

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

print(ans)

Submission status: Wrong Answer

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