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:
# B
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:
            count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    m = S-x
    if (m == 0 or m == 2*K):
        res += 1
    elif (m > 0 and m < 2*K):
        res += m + 1
    else:
        res += 0
print(res)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    m = S-x
    if (m == 0 or m == 2*K):
        res += 1
    elif (m > 0 and m < 2*K):
        res += m + 1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    domain, num_sum = map(int, input().split())
    answer = 0
    for i in range(domain + 1):
        if num_sum < i or 2 * domain < (num_sum - i):
            continue
        else:
            if domain < num_sum - i - 1:
                answer += num_sum - i - 2 * domain + 1
            elif not i == num_sum:
                answer += domain + 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(s - x - k, min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(k):
    for j in range(k):
        for m in range(k):

            if i + j + m == s:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC 051 B Sum of Three Integers

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

li = [x for x in range(k+1)]
li.reverse()

res = 0
for x in range(len(li)):
    for y in range(len(li)):
        if x+y==s:
            res += 1
            break
        if x+y+max(li)<s:
            break
        for z in range(len(li)):
            if x+y+z == s:
                res += 1
                break

print(res)

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(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = 3 * k - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)

Submission status: Wrong Answer

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

def main():
    k, s = map(int, input().split())
    vals = [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(len([vals]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ans = 0 
for X in range(S//3, K + 1):
    for Y in range(S // 3, K + 1):
        if X + Y > S:
            continue
        for Z in range(S//3,K + 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//3, K + 1):
    for Y in range(S//3, K + 1):
        for Z in range(S//3,K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<4:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*10-(S-K-3)*12))

Submission status: Wrong Answer

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

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<5:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*10-(S-K-3)*12))

Submission status: Wrong Answer

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

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<5:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*(((5-1)*5)/2)-(S-K-5)*4))

Submission status: Wrong Answer

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

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<5:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*(((5-1)*5)/2)-(S-K-5)*12))

Submission status: Wrong Answer

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

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))

Submission status: Wrong Answer

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

l = set()
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s:
            l.add((i, j, s-k-j))
        else:
            continue

print(len(l))

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

print(count)

Submission status: Wrong Answer

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
total = 0
for X in range(K+1):
  if X > S:
    break
  for Y in range(K+1):
    add_xy = X + Y
    if S < add_xy and add_xy < (2/3) * S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1
  if S < add_xy:
    break
      
print(count)

Submission status: Wrong Answer

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
total = 0
flag = False
for X in range(K, -1, -1):
  for Y in range(K, -1, -1):
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1
    if K < Z:
      flag = True
  if flag:
    break
        
print(count)

Submission status: Wrong Answer

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
total = 0
flag = False
for X in range(K, -1, -1):
  for Y in range(K, -1, -1):
    Z = S - X - Y
    print(X, Y, Z)
    if 0 <= Z and Z <= K:
      count +=1
    if K < Z:
      flag = True
  if flag:
    break
        
print(count)

Submission status: Wrong Answer

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

ans = 0
for x in reversed(range(k+1)):
    for y in reversed(range(k+1)):
        for z in reversed(range(k+1)):
            if x+y+z == s:
                ans += 1
                break
            else:
                break
print(ans)

Submission status: Wrong Answer

Solution code:
a,b=list(map(int,input().split()))
count=0
for x in range(a+1):
    for y in range(a+1):
        if b < x+y:
            break
            if b-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):
        if 0 <= S-(x+y) <= K+1:
            count+=1
print(count)

Submission status: Wrong Answer

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

arr=[]
cnt=0

for x in range(k+1):
  for y in range(x,k+1):
    z=s-x-y
    if 0<=z<=k:
      if x==y==z:
        cnt+=1
      elif x==y or y==z or z==x:
        cnt+=3
      else:
        cnt+=6
print(cnt)

Submission status: Wrong Answer

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

arr=[]
cnt=0

for x in range(k+1):
  for y in range(x,k+1):
    z=s-x-y
    if 0<=z<=k:
      print((x,y,z))
      if x==y==z:
        cnt+=1
        print('add 1')
      elif x==y or y==z or z==x:
        cnt+=3
        print('add 3')
      else:
        cnt+=6
        print('add 6')
print(cnt)

Submission status: Wrong Answer

Solution code:
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  for x in range(a+1):
    if (sums-x <=2*a)&(sums>=x):
      for y in range(a+1):
        if sums-x-y>=0:
          ret+=1
  print(ret)

Submission status: Wrong Answer

Solution code:
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for x in range(a+1):
    if sums-x <=2*a:
      for y in range(a+1):
        if sums-x-y<=a:
          ret+=1
  print(ret-mai)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = [int(n) for n in 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 = [int(n) for n in input().split(" ")]
 
cnt = 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:
        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 x > K:
      break
    for z in range(K + 1):
      if x + y > K:
        break
      if x + y + z == S:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

import itertools
l = list(itertools.combinations_with_replacement(n, 3))
ans = 0
for i in range(len(l)):
  if sum(l[i]) == S:
    ans += 1

print((ans - 1) * 2 + 1 if S % 3 == 0 else ans * 3)

Submission status: Wrong Answer

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

number_lis = []
ans = 0

for i in range(0,K+1):
    number_lis.append(i)

for j in number_lis:
    for k in number_lis:
        for l in number_lis:
            if 0<= (S - (j + k)) <=K:
                ans = ans + 1
                
print(ans)

Submission status: Wrong Answer

Solution code:
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for x in range(a+1):
    if sums-x <2*a:
      for y in range(a+1):
        if sums-x-y<a:
          if (sums-x-y == x) | (sums-x-y == y):
            ret+=1
          else:
            ret+=2
    if sums-x == 2*a:
      ret+=1
  print(ret-mai)

Submission status: Wrong Answer

Solution code:
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for i in range(a):
    if sums-i <2*a:
      for d in range(a):
        if sums-i-d<a:
          if (sums-i-d == i) | (sums-i-d == i):
            ret+=1
          else:
            ret+=2
    if sums-i == 2*a:
      ret+=1
  print(ret*3-mai)

Submission status: Wrong Answer

Solution code:
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for i in range(a):
    if sums-i <2*a:
      for d in range(a):
        if sums-i-d<a:
          if sums-i-d == d:
            ret+=1
          else:
            ret+=2
    if sums-i == 2*a:
      ret+=1
  print(ret*3-mai)

Submission status: Wrong Answer

Solution code:
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 3
print(cnt)

Submission status: Wrong Answer

Solution code:
k, s = [int(x) for x in input().split()]
cnt = 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 == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 3
print(cnt)

Submission status: Wrong Answer

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

ans_count = 0
for i in range(0, input[0]):
  for j in range(0, input[0]):
    for k in range(0, input[0]):
      if (i + j + k == input[1]):
        ans_count+=1
        
print(ans_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 0 <= s-i-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):
  for j in range(s-i-k, s-i+1):
    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(s-i+1):
    for l in range(s-i-j+1):
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
X = []
Y = []
Z = []
count = 0

for i in range(0 ,K + 1):
	for j in range(0 ,K + 1):
		for k in range(0 ,K + 1):
			X.append(i)
			Y.append(i)
			Z.append(i)
			if S == X[i] + Y[j] + Z[k]:
				count += 1

print(str(count))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Max, Sum = map(int, input().split())

counter = 0
for i in range(Max+1):
  for j in range(Max+1):
    if Max -i -j >= 0:
      k = Max -i -j
    if i + j + k == Sum:
      counter += 1
 
print(counter)

Submission status: Wrong Answer

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

c = int(s / 3)
 
ans = (k - c) 

if ans == 0:
  print(1)
else:
  print(ans*3)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#coding: utf-8
K,S=map(int,input().split(" "))
answer=0
for X in range(K+1):
  for Y in range(K+1):
    print(X,Y)
    if S-(X+Y)<=K and S-(X+Y)>=0:
      answer+=1
print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
n=sum( 0<=s-i-j<=k for i in range(k) for j in range(k))
print(n)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

for x in range(K):
    for y in range(K):
        if x + y + (S-(x+y)) == S:
            ans += 1
ans += ans/2
print(int(ans))

Submission status: Wrong Answer

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

for x in range(K):
    for y in range(K):
        if x + y + (S-(x+y)) == S:
            ans += 1
ans += ans/2
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = input().split()
N = [int(i) for i in N]
num = [i for i in range(N[0]+1)]

count = 0

#1
for i in range(N[0]):
    if(3*i == N[1]):
        count += 1

l2 = list(itertools.combinations(num, 2))
l3 = list(itertools.combinations(num, 3))
#print(num)
#print(l2)

#2
for i in range(len(l2)):
    if((l2[i][0] + 2*l2[i][1]) == N[1]):
        count += 1*3
    if((l2[i][0]*2 + l2[i][1]) == N[1]):
        count += 1*3

#3
for i in range(len(l3)):
    if((l3[i][0] + l3[i][1] + l3[i][2]) == N[1]):
        count += 1*6

print(count)

Submission status: Wrong Answer

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

ans = 0
for h in range(k//3,k+1):
    for i in range(k//3,k+1):
        for j in range(k//3,k+1):
            if h+i+j==s:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int,input().split())
 
l1 = tuple([i for i in range(K+1)])
r = 0
for i in l1:
  if i > S:
    continue
  else:
    for j in l1:
      if S - i - j <= K:        
        r += 1
print(r)

Submission status: Wrong Answer

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

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        for z in range(k + 1):
            print(x, y, z)
            if x + y + z == s:
                count = count + 1
            elif x + y + z > s:
                break

print(count)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for X in range(K+1):
    T = S-X
    if T <= K:
        ans += T + 1
    elif T <= 2*K:
        ans += 2*K-T+1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for X in range(K+1):
    T = S-X
    if T <= K:
        ans += T+1
    else:
        ans += max(2*K-T+1,0)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  for y in range(b+1):
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)

Submission status: Wrong Answer

Solution code:
import math

k,s = map(int, input().split())
#n, x  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))

counter = 0
for i in range(k+1):
  for ii in range(k+1):
    for iii in range(k+1):
      if (s == i+ii+iii):
        counter = counter + 1
        print(i, ii, iii)
        
print(counter)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
count = 0
for a in range(k+1):
  for b in range(k+1):
      if a + b <= s:
        count += 1
      else:
        pass
print(count)

Submission status: Wrong Answer

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

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

        z = S - x - y
        if z <= K and z > 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):

        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 i in range(K+1):
  if i > S:
    break
  for j in range(K+1-i):
    zz = i + j
    if zz > S:
      break
    for k in range(K+1-zz):
      z = i + j + k
      if z == S:
        #print(i,j,k)
        ANS+=1
      elif z >= S:
        break
print(ANS)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
res = 0
I = max((S+1,K+1))
for X in range(0,I):
    if X > S:
        break
    for Y in range(0,I):
        if X + Y > S:
            break
        elif (0<=S-X-Y) and ((S-X-Y) <= K):
            res += 1
print(res)

Submission status: Wrong Answer

Solution code:
#B - Sum of Three Integers
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif 0<=(X + Y - S) and (X + Y - S) <= K:
            res += 1
print(res)

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

Submission status: Wrong Answer

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

count=0
for i in range(k+1):
  if s-i-2*k >=0:
    for j in range(k+1):
      if s-i-j-k>=0:
        for h in range(k+1):
          if i+j+h ==s:
            count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
print([S - x - y <= K for x in range(K+1) for y in range(K+1)].count(True))

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
print([x+y+z == S for x in range(K+1) for y in range(K+1) for z in range(K+1)])

Submission status: Wrong Answer

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

ways = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= 2*K:
            ways += 1

print(ways)

Submission status: Wrong Answer

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

count = 0

for x in range(K + 1):
  for y in range(K + 1):
    for x in range(K + 1):
      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())

ans = 0
for x in range(k+1)[::-1]:
    y = max(0, min(s-x, k))
    z = s-x-y
    if z > k or z < 0:
        break
    ans += y - z + 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
for x in range(k+1)[::-1]:
    y = min(s-x, k)
    z = s-x-y
    if z > k:
        break
    ans += y - z + 1

print(ans)

Submission status: Wrong Answer

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

if K == S:
	print( (K+5)*(K+4)//2 )
	exit() 

ans = 0
for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += S1 - 2*K + 1
		else:
			continue

print(ans)

Submission status: Wrong Answer

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

ans = 0

for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += S1 - 2*K + 1
		else:
			continue

print(ans)

Submission status: Wrong Answer

Solution code:
k, s = 5, 15

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

print(count)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      break
    elif i == b:
      ans += 1
      break
    elif i < b:
      if i+2*a < b:
        break
      elif i+2*a == b:
        ans += 1
        break
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            break
          elif i+j == b:
            ans += 1
            break
          elif i+j < b:
            if i+j+a < b:
              break
            elif i+j+a == b:
              ans += 1
              break
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k > b:
                  break
                elif i+j+k == b:
                  ans += 1
              
  print(ans)