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:
ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(k + 1)[::-1]:
    for y in range(min(x + 1, s - x))[::-1]:
        z = s - x - y
        if x <= k and y <= k and z <= k:
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)

Submission status: Wrong Answer

Solution code:
ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(k + 1)[::-1]:
    for y in range(min(x + 1, s - x))[::-1]:
        z = s - x - y
        if x <= k and y <= k and z <= k:
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6

Submission status: Wrong Answer

Solution code:
sk = input()
count = 0
s, k = [int(x) for x in sk.split(" ")]
count = 0
for i in range(min(k+1, s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
sk = input()
count = 0
s, k = [int(x) for x in sk.split(" ")]
for i in range(s + 2):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = int(0)

for i in range(k + 1):
    for j in range(k + 1):
        l = int(i + j - s)
        if 0 <= l <= k:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0 
for x in range(0,K+1):
  if 0 <= S - x < K:
    cnt += S - x + 1
  elif 0 <= S - x:
    cnt += K + 1
print(cnt)

Submission status: Wrong Answer

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0 
x_flg = bool()
out = int()
for x in range(0,K+1):
  for y in range(0,K+1):
    if S - x < K:
      cnt += S - x + 1
      break
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
    elif z < 0:
      break
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
K, S = [int(i) for i in input().split()]
cnt = 0 
x_flg = bool()
out = int()
for x in range(0,K+1):
  for y in range(0,math.ceil(S/2)+1):
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
    elif z < 0:
      break
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
K, S = map(int, input().split())
cnt = 0

for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if Z > 0 and Z <= K:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0

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


print(count)

Submission status: Wrong Answer

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

count=0

for i in range(k+1):
  for j in range(k+1):
      if s <= i+j <= s+k:
        count += 1
print(count)

Submission status: Wrong Answer

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

count=0

for i in range(k+1):
  for j in range(k+1):
      if s < i+j < s+k:
        count += 1
print(count)

Submission status: Wrong Answer

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

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

matched = []

for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y
        if 0 <= z and z <= 5:
            matched.append((x, y, z))

# print(matched)
print(len(matched))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
a=0
b=0
c=0
l=0
while l*2<=s and l<=k:
    if s-l*2<=k:
        b+=1
    l+=1
if s%3==0:
    a+=1
    b-=1
for x in range(k+1):
    for y in range(x+1,k+1):
        if k>s-x-y>y:
            c+=1
print(a+3*b+6*c)

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
a=0
b=0
c=0
l=0
while l*2<=s and l<=k:
    if s-l*2<=k:
        b+=1
    l+=1
if s%3==0:
    a+=1
    b-=1
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:
                c+=1
print(a,b,c,a+3*b+6*c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

count = 0
lis = []

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:
                lis.append([x,y,z])

c1 = 0
c2 = 0
c3 = 0
for l in range(0, len(lis)):
    if len(set(lis[l])) == 1:
        c1 += 1
    if len(set(lis[l])) == 2:
        c2 += 1
    if len(set(lis[l])) == 3:
        c3 += 1

#print(c1)
#print(c2)
#print(c3)

if c3 == 0:
    c3_add = 0
else:
    c3_add = math.factorial(c3)

ans = c1 + c2*3 + c3_add

print(ans)

Submission status: Wrong Answer

Solution code:
import math
k, s = map(int, input().split())
count=0
if k < s/3:
  print(0)
  quit()
for a in range(math.ceil(s/3), k+1):
  for b in range(math.ceil(s/3), k+1):
    for c in range(math.ceil(s/3), k+1):
      if a+b+c == s:
        count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for i1 in range(k+1):
  for i2 in range(k+1):
      if i1 + i2 <= s <= i1 + i2 + k:
        ans += 1
        print(i1, i2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ks = input().split()

k = int(ks[0])
s = int(ks[1])

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

val=list(range(1, k+1))[::-1]
n=len(val)
ans=0

for i in range(n-2):
  if val[i]>=s:
    continue
  for j in range(i, n-1):
    if val[i]+val[j]>=s:
      continue
    for k in range(j, n):
      if val[i]+val[j]+val[k]==s:
        ans+=1
        break
print(ans)

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())
print([x+y+z for x in range(k) for y in range(k) for z in range(k)].count(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np


def count_true(matrix:np.array, s:int):
    return np.count_nonzero(matrix == s)


def unk(k:int, s:int):
    # 条件チェック
    if all([(2 <= k <= 2000), (0 <= s <= 3*k)]):

        x = y = z = np.array([range(0,k+1)])

        c1 = count_true(x, s)
        tmp = x.T + y
        c2 = count_true(tmp, s)
        tmp = tmp + z
        c3 = count_true(tmp, s)

        print(c1 + c2 + c3)
        


if __name__ == '__main__':
    data = input().split(" ")
    data = list(map(int, data))
    unk(data[0], data[1])

Submission status: Wrong Answer

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

count=0

for x in range(data[0]):
    for y in range(x+1, data[0]+1):
        
        # 枝刈り
        if x+y>data[1]:
            break
        
        if data[0] >= (data[1]-(x+y)) >= 0:
            z = data[1]-(x+y)
            
            if x + y + z == data[1]:
                count+=1

count*=3
if data[0]*3 == data[1]:
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
count = 0
for i in range(max(0, S - 2 * K), min(K + 1, S)):
  for j in range(max(0, S - 2 * K), min(K + 1, S)):
      if i + j <= S and i + j >= S - 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 z in range(K+1):
    if S - z > 2*K:
        continue
    elif K < S - z <= 2*K:
        ans += K - (S - z - K) + 1
    else:
        ans += S - z + 1
print(ans)

Submission status: Wrong Answer

Solution code:
ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            z = ks[1] - (targetX + targetY)
            print(z)
            
            if 0 <= z and z <= ks[0]:
                count += 1
                
        
            targetY +=1
        
    targetX +=1
        
 
print(count)

Submission status: Wrong Answer

Solution code:
c = input() #print(c)
ini = c.split() #print(ini[1])
k = int(ini[0]) #k
s = int(ini[1]) #s
count = 0
#print('k:{0} s:{1}'.format(k, s))

for z in range(k+1):
    for y in range(k+1):
        for x in range(k+1):
            if x + y + z == s:
                count +=1
                #break
            
print('count = {0}'.format(count))

Submission status: Wrong Answer

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

count = 0

x = 0
y = 0
z = 0

for targetX in range(ks[1]+1):
    
    for targetY in range(ks[1]+1):
    
        for targetZ in range(ks[1]+1):
        
            if targetZ <= ks[0] and 0 <= targetX:
                if targetX + targetY + targetZ == ks[1]:
                
                    count +=1
                    #print(targetX)
                    #print(targetY)
                    #print(targetZ)
            
            targetZ +=1
    
        targetY +=1
        
    targetX +=1
        

#print(ks)
print(count)

Submission status: Wrong Answer

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

counter = 0

#すべての値が等しい場合 i = j = k
if S%3 == 0:
    counter += 1

for i in range(K):
    yz = S - i
    #2つの値が等しい場合 i < j = k
    if yz%2 == 0 and yz/2 <= K and yz/2 > i:
        counter += 3
    # 2つの値が等しい場合 i = j < k
    if yz - i <= K and yz - i > i:
        counter += 3
    #すべての値が異なる場合 i < j < k
    for  j in range(i+1, K):
        k = S - i - j
        if k > j + 1 and k <= K:
            counter += 6

print(counter)
print("\n")

Submission status: Wrong Answer

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

counter = 0

#すべての値が等しい場合 i = j = k
if S%3 == 0:
    counter += 1

for i in range(K):
    yz = S - i
    #2つの値が等しい場合 i < j = k
    if yz%2 == 0 and yz/2 <= K:
        counter += 3
    # 2つの値が等しい場合 i = j < k
    if yz - i <= K and yz - i > i:
        counter += 3
    #すべての値が異なる場合 i < j < k
    for  j in range(i+1, K):
        k = S - i - j
        if k > j + 1 and k <= K:
            counter += 6

print(counter)
print("\n")

Submission status: Wrong Answer

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

counter = 0

#すべての値が等しい場合
if S/K == 3:
    counter += 1

for i in range(K + 1):
    yz = S - i
    #2つの値が等しい場合
    if yz/2 == K and yz/2 != K:
        counter += 3
    #すべての値が異なる場合
    for  j in range(i+1, K+1):
        if S - i - j >= j + 1 and S - i - j <= K:
            counter += 6

print(counter)
print("\n")

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

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

X=Y=Z=0
result = 0
while(X<=S):
    while(X+Y<=S):
        Z = S-X-Y
        print("X,Y,Z",X,Y,Z)
        if X+Y+Z == S:
            if X<=K and Y<=K and Z<=K :
                result+=1 
        # Z=X+Y-S
        # if X+Y+Z==S:
        #     result +=1
        # while(Z<=K):
        #     if X+Y+Z<S:
        #         pass
        #     elif X+Y+Z==S:
        #         result +=1
        #     else:
        #         break
        #     Z+=1
        # if X+Y+Z>S:
        #     break
        if Y<K:
            Y+=1
        else:
            break
    if X<K:
        Y=0
        X+=1
    else:
        break

print(result)

Submission status: Wrong Answer

Solution code:
#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

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

X=Y=Z=0
result = 0
while(X<=S):
    while(X+Y<=S):
        Z = S-X-Y
        print("X,Y,Z",X,Y,Z)
        if X+Y+Z == S:
            if X<=K and Y<=K and Z<=K :
                result+=1 
        # Z=X+Y-S
        # if X+Y+Z==S:
        #     result +=1
        # while(Z<=K):
        #     if X+Y+Z<S:
        #         pass
        #     elif X+Y+Z==S:
        #         result +=1
        #     else:
        #         break
        #     Z+=1
        # if X+Y+Z>S:
        #     break
        Y+=1
    Y=0
    X+=1
print(result)

Submission status: Wrong Answer

Solution code:
#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

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

X=Y=Z=0
result = 0
while(X<=K):
    while(Y<=K):
        while(Z<=K):
            if X+Y+Z<S:
                pass
            elif X+Y+Z==S:
                result +=1
            else:
                break
            Z+=1
        if X+Y+Z<=S:
            Z=0
            Y+=1
        else:
            break
    Y=0
    X+=1
print(result)

Submission status: Wrong Answer

Solution code:
#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

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

X=Y=Z=0
result = 0
while(X<=K):
    while(Y<=K):
        while(Z<=K):
            print("X,Y,Z",X,Y,Z)
            if X+Y+Z<S:
                pass
            elif X+Y+Z==S:
                result +=1
            else:
                break
            Z+=1
        Z=0
        Y+=1
    Y=0
    X+=1
print(result)

Submission status: Wrong Answer

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

#これは立方体の中のどこか一点を選ぶ問題とみなせる
#その中で選ばれた座標の各要素の和が、Sに等しければ良い
#点の総和は(K+1)*3個あり（※ゼロを含むから）、それらが選択可能なx,y,zの集合である
#x,y,zの和がSに達しない場合は、Sを満たす集合はその立方体の外側にある

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

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
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 =  list(map(int,input().split()))

cnt = 0
for X in range(0,K+1):
    if S-X > 2*K:
        continue
    else:
        cnt += (K+1) - abs(S-X-K)
      
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z <= K and z >= 0:
            print(str(x)+str(y)+str(z))
            count += 1
print(str(count))

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
K, S = map(int, input().split())
count = 0
for x in range(K):
    for y in range(K):
        z = S - x - y
        if z <= K & z >= 0:
            count += 1
print(str(count))

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
K, S = map(int, input().split())
S = S if K * 3 / 2 > S else K * 3 - S
count = int((S+1) * (S+2) / 2)
print(str(count))

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
from math import factorial
K, S = map(int, input().split())
S = S if K * 3 / 2 > S else K * 3 - S
count = int((S+1) * (S+2) / 2)
print(str(count))

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
import itertools
K, S = map(int, input().split())
S = S if K * 3 / 2 - S > 0 else K * 3 - S
count = len(list(itertools.combinations(range(S+2), 2)))
print(str(count))

Submission status: Wrong Answer

Solution code:
lines = input().split(" ")
K = int(lines[0])
S = int(lines[1])

count = 0
for i in range(K):
    for j in range(K):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            count += 1
        
print(count)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
if k*3 > s:
  i = 0
  count = 0
  x = k - i
  while x >= s/2:
    for j in range(int(s/2)+1):
      z = int(s/2) - j
      y = s-(k-i)-z
      if x+y+z == s and x >= y >= z:
        if x == y != z or x != y == z:
          count += 3
        elif x == y == z:
          count += 1
        elif x != y and y != z and z != x:
          count += 6
    i += 1
    x = k - i
  print(count)
elif k*3 == s:
  print(1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
if k*3 > s:
  i = 0
  count = 0
  x = k - i
  while x >= s/2:
    for j in range(int(k/2)+1):
      z = int(k/2) - j
      y = s-(k-i)-z
      if x+y+z == s and x >= y >= z:
        if x == y != z or x != y == z:
          count += 3
        elif x == y == z:
          count += 1
        elif x != y and y != z and z != x:
          count += 6
    i += 1
    x = k - i
  print(count)
elif k*3 == s:
  print(1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
if k*3 > s:
  i = 0
  count = 0
  x = k - i
  while x >= k/2:
    for j in range(int(k/2)+1):
      z = int(k/2) - j
      y = s-(k-i)-z
      if x+y+z == s and x >= y >= z:
        if x == y != z or x != y == z:
          count += 3
        elif x == y == z:
          count += 1
        elif x != y and y != z and z != x:
          count += 6
    i += 1
    x = k - i
  print(count)
elif k*3 == s:
  print(1)
else:
  print(0)

Submission status: Wrong Answer

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

else:
  print(0)

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

Submission status: Wrong Answer

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

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

print(count)

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)[i:]:
        for n in range(k + 1)[j:]:
            if i + j + n == s:
                count += 1

print(count)

Submission status: Wrong Answer

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

R = 0

for X in range(max(0, S-2*K), K+1):
    for Y in range(max(0, S-2*K), K+1):
        if X + Y <= S:
            R += 1

print(R)

Submission status: Wrong Answer

Solution code:
import itertools


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

X = min(K, S)
Y = max(0, min(K, S-X))
Z = max(0, min(K, S-X-Y))

R = set([tuple(set([X, Y, Z]))] + [tuple(set([x, y, S-x-y])) for x in range(Y, X) for y in range(Z, X)])

H    = {}
H[1] = 1
H[2] = 3
H[3] = 1

print(sum([H[len(r)] for r in R]))

Submission status: Wrong Answer

Solution code:
import numpy as np
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)&(z<=K):
            count += 1
print(count)

Submission status: Wrong Answer

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

count = 0

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

print(count)

Submission status: Wrong Answer

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

count = 0

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

print(count)

Submission status: Wrong Answer

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

ans = 0
num = min(s, k)+1
for i in range(0, num):
    for j in range(0, min(k, s-i)):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)

Submission status: Wrong Answer

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

same_all = 0
same_two = 0
same_none = 0

for i in range(K, 0, -1):
    for j in range(S - i, -1, -1):
        if ( K<j ):
            continue
        k = S-i-j
        
        if (k <= K and k<=j):
            if(i == j and j == k):
                same_all += 1
            elif(i == j or i == k or k == j):
                same_two += 1
            else:
                same_none += 1


print(same_all + same_two*3 + same_none*6)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(0,k+1):
    for j in range(i,k+1):
        x=i
        y=j
        z=max(y,min(k,s-i-j))
        if x+y+z==s:
            if x==y==z:
                ans+=1
            else:
                ans+=3
        else:
            ans+=0


print(ans)

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

Submission status: Wrong Answer

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

for i in range(1,k+1):
    x=i
    y=min(x,s-x)
    z=min(y,s-x-y)
    if x+y+z==s:
        if x==y==z:
             ans+=1
        else:
             ans+=3
    else:
        ans+=0

print(ans)

Submission status: Wrong Answer

Solution code:

def solve(K, S):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if S - x - y <= K:
                count = count + 1
    return count


if __name__ == '__main__':
    K, S = map(int, input().split())
    print(solve(K, S))