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 = [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 i in range(max(0, S-2*K), min(K, S)+1):
    upper = min(K, S-i)
    lower = S-i - upper
    ans += upper - lower + 1

print(ans)

Submission status: Accepted

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

def solve_2(num):
    if num > k:
        return k - (num-k) + 1
    else:
        return num + 1
ans = 0
first = 0
if s > 2*k:
    first = s -2*k
while first <= k:
    if s - first < 0:
        break
    ans += solve_2(s - first)
    first += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
count=0
for X in range(K,-1,-1):
  if S-X>2*K:
    break    
  for Y in range(K,-1,-1):
    if 0<=S-(X+Y)<=K:
       count+=1
    elif 0>S-(X+Y):
       continue
    else:    
       break
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 = 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())
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:
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 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())
c=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,s = map(int, input().split())
ans = 0
for p in range(min(k+1,s+1)):
    for q in range(p, s+1):
        if q-p > k or s - q > k:
            continue
        else:
            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:
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())

    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
            else:
                break

    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
                    # ans.append([x,y,z])
            else:
                break
    # sys.stdout.write("%d" % len(ans))
    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0

for z in range(K, -1, -1):
    for y in range(K, -1, -1):
        x = S - z - y
        if z >= y and y >= x and x >= 0:
            if x == y == z:
                count += 1
            elif (x == y and y != z) or (y == z and z != x):
                count += 3
            else:
                count += 6

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,s = map(int,input().split())
counter = 0
for x in range(k+1):
    if s-x >= k:
        for y in range(k+1):
            z = s-x-y
            if 0<=z<=k:
                counter += 1
    else:
        for y in range((s-x)+1):
            z = s-x-y
            if 0<=z<=k:
                counter += 1
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 0 <= s-i-j <= k:
            count = count + 1

print(count)

Submission status: Accepted

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

t = 0

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

print(t)

Submission status: Accepted

Solution code:
from itertools import  product
K, S = map(int, input().split())
ans = 0
for x,y in product(range(K+1),repeat=2):
    z = S - x - y
    if 0 <= z <= K and x + y + z == S:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#51b
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:
#-*-coding:utf-8-*-

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    K, S = map(int, input().strip().split())
    result = 0
    for z in range(0, K+1):
        target = S - z
        k = 0
        while k <= K:
            if 0 <= target - k <= K:
                result += 1
                k += 1
            else:
                k += 1
                continue
    print(result)

if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
# vim: set fileencoding=utf-8 :
k, s = map(int, raw_input().split())
patterns = []
ct = 0

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

print(ct)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
count = 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:
            count += 1
print(count)

Submission status: Accepted

Solution code:
def main():
    K, S = map(int, raw_input().split())

    count = 0

    # X
    for i in range(K+1):
        # Y
        for j in range(K+1):
            if i + j > S:
                break
            if S-i-j > K:
                continue
            count += 1

    print count

main()

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):
            if s-(i+j) >= 0 and s-(i+j) <= 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(min(K, S - x) + 1):
        z = S - (x + y)
        if 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())

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

Submission status: Accepted

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

Submission status: Accepted

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

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().split()))
re = 0
for x in range(min(S+1, K+1)):
    for y in range(min(S+1-x, K+1)):
        if S - x - y <= K:
            re += 1
print(re)

Submission status: Accepted

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

ans = 0

for i in range(min([S + 1, K + 1])):
    for j in range(min([S -i + 1, K + 1])):
        if S - i - j <= K:
            ans += 1

print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

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

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

print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k, s = [int(i) for i in 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())

p = 0
for X in range(max(0, S - 2*K), min(K, S) +1):
  Y = S - X
  p += min(Y, K) - max(Y - K, 0) + 1
  
print(p)

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(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 = list(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:
def main():
    a = input().split(" ")
    K = int(a[0])
    S = int(a[1])
    X = Y = Z = count = 0

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

if __name__ == '__main__':
    main()

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

k, s = map(int, input().split())
ans = 0
for a in range(k+1):
    for b in range(k+1):
        if 0 <= s-a-b <= 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 <= K:
            cnt += 1
                
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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):
        # zは全部回さないで、Sを満たすようなものだけ用意する
        z = S - x - y
        # 候補となるzがKの範囲内であれば有効
        if 0 <= z <= K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = input().split()
N = []
for i in n :
  N.append(int(i))
t = 0
for i in range(0,N[0]+1) :
  for j in range(0,N[0]+1):
    z = N[1] -i-j
    if 0 <= z <=N[0] :
      t += 1
print(t)

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 i + j > s:
      break

    if s - (i + j) > k:
      continue

    count+=1

print(count)

Submission status: Accepted

Solution code:
k, s = [int(_) for _ in input().split(' ')]
answer = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            answer += 1
print(answer)

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

Submission status: Accepted

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

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 0 <= k <= K:
            count += 1
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):
        Z = S-X-Y
        if Z<0:
            continue
        elif K<Z:
            continue
        elif S == X+Y+Z:
            result += 1
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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) and (S-X-Y)<=K:
            res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
    n = S - i
    if i <= S and n <= K * 2:
        a = (n + 1) - max(0, n - K) * 2
        ans += a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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 k >= s - (i + j) >= 0:
            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())
ans = 0
for x in range(K + 1):
    remainder = S - x
    if remainder < 0:
        break
    elif remainder > K * 2:
        continue
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)

Submission status: Accepted

Solution code:
k,s=[int(i) for i in input().split()]
ans=0
for a in range(k+1):
  for b in range(a+1):
    if 0<=s-a-b<=b:
      l=len(set([a,b,s-a-b]))
      if l==1:
        ans+=1
      elif l==2:
        ans+=3
      else:
        ans+=6
print(ans)

Submission status: Accepted

Solution code:
def getinputdata():

    array_result = []
    
    data = input()
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#maxvalue
k = int(arr_data[0][0])

#sumvalue
s = int(arr_data[0][1])

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

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

Submission status: Accepted

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

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

K, S = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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 = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if S <= x + y + K and x + y <= S:
      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):
    if x + y <= S and x + y + K >= S:
      count += 1
print(count)

Submission status: Accepted

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

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

    print(comb)


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

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:
# coding: utf-8
count = 0
K, S = map(int, input().split())

for x in range(K + 1):
    for y in range(K + 1):
        # print('(x,y,z) = ({},{},?)'.format(x, y))
        if -K <= (x + y - S) <= 0:
            count += 1
print(count)

Submission status: Accepted

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

print cnt

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

Submission status: Accepted

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

count = 0
for x in range(k+1):
    for y in range(k+1):
        if x+y+k >= s and x+y <= s:
            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())
S1 = 0
counter = 0
for X in range(min(K,S)+1):
    S1 = S - X
    for Y in range(min(K,S1)+1):
        Z = S - X - Y
        if (Z >= 0 and Z <= K):
            counter += 1
            #print(X,Y,Z)
print(counter)

Submission status: Accepted

Solution code:
k,s = map(int, input().split())
ans = 0
for x in range(k+1):
    if x>s:
        break
    for y in range(k+1):
        if x+y<=s and s-(x+y)<=k:
            ans += 1
        if x+y>s:
            break
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:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    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 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:
data = list(map(int,input().split()))
cou = 0
for i in range(data[0] + 1):
  for j in range(data[0] + 1):
    k = data[1] - i - j
    if 0 <= k and k <= data[0]:
      cou += 1
print(cou)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())
count = 0
for y in range(k+1):
    for x 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())
O=0
for X in range(K+1):
  for Y in range(K+1):
    Z=S-X-Y
    if 0<=Z<=K:
      O+=1
print(O)