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:
a,b = list(map(int, input().split()))
ans = 0

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

Submission status: Wrong Answer

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

for i in range(a):
  for j in range(a):
    for k in range(a):
      if i+j+k==b:
        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 and 0 <= 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(x, 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())

x_min = max(0, s-2*k)
x_max = min(int(s//3), k)
z_count = 0
for x in range(x_min, x_max+1):
    res = s - x
    
    y_min = x
    y_max = int(s//2)

    for y in range(y_min, y_max+1):
        res_z = res - y
        if y <= k and res_z <= k and y <= res_z:
            z_count += 1

if s % 3 == 0:
    ans = (z_count)*3 - 2
else:
    ans = (z_count)*3

print(ans)

Submission status: Wrong Answer

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

x_min = max(0, s-2*k)
x_max = int(s//3)
z_count = 0
for x in range(x_min, x_max+1):
    res = s - x
    
    y_min = x
    y_max = int(s//2)

    for y in range(y_min, y_max+1):
        if y <= k:
            z_count += 1

if s % 3 == 0:
    ans = (z_count)*3 - 2
else:
    ans = (z_count)*3

print(ans)

Submission status: Wrong Answer

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

x_min = max(0, s-2*k)
x_max = int(s//3)
z_count = 0
for x in range(x_min, x_max+1):
    res = s - x
    
    y_min = x
    y_max = int(res//2)

    for y in range(y_min, y_max+1):
        z_count += 1

if s % 3 == 0:
    ans = (z_count)*3 - 2
else:
    ans = (z_count)*3

print(ans)

Submission status: Wrong Answer

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

ans = 0
for x in range(K):
    sum_y_z = S - x # y + z = S - x
    if sum_y_z <= 2 * K: # x + y + z <= 3 * K の制約あり
        ans += sum_y_z + 1
ans += 1 # x = Sの場合

print(str(ans))

Submission status: Wrong Answer

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

ans = 0

for z in range(k + 1):
	if k >= s - z:
		ans += s - z + 1
	elif 2 * (k + 1) > s - z + 1:
		ans += 2 * k - s + z + 1

print(ans)

Submission status: Wrong Answer

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

ans = 0

for z in range(k + 1):
	if k >= s - z:
		ans += s - z + 1
	elif 2 * k - s + z + 1 >= 0:
		ans += 2 * k - s + z + 1

print(ans)

Submission status: Wrong Answer

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

ans = 0

for z in range(k + 1):
	if k > s - z:
		ans += s - z + 1
	elif 2 * k - s + z + 1 >= 0:
		ans += 2 * k - s + z + 1

print(ans)

Submission status: Wrong Answer

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

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

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

print(result)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = 5
S = 15

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
if K*3<S:
  print(0)
  exit()

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

print(ans)

Submission status: Wrong Answer

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

ans = 0
if K*3<S:
  print(0)
  exit()

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

print(ans)

Submission status: Wrong Answer

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

ans = 0
if K*3<S:
  print(0)
  exit()

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

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

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):
    for z in range(y+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(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        ans +=1
      elif x+y+z >S:
        break
    if x+y+z >S:
      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=k-x-y
        if(z>=0)&((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=k-x-y
        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 (x+y+z)==s:
             count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = [int(num) for num in input().split()]

count = 0

for x in range(K + 1):
    for y in range(K + 1 - x):
        for z in range(K + 1 - x - y):

            if x + y + z == S:
                count += 1

print(count)

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
k = int(line[0])
s = int(line[1])
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())

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

print(ans)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split(' '))
cnt_pattern = 0
for a in range(k+1):
  if a > s:
    continue
    for b in range(k+1):
      if a + b > s:
        break
        for c in range(k+1):
          if s == a + b + c:
            cnt_pattern += 1
            if s < a + b + c:
              break
print(cnt_pattern)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
count=0
for i in range(K+1):
  X=i
  if S-i>=0:
    for j in range(K+1):
      Y=j
      Z=S-i-j
      #print(X,Y,Z)
      if S-i-j>=0 and X<=K and Y<=K and Z<=K:
        #print('correct!',X,Y,Z)
        count+=1
      else:
        break
  else:
    break
print(count)

Submission status: Wrong Answer

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

import sys

input = sys.stdin.readline

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


main()

Submission status: Wrong Answer

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

import sys

input = sys.stdin.readline

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


main()

Submission status: Wrong Answer

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

import sys

input = sys.stdin.readline

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


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

c = 0
for X in range(K + 1):
    for Y in range(X, K + 1):
        Z = S - X - Y
        if Y <= Z <= K:
            c += 1

print(c)

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

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

print(x)

Submission status: Wrong Answer

Solution code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


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

cnt = 0

for i in range(min(k,s)+1):
    for j in range(min(k,s)+1):
        memo = s-i-j

        if 0<=memo and memo<=s:
            cnt += 1
            

print(cnt)

Submission status: Wrong Answer

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


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > 2 * k and s < 3 * k:
  print(a(s + 1) -3 * a(s - k))
else:
  print(0)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
import math
K,S=map(int,input().split())
c=[]
for i in range(1,2500):
  if S%i==0 and S<=i*3 and i<=K:
    c.append(i)
if len(c)==1:
  print(len(c))
else:
  print(math.factorial(len(c)+1))

Submission status: Wrong Answer

Solution code:
from sys import stdin

k,s = [int(x) for x in stdin.readline().rstrip().split()]

point = 0

for i in range(k-1):
    for j in range(i+1,k):
        for k in range(j+1,k+1):
            if i+j+k == s:
                point += 1

point *= 6

if s % 3 == 0:
    point += 1
po = 0
for i in range(k+1):
    if (s-i) %2 == 0 and (s-i)//2 <= k and (s-i)//2 != i:
        po += 1
point += po*3
print(point)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for x in range(K+1):
    xyz = 0
    if S > x:
        break
    for y in range(K+1):
        if S > x+y:
            break
        for z in range(K+1):
            if x+y+z == S:
                ans += 1
            elif S > x+y+z:
                break

print(ans)

Submission status: Wrong Answer

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

ans = 0
for x in range(K+1):
    xyz = x
    if S > xyz:
        continue
    for y in range(K+1):
        xyz += y
        if S > xyz:
            continue
        for z in range(K+1):
            xyz += z
            if xyz == S:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:

l = list(map(int,input().split()))

count = 0

for x in range(l[0] + 1):
    for y in range(l[0] + 1):
        for z in range(l[0] + 1):
            if x + y + z == l[1]:
                count += 1
                print(x,y,z)

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

Submission status: Wrong Answer

Solution code:
def solve():
    K, S = map(int, input().split())
    
    lower = S - 2 * K
    if lower < 0:
        lower = 0
    
    cnt = 0
    for x in range(lower, K + 1):
        upper = S - x
        if upper > K:
            upper = K
        for y in range(lower, upper + 1):
            cnt += 1
    
    print(cnt)

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0

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

Submission status: Wrong Answer

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0

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

Submission status: Wrong Answer

Solution code:
K, S = [int(i) for i in 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())
counter = 0
for X in range(K):
    for Y in range(X, K):
        for Z in range(Y, K):
            if X + Y + Z == S:
                counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
counter = 0
for X in range(K):
    for Y in range(K):
        for Z in range(K):
            if X + Y + Z == S:
                counter += 1
print(counter)

Submission status: Wrong Answer

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

c=0
for i in range(K+1):
    for j in range(K+1):
        if((i+j)<=S):
            c+=1
        else:
            break
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
    K, S = map(int, input().split())
    start = S // 3
    ans = 0

    for i in range(start, K+1):
        for j in range(start, K+1):
            if S - i - j >= 0:
                ans += 1
            else:
                break

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
L=[]
points=0
m=S
for i in range(K):
  S=m
  S-=i
  if S>2*K:
    pass
  else:
    for j in range(K):
      S-=j
      if S>K:
        pass
      else:
        if set([i,j,S]) not in L:
          L.append(set([i,j,S]))
for k in range(len(L)):
  if len(L[k])==3:
    points+=6
  elif len(L[k])==2:
    points+=3
  elif len(L[k])==1:
    points+=1
print(points)

Submission status: Wrong Answer

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


count = 0
for x in range(K+1):
    if x > S or S - x > 2*K:
        break
    for y in range(K+1):
        if x + y > S or S - (x+y) > K:
            break
        for z in range(K+1):
            if x + y + z > S:
                break
            elif x + y + z == S:
                count +=1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def examB():
    K, S = LI()
    minX = max(S - 2*K,0)
    maxX = min(S, K)
    ans = 0
    start = max(S-K+1,1)
    for i in range(start,start+maxX-minX+1):
        ans += i
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

Solution code:
def examB():
    K, S = LI()
    minX = max(S - 2*K,0)
    maxX = min(S, K)
    ans = 0
    for i in range(1,maxX-minX+2):
        ans += i
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

Solution code:
def examB():
    K, S = LI()
    minX = max(S - 2*K,0)
    ans = 0
    for i in range(1,K-minX+2):
        ans += i
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
#        check_tmp =0
#        check_tmp =check1(x,l_s,l_k)
#        if check_tmp == 1:
#            break
#        elif check_tmp  == 2:
#            continue
        for y in range(l_k):
#            check_tmp =check2(x,y,l_s,l_k)
#            if check_tmp == 1:
#                break
#            elif check_tmp  == 2:
#                continue2
#            sum = x+y+l_k 
            sum = l_s- x-y 
            if 0<=sum and sum <= k:
                print("x=",x,"y="   ,y) 
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
num = 0
for x in range(K + 1):
    ukou = S - x
    if ukou <= K * 2:
        y = K if K <= ukou else ukou
        z = ukou - y
        num += ((y + 1) - z)

print(num)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
if K == S or K * 2 == S:
    print(sum(range(1, K + 2)))
elif K * 3 == S:
    print(1)
elif K * 3 > S:
    print(0)
elif K * 2 > S:
    print(sum(range(1, K + 1)))
elif K * 2 < S:
    print(sum(range(2, K + 2)) + K)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
if K == S or K * 2 == S:
    print(sum(range(1, K + 2)))
elif K * 2 > S:
    print(sum(range(1, K + 1)))
elif K * 2 < S:
    print(sum(range(2, K + 2)) + K)
elif K * 3 == S:
    print(1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
point=0
m=S
if 3*K==S:
  print(1)
else:
  for i in range(K+1):
    if S-i<0:
      break
    for j in range(K+1):
      if S-j-i<0:
        break
      for k in range(K+1):
        if S-i-j-k<0:
          break
        elif i+j+k==S:
          point+=1
print(point)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

li = []
for x in range(K+1):
    for y in range(K+1):
        if S-x-y >= 0 and S-x-y <= K:
            print([x, y, S-x-y])
            li.append([x, y, S-x-y])
print(len(li))

Submission status: Wrong Answer

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

sum = 0
for i in range(0,a+1):
    for j in range(0,a+1):
        if s-i-j <= a:
            sum += 1
print(sum)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
flag = 1
s = 0
for l in range(K+1):
  if l == S+1:
    break
  for m in range(K+1):
    if l == S+1:
      break
    n = S - (l+m)
    
    if (n<=0) and (l+m+n == S):
      s = s+1
print(s)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
flag = 1
s = 0
for l in range(K):
  for m in range(K):
    for n in range(K):
      if l+m+n <= S:
        s = s+1
      else:
        flag = 0
        break
    if flag:
      break
  if flag:
    break
print(s)

Submission status: Wrong Answer

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

a = 0
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:
        a += 1
a *= 6

b = 0
for X in range(K + 1):
  if (S - X) % 2 == 0 and (S - X) // 2 <= K and (S - X) // 2 != X:
    b += 1
b *= 3

c = 0
if S % 3 == 0:
  c = 1
        
print(a + b + c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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