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

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


i = 0

for n1 in range(k +1):
    if n1 <= s:
        for n2 in range(k+1):
            if n2 <= s and (n1 + n2) <= s:
                for n3 in range(k+1):
                    if n1 + n2 + n3 == s:
                        i = i + 1
                        break
           
print(i,end="")

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import os

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


i = 0

for n1 in range(k +1):
    if n1 <= s:
        for n2 in range(k+1):
            if n2 <= s and (n1 + n2) <= s:
                for n3 in range(k+1):
                    if n1 + n2 + n3 == s:
                        i = i + 1
           
print(i,end="")

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import os

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


i = 0

for n1 in range(k +1):
    if n1 <= s:
        for n2 in range(k+1):
            if n2 <= s:
                for n3 in range(k+1):
                    #print(' %s %s %s' % (n1,n2,n3))
                    if n1 + n2 + n3 == s:
                        i = i + 1
           
print(i,end="")

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import os

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


i = 0

for n1 in range(k +1):
    if n1 == s:
        i=i+1
    else:
        for n2 in range(k+1):
            if n1 + n2 <= s:
                #print(n1+n2)
                for n3 in range(k+1):
                    #print(' %s %s %s' % (n1,n2,n3))
                    if n1 + n2 + n3 == s:
                        i = i + 1
print(i,end="")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: cp932 -*-


import math
import sys
import os

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


i = 0

for n1 in range(k +1):
    for n2 in range(k+1):
        if n1 + n2 <= s:
            #print(n1+n2)
            for n3 in range(k+1):
                #print(' %s %s %s' % (n1,n2,n3))
                if n1 + n2 + n3 == s:
                    i = i + 1
print(i,end="")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: cp932 -*-


import math
import sys
import os






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


i = 0

for n1 in range(k +1):
    for n2 in range(k+1):
        for n3 in range(k+1):            
            if n1 + n2 + n3 == s:
                i = i + 1
print(i,end="")

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

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

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):
			if x+y+z==s:
				counter+=1

print(counter)

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

Submission status: Time Limit Exceeded

Solution code:
K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        for Z in range(int(K_S[0]) + 1):
            if (X + Y + Z) == int(K_S[1]):
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
list2K = [i for i in range(K**2)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(K: int, S: int):
    answer=0
    for i in range(K+1):
        for j in range(K+1):
            for k in range(K+1):
                if i+j+k == S:
                    answer+=1
    print(answer)
    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())
cnt = 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+z == s:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
print(sum([h+i+j==s for j in range(k+1) for i in range(k+1) for h in range(k+1)]))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# ABC051 B - Sum of Three Integers
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        for k in range(0,S-i-j+1):
            if i+j+k == S and 0<=k<=K:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

rec = 0
lst_rec = []
for x in lst_temp:
  for y in lst_temp:
    for z in lst_temp:
      lst_rec.append(x+y+z)
      
rec = [ i for i in lst_rec if i == S]
print(len(rec))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

X=Y=Z=K+1

rec = 0
for i in range(X):
  for j in range(Y):
    for k in range(Z):
      xyz = i + j + k			#合計値
      if xyz == S:
        rec += 1

print(rec)

Submission status: Time Limit Exceeded

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

X=Y=Z=K

rec = 0
for i in range(X+1):
  for j in range(Y+1):
    for k in range(Z+1):
      xyz = i + j + k			#合計値
      if xyz == S:
        rec += 1

print(rec)

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    mi = min(k, s)
    ma = max(k, s)
    for i in range(mi + 1):
        for j in range(mi + 1):
            res += int(0 <= s - i - j and s - i - j <= k)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    mi = min(k, s)
    ma = max(k, s)
    for i in range(mi + 1):
        for j in range(mi + 1):
            res += int(0 <= s - i - j <= k)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    for i in range(k + 1):
        for j in range(k + 1):
            res += int(0 <= s - i - j <= k)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    for i in range(k + 1):
        for j in range(k + 1):
            for k in range(k + 1):
                res += int(i + j + k == s)

    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 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())
c=0
#x>=y>=z
for i in range(k+1):
    for j in range(i+1):
        for k in range(j+1):
            if i+j+k==s:
                if i==j==k:
                    c+=1
                elif i!=j and j!=k:
                    c+=6
                else:
                    c+=3
                
print(c)

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

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

Submission status: Time Limit Exceeded

Solution code:
# N

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

K+=1

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

i = 0

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

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

Submission status: Time Limit Exceeded

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


def calc_yz(target, limit):
    yz_list = []
    for y in range(limit + 1):
        z = target - y
        if 0 <= z <= limit:
            yz_list.append([y, z])
    return yz_list


def calc_xyz(target, limit):
    xyz_list = []
    for x in range(limit + 1):
        yz_sum = target - x
        if yz_sum < 0:
            continue
        yz_list = calc_yz(yz_sum, limit)
        for yz in yz_list:
            xyz_list.append([x] + yz)
    return xyz_list


print(len(calc_xyz(s, min(s, k))))

Submission status: Time Limit Exceeded

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


def calc_yz(target, limit):
    yz_list = []
    for y in range(limit + 1):
        z = target - y
        if 0 <= z <= limit:
            yz_list.append([y, z])
    return yz_list


def calc_xyz(target, limit):
    xyz_list = []
    for x in range(limit + 1):
        yz_sum = target - x
        if yz_sum < 0:
            continue
        yz_list = calc_yz(yz_sum, limit)
        for yz in yz_list:
            xyz_list.append([x] + yz)
    return xyz_list


print(len(calc_xyz(s, k)))

Submission status: Time Limit Exceeded

Solution code:
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
print(c)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
result = [i_1+i_2+i_3 for i_1 in range(k+1) for i_2 in range(k+1) for i_3 in range(k+1) if i_1+i_2+i_3==s]
print(len(result))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
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())
count = 0
for a in range(k + 1):
    for b in range(k + 1):
        for c in range(k + 1):
            if a + b + c == s:
                count += 1
print(count)

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

    count = 0
    for x_i in range(K+1):
        for y_i in range(K+1):
            for z_i in range(K+1):
                if x_i + y_i + z_i == S:
                    count += 1
                    break

    print(count)

solve()

Submission status: Time Limit Exceeded

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

    count = 0
    for x_i in range(K+1):
        for y_i in range(K+1):
            for z_i in range(K+1):
                if x_i + y_i + z_i == S:
                    count += 1

    print(count)

solve()

Submission status: Time Limit Exceeded

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

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        for k in range(K + 1):
            s = i + j + k
            if S == s:
                ans += 1
                break

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 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+z==s:
        ans += 1
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 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+z==s:
        ans += 1
        continue
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = input().split()
k, s = int(k), int(s)
ans = 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+z==s:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    k, s = map(int, input().split())
    if s > 3*k:
        pass
    elif s == 3*k:
        ans = 1
    else:
        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)
main()

Submission status: Time Limit Exceeded

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

counter = 0

for x in range(k+1):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        elif s-x-y <= k and s-x-y >=0:
            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):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        if s-x-y <= k and s-x-y >=0:
            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):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        for z in range(k+1):
            if s == x+y+z:
                counter += 1
                break
                
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):
            if s == x+y+z:
                counter += 1
                
print(counter)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int, input().split())
x=list(range(k+1))
y=x
z=x
count=0

for _x in x:
  for _y in y:
    for _z in z:
      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 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:
a, b = map(int, input().split())
count = 0
for i in range(a+1):
    for j in range(a+1):
        for k in range(a+1):
            if i + j + k == b:
                count += 1
print(count)

Submission status: Time Limit Exceeded

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

for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if S==X+Y+Z:
        flag += 1
print(flag)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
cnt = 0

l = []
l = input().split()
k = int(l[0])
s = int(l[1])

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

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

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    k, s = map(int, input().split())
    # print(k, s)
    ans = 0
    for z in range(k, -1, -1):
        for y in range(k, -1, -1):
            for x in range(k, -1, -1):
                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())

count = 0

x = 0
while (x <= K):
    if x > S:
        break
    y = 0
    while (y <= K):
        if y > S:
            break
        if 0 <= S - (x + y) <= K:
            count += 1
        y += 1
    x += 1



print(count)

Submission status: Time Limit Exceeded

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

count = 0

x = 0
while (x <= K):
    if x > S:
        break
    y = 0
    while (y <= K):
        if y > S:
            break
        if S - (x + y) <= K and 0 <= S - (x + y):
            count += 1
        y += 1
    x += 1



print(count)

Submission status: Time Limit Exceeded

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y <= K):
        if S - (x + y) <= K and 0 <= S - (x + y):
            count += 1
        y += 1
    x += 1



print(count)

Submission status: Time Limit Exceeded

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y <= K):
        z = S - (x + y)
        if z <= K and 0 <= z:
            #print(x, y, z)
            count += 1
        y += 1
    x += 1



print(count)

Submission status: Time Limit Exceeded

Solution code:
def SumofThreeIntegers():
    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 and x<=K and y<=K and z<=K:
                    count += 1

    print(count)

if __name__ == "__main__":
    SumofThreeIntegers()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y <= K):
        z = 0
        while (z <= K):
            if x + y + z == S:
                count += 1
            z += 1
        y += 1
    x += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

data=input().split(' ')
data_1=int(data[0])
data_1sub=data_1+1
data_2=int(data[1])
d=0
e=0
for i in range(data_1sub):	
	for j in range(data_1sub):
         for k in range(data_1sub):
         	d=i+j+k
         	if d == data_2:
         		e=e+1
         	else:
         		pass
print(e)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
k, s = na()

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
k,s = map(int,input().split())
sum = [i+j+l for i in range(k+1) for j in range(k+1) for l in range(k+1)]
print(sum.count(s))

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

Submission status: Time Limit Exceeded

Solution code:
#abc051_B - Sum of Three Integers
K, S = list(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 += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    for c in range(K+1):
      if a+b+c == A:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from itertools import combinations_with_replacement

cwr = combinations_with_replacement(range(0, k + 1), 3)
ans = 0

for x, y, z in cwr:
    if x + y + z == s:
        st = set([x, y, z])
        if len(st) == 1:
            ans += 1
        elif len(st) == 2:
            ans += 3
        else: #len(st) == 3
            ans += 6

print(ans)

Submission status: Time Limit Exceeded

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

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

# print(K)
# print(S)

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