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

Submission status: Time Limit Exceeded

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

#setlist = []
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:
                #setlist.append(str(X) + " " + str(Y) + " " + str(Z))
                count += 1
            else:
                continue
#print(setlist)
print(count)

Submission status: Time Limit Exceeded

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

#setlist = []
count = 0
for x in range(K + 1):
    X = x
    for y in range(K + 1):
        Y = y
        for z in range(K + 1):
            Z = z
            if X + Y + Z == S:
                #setlist.append(str(X) + " " + str(Y) + " " + str(Z))
                count += 1
            else:
                continue
#print(setlist)
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
p=input().rstrip().split(' ')
k=int(p[0])
s=int(p[1])
G=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:
                G+=1;
print(G)

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


abc()

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= a[0] and a[1]-l-m >= 0):
            num+=1
print(num)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

count=0
  
	
for i, j, m in itertools.product(range(k+1), range(k+1), range(k+1)):
  if i + j + m == s:
    count+=1
    	
print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

count=0

def sum(a,b,c):
  return 1 if (a + b + c == s) else 0
  
	
for i, j, m in itertools.product(range(k+1), range(k+1), range(k+1)):
  count += sum(i,j,m)
    	
print(count)

Submission status: Time Limit Exceeded

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

count=0

def sum(a,b,c):
  return 1 if (a + b + c == s) else 0
  
	
    
for i in range(k+1):
  for j in range(k+1):
    for m in range(k+1):
      count += sum(i,j,m)
    	
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 S == x + y + z:
        count = count + 1
          
print(count)

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
l = [i for i in range(K+1)]
cnt = 0
for i in l:
    if i > S:
        break
    elif i == S:
        cnt += 1
        break
    elif i < S:
        for j in l:
            if i+j > S:
                break
            elif i+j == S:
                cnt += 1
                break
            elif i+j < S:
                if K >= S-i-j:
                    cnt += 1
                
print(cnt)

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

Submission status: Time Limit Exceeded

Solution code:
#ABC51-B

K,S=map(int,input().split())
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if sum==S: #X＝Sの場合
            count+=1
            #print(str(i)+" "+str(j))
            break
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if sum==S: #X＝Sの場合
            count+=1
            #print(str(i)+" "+str(j))
            break
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    for j in range(K+1):
        sum+=j
        if sum==S: #X＝Sの場合
            count+=1
            #print(str(i)+" "+str(j))
            break
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

maximum, equal = map(int, input().split())
counter = 0

for i in range(maximum + 1):
    for j in range(maximum + 1):
        for k in range(maximum + 1):
            if equal == i + j + k:
                counter += 1

print(counter)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

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

ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                # print([x,y,z])
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
data = input().split(" ")

K = int(data[0])
S = int(data[1])

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:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

    c = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if i + j > s:
                break
            for l in range(k + 1):
                if i + j + l > s:
                    break
                if i + j + l == s:
                    c += 1
                    # print(i, j, l)

    print(c)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

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

count = 0

for x in range(0,k+1):
    #print(x)
    for y in range(0,k+1):
        #print(y)
        for z in range(0,k+1):
            #print(z)
            if (x+y+z) == s :
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def main():
	c = 0
	k, s = map(int, input().split())
	#k, s = map(int, "2 2".split())
	for x in range(k + 1):
		for y in range(k + 1):
			for z in range(k + 1):
				if s == x + y + z:
					c += 1
	print(c)
	return

if __name__ == '__main__':
	main()

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:
# -*- coding: utf-8 -*-
k, s = map(int,input().split())
count = 0
if k == s/3:
  print(1)
  exit()
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        #print(x,y,z)
        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 = count + 1
print(count)

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):
      if l+m+n == s:
        count += 1
        
print(count)

Submission status: Time Limit Exceeded

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


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1

print(count)

Submission status: Time Limit Exceeded

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


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

print(count)

Submission status: Time Limit Exceeded

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


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

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int, (input()).split(' ')))
#print(n)
x = [ i   for i in range(n[0]+1)]
#y = [ i   for i in range(n[1]+1)]
#z = [ i   for i in range(n[1]+1)]
#print(x)
counter = 0
for x1 in x:
  for y1 in x:
    for z1 in x:
      if x1+y1+z1== n[1]:
        counter +=1

        
print(counter)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=nums

count=0

for i in x:
    for j in y:
        z=s-(i+j)
        
        if nums.count(z):
            count+=1
print(count)

Submission status: Time Limit Exceeded

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=z=nums

count=0

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

Submission status: Time Limit Exceeded

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        x = i
        for j in range(A):
            y = j
            for k2 in range(A) :
                z = k2
                if x + y + z == S:
                    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        x = i
        if x + y + z == S :
            cnt += 1
        for j in range(A):
            y = j
            if x + y + z == S :
                cnt += 1
            for k2 in range(A) :
                z = k2
                if x + y + z == S:
                    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
if K * 3 == S:
    cnt = 1
else :
    for i in range(K + 1):
        x = i
        if x + y + z == S :
            cnt += 1
        for j in range(K + 1):
            y = j
            if x + y + z == S :
                cnt += 1
            for k2 in range(K + 1) :
                z = k2
                if x + y + z == S:
                    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K , S = map(int, input().split())
x = 0
y = 0
z = 0
sum = 0
cnt = 0
if K * 3 == S:
    cnt = 1
else :
    for i in range(K + 1):
        x = i
        if x + y + z == S :
    #        print(str(x) + str(y) + str(z))
            cnt += 1
        for j in range(K + 1):
            y = j
            if x + y + z == S :
    #            print(str(x) + str(y) + str(z))
                cnt += 1
            for k2 in range(K + 1) :
                z = k2
                if x + y + z == S:
    #                print(str(x) + str(y) + str(z))
                    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

ar = itertools.product(range(K+1), repeat=3)

ans = 0
for a,b,c in ar:
  if a+b+c == S: ans += 1

print(ans)

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:
def permutations(iterable, permutation=[]):
    if not iterable: 
        yield permutation
        pass
    for i in [iterable.index(i) for i in set(iterable)]:
        yield from permutations(iterable[:i] + iterable[i+1:], permutation + [iterable[i]])


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

l=[]
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        l.append([i,j,k])

for item in l:
  for v in permutations(item):
    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:
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

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())
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())
ac=[]
nums=[]
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:
        ac.append((i,j,l))
for i in range(len(ac)):
  if len(set(ac[i]))==1:
    nums.append(1)
  elif len(set(ac[i]))==2:
    nums.append(3)
  else:
    nums.append(6)
print(sum(nums))

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

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

ans = 0

for i in range(k+1):
    for j in range(k+1):
        k2 = s - j - i

        if k2 > k or k2 < 0:
            continue

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

print(ans)

Submission status: Time Limit Exceeded

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

print([x+y+z for z in range(k+1) for y in range(k+1) for x in range(k+1)].count(s))

Submission status: Time Limit Exceeded

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

T=[]
for z in range(k+1):
    for y in range(k+1):
        for x in range(k+1):
            T.append(x+y+z)
print(T.count(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(sum)

Submission status: Time Limit Exceeded

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

x =0

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

print(x)

Submission status: Time Limit Exceeded

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

r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        for c in range(k + 1):
            if a + b + c == s:
                r += 1
                break
            if a + b + c > s:
                break
print(r)

Submission status: Time Limit Exceeded

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

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

print(r)

Submission status: Time Limit Exceeded

Solution code:
K,S = list(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:
import itertools
K,S=map(int,input().split())
ans=0
l=[]

for i in range(K+1):
    for j in range(i+1):
        for k in range(j+1):
            if i+j+k==S:
                l.append([i,j,k])
                break
L=[]
for c in l:
    for a in itertools.permutations(c):
        L.append(a)

print(len(set(L)))

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
                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):
            if i+j+k==S:
                ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    k,s = f()
    
    cnt = 0
    for i in range(k+1):
        for j in range(k+1):
            for m in range(k+1):
                if i + j + m == s:
                    cnt += 1

    
    print(cnt)


solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        for ksk3 in ks:
            if s == ksk1 + ksk2 + ksk3:
                count += 1
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        if s -(ksk1 + ksk2) in ks:
            count += 1
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
# 蟻本1-6-1例題相当
# 数学的に解けそうであるが、とりあえず3重のfor文で回してみる
# 最大で2500^3≒100億となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

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

print(count)

Submission status: Time Limit Exceeded

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

for x in range(K+1):
    for y in range(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 = 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
      else:
        continue
print(count)

Submission status: Time Limit Exceeded

Solution code:
answer=0
i = list(map(int, input().split()))
f=i[0]+1
for a in range(f):
    for b in range(f):
        for c in range(f):
            sum=a+b+c
            if sum==i[1]:
                answer+=1
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
input_data = input().split()

k=int(input_data[0])+1
s=int(input_data[1])
count=0

for i in range(k):
  for j in range(k):
    for u in range(k):
      if i + j + u == s:
        count= count +1
      else:
        pass

print(count)

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
k,s = (int(i) for i in input().split())
cnt = 0
for a in product(range(min(k+1,s+1)),repeat=3):
    if sum(a) == s:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
k,s = (int(i) for i in input().split())
cnt = 0
for a in product(range(k+1),repeat=3):
    if sum(a) == s:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0
for i in range(k, -1,-1):
        for j in range(k, -1,-1):
                z = s - i - j
                if i + j + z == s and k >= z and z >= 0:
                        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 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())
cnt = 0
K += 1
for X in range(K):
    if X > S:
        break
    for Y in range(K):
        if X + Y > S:
            break
        for Z in range(K):
            if X + Y + Z == S:
                cnt += 1
            if X + Y + Z > S:
                break

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    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 l in range(k+1):
                if i+j+l == s:
                    ans += 1
                elif i+j+l > s:
                    break
            else:
                continue
        else:
            continue
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    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())
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:
n,s = map(int, input().split())
cnt = 0
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if s == i + j + k:
                cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

max_k = max(K,int(S/3))
min_k = int(max(S-max_k*2,0))
cnt=0
max_k+=1

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