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:


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

def f(s,k):
	ans = 0
	for c in range(k+1): 
		ans += g(s - c,k)
	return ans
k,s = map(int, raw_input().split())
print f(s,k)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):    
        if 0 <= s-i-j <= k and j <= s-i-j:
            if i == j == s-i-j:
                ans1 +=1
            elif i == s-i-j or i == j or j == s-i-j:
                ans2 += 1
            else:
                ans3 += 1
                    

print(ans1+ans2*3+ans3*6)
#print(ans1, ans2, ans3)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K,S = (int(T) for T in input().split())
Count = 0
for TX in range(0,K+1):
    for TY in range(0,K+1):
        if 0<=(S-TX-TY)<=K:
            Count += 1
print(Count)

Submission status: Accepted

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

if k > s:
    k = s

ans = 0
for x in range(k+1):
    rem = s - x
    if rem > 2 * k:
        continue
    elif rem > k:
        ans += 2 * k - rem + 1
    else:
        ans += rem + 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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 = SJIS
k, s = map(int, input().split())
if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    ans = ((k + 1) * (k + 2) / 2) - ((2 * k - s) * ((2 * k - s) + 1) / 2) + (t * (2 * k - ((2 * k - s) - 1)) / 2)
elif s <= 3 * k:
    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2
print(int(ans))

Submission status: Accepted

Solution code:
# coding = SJIS

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:
# coding = SJIS

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

if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    a = (k + 1) * (k + 2) / 2
    b = t * (t + 1) / 2
    c = t * (2 * k - (t - 1)) / 2
    ans = a - b + c
elif s <= 3 * k:
    t = 3 * k - s + 1
    ans = t * (t + 1) / 2
print(int(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):
        c = s - (i + j)
        if 0 <= c <= k and s == i + j + c:
            cnt += 1

print(cnt)

Submission status: Accepted

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

minz = max(0, s-2*k)
maxz = min(s, k)

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

ans = 0
for i in range(minz, maxz+1):
    ans += f(s-i, k)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
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())
ii = 0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if k <= K and 0 <= k:
            ii+=1
print(ii)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# B - Sum of Three Integers
def main():
    k, s = map(int, input().split())
    cnt = 0

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



if __name__ ==  "__main__":
    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 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):
        z = S - x - y
        if 0 <= z <= K:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# from numba import njit

# input = stdin.readline

# @njit
def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      l = s - i - j
      if 0 <= l <= k:
        res += 1

  return res



def main():
  K,S = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(K,S))
  return

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

Submission status: Accepted

Solution code:
k,s = map (int ,input ().split ())
x = 0
y = 0
p = 0
while x <= k:
  while y <= k:
    if x+y > s:
      break
    z = s-(x+y)
    if 0 <= z <= k:
      p += 1
    y += 1
  x += 1
  y = 0
print (p)

Submission status: Accepted

Solution code:
k, s = map(int,input().split())
 
ans = 0
for i in range(k+1):
    yz = s - i
    for j in range(k+1):
        if k >= yz - 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):  #xは 0~kまで  x=0,1,2,.....k
  for y in range(x,k+1): #yはx~k+1まで, 
    z = s-(x+y)  #zはxとyできまる, このときxyzの組み合わせが確定して評価する.
    if z>k or z<y:
      continue
    if x == y and y == z: #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:
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:
#
# abc051 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
    # unittest.main()
    resolve()

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:
ans=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:
      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):
        z=s-x-y
        if z<0:
            break
        ans+=1 if 0<=z<=k else 0

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

Submission status: Accepted

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

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

  
if __name__ == "__main__":
  	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
ans=0
for x in range(a+1):
    #y+z=b-x
    minn=min(a,b-x)
    for y in range(minn+1):
        z=b-x-y
        if 0<=z and z<=a:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

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

print(n)

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

Submission status: Accepted

Solution code:
# abc051
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:
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 x in range(k + 1):
  for y in range(min(k + 1, s + 1 - x)):
    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())
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())

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:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

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


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

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = list(map(lambda n: int(n), input().split(" ")))
cnt = 0
# X + Y + Z = S, 0 <= X, Y, Z <= K #
for x in range(K + 1):
  if S - x > 2 * K:
    continue
  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())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
K, S = map(int, input().split())
results = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            results += 1
print(results)

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(K >= S-(i+j) >= 0):
            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):
        if 0 <= s-x-y <= k:
            cnt+=1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
splited = input().split(" ")

k = int(splited[0])
s = int(splited[1])

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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

Submission status: Accepted

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

if __name__ == "__main__":
    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):
    if S-(i+j) <= K and S-(i+j) >= 0:
      cnt += 1
 
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

l = max(S-K*2, 0)
h = min(K, S)

res = 0
for i in range(l, h+1):
    x = S-i
    ll = max(x-K, 0)
    hh = min(h, x)
    res += hh-ll+1

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
cnt = 0
for i in range(x[0]+1):
  for j in range(x[0]+1):
    p = i+j
    if (p <= x[1]) and (x[0]+p) >= x[1]:
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
R=range(0,K+1)

W=0
for X in R:
    for Y in R:
        Z=S-(X+Y)
        W+=(0<=Z<=K)
print(W)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k:
                break
            
            if n >= 0:
                ans += 1

            m -= 1
        l -= 1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  3 13:34:09 2020

@author: ito
"""


# -*- coding: utf-8 -*-

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

ans = 0

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

Submission status: Accepted

Solution code:
import math

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

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

        if 0 <= 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 0<=z<=K:
            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 i + j <= S and K + i + j >= S:
            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):
        dum = (s - (i + j))
        if dum < 0:
            continue
        if dum <= k:
            ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k,s=input().split()
k=int(k)
s=int(s)
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:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Accepted

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

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

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

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):
        #.
        des_v = s - x - y

        #.
        if des_v >= 0 and des_v <= k:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[4]:


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


# In[6]:


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


# In[ ]:

Submission status: Accepted

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

print(res)

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

Submission status: Accepted

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

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