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:
if __name__ == '__main__':
    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 = s - i - j
            if i + j > s:
                break
            elif 0 <= z and 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:
K,S=map(int,input().split())
cnt=0
for i in range(min(K,S)+1):
    for j in range(min(K,S-i)+1):
        if S-i-j <= 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:
# -*- coding: utf-8 -*-

def solve(K, S):
    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__': 
    K, S = map(int, input().split())
    
    solve(K, S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def main():
    k, s = tuple(input_ints())

    def solve2(ss):
        if ss > 2 * k:
            return 0
        elif ss > k:
            return 2 * k - ss + 1
        else:
            return ss + 1

    print(sum([solve2(ss) for ss in range(max(0, s - k), s + 1)]))


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC951B/Sum_of_Three_Integers

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    ans = 0
    ## TLE
    # for i in range(K+1):
    #     for j in range(K+1):
    #         for r in range(K+1):
    #             if(i+j+r == S):
    #                 ans += 1

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

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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())
d = 0
for a in range(0,k+1):
    for b in range(0,k+1):
        if 0 <= s-a-b <= k:
                d += 1
print(d)

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(lambda: 0)
K,S=[int(a) for a in input().split(" ")]
for x in range(0,K+1):
    for y in range(0,K+1):
        dic[S-x-y] += 1
ans = 0
for z in range(0, K+1):
    ans += dic[z]
print(ans)

Submission status: Accepted

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

# print(K,S)
cnt = 0
for i in range(K+1):
  for j in range(K+1):
    if i+j <= S and i+j+K >= S:
      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):
        # **3の全探索は間に合わないため、S-a-bの値が0からKの間である組を数えれば良い。
        # for c in range(K+1):
        #     if a+b+c == S:
        c = S - a - b
        if 0<=c<=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())
count = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 > z or z > k:
            continue
        else:
            count += 1

print(count)

Submission status: Accepted

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

s = 0

X = max(0,S-2*K)
while X <= min(K,S):
    s += min(K,S-X) - max(0,S-X-K) + 1
    X += 1

print(s)

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 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:
def f(K, S):
    #ここに処理を書いてください
    res = 0
    for i in range(K+1):
      for j in range(K+1):
        if i + j <= S and S-i-j <= K:
          res += 1
    return res

inx = list(map(int, input().split()))
print(f(inx[0], inx[1]))

Submission status: Accepted

Solution code:
# 2019/05/07
# AtCoder Beginner Contest 051 - B

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

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

print(cnt)

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())  
print(sum([min(2*a+i-b+1,b-i+1) for i in range(a+1) if min(2*a+i-b+1,b-i+1) > 0]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC51 B
k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
else:
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            remainder = s - i - j
            if 0 <= remainder <= 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):
        Z = S - j -i
        if 0 <= Z <= K:
            count += 1
print(count)

Submission status: Accepted

Solution code:
# ABC051B - Sum of Three Integers
k, s = list(map(int, input().rstrip().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 = list(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:
K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if K >= S-X-Y >= 0:
            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)

# 全探索の3重ループだとTLE

# x,yを決めると x+y+z=S となるような z が一意に定まる
# そのようなzが 問題文の条件(0<=z<=K)であり得るか を考える

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = input().strip().split()
K, S = [int(K), int(S)]

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

print(A)

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:
def main():
	K, S = map(int, input().split())
	ans = 0
	for X in range(K+1):
		for Y in range(min(K+1, S-X+1)):
			if S-X-Y <= K:
				ans += 1
	print(ans)


if __name__ == '__main__':
	main()

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

k += 1

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

print(ans)

Submission status: Accepted

Solution code:


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

    return k, s


def check_z(z, k):
    if z <= k:
        return z
    else:
        return -1


def check_yz(y, k):
    count = 0
    tempy = min(y, k)
    while tempy >= 0:
        if check_z(y - tempy, k) != -1:
            count += 1
        tempy -= 1
    return count

def check_xyz(x, k):
    count = 0
    tempx = min(x, k)
    while tempx >= 0:
        yc = check_yz(x - tempx, k)
        if yc != -1:
            count += yc
        tempx -= 1
    return count



def submit():
    k, s = read_input()

    print(check_xyz(s, k))

if __name__ == '__main__':
    submit()

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

Submission status: Accepted

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

cnt = 0

if S <= 0:
  cnt += 1
else:

  if K >= S:
      cnt+=3

  def cnt2(k, s):
      if 2 * k >= s:
          if s - 1 <= k:
              return s-1
          else:
              return k-(s-k)+1
      else:
          return 0

  cnt+=3*cnt2(K, S)

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

print(cnt)

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 S-i-j >= 0 and S-i-j <= K:
      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 k>=s-x-y>=0:
            sum=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:
        continue
    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())

res = 0

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

print(res)

Submission status: 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):
        a = S-x-y
        if a <= K and a>= 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:
sk = list(map(int, input().split()))

num = 0
for x in range(sk[0] + 1):
	for y in range(sk[0] + 1):
		if x + y <= sk[1] and sk[1] - x - y <= sk[0]:
			num += 1
        

print(num)

Submission status: Accepted

Solution code:
import numpy as np


A = list(map(int, input().split()))
K = A[0]
S = A[1]
counter = 0
for i in range(K+1):
	for j in range(K+1):
		sa = S - (i + j)
		if 0 <= sa and sa <= K:
			counter = counter + 1
			
			
print(counter)
print("\n")

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) <= 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 s-i-j >= 0 and s-i-j <= 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):
        if -1<s-x-y<k+1:
            count += 1
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)):
        Z = S - X - Y
        if 0 <= Z <= K:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
print(sum(map(lambda x: K+1-abs(K-S+x) if 0<=S-x<=K*2 else 0 , [i for i in range(K+1)])))

Submission status: Accepted

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

Xs = [i for i in range(K+1)]

count = 0
for x in Xs:
    yz = S - x
    if 0 <= yz  <= K*2:
        count += K+1-abs(K-yz)
    
print(count)

Submission status: Accepted

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

Xs = [i for i in range(K+1)]
Ys = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        if 0<= 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(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())

# カウンター
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()))
ct = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            ct += 1
print(ct)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
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
input=sys.stdin.readline
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:
# coding: utf-8
# Your code here!
l = list(map(int,input().split()))	
K = l[0]
S = l[1]
count = 0
for i in range(K + 1):
    X = i
    if X > S:
        break
    for j in range(K + 1):
        Y = j
        if X + Y > S:
            break
        else:
            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(S + 1) :
    if x > K :
        continue
    for y in range(S - x + 1) :
        if y > K :
            continue
        z = S - x - y
        if z > K:
            continue
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split(' '))
count = 0
for x in range(K+1):
    t1 = S - x
    for y in range(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())
x, y, z = 0, 0, 0
c = 0
for i in range(K + 1):
    if S - i > 2 * K:
        continue
    for j in range(K + 1):
        if i + j > S:
            break
        elif S - i - j > K:
            continue
        c += 1
print(c)

Submission status: Accepted

Solution code:
from itertools import product

n, s = map(int, (input().split()))
ans = 0

for x,y in product(range(n+1), range(n+1)):
    if 0 <= s - x - y <= n:
        ans += 1
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

true=0

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

print(true)

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    ks = input()
    k, s = [int(i) for i in ks.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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
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 = [int(item) for item in input().split()]
ans = 0
for x in range(0,k+1):
    for y in range(0,k+1):
        if x + y <= s and s - (x+y) <= k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
#AtCoder Beginner Contest 051 B - Sum of Three Integers
k, s = map(int, input().split())
cnt = 0
for l in range(k+1):
    for m in range(k+1):
        if l+m<=s and s-l-m<=k:
            cnt += 1
print(cnt)

Submission status: Accepted

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

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

def main():
    input = sys.stdin.readline
    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

    return ans


if __name__ == '__main__':
    print(main())

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

print(ans)

Submission status: Accepted

Solution code:
K,S=input().split()
K=int(K)
S=int(S)
ans=0
for l in range(K+1):
    for m in range(K+1):
        if l+m<=S and l+m+K>=S:
            ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            # aは増える一方なので
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

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

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

print(counter)

Submission status: Accepted

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

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

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

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) :
    tmp = S - i - j 
    if 0 <= tmp and tmp <= 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):
        x_y = x + y
        if x_y > S:
            break
        if 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 ((s-x-y) <= k) & ((s-x-y) >= 0):
            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 - (x + y) <= K) and (0 <= S - (x + y)):
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
#ABC051 B 
#入力
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:
import itertools
    
K, S = map(int,input().split())

count = 0
for x,y in itertools.product(range(0,K + 1),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())
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 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(0,k+1):
    for y in range(0,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())

c=0

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

print(count)

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
K=A[0]
S=A[1]
count=0
for a in range(K+1):
    for b in range(K+1):
        c=S-a-b
        if 0<=c<=K:
            count+=1
        else:
            continue
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(i+j<=s and 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 (x + y <= s and s - (x + y) <= k):
      ans += 1


print(ans)

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())
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:
#B問題
K,S=map(int,input().split())
count=0
for y in range(K+1):
    x=0
    for x in range(K+1):
        z=S-(x+y)
        if z <= K and z >= 0:
            count+=1
print(count)