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())
res = 0
for x in range(k + 1):
    if (s - x) < 0:
        break
    for y in range(0, s - x + 1):
        if (s - x - y) < 0:
            break
        z = s - y - x
        if z >= 0 and x <= k and y <= k and z <= k:
            #print("{0}, {1} {2}".format(str(x), str(y), str(z)))
            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 and z<=K:
            # print([x,y,z])
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    k, s = map(int, input().split())

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

    print(c)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def F(K,S):
  # x+y = S, <=K
  if S < 0:
    return 0
  if S <= K:
    return (S+1)
  if S > K+K:
    return 0
  return (K+K-S+1)

answer = 0

for x in range(K+1):
  answer += F(K,S-x)

print(answer)

Submission status: Accepted

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

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

#print
print(counter)

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

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

print(cnt)

Submission status: Accepted

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

for T in range(S-K, S+1):
    if T <= K:
        ans += max(0, T+1)
    else:
        ans += max(0, 2*K - T +1)
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 <= K:
                result+=1
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

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

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:
# -*- coding:utf-8 -*-

def solve():
    K, S = list(map(int, input().split()))

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



if __name__ == "__main__":
    solve()

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())
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:
n = list(map(int, (input()).split(' ')))
#n = [2500,7500]
#print(n)
x = [ i   for i in range(n[0]+1)]
#y = [ i   for i in range(n[1]+1)]
#z = [ i   for i in range(n[1]+1)]
#print(x)
counter = 0
if n[0]*3 >= n[1]:
  for x1 in x:
    for y1 in x:
      if 0<= n[1]-x1-y1 <=n[0]  :
          counter +=1

        
print(counter)

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


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

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
res = 0
for a in range(k + 1):
  for b in range(k + 1):
    z = s - a - b
    if z >= 0 and z <= k:
        res += 1
        
print(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:
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [K, S] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = 0
    for x in range(0, K + 1):
        for y in range(0, K + 1):
            tmp_z = S - x - y
            if tmp_z <= K and tmp_z >= 0:
                pattern += 1

    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

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

print(count)

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

Submission status: Accepted

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

Submission status: Accepted

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

ar = itertools.product(range(K+1), repeat=2)

ans = 0
for a,b in ar:
  if S - a-b <= K and a+b <= S: 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 s - k <= i + j <= s:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def main():
    K, S = LI()

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

    print(counter)

main()

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:
import itertools

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

Submission status: Accepted

Solution code:
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

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

print(count)

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = [int(x) for x in input().split()]
print(sum([1 if s - k <= i + j <= s else 0 for i in range(0, k + 1) for j in range(0, k + 1)]))
# print(*data, sep='\n')

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

Submission status: Accepted

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

ans = 0
for x in range(min(K+1, S+1)):
    if K < (S - x) //2:
        ans +=  0
    elif K < (S - x):
        ans += K * 2 - (S - x) + 1
    else:
        ans += (S - x) + 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

x =0

for i in range(min(k+1,s+1)):
    x += max(0, min(s-i,k)+1 - max(0,s-i-k) )

print(x)

Submission status: Accepted

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

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 s-i-j<=k and s-i-j>=0:
            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:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

    
    print(cnt)


solve()

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 S-i-j <= K and S-i-j >= 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
            
print(count)

Submission status: Accepted

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

count = 0
for i in range(K+1):
    X = i
    for j in range(K+1):
        Y = j
        Z = S - i - j
        if Z >= 0 and Z <=K:
            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:
# 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮する

k, s = map(int,input().split())
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  if 0 <= s-x and s-x <= k: #(y,z) = (0, s-x), ... ,(s-x, 0)
    count += s-x+1
  elif k <= s-x and s-x <= 2*k: #(y,z) = (s-x-k, k), ... ,(k, s-x-k)
    count += 2*k-(s-x)+1
print(count)

Submission status: Accepted

Solution code:
# 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮しない

k, s = map(int,input().split())
count = 0
for x in range(0, k+1):
  if 0 <= s-x and s-x <= k: #(y,z) = (0, s-x), ... ,(s-x, 0)
    count += s-x+1
  elif k <= s-x and s-x <= 2*k: #(y,z) = (s-x-k, k), ... ,(k, s-x-k)
    count += 2*k-(s-x)+1
print(count)

Submission status: Accepted

Solution code:
# 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する

k, s = map(int,input().split())
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  ymin = (s - k - x) if (s - k - x) > 0 else 0
  ymax = k if k < s - x else s - x
  for y in range(ymin, ymax+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)

Submission status: Accepted

Solution code:
# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 0
k, s = map(int,input().split())
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y and s-x-y <= 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):
    if x > S:
        break
    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())

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

print(count)

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())
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 = (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:
m,n,l = 1,1,1

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

rangeX,rangeY,rangeZ = K,K,K

W=S

cnt = 0
for i in range(min(W//m+1,rangeX+1)):
    for j in range( min((W-m*i)//n+1,rangeY+1)):
        if  (lambda d,m: m==0 and d<=rangeZ)(*divmod((W-m*i-n*j),l)):
            cnt +=1
print(cnt)

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

ret = 0

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

print(ret)

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:
answer=0
i = list(map(int, input().split()))
f=i[0]+1
for a in range(f):
    for b in range(f):
        sum=a+b
        if 0 <= i[1]-sum <= i[0] :
                answer+=1
print(answer)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - Sum of Three Integers
https://atcoder.jp/contests/abc051/tasks/abc051_b

"""
import sys


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


def main(args):
    K, S = map(int, input().split())
    ans = solve(K, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

print(ans)

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:
input_data = input().split()

k=int(input_data[0])
s=int(input_data[1])
count=0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    if s-i > 2*k or s-i < 0:
        continue
    temp = s-i
    for j in range(k+1):
        if temp-j > k or temp - j < 0:
            continue
        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(s+1-i):
        if j>k:break
        z=s-(i+j)
        if 0<=z<=k :cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

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

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

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

Submission status: Accepted

Solution code:
K, S = [int(i) for i in 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:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
total = 0
for i in range(m+1):
    for k in range(m+1):
        if n-i-k <= m and n-i-k >= 0: total+=1
print(total)

Submission status: Accepted

Solution code:
m,n= (int(i) for i in input().split()) 
total = 0
for i in range(m+1):
    for k in range(m+1):
        if n-i-k <= m and n-i-k >= 0: total+=1
print(total)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    m=0
    for i in range(K+1):
        s=S-i
        if s<=K:
            m+=s+1
            
        else:
            c=s-K
            a=s-2*c
            m+=a+1         
    print(m)

else:
    s=3*K-S
    print((s+2)*(s+1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

print(cnt)

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

Submission status: Accepted

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

Submission status: Accepted

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