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: Wrong Answer

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

for x in range(k+1):
    yz = s - x
    if yz > k*2:
        break
    for y in range(k+1):
        z = yz - y
        if 0 <= x <= y <= z:
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

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

for x in range(k+1):
    yz = s - x
    if yz > k*2:
        break
    for y in range(k+1):
        z = yz - y
        if x >= y >= z >= 0:
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

Solution code:


k, s = list(map(int, input().split()))
z = min(k,s)
y = min(k,s-z)
xmax = min(y + z,k)
x = s-z-y
count = 0

while x <= xmax :
    z0 = z
    y0 = y
    while z >= 0 and y<= k:
        z -= 1
        y += 1
        count+=1
    z = z0-1
    y = y0
    x +=1
print(count)

Submission status: Wrong Answer

Solution code:

import numpy as np
import scipy.misc as scm

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

allp = scm.comb(K+2,2)
partp = scm.comb(K-S,2)

ans = allp-3*partp
if ans < 0:
    ans=0

if S<3*K:
    ans =0

print int(ans)

Submission status: Wrong Answer

Solution code:
#-*- coding=utf-8 -*-

import numpy as np
import scipy.misc as scm

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

allp = scm.comb(K+2,2)
partp = scm.comb(K-S,2)

ans = allp-3*partp
if ans < 0:
    ans=0

print int(ans)

Submission status: Wrong Answer

Solution code:


k, s = list(map(int, input().split()))
z = min(k,s)
y = min(k,s-z)
xmax = min(y + z,k)
x = s-z-y
count = 0

while x <= xmax and z >= 0:
    count += max(z,y)+1-min(z,y)
    x += 1
    z -=1
print(count)

Submission status: Wrong Answer

Solution code:
#-*- coding=utf-8 -*-

import numpy as np
import scipy.misc as scm

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

allp = scm.comb(K+2,2)
partp = scm.comb(K-S,2)

ans = allp-3*partp
if ans < 0:
    ans=0

print ans

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []
count = int(0)

for x in range(k+1)[::-1]:
    a = s-x
    if a > k*2:
        break
    for y in range(k+1)[::-1]:
        z = a - y
        if z > y or z < 0:
            break
        else:
            xyz_l.append([x, y, z])
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []
count = int(0)

for x in range(s//3, k+1)[::-1]:
    a = s-x
    if a > k*2:
        break
    for y in range(k+1)[::-1]:
        z = a - y
        if z > y or z < 0:
            break
        else:
            xyz_l.append([x, y, z])
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)

Submission status: Wrong Answer

Solution code:
line = raw_input()
num = line.split(" ")
K = int(num[0])
S = int(num[1])

result = []

for X in range(1, K + 1):
    for Y in range(X, K + 1):
        for Z in range(Y, K + 1):
            if X + Y + Z == S:
                result.append(0)

print(len(result))

Submission status: Wrong Answer

Solution code:


k, s = list(map(int, input().split()))
z = min(k,s)
y = min(k,s-z)
xmax = min(y + z,k)
x = s-z-y
count = 0

while x <= xmax and z >= 0:
    count += max(z,y)+1-min(x,y)
    x += 1
    z -=1
print(count)

Submission status: Wrong Answer

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

cnt = 0
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				cnt += 1
				print(x,y,z) #for debug
		else:
			break

print(cnt)

Submission status: Wrong Answer

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

for i in range(k + 1):
    if i <= s:
        cnt += s - i + 1
print(cnt)

Submission status: Wrong Answer

Solution code:
[a, b] = map(int, input().split())
cnt = 0
if a*3==b:
    print(1)
else:
    for x in range(0, b-2*a+1):
        for y in range(x, a+1):
            for z in range(y, a+1):
                if x+y+z == b:
                    cnt += 1
                    break
                if x+y+z > b:
                     break
    if b%3 ==0:
        print(cnt*3-2)
    else:
        print(cnt*3)

Submission status: Wrong Answer

Solution code:
[a, b] = map(int, input().split())
cnt = 0
if a*3==b:
    print(1)
else:
    for x in [0, 1]:
        for y in range(x, a+1):
            for z in range(y, a+1):
                if x+y+z == b:
                    cnt += 1
                    break
                if x+y+z > b:
                     break
    if b%3 ==0:
        print(cnt*3-2)
    else:
        print(cnt*3)

Submission status: Wrong Answer

Solution code:


k, s = list(map(int, input().split()))
z = min(k,s)
y = min(k,s-z)
xmax = min(y + z,k)
x = s-z-y
count = 0

while x <= xmax and z >= 0:
    count += z+1-y
    x += 1
    z -=1
print(count)

Submission status: Wrong Answer

Solution code:
[k, s] = [int(s) for s in input().split(' ')]
count = 0
for x in range(max(s-2*k, 0), k+1):
    count += min(s-x, 2*k-(s-x)) + 1

print(count)

Submission status: Wrong Answer

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

for x in range(0, K + 1):
    if S - x <= K:
        wariate += S - x + 1
    else:
        wariate += max(0, 2 * K - (S - x) + 1)

print(wariate)

Submission status: Wrong Answer

Solution code:
k,s = input().strip().split(' ')
k,s = [int(k),int(s)]
cnt = 0
for i in range(k+1):
	if i>s:	
		break;
	for j in range(k+1):
		if i+j>s:
			break;
		else:
			cnt+=1
print (cnt)

Submission status: Wrong Answer

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

a = 0
for i in range(K + 1):
    r = S - i
    if r <= K * 2:
        t = (r + 1) - max(0, r - K) * 2
        a += t

print(a)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().strip().split(' '))
cnt = 0
for X in range(0, K+1):
	if (S-X) <= (2*K):
		if (S-X) < K:
			cnt += (S-X+1)
		elif (S-X) > K:
			Z = S-X-K
			cnt += (K-Z+1)
		else:
			cnt += (K+1)
 
print(cnt)

Submission status: Wrong Answer

Solution code:
[a, b] = map(int, input().split())
if a*3 == b or b == 0:
    print(1)
elif b % 3 == 0:
    print(b*3+1)
else:
    print(b*3)

Submission status: Wrong Answer

Solution code:
def getInput():
    nums = list(map(int, input().split()))
    k, s = nums[0], nums[1]
    return k, s

if __name__ == '__main__':
    k, s = getInput()
    n = k ** 3  # loop times
    memo = [[[0 for i in range(n)] for j in range(n)] for k in range(n)]
    print(memo)
    count = 0
    for x in range(k + 1):
        for y in range(k + 1):
            for z in range(k + 1):
                if memo[x][y][z] is not 0:
                    count += 1
                if (x + y + z) == s:
                    memo[x][y][z] = 1
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
def nHr(n):
    return (n+2)*(n+1)//2
whole = nHr(S)
oneGreater = twoGreater = threeGreater = 0
if S > K:
    oneGreater = nHr(S-K)
    if S > 2*K:
        twoGreater = nHr(S-2*K)
        if S > 3*K:
            threeGreater = nHr(S-3*K)

ans = whole -(oneGreater*3 - twoGreater*3 + threeGreater)
print(ans)

Submission status: Wrong Answer

Solution code:
[a, b] = map(int, input().split())
if a*3==b:
    print(1)
elif b%3==0:
    print(b*3+1)
else:
    print(b*3)

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
x0 = z = min(k,s)
y = min(k,s-z)
x = min(k,s-z-y)
count = 0

while x <= x0:
    count += z+1-y
    x += 1
    z -=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
inp=sys.stdin.readline()
K,S=map(lambda x: int(x), inp.split(' '))
K,S

if K<=S:
    ret=(K+1)*(K+2)/2
elif K>=S*2:
    K=S*3-K
    ret=(K+1)*(K+2)/2
else:
    ret=(K+1)*(K+2)/2-(K-S)*(K-S+1)/2*3
print(int(ret))

Submission status: Wrong Answer

Solution code:
import sys

K,S = map(int, raw_input().split())
ans=0
for X in range(0,K+1):
 YZ=S-X
 if(YZ<=2*K):
  ans=ans+YZ+1
print ans

Submission status: Wrong Answer

Solution code:
# coding: utf-8
k, s = [int(i) for i in input().split()]

cnt = 0

for x in range(0,k+1):
    for y in range(0,x+1):
        for z in range(0,y+1):
            if x+y+z == s:
                if x==y==z:
                    cnt+=1
                else:
                    cnt+=3

print(cnt)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().strip().split(' '))
cnt = 0
for X in range(0, K+1):
	if S-X <= 2*K:
		if S-X <= K:
			cnt += (S-X+1)
		else:
			Z = S-X-K
			cnt += (K-Z+1)
print(cnt)

Submission status: Wrong Answer

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

for x in range(0, K + 1):
    if S - x <= K:
        wariate += S - x + 1
    elif S - x <= 2 * K:
        wariate += 2 * K - (S - x) + 1

print(wariate)

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []
r_k = range(k+1)[::-1]

for x in r_k:
    a = s-x
    if a > k*2:
        break
    for y in r_k:
        b = a - y
        if b > k:
            break
        else:
            z = b - y
            xyz_l.append([x, y, z])
print(len(xyz_l))

Submission status: Wrong Answer

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

cnt = 0
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, S-x+1):
		z = S-x-y
		if z>0 or z==0:
			cnt += 1
		else:
			break

print(cnt)

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

Solution code:
k,s = input().strip().split(' ')
k,s = [int(k),int(s)]
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
			elif i+j+k>s:
				break;
		if i+j>s:
			break;
print (cnt)

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []

for x in range(k+1):
    a = s-x
    if a > k*2:
        break
    for y in range(k+1):
        b = a - y
        if b > k:
            break
        for z in range(k+1):
            c = b - z
            if c == 0:
                xyz_l.append([x, y, z])
print(len(xyz_l))

Submission status: Wrong Answer

Solution code:
k,s = input().strip().split(' ')
k,s = [int(k),int(s)]
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
			elif i+j+k>s:
				break;
	if i+j>s:
		break;
print (cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def func(k, n):
    if n <= k:
        return n + 1
    elif n <= 2 * k:
        return 2 * k - n + 1
    else:
        return 0

K,S = map(int,input().split())
ans = 0
for a in range(K+1):
    ans += func(K, S-a)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i1 in range(k+1):
    for i2 in range(k+1):
        for i3 in range(k+1):
            if i1 + i2 + i3 == 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 t in range(k + 1):
            if i + j + t == 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
            if x + y + z > s:
                break

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

Submission status: Time Limit Exceeded

Solution code:
x, y  =input().split(' ')
count = 0
for i in range(int(x)+1):
    for j in range(int(x)+1):
        for k in range(int(x)+1):
            if i + j + k == int(y):
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

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

print(kotae)

Submission status: Time Limit Exceeded

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

if k*3==s:
  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:
        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:
k,s=map(int,input().split())
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    if i + j > s:
      break
    for k in range(lower,upper):
      if i+j+k == s:
        ans += 1
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    for k in range(lower,upper):
      if i+j+k == 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 0<= i <= K and 0<= j <= K and 0<=k<=K and i+j+k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if ((i+j+m) == s):
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
lst = input().split()
K = int(lst[0])
S = int(lst[1])

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(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())
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
start = max(0,s-2*k)
for a in range(start,k+1):
  for b in range(start,k+1):
    for c in range(start,k+1):
      if a+b+c==s:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      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):
    left = S-(i+j)
    low = 0
    high = K

    while low <= high:
      n = (low + high) // 2
      if left == n:
        count += 1
        break
      elif left < n:
        high = n - 1
      elif left > n:
        low = n + 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_num, s_num = map(int, input().split())

cnt = 0
for x in range(k_num+1):
    for y in range(k_num+1):
        for z in range(k_num+1):
            if x + y + z == s_num:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

success = 0

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

print(success)

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    K, S = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0
for z in range(0, k+1):
    sz = s-z
    for xy in range(0, k+1):
        if xy+xy == sz:
            ans += 1
            break
        elif xy+xy > sz:
            break

    for x in range(0, k):
        for y in range(x+1, k+1):
            if x+y == sz:
                ans +=2
                break
            elif x+y > sz:
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
n=0

for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      
      if x+y+z==b:
        n+=1
print(n)

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:
# coding: utf-8
# Your code here!
import itertools
import numpy as np

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

lst = [i for i in range(k+1)]


prod = list(itertools.product(lst, repeat=3))

arr = np.array(prod)
arr_sum = arr.sum(axis=1)
ans = np.count_nonzero(arr_sum == s)

print(ans)

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

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

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 x in range(k+1):
      if i+j+x==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,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):
    Z = S - X - Y
    if 0 <= X <= K and 0 <= Y <= K and 0 <= Z <= K and X + Y + Z == S:
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる

"""


def solve(k, s):
    pattern = 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:
                    pattern += 1

    return pattern


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

"""


def solve(k, s):
    pattern = 0
    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if (x+y+z == s):
                    pattern += 1
    return pattern


if __name__ == "__main__":
    main()

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

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

Submission status: Time Limit Exceeded

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

count=0
for i in range(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 = list(map(int, input().split()))
count = 0

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

Submission status: Time Limit Exceeded

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

count = 0

for p in range(k+1):
    if p > s:
        break
    for q in range(k+1):
        if p + q > s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)

Submission status: Time Limit Exceeded

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

count = 0

for p in range(k+1):
    if p > s:
        break
    for q in range(k+1):
        if p + q > s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

count = 0

for p in range(k+1):
    for q in range(k+1):
        if p + q > s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

count = 0

for p in range(k+1):
    for q in range(k+1):
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
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:
import itertools
K,S = map(int,input().split())
c = 0
for i in itertools.product(range(K+1), repeat=3):
  if sum(i) == 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:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    l = list(itertools.combinations_with_replacement(list(range(k+1)),3))
    for i in l:
        x = i[0]
        y = i[1]
        z = i[2]
        if x+y+z == s:
            if len(set(i)) == 1:
                ans += 1
            elif len(set(i)) == 2:
                ans += 3
            else:
                ans += 6
    print(ans)

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    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)


if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

cnt = 0
for x in range(0,K+1):
  if x > S:
    continue
  for y in range(0,K+1):
    if x+y > S:
      continue
    for z in range(0,K+1):
      check = x+y+z
      if check == S:
        cnt += 1
      elif check > S:
        continue
        
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8

count = 0
k, s = map(int, input().split())
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)