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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = list(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 and z <= k:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

ans=0
for i in range(0,K+1):
    for j in range(0,K+1):
        if 0<=S-(i+j) and S-(i+j)<=K:
            ans +=1

print(ans)

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    y_z = S - x
    if y_z < 0:
        continue
    
    y_min = max(y_z-K,0)
    y_max = min(y_z,K)
    res += max(y_max-y_min+1,0)

print(res)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

K, S = MAP()

count = 0

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

K, S = MAP()

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
"""
・Z=S-(X+Y)
・0<=Z<=K
"""
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s >= x + y >= s - k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
#複数の整数入力を受け付ける関数
def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

data = datain(2)
ans = 0

for x in range(data[0]+1):
    for y in range(data[0]+1):
        #print(x,y,data[1]-x-y)
        if data[0] >= data[1]-x-y >= 0:
            ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    K, S = list(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 and z <= K:
                cnt += 1
    print(cnt)
    

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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 0 <= z <= K:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import math

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

res = 0

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#2020-04-29
k, s = map(int,input().split())
cou = 0
for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <=k:
            cou += 1
print(cou)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

K, S = map(int, sys.stdin.readline().split())
ans = 0
for i in range(K+1):
  for j in range(K+1):
    if S - i - j < 0:
      break
    elif S - i - j > K:
      continue
    else:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
class SumofThreeIntegers:
    def calculate(self, K, S):
        self.counter = 0
        for x in range(K+1):
            for y in range(K+1):
                z = S - x - y
                if z < 0 or K < z:
                    pass
                elif x + y + z == S:
                    self.counter += 1
        return self.counter
            
if __name__ == "__main__":
    K, S = map(int, input().split())
    sti = SumofThreeIntegers()
    res = sti.calculate(K, S)
    print(str(res))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)

Submission status: Accepted

Solution code:
line = input().split()
k =int(line[0])
s =int(line[1])
data =[0,0,0]
out =0

for i in range(k+1):
  for t in range(i,1+k):
    data[0] =i
    data[1] =t
    data[2] =s-data[1]-data[0]
    
    if data[2] >=0 and data[2] <=k and data[2]>=t :
     
      if data[0] ==data[1] and data[0] ==data[2] and data[1] ==data[2]:
        out +=1
      elif data[0] !=data[1] and data[0] !=data[2] and data[1] !=data[2]:
        out +=6
      else:
        out +=3
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inf = 10**15
mod = 10**9+7
k,s = map(int, input().split())
ans = 0
for i in range(k+1):
    tmp = s-i
    if tmp >= 0:
        for j in range(k+1):
            t = tmp-j
            if 0 <= t <= k:
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,S = map(int,input().split())
def main(K,S):
    if S > 3*K:
        print(0)
        
    else:
        count = 0
        for i in range(K+1):
            for j in range(K+1):
                if 0 <= S - i - j <= K:
                    count += 1
        print(count)
if __name__ == '__main__':
   main(K,S)

Submission status: Accepted

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

def main():
    K, S = map(int, readline().rstrip().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import string
import time


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


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


def S():
    return input()


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


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


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


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


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


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


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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    k,s = readInts()
    cnt = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = (int(x) for x in 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:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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 0 <= z and z <= K:
    	count += 1
print(count)

Submission status: Accepted

Solution code:
def ABC051B(k, s):
    count = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                count += 1
    print(count)

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

Submission status: Accepted

Solution code:
def ABC051B(k, s):
    a = [0] * (3 * k + 1)
    mx = -(-3 * (k + 1) ** 2 // 4)
    for i in range(k + 1):
        a[i] = (i + 1) * (i + 2) // 2
        a[3 * k - i] = (i + 1) * (i + 2) // 2
    if k % 2 == 0:
        max_point = 3 * (k // 2)
        a[max_point] = mx
        odd_cum_diff = [x ** 2 for x in range(k // 2)]
        for j in range(k // 2):
            a[max_point - j] = mx - odd_cum_diff[j]
            a[max_point + j] = mx - odd_cum_diff[j]
    else:
        max_point = 3 * (k // 2) + 1
        a[max_point] = mx
        even_cum_diff = [x * (x + 1) for x in range(k // 2)]
        for j in range(k // 2):
            a[max_point - j] = mx - even_cum_diff[j]
            a[max_point + j + 1] = mx - even_cum_diff[j]
    # for i, v in enumerate(a):
    #     print(i, v)
    print(a[s])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
print(len([0 for X in range(K+1) for Y in range(K+1) if 0<=S-X-Y<=K]))

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
print(len([1 for X in range(K+1) for Y in range(K+1) if 0<=S-X-Y<=K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
    y_min = max(S- x - K, 0)
    y_max = min(S - x, K)
    ans += max(0, y_max - y_min + 1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


[K, S] = list(map(int, stdin.readline().rstrip().split()))

count=0

for x in range(K+1):
    for y in range(K+1):
        if x + y > S:
            continue
        if S - (x + y) <= K:
            #print("%d %d %d" % (x, y, S-(x+y)))
            count = count + 1

print(count)

Submission status: Accepted

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

def fun(k, s):
    count = 0
    for i in range(k+1):
        for j in range(k+1):
            if s - i - j <= k and s - i - j >= 0:
                count += 1

    return count

print(fun(k, s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc051/tasks/abc051_b
# -*- coding: utf-8 -*-
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
  for j in range(0,K+1):
    z = S-i-j
    if 0 <= z <= K: ans +=1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            
            # zが条件を満たすか
            if K >= z >= 0:
                count += 1
                    
    print(count)

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

Submission status: Accepted

Solution code:
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
                if K >= S - (x + y) >= 0 :
                    count += 1
                    
    print(count)

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

Submission status: Accepted

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 - x - y) == S and 0 <= S - x - y <= K:
            cnt += 1

print(cnt)

Submission status: Accepted

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

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


print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Solution code:
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    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
    print(ans)
if __name__ == '__main__':
    main()