Problem:


Score : 200 points

Problem Statement

You are given two integers K and S.

Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.

How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?  

Constraints

2≤K≤2500 

0≤S≤3K 

K and S are integers.  

Input

The input is given from Standard Input in the following format:

K S

Output

Print the number of the triples of X, Y and Z that satisfy the condition.

Sample Input 1

2 2

Sample Output 1

6

There are six triples of X, Y and Z that satisfy the condition:

X = 0, Y = 0, Z = 2 

X = 0, Y = 2, Z = 0 

X = 2, Y = 0, Z = 0 

X = 0, Y = 1, Z = 1 

X = 1, Y = 0, Z = 1 

X = 1, Y = 1, Z = 0

Sample Input 2

5 15

Sample Output 2

1

The maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z.



Sample input:
2 2


Sample output:
6

Submission status: Wrong Answer

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

ans = 0
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z <= 0 and z >= k):
      ans += 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)

Submission status: Wrong Answer

Solution code:
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)

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

Submission status: Wrong Answer

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n,k = cin()
    ans = 0
    for i in range(n+1):
      for j in range(n+1):
        if k-i-j>=0 and k-i-j<=(n+1):
          ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n,k = cin()
    ans = 0
    for i in range(n):
      for j in range(n):
        if k-i-j>=0 and k-i-j<=n:
          ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    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 S >= 0 and S <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    K, S = map(int, input().split())
    ans = 0
    for X in range(K + 1):
        for _ in range(K - X + 1):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

count = 0
for x in range(K+1):
    if S-x<=2*K and S-x>=0:
        for y in range(K+1):
            if S-x-y<=K and S-x-y>=0:
                print(x, y)
                count += 1
#                 for z in range(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):
    if S-x<=2*K:
        for y in range(K+1):
            if S-x-y<=K:
                count += 1
#                 for z in range(K+1):
#                     if x+y+z==S:
#                         count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools

s, k = map(int, input().split())
permutations_lis = list(itertools.product(range(k+1), repeat=3))
cnt = 0
for i in permutations_lis:
    if i[0] + i[1] + i[2] == s:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
s,k = map(int,input().split())
permutations_lis = list(itertools.product(range(k),repeat=3))
cnt = 0
for i in permutations_lis:
  if i[0] + i[1] + i[2] == s:
    cnt += 1
print(cnt)

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

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):
            if X+Y<=S:
                N+=1
print(N)

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

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

print(num)

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for l in range(k+1):
        z = s - i - l
        if 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):
    if i > s:
        break
    for l in range(i+1):
        if i + l > s:
            break
        z = s - i - l
        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):
    flg = False
    for j in range(K+1):
        if flg == True:
            break
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                flg = True
                cnt += (K+1 - j)
                break
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 = K -(X + Y)
        if 0 <= Z <= K:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
x=[0]*k
for i in range(0,k):
  x[i]=i
x.append(k)
a=int(s/3)-1
count=0
for i in range(0,len(x)):
  stemp=s-x[i]
  for j in range(0,min(k+1,stemp)):
    if stemp-x[j] in x:
      count=count+1
print(count)

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

K,S = inputIL()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
K,S=2500,5692

ans = []
 
for i in range(K+1):
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Wrong Answer

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

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)
    
print(sum(answer))

Submission status: Wrong Answer

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

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))

  else:
      answer.append(s_z + 1)

print(sum(answer))

Submission status: Wrong Answer

Solution code:
def f(K, S):
    z = list(range(0,K+1))
    answer = []

    for i in z:
      s_z = S - i
      if K < s_z:
        if (K + 1) > (s_z - K):
          answer.append(K + 1 - (s_z - K))

      else:
          answer.append(s_z + 1)

    return sum(answer)

Submission status: Wrong Answer

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

for x in range(k+1):
    for y in range(k+1):
        if s==0:
            print(1)
            sys.exit()
        elif s<=k:
            lis=list(itertools.combinations(list(range(1,s+2+1)),2))
            print(len(lis))
            sys.exit()
        else:
            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):
        for l in range(k+1):
            if i+j+k==s:
                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):
        if x + y <= k:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
k,s=map(int,stdin.readline().split())
print(((k+2)*(k+1))//2)

Submission status: Wrong Answer

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

pair = list()

for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        pair.append([x, y, z])
ans = len(pair)

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 0<=z<=k:
      ans+=1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
k, s=map(int, input().split())
ans=[]
for x in range(k+1):
    for y in range(x+1, k+1):
        for z in range(y+1, k+1):
            if x+y+z==s:
                ans.append((x, y, z))

print(6*len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def actual(K, S):
    my_range = lambda n: range(n + 1)

    count = 0

    for x in my_range(K):
        for y in my_range(K):
            z = S - (x + y)

            if z >= 0:
                count += 1

    return count

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

print(actual(K, S))

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement

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

ans = 0
for x, y, z in combinations_with_replacement(range(k+1), 3):
    if x + y + z == s:
       ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement

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

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

print(ans)

Submission status: Wrong Answer

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

res = 0

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

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

#data = [i for i in range(k + 1)]
# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)
target = s / 3
ans = 0
if (target < k):
    pass
else:
    for x in range(0, k + 1):
        #temp = s - x
        # 2なら、（０、２）（１、１）（２、０）
        for y in range(0, k + 1):
            if (0 <= s - (x + y) <= k):
                ans += 1


print(ans)

'''
ans = 0
for i in dd:
    #print(sum(i))
    if (sum(i) == s):
        ans += 1

print(ans)
'''

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
lst=[]
for i in range(k+1):
  for j in range(k+1):
    temp = 100*i + 10*j + (s-i-j)
    if 0<= s-i-j <=k and temp not in lst:
      lst.append(temp)
print(len(lst))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split() )
cnt = 0
cnt_one = 0
for x in range(K+1):
  for y in range(x+1):
    for z in range(y+1):
      if x+y+z == S:
        if x == y & x==z:
          cnt_one +=1
        else:
          cnt+=1
print(cnt*3 + cnt_one)

Submission status: Wrong Answer

Solution code:
K,S = (int(x) for x in input().split())
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 += 1
                print(x,y,z)


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

print(count * 3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(x,K+1):
            z = S-(x+y)
            if x+y+z > S:
                break
            # print(x,y,z)
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import itertools

K,S = map(int,input().split())
cnt = 0
for i in itertools.product(range(K+1),repeat = 2):
    if 0 <= S - i[0] + i[1] <= K:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
if s==0:
  print('0')
else:
  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())
ans = 0
for x in range(k+1):
    for y in range(x, k+1):
        z = s - x - y
        if z>=y and z<=k:
            tmp = set([x,y,z])
            if len(tmp)==3:
                ans += 6
            if len(tmp)==2:
                ans += 3
            else:
                ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = 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 i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            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(0,K+1,1):
    for j in range(0,K+1,1):
        for k in range(0,K+1,1):
            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(0,K+1):
    for j in range(0,K+1):
        for k in range(0,K+1):
            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(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:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    k, s = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for x in range((s- 2*((s//3) +1)), k+1):
        if x == s:
            cnt += 1
            break
        for y in range(k+1):
            if x + y == s:
                cnt += 1
                break
            for z in range(k+1):
                if x + y + z == s:
                    cnt += 1
                    break
    print(cnt)

resolve()

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
res = 0
for XY in range(2*K+1):
    Z = S - XY
    if Z in range(K):
        res += 2
    else:
        res += 1

print(res)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
res = 0
for XY in range(2*K+1):
    Z = S - XY
    if Z in range(K+1):
        res += 1

print(res)

Submission status: Wrong Answer

Solution code:
K,N=map(int,input().split())
cnt=0
def souatari(K,N):
    ans=0
    if 2*K<N:
        return 0
    elif 2*K>=N and K<N:
        return 2*K-N+1
    elif K>=N:
        return N+1

for i in range(K+1):
    cnt+=souatari(K,N-i)

print(cnt)
1,9
2,8
3,7
4,6
5,5

2,9
3,8
4,7
5,6

0,10
1,9
2,8
3,7
4,6
5,5

Submission status: Wrong Answer

Solution code:
K,N=map(int,input().split())
cnt=0
def souatari(K,N):
    ans=0
    if 2*K<N:
        return 0
    elif 2*K>=N and K<N:
        return 2*K-N+1
    else:
        return N+1


for i in range(K+1):
    cnt+=souatari(K,N-i)

print(cnt)
1,9
2,8
3,7
4,6
5,5

2,9
3,8
4,7
5,6

0,10
1,9
2,8
3,7
4,6
5,5

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
(k, s) = list(map(int, input().split()))
count = 0
kmax = (s / 3) if s % 3 == 0 else (s / 3 + 1)
for x in range(k + 1):
    if s - x > kmax * 2:
        continue
    for y in range(k + 1):
        if s - x - y > kmax:
            continue
        for z in range(k + 1):
            if s == x + y + z:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
(k, s) = list(map(int, input().split()))
count = 0
kmax = int(s / 3) if s % 3 == 0 else int(s / 3) + 1
print(kmax)
for x in range(kmax + 1):
    for y in range(kmax + 1):
        for z in range(kmax + 1):
            if s == x + y + z:
                print(s, x, y, z)
                count += 1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
K, S = map(int,input().split())
X = 0
Y = 0
Z = 0
count = 0
for X in range(X):
  for y in range(Y):
    for z in range(Z):
      if x + y + z == S:
        count = 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(x,K+1):
        for z in range(x+y,K+1):
            if x + y + z == S:
                cnt += 1

cnt = cnt * 3

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

for i in range(K+1):
   if 3 * i == S:
       cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

res = 0

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

Submission status: Wrong Answer

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

ans = 0
for i in range(K+1):
    if S-i <= K:
        ans += (S-i)+1
    elif S-i <= 2*K:
        a = (S-i) -K
        ans += (K-a)+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(S-x+1):
    for z in range(S-x-y+1):
      if x+y+z == S:
        count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
from math import factorial

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
ans = 0
k, s = map(int, input().split())
sa = [int(i) for i in range(k+1)]
tt = [int(i) for i in range(k+1)]
c = itertools.product(sa,repeat=2)

for i in c:
  if i[0] + i[1] - s  in tt:
      ans+=1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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