Problem:


Score : 200 points

Problem Statement

You are given two integers K and S.

Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.

How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?  

Constraints

2≤K≤2500 

0≤S≤3K 

K and S are integers.  

Input

The input is given from Standard Input in the following format:

K S

Output

Print the number of the triples of X, Y and Z that satisfy the condition.

Sample Input 1

2 2

Sample Output 1

6

There are six triples of X, Y and Z that satisfy the condition:

X = 0, Y = 0, Z = 2 

X = 0, Y = 2, Z = 0 

X = 2, Y = 0, Z = 0 

X = 0, Y = 1, Z = 1 

X = 1, Y = 0, Z = 1 

X = 1, Y = 1, Z = 0

Sample Input 2

5 15

Sample Output 2

1

The maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z.



Sample input:
2 2


Sample output:
6

Submission status: Time Limit Exceeded

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

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

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(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):
    if x > s:
        break
    if x+k+k < s:
        continue
    for y in range(k+1):
        xy = x+y
        if xy > s:
            break
        if xy+k < s:
            continue
        for z in range(k+1):
            xyz = x+y+z
            if xyz > s:
                break
            if xyz == 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):
    if x > s:
        break
    for y in range(k+1):
        xy = x+y
        if xy > s:
            break
        for z in range(k+1):
            xyz = x+y+z
            if xyz > s:
                break
            if xyz == 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:
import itertools
k, s = map(int, input().split())

a = list(itertools.combinations_with_replacement(range(0, k+1), 3))
ans = 0
for i in a:
    if sum(i) == s:
        if i[0] == i[1] == i[2]:
            ans += 1
        elif i[0] != i[1] != i[2] != i[0]:
            ans += 6
        else:
            ans += 3
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
k,s = map(int, input().split())
num = 0
for i,h,j in itertools.combinations_with_replacement(range(k+1),3):
    if i+h+j == s:
        if i == h == j:
            num += 1
        elif i == h or h == j or j == i:
            num += 3
        else:
            num += 6
print(num)

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
ans = 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 :
                    ans += 6
                elif x == y != z or x != y == z:
                    ans += 3
                elif x == y == z:
                    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = list(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 = []
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans.append([x,y,z])
print(len(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 S == x + y + z:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            if i + j + l == s:
                if i == j == l:
                    ans1 +=1
                elif i == l or i == j or j == l:
                    ans2 += 1
                else:
                    ans3 += 1
                    

print(ans1+ans2*3+ans3*6)

Submission status: Time Limit Exceeded

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            if i + j + l == s:
                if i == j == l:
                    ans1 +=1
                elif i == l or i == j or j == l:
                    ans2 += 1
                else:
                    ans3 += 1
                    

print(ans1+ans2*3+ans3*6)

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):
            ans = ans + (i+j+l == s)
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:
# coding = SJIS

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# B - Sum of Three Integers
def main():
    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
    else:
        print(cnt)



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:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      for l in range(k+1):
        if i+j+l == s:
          res += 1

  return res



def main():
  K,S = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(K,S))
  return

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

for i in range(K+1):
    x = i
    if x == S:
        n += 1
        break
    for j in range(K+1):
        y = j
        if x+y == S:
            n += 1
            break
        for k in range(K+1):
            z = k
            if x+y+z == S:
                n += 1

print(n)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

for i in range(K+1):
    x = i
    for j in range(K+1):
        y = j
        for k in range(K+1):
            z = k
            if x+y+z == S:
                n += 1

print(n)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

k, s = rm()
cnt = 0
for x in range(k, -1, -1):
    for y in range(k, -1, -1):
        for z in range(k, -1, -1):
            if x+y+z == s:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
splited = input().split(" ")

k = int(splited[0])
s = int(splited[1])

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
K+=1
ans=0
a=max(0,S-2*K)
for i in range(a,K):
  if i>S:
    break
  for j in range(a,K):
    if i+j>S :
      break
    for k in range (a,K):
      if i+j+k>S:
        break
      if i+j+k==S:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
K+=1
ans=0
for i in range(K):
  for j in range(K):
    for k in range (K):
      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 = [int(n) for n in input().split()]
ac = 0
for x in range(k+1):
  if s-x <= 2*k:
    for y in range(k+1):
      if s-x-y <= k:
        for z in range(k+1):
          if x+y+z == s:
            ac += 1
print(str(ac))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = list(map(int, input().split()))
cnt = 0
for i in range(x[0]+1):
  for j in range(x[0]+1):
    for k in range(x[0]+1):
      p = i+j+k
      if p == x[1]:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
x = list(map(int, input().split()))
cnt = 0
for i in range(x[0]+1):
  for j in range(x[0]+1):
    for k in range(x[0]+1):
      p = i+j+k
      if p == x[1]:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

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())
#k, s = 5,15

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python

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

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

print(ans)

Submission status: Time Limit Exceeded

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k or l + m + n < s:
                break
            
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)

Submission status: Time Limit Exceeded

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    while l >= 0:
        t_sum = s - l
        m = k
        if t_sum > 2*k:
            break
        if m < k:
            m = k
        while m >= 0:
            n = s - l - m
            if n > k:
                n = k
            if l + m + n < s:
                break
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)

Submission status: Time Limit Exceeded

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
else:
    l = k
    while l >= 0:
        t_sum = s - l
        m = k
        if t_sum > 2*k:
            break
        if m < k:
            m = k
        while m >= 0:
            n = s - l - m
            if n > k:
                n = k
            if l + m + n < s:
                break
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)

Submission status: Time Limit Exceeded

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

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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif  s < k:
    k = s
    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
else:
    k = s
    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:
# -*- coding: utf-8 -*-

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

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

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        for 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,x = 0,0
total = (k+1)**2
if (k*2) >= s:
	x = 0
else:
	x = s-(k*2)
while(x<=k):
	res = s-x
	for i in range(k+1):
		for j in range(k+1):
			if i+j == res:
				#print(i,j)
				cnt += 1
	x += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s=input().split()
k=int(k)
s=int(s)
cnt=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:
	        cnt+=1
        elif x==y or y==z or x==z:
          cnt+=3
        else:
          cnt+=6
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

resolve()

Submission status: Time Limit Exceeded

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

resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    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
                    break
    print(count)

resolve()

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

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int, input().split())
count = 0
if 3*k < s:
  print(0)
else:
  for i in range(0,k+1,1):
    for j in range(0,k+1,1):
      for k in range(0,k+1,1):
        if i+j+k == s:
          count = 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,1):
  if i > s:
    break
  for j in range(0,k+1,1):
    if j > s:
      break
    for k in range(0,k+1,1):
      if k > s:
        break
      if i+j+k == s:
        count = 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,1):
  for j in range(0,k+1,1):
    for k in range(0,k+1,1):
      if i+j+k == s:
        count = count+1
print(count)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

print(res)

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:
from itertools import product

K,S=map(int,input().split())
li_=list(product(range(K+1),repeat=3))
ans=0
for x in li_:
  if sum(x)==S:
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

d = {}
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if(z >= 0 and z <= k):
            key = (x,y,z)
            d[key] = 1

print(len(d))

Submission status: Time Limit Exceeded

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

d = {}
for x in range(k+1):
    mx_y = min(s-x,k)
    for y in range(mx_y+1):
        z = s - x - y
        if(z >= 0 and z <= k):
            key = (x,y,z)
            d[key] = 1

print(len(d))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
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
      elif i + j + l > s:
        break
    if i + j > s:
      break
print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

K, S = map(int, input().split())
num = list(range(K+1))
count = 0

for x in range(K+1):
    if K < 1/2 * (S - x):
        continue
    for y in range(min(S - x + 1, K + 1)):
        if K < (S - x - y):
            continue
        for z in range(min(S - x - y + 1, K + 1)):
            if x + y + z == S:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
#-------------
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) == 0:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c=0

for x in range(s+1):
  for y in range(s+1-x):
    for z in range(s+1-x-y):
      if x>k or y>k or z>k:
        continue
      if x+y+z==s:
        c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:

K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        ij = i + j
        if ij > S:
            break
        for k in range(K+1):
            if (ij + k == S):
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def actual(K, S):
    count = 0

    for x in range(S + 1):
        for y in range(S + 1):
            z = S - (x + y)

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

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

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

k = int(p[0])
s = int(p[1])

x = -1
y = -1
z = -1
answer = 0

for number in range(k+1):
    x += 1
    y = -1
    z = -1
    for num in range(k+1):
        y += 1
        z = -1
        for n in range(k+1):
            z += 1
            if x + y + z == s:
                answer += 1

print(answer)