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 n in range(k+1):
    for m in range(k+1):
        for j in range(k+1):
            if n+m+j==s:
                cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s=[int(i) for i in 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())
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())
counter = 0
for i in range(k+1):
  for m in range(k+1):
    for l in range(k+1):
      if (i + m + l) ==  s:
        counter+= 1
print(counter)

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

result = 0

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

print(result)

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 = 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 = [int(i) for i in input().split()]
cnt = 0

for x in range(K+1):
  for y in range(K+1):
    candi_z = S - x - y 
    for z in range(candi_z + 1):
      if x + y + z == S and x <= K and y <= K and z <= K:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in 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:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
K, S = map(int,F.readline().split())
count = 0
for x in range(K+1):
    yplusz = S - x
    for y in range(yplusz+1):
        z = yplusz - y
        if z <= K and y <= K:
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# Me
def resolve(k, s):
    c = 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:
                    c += 1
    return c


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

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:
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(S-x-y+1):
          if z > K or x + y + z != S:
            continue
          count += 1
            
# 出力
print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
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:
                continue
            count += 1

# 出力
print(count)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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


count = 0
for x in range(K+1):
    if x > S or S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S or S - (x+y) > K:
            continue
        for z in range(K+1):
            if x + y + z > S:
                continue
            elif x + y + z == S:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int , input().strip().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:
                continue
            elif x + y + z == S:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = [int(x) for x in 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 and x==z:
					count+=1
				elif x==y or x==z or y==z:
					count+=3
				else:
					count+=6
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
	
k, s = [int(x) for x in 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(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())
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=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
                break
            elif check_tmp  == 2:
                continue
            sum = x+y+l_k    
            if l_s <= sum:
#                print("x=",x,"y=",y)
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
                break
            elif check_tmp  == 2:
                continue
            for z in range(l_k):
                check_tmp =check3(x,y,z,l_s) 
                if check_tmp == 1:
                    break
#                print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
                break
            elif check_tmp  == 2:
                continue
            for z in range(l_k):
                check_tmp =check3(x,y,z,l_s) 
                if check_tmp == 1:
                    break
#                print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

k,s=nyu()
print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
              break
            elif check_tmp  == 2:
                continue
            for z in range(l_k):
                check_tmp =check3(x,y,z,l_s) 
                if check_tmp == 1:
                    break
#                print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
                    
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+k*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k < s:
        return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

k,s=nyu()
print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        if check1(s,l_s) == True:
            break
        for y in range(l_k):
            if check2(x,y,l_s) == True :
               break
            for z in range(l_k):
                if check3(x,y,z,l_s) == True :
                    break
    #            print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
                    
    return l_combi

def check1(x,s):
    if x<s:
        return True
    return False

def check2(x,y,s):
    sum = x+y
    if s<sum:
        return True
    return False

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return True
    return False    


k,s=nyu()
print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        for y in range(l_k):
            if check1(x,y,l_s) == True :
               break
            for z in range(l_k):
                if check2(x,y,z,l_s) == True :
                    break
        #        print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
                    
    return l_combi

def check1(x,y,s):
    sum = x+y
    if s<sum:
        return True
    return False

def check2(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return True
    return False    









    

    



k,s=nyu()
print(calc(k+1,s))

Submission status: Time Limit Exceeded

Solution code:
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    
    for x in range(l_k):
        for y in range(l_k):
            for z in range(l_k):
     #           print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
                    
    return l_combi

k,s=nyu()
print(calc(k+1,s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

k,s = (int(x) for x in 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 = [int(i) for i in 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())
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())
data=[[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(data))

Submission status: Time Limit Exceeded

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

li = []
for x in range(K+1):
    for y in range(K+1):
        if S-x-y >= 0 and S-x-y <= K:
            li.append([x, y, S-x-y])
print(len(li))

Submission status: Time Limit Exceeded

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

li = []
for x in range(0, S+1):
    if x <= K:
        for y in range(0, S+1-x):
            if y <= K:
                for z in range(0, S+1-x-y):
                    if x + y + z == S and z <= K:
                        li.append([x, y, z])
print(len(li))

Submission status: Time Limit Exceeded

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

li = []
for x in range(0, S+1):
    for y in range(0, S+1-x):
        for z in range(0, S+1-x-y):
            if x + y + z == S and x <= K and y <= K and z <= K:
                li.append([x, y, z])
print(len(li))

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:
# ABC 051: B – Sum of Three Integers
k, s = [int(s) for s in input().split()]
number = 0

for a in range(k + 1):
    for b in range(k + 1):
        for c in range(k + 1):
            if a + b + c == s:
                number += 1

print(number)

Submission status: Time Limit Exceeded

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

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

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):
            while 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):
            sumn = x + y + z
            if sumn == 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())
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,input().split())
flag = 1
s = 0
for l in range(K+1):
  if l == S+1:
    break
  for m in range(K+1):
    n = S - (l+m)
    if l == S+1:
      break
    elif (0<=n)and(n<=K) and (l+m+n == S):
      s = s+1
print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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())
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())
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:
from sys import stdin
n = input().split(' ')
c = 0
K = n[0]
S = n[1]
for i in range(int(K)+1):
    for j in range(int(K)+1):
        for k in range(int(K)+1):
            sum=i+j+k
            if sum is int(S):
                c += 1
                break
                
print(c)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n = input().split(' ')
c = 0
K = n[0]
S = n[1]
for i in range(int(K)+1):
    for j in range(int(K)+1):
        for k in range(int(K)+1):
            sum=i+j+k
            if sum is int(S):
                c += 1
                
print(c)

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
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 = map(int, input().split())

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            comb = [i, j, m]
            sum_set.append(comb)
        else:
            continue
print(len(sum_set))

Submission status: Time Limit Exceeded

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            comb = [i, j, m]
            sum_set.append(comb)
print(len(sum_set))

Submission status: Time Limit Exceeded

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        for m in range(k + 1):
            if i + j + m == s:
                comb = [i, j, m]
                sum_set.append(comb)
                break
        else:
            continue
print(len(sum_set))

Submission status: Time Limit Exceeded

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        for m in range(k + 1):
            if i + j + m == s:
                comb = [i, j, m]
                sum_set.append(comb)
                break
print(len(sum_set))

Submission status: Time Limit Exceeded

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        for m in range(k + 1):
            if i + j + m == s:
                comb = [i, j, m]
                sum_set.append(comb)
print(len(sum_set))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
k,s = map(int, input().split())
count = 0
for h in range(k+1):
    for i in range(k+1):
        for j in range(k+1):
            if (h+i+j) == 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 sum([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(K+1):
        for l in range(K+1):
            if i + j + l == S:
                ans += 1


print(ans)