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

print(count)

Submission status: Accepted

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

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

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:
k, s = map(int, input().split())
res = 0

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

Submission status: Accepted

Solution code:
K, S = list(map(int, input().split()))
#Kは上限、S=X+Y+Z 0<=X,Y,Z<=K
x, y = 0, 0
ans = 0
#z = S - x - y
for i in range(0, K+1):
    x = i
    for j in range(0, K+1):
        y = j
        z = S - x - y
        if 0 <= z <= K:
            ans += 1
        else:
            pass
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<=K:
            c+=1

print(c)

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())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
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 = [int(i) for i in input().split()]
c = 0
for x in range(K+1):
    for y in range(x+1):
        z = S - x - y
        if x >= y >= z >= 0:
            if len({x, y, z}) == 3:
                c += 6
            if len({x, y, z}) == 2:
                c += 3
            if len({x, y, z}) == 1:
                c += 1
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

l = []

for i in range(K + 1):
    l.append(i)

count = 0

for i in l:
    for j in l:
        z = S - i - j
        if 0 <= z and z <= K:
            count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k, -1, -1):
    # 1桁目を決定する
    if s - i > k * 2:
        continue

    # 2桁目を決定する
    for j in range(k, -1, -1):
        # 3桁目を決定する
        x = s - i - j

        if x > k:
            # 3桁目が設定できないとき
            continue
        cnt += x >= 0
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,s=[int(x) for x in 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())
ans = 0
for i in range(k+1):
	for j in range(k+1):
		if 0 <= s - i - j <= k: ans += 1
		elif s - i - j < 0: break# これ以上減っても 0未満のまま
print(ans)

Submission status: Accepted

Solution code:
import itertools

K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
count = 0
for i, j in itertools.product(X, repeat=2):
  if 0 <= S - i - j <= K:
    count += 1
print(count)

Submission status: Accepted

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

import sys
import itertools

# import numpy as np

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

K, S = map(int, readline().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:
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))

    #第3要素で並び替え
    magics.sort(key=lambda x:x[2],reverse=True)


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

K,S = input_multiple_number()

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_b
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:
import sys

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

c=0

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

print(c)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

for x_i in range(k+1):
  for y_i in range(k+1):
    if 0<=s-x_i-y_i<=k:
      counter += 1
    
print(counter)

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

print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
K, S = [int(i) for i 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 = tuple(map(int, input().split()))


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

Submission status: Accepted

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

ans = 0
# X <= Y <= Zとしても一般性を失わない
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - x - y
        if z < y:
            break
        if z <= K:
            if x == y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6
print(ans)

Submission status: Accepted

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


t = sum(min(max(s - i + 1, 0), max(2*k - s + i +1, 0)) for i in range(k+1))
print(t)

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:
N = input().split()
N = [int(i) for i in N]
count = 0
for i in range(N[0]+1):
    for j in range(N[0]+1):
        k = N[1] - i - j
        if((k <= N[0])and(k>=0)):
            count += 1
print(count)

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

Submission status: Accepted

Solution code:
def solve(k, s):
    return sum(
        s - x - y <= k
        for x in range(min(k + 1, s + 1))
        for y in range(min(k + 1, s - x + 1))
    )

_k, _s = map(int, input().split())
print(solve(_k, _s))

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
k,s=LI()
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())
 
l1 = tuple([i for i in range(K+1)])
r = 0
for i in l1:
  if i > S:
    continue
  else:
    for j in l1:
      if i + j > S:
        continue
      elif S - i - j <= K:        
        r += 1
print(r)

Submission status: Accepted

Solution code:
(k, s),  = [list(map(int, s.split())) for s in open(0)]

num = 0
for i in range(k + 1):
    for j in range(k + 1):
        if s - i - j <= k and s - i - j >= 0 :
            num += 1
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        else:
            if (k + 1) > (s - x - y):
                # print(x, y, (s - x - y))
                count = count + 1

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


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

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

import sys
import itertools

# import numpy as np

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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)
main()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
import itertools
from itertools import combinations
from itertools import permutations

# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def crange(a, b, i):
    return range(a, b + 1, i)


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


# import random
# import time

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

Submission status: Accepted

Solution code:
#python3

def main():

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

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:
k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))

Submission status: Accepted

Solution code:
import numpy as np
K, S = map(int, input().split())

x1 = np.ones(K+1, np.int32)
x2 = np.convolve(x1,x1)
x3 = np.convolve(x1,x2)
ans = x3[S]
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:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    k,s=INTM()
    ct=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            if 0<=z and z<=k:
                ct+=1
    print(ct)
if __name__ == '__main__':
    do()

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

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

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

print(count)

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

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    z = i + j
    
    if S - z >= 0 and S - z <= K:
      #print(i,j,S-z)
      ANS+=1
    else:
      if S - z <= 0:
      	break
print(ANS)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Sumofnum(K,S):
    A = min(K,S) + 1
    a = max(S - 2*K, 0)
    c = 0
    for x in range (a,A):
        B = min(S - x,K) + 1
        b = max(S - x - K,0)
        for y in range (b,B):
            c = c + 1
    print(c)
    
s = list(map(int,input().split()))
K = s[0]
S = s[1]
Sumofnum(K,S)

Submission status: Accepted

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

n = 0

for i in range(k + 1):
  for j in range(k + 1):
    dif = s - (i + j)
    if dif >= 0 and dif <= k:
      n += 1
        
print(n)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc051/tasks/abc051_b
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 += 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:
import sys
input = sys.stdin.readline
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:
def main():
    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)
 
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):
        if 0 <= s-x-y <= k:
            ans += 1
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

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:
KS = input().split()
K,S = int(KS[0]), int(KS[1])
S_count = 0

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

Submission status: Accepted

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

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

c = 0
for x in range(K+1):
    for y in range(K+1):
        if x+y <= S and x+y+K >= S:
            c += 1
print(c)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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)