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

max_k = max(K,int(S/3)) +1
cnt=0

for i in range(max_k):
    for j in range(max_k):
        for k in range(max_k):
            if i+j+k==S: cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

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=ans+1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#ABC951B/Sum_of_Three_Integers

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

Submission status: Time Limit Exceeded

Solution code:
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for X in range(0, K+1):
    Y = X
    Z = X
    if X + Y + Z == S:
        ans += 1
for X in range(0, K+1):
    Y = X
    for Z in range(0, K+1):
        if X != Z and X + Y + Z == S:
            ans += 3
for X in range(0, K-1):
    for Y in range(X+1, K):
        for Z in range(Y+1, K+1):
            if X + Y + Z == S:
                ans += 6
print(ans)

Submission status: Time Limit Exceeded

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

for a in range(0, K + 1):
  for b in range(0, K + 1):
    for c in range(0, K + 1):
      if a + b + c == S:
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

for a in range(0, K + 1):
  for b in range(0, K + 1):
    for c in range(0, K + 1):
      if a + b + c == S:
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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


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

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()

Submission status: 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())
d = 0
for a in range(0,k+1):
    for b in range(0,k+1):
        for c in range(0,k+1):
            if a+b+c == s:
                d += 1
print(d)

Submission status: Time Limit Exceeded

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

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

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())
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            #print(x , y, 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:
k, s = (int(i) for i in input().split())
t = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l  == s:
                t += 1
print(t)

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

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:
a, b = (int(_) for _ in input().split())  
res = 0
for x in range(a,-1,-1):
  if x + 2*a < b:
    break
  for y in range(a,-1,-1):
    if x + y + a < b:
      break
    for z in range(a,-1,-1):
      if x + y + z == b:
        res+=1

print(res)

Submission status: Time Limit Exceeded

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

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):
            m = i+j+k
            if m == S:
                cnt += 1
print(cnt)

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 = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(x,K+1):
        if x+y > S:
            break
        for z in range(y,K+1):
            if x+y+z == S:
#                print(x,y,z)
                if len({x,y,z}) == 1:
                    count += 1
                elif len({x,y,z}) == 2:
                    count += 3
                elif len({x,y,z}) == 3:
                    count += 6
            elif x+y+z > S:
                break
print(count)

Submission status: Time Limit Exceeded

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

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

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
x = 0
while x <= K:
    y = 0
    while y <= K:
        a = S-x-y
        if a <= K and a >= 0:
            count += 1
        y += 1
    x += 1

print(count)

#↑TLE

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 S-x-y >= 0:
            count += 1
        y += 1
    x += 1

print(count)

Submission status: Time Limit Exceeded

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

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

print(num)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


A = list(map(int, input().split()))
K = A[0]
S = A[1]
counter = 0
for i in range(K+1):
	for j in range(K+1):
		for l in range(K+1):
			temp = i + j + l
			if(temp == S):
				counter = counter + 1

print(counter)
print("\n")

Submission status: Time Limit Exceeded

Solution code:
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, K+1):
            if i + j + 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(i, k + 1):
        for l in range(j, k + 1):
            if i + j + l == s:
                if i != j and j != l:
                    ans += 6
                elif i != j or j != l:
                    ans += 3
                else:
                    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 l in range(k + 1):
            if i + j + l == s:
                ans += 1
                break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())  # �������l����
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 = 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 or y==z:
                    count +=3
                else:
                    count +=6
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:
#51
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    if s-i>=0:
        for j in range(k+1):
            if s-i-j>=0:
                    if 0<=s-(i+j) and s-(i+j)<=k:
                        count = count + 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#51
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 = count + 1
print(count)

Submission status: Time Limit Exceeded

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

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

count = 0
for x in Xs:
    for y in Ys:
        for z in Zs:
            if x+y+z == 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):
        z=s-x-y
        if 0<=z and z<=k:
            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):
    if s/k==3 :
        cnt=1
        break
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:
            sum=x+y+z   
            if sum == s:
                cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
ct = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        if x + y > s:
            break;
        for z in range(min(k+1,s-x-y+1)):
            if x + y + z == s:
                ct += 1
                break;
print(ct)

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
ct = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        for z in range(min(k+1,s-x-y+1)):
            if x + y + z == s:
                ct += 1
                break;
print(ct)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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
      if x+y+z>s: 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 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 sys
input=sys.stdin.readline
K,S=map(int,input().split());c=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:
        c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
K,S=map(int,input().split());c=0
for x in range(K+1):
  for y in range(K+1):
    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())
cnt = 0
for x in range(S + 1) :
    for y in range(S - x + 1) :
        z = S - x - y
        if x <= K and y <= K and z <= K :
            cnt += 1
print(cnt)

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

Submission status: Time Limit Exceeded

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

for x in range(n):
    for y in range(n):
        for z in range(n):
            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 = (int(x) for x in 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 = (int(x) for x in input().split())
result = [(x,y,z) for x in range(K+1) for y in range(K+1) for z in range(K+1) if (x + y + z) == S]

print(len(result))

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

true=0

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

print(true)

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
number = 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 and x == z:
          number += 1
        elif x == y or y == z or z == y:
          number += 3
        else:
          number += 6
print(number)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    ks = input()
    k, s = [int(i) for i in ks.split()]

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

    print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s = list(map(int, input().split()))
i = 0
flag = False
for x in range(k+1):
    if x > s:
      flag = True
      break
    for y in range(k+1):
        if y > s-x: break
        for z in range(k+1):
            if z > s-x-y: break
            if x+y+z==s: i+=1
else:
    print(i)
if flag:
  print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

            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):
        if x + y > S:
            break
        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())
L=[x+y+z for x in range(k+1) for y in range(k+1) for z in range(k+1)]
print(L.count(s))

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

print(count)

Submission status: Time Limit Exceeded

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

count = 0
for x,y,z in [(x,y,z) 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:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

count = 0
for x,y,z in itertools.product(range(0,K + 1),range(0,K + 1),range(0,K + 1)):
    if x + y + z == S:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

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

print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

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

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

print(cnt)

Submission status: Time Limit Exceeded

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

print cnt

Submission status: Time Limit Exceeded

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

print cnt

Submission status: Time Limit Exceeded

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

print cnt

Submission status: Time Limit Exceeded

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

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 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:
                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:
def main(input_str):
    nums = list(map(int, input_str.split()))

    count = 0
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            for num_3 in range(nums[0]+1):
                result = num_1 + num_2 + num_3
                if result == nums[1]:
                    count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Submission status: Time Limit Exceeded

Solution code:
def main(input_str):
    nums = list(map(int, input_str.split()))

    result_list = []
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            for num_3 in range(nums[0]+1):
                result = num_1 + num_2 + num_3
                if result == nums[1]:
                    result_list.append(result)

    return len(result_list)


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

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