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: Time Limit Exceeded

Solution code:
K,S = [int(i) for i in input().split()]
count = 0
for z in range(0,K+1):
	for y in range(0,z+1):
		for x in range(0,y+1):
			if x + y + z == S:
				if  x == y and y == z:
					count += 1
				elif (x-y)*(y-z)*(z-x) == 0:
					count += 3
				else:
					count += 6
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = [int(i) for i in input().split()]
count = 0
for z in range(0,K+1):
	for y in range(0,z+1):
		for x in range(0,y+1):
			if x > y:
				continue
			elif y > z:
				continue
			elif x > z:
				continue
			else:
				if x + y + z == S:
					if  x == y and y == z:
						count += 1
					elif (x-y)*(y-z)*(z-x) == 0:
						count += 3
					else:
						count += 6
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = [int(i) for i in input().split()]
count = 0
for x in range(0,K+1):
	for y in range(0,K+1):
		for z in range(0,K+1):
			if x > y:
				continue
			elif y > z:
				continue
			elif x > z:
				continue
			else:
				if x + y + z == S:
					if  x == y and y == z:
						count += 1
					elif (x-y)*(y-z)*(z-x) == 0:
						count += 3
					else:
						count += 6

						
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1
                    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
import bisect

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

ans = 0
# for v in combinations_with_replacement(range(k + 1), 3):
#     if sum(v) == s:
#         leng = len(set(v))
#         if leng == 1 or leng == 3:
#             ans += 1
#         else:
#             ans += 3

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1

            # leng = len(set([v, x, hoge]))
            # if leng == 1 or leng == 3:
            #     ans += 1
            # else:
            #     ans += 3

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

def main():
    cnt = 0
    for x in range(K+1):
        if x <= S:
            for y in range(K+1):
                if x+y <= S:
                    for z in range(K+1):
                        if x+y+z <= S: 
                            if x+y+z == S:
                                cnt += 1
                                break
                            else:
                                pass
                        else:
                            break
                else:
                    break
        else:
            break
    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

def main():
    cnt = 0
    for x in range(K+1):
        for y in range(K+1): 
            for z in range(K+1):
                if x+y+z == S:
                    cnt += 1
                    break
                else:
                    pass
            
    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

def main():
    cnt = 0
    for x in range(K+1):
        for y in range(K+1): 
            for z in range(K+1):
                if x+y+z == S:
                    cnt += 1
                else:
                    pass
            
    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(K: int, S: int):
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x + y + z == S:
                    cnt += 1
    print(cnt)
    return


# Generated by 1.1.6 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: Time Limit Exceeded

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

count = 0
for i in range(k+1):
    if s-i > k:
        rang = k
    else:
        rang = s-i
    for j in range(rang+1):
        if s-i-j < 0:
            continue
        elif s-i-j > k:
            rangg = k
        else:
            rang = s-i-j
        for h in range(rang+1):
            if i+j+h == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(k+1):
    for j in range(k+1):
        for h in range(k+1):
            if i+j+h == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
count=0
ans=0
total=0
for a in range(K+1):
    ans=S-a
    for b in range(K+1):
        ans1=ans-b
        if ans1<0:
            break
        for c in range(K+1):
            ans2=ans1-c
            if ans2<0:
                break
            if a+b+c == S:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
count=0
for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            total = a+b+c
            if total == S:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        for Y in range(S + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools

a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [0 for x,y,z in itertools.product(l,l,l)if (x+y+z) == b]
#m = [0 for x in l for y in l for z in l if (x+y+z) == b]
print(len(m))

Submission status: Time Limit Exceeded

Solution code:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l)]
for z in l:
  for f in m:
    if f+z == b:
      count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b=(int(x) for x in input().split())
count = 0
l = range(a+1)
m = [0 for x in l for y in l for z in l if (x+y+z) == b]

print(len(m))

Submission status: Time Limit Exceeded

Solution code:
a,b=(int(x) for x in input().split())
count = 0
l = range(a+1)

for x in l:
  for y in l:
    for z in l:
      if (x+y+z) == b:
        count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b=(int(x) for x in input().split())
count = 0
for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      if (x+y+z) == b:
        count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
c = 0
for i_x in range(k+1):
    for i_y in range(k+1):
        for i_z in range(k+1):
            if i_x + i_y + i_z == s:
                c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func, iter_)


def parg(**kwargs):
    text = ''
    for item in kwargs.items():
        if text:
            text += ',\t'
        text += '{}: {}'.format(*item)
    print(text)


K, S = spline()
count = 0
k = K + 1
for x in range(k):
    if x + K * 2 < S:
        continue
    for y in range(k):
        if x + y + K < S:
            continue
        for z in range(k):
            if x + y + z == S:
                count += 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func, iter_)


def parg(**kwargs):
    text = ''
    for item in kwargs.items():
        if text:
            text += ',\t'
        text += '{}: {}'.format(*item)
    print(text)


K, S = spline()
count = 0
K += 1
for x in range(K):
    for y in range(K):
        for z in range(K):
            tmp = x + y + z
            if tmp == S:
                count += 1
                # parg(x=x, y=y, z=z, sum=tmp)
                break

print(count)

Submission status: Time Limit Exceeded

Solution code:
def main():

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

    ans = 0

    for p in range(s // 3 + 1):
        for q in range(p, min(k+1, s-p+1)):
            for r in range(q, min(k+1, s-p-q+1)):
                if p + q + r == s:
                    n = len({p, q, r})
                    if n == 3:
                        ans += 6
                    elif n == 2:
                        ans += 3
                    else:
                        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():

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

    ans = 0

    for p in range(min(k+1, s+1)):
        for q in range(min(k+1, s-p+1)):
            for r in range(min(k+1, s-p+1)):
                if p + q + r == s:
                    ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():

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

    ans = 0

    for p in range(k+1):
        for q in range(k+1):
            for r in range(k+1):
                if p + q + r == s:
                    ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():

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

    ans = 0

    for p in range(k+1):
        if p > s:
            continue
        for q in range(k+1):
            if p + q > s:
                continue
            for r in range(k+1):
                if p + q + r == s:
                    ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0

for p in range(k+1):
    for q in range(k+1):
        for r in range(k+1):
            if p + q + r == s:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s  = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(i, k + 1):
        for l in range(j, k + 1):
            if i + j + l == s:
                if i == j == l:
                    ans += 1
                elif i == j or j == l:
                    ans += 3
                elif i != j != l:
                    ans += 6
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
ans = 0
 
for x in range(k+1):
  for y in range(x,k+1):
    for z in range(y,k+1):
      if x + y + z == s:
        if x == y == z:
          ans += 1
        elif x == y or y == z:
          ans += 3
        else:
          ans += 6
          
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 0

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

cnt = 0
for i in list(itertools.product(range(K+1),repeat = 3)):
    if sum(i) == S:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

l = []
for i in range(k+1):
    for j in range(k+1):
        l.append([i,j])
#print(len(l))

q = 0
for r in range(k+1):
    for p in range(len(l)):
        if r + sum(l[p]) == s:
                q += 1

#print(k,s,l)
print(q)

Submission status: Time Limit Exceeded

Solution code:
I = list(map(int, input().split()))
K, S = I[0], I[1]

count = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k == S:
        count += 1
        
print(count)

Submission status: Time Limit Exceeded

Solution code:
#051_B
k,s=map(int,input().split())
print(sum([x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1)]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def is_same(x, y, z, s):
    return x+y+z == s


k, s = [int(e) for e in input().split()]
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if is_same(x,y,z,s):
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

print(counter)

Submission status: Time Limit Exceeded

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

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      total = x + y + z
      if total == S:
        counter += 1

print(counter)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
res = 0
for X in range(0, K+1):
    for Y in range(0, K+1):
        for Z in range(0, K+1):
            total = X + Y + Z
            if total == S:
                res += 1
print(res)

Submission status: Time Limit Exceeded

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

for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):

            if i + j + m == s:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

count = 0

for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if i + j + l == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
# ABC 051 B Sum of Three Integers

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

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

print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def solve():
    K, S = map(int, input().split())
    
    c = 0
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x+y+z == S:
                    c += 1
    return c

print(solve())

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
k, s = [int(i) for i in input().split()]
print([a + b + c == s for a in range(k + 1) for b in range(k + 1) for c in range(k + 1)].count(True))

Submission status: Time Limit Exceeded

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

print([a + b + c == s for a in range(k + 1) for b in range(k + 1) for c in range(k + 1)].count(True))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)

count = 0
for i, j, k in itertools.product(X, Y, Z):
  if i + j + k == S:
    count += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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):
        if a + b > s:
            break
        for c in range(k+1):
            if a + b + c == s:
                ans += 1
            elif a + b + c > s:
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0
for a in range(k+1):
    for b in range(k+1):
        if a + b > s:
            break
        for c in range(k+1):
            if a + b + c == s:
                ans += 1
            elif a + b + c > s:
                break
print(ans)

Submission status: Time Limit Exceeded

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

count = (K + 1) ** 3
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z != S:
                count -= 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():
    k, s = map(int, input().split())
    vals = [x + y + z for x in range(k+1) for y in range(k+1) for z in range(k+1)]
    print(len([v for v in vals if v == s]))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    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:
                break
            for z in range(k+1):
                if x + y + z > s:
                    break
                if x + y + z == s:
                    ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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:
            continue
        for Z in range(K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

for x in range(int(k)+1):
  for y in range(int(k)+1):
    for z in range(int(k)+1):
      a = x + y + z
      if int(s) == a:
        count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

l = set()
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s and s-i-j >= 0:
            l.add((i, j, s-i-j))
        else:
            continue

print(len(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            if x + y + z == s:
                if x == y == z:
                    count += 1
                elif x != y and y != z and z != x:
                    count += 6
                else:
                    count += 3
print(count)

Submission status: Time Limit Exceeded

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
for X in range(K+1):
  if X > S and 3*K < S:
    break
  for Y in range(K+1):
    add_xy = X + Y
    if S < add_xy and add_xy < (2/3) * S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1

      
print(count)

Submission status: Time Limit Exceeded

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
total = 0
for X in range(K+1):
  if X > S:
    break
  for Y in range(K+1):
    sub = X + Y
    if S < sub and sub < (2/3) * S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1
      
print(count)

Submission status: Time Limit Exceeded

Solution code:
[K, S] = list(map(int, input().split()))
count = 0
total = 0
for X in range(K+1):
  if X > S:
    break
  for Y in range(K+1):
    sub = X + Y
    if sub > S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1
      

            
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math 
[K, S] = list(map(int, input().split()))
count = 0
total = 0
for X in range(K+1):
  if X > S:
    break
  for Y in range(K+1):
    sub = X + Y
    if sub > S:
      break
    for Z in range(K+1):
      total = X + Y + Z 
      if total == S:
        count += 1
      if total > S:
        break
      if total < S/2:
        Z += math.floor(S/2)
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
try:
    K, S = map(int, input().split())
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x+y+z==S:
                    cnt += 1
    print(cnt)
except EOFError:
    pass

Submission status: Time Limit Exceeded

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

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l == s:
                c += 1
print(c)