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

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

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

Submission status: Time Limit Exceeded

Solution code:
k, s = [int(i) for i in 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:
import itertools

k, s = (int(x) for x in input().split())
sum_ = 0
for x, y, z in itertools.product(range(k+1), range(k+1), range(k+1)):
    if x + y + z == s:
        sum_ += 1
print(sum_)

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:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, S = il()
    print([x+y+z for x in range(K + 1) for y in range(K + 1) for z in range(K+1)].count(S))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

counter = 0

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

print(counter)

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())
ans=0
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:
        if i<j<k:
          ans+=6
        elif i<j==k or  i==j<k:
          ans+=3
        else:
          ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

counter = 0

for i in range(K+1):
    x = i
    for ii in range(K+1):
        y = ii
        z = S - i - ii
        if 0<=z and z<=K and (x+y+z)==S:
            counter += 1

print(counter)

Submission status: Time Limit Exceeded

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

cnt = 0

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

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

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:
a,b=map(int,input().split())
c=0
for l in range(a+1):
    for m in range(l,a+1):
        for r in range(m,a+1):
            if l+m+r==b:
                if l==m and m==r:
                    c+=1
                elif l==m:
                    c+=3
                elif m==r:
                    c+=3
                else:
                    c+=6
print(c)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
if __name__ == "__main__":
    K, S = list(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:
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    if i>S:
        break
    for j in range(K+1):
        if i+j>S:
            break
        if i+j<=S and K+i+j>=S:
            count+=1

print(count)

Submission status: Time Limit Exceeded

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

C = set([])
for x in range(min(K+1,S+1)):
    for y in range(min(K+1,S-x+1)):
        if 0 <= S-x-y and S-x-y <= K:
            C.add((x,y,S-x-y))

print(len(C))

Submission status: Time Limit Exceeded

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

r = range(K+1)

counter = 0
for x in r:
    for y in r:
        z = S - x - y
        if 0 <= z <= K and x + y + z == S:
            counter += 1
print(counter)

Submission status: Time Limit Exceeded

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


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

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

for X in range(0, K+1):
     for Y in range(0, K+1):
         for Z in range(0, K+1):
             SUM = X + Y + Z
             if SUM == S:
                 cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in range(K + 1):
    if S - x >= 0:
        for y in range(K + 1):
            if K >= S - x - y >= 0:
                z = S - x - y
                l.append((x, y, z))


print(len(l))

Submission status: Time Limit Exceeded

Solution code:

import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            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())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            x = i
            y = j
            z = l
            if i + j + l == s:
                count += 1
print(count)

Submission status: Time Limit Exceeded

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

for i in range(0, K+1):
  for j in range(0, K+1):
    if ((S - (i+j)) <= K) & (S - (i+j) >= 0):
      pattern = pattern+1
print(pattern)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(cnt)

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

Submission status: Time Limit Exceeded

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

out = 0

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

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:
N,M = input().split()
N = int(N)
M = int(M)

sum = 0

for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            if i + j + k == M:
                sum += 1
            
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = list(map(int,input().split()))
count=0
for a in range(max(0,x[1]-2*x[0]),min(x[0],x[1])+1):
    for b in range(max(0,x[1]-a-x[0]),min(x[0],x[1]-a)+1):
        for c in range(max(x[1]-a-b,0),min(x[1]-a-b,x[0])+1):
            if(a+b+c==x[1]):
                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):
        l = s - i - j
        #print('{} {} {}'.format(i,j,l))
        if i + j + l == s and l >= 0 and k >= l:
            ans +=  1
            
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in input().split()]
pos = []
for a in range(K+1):
    for b in range(K+1):
        c = S - a - b
        if 0 <= c <= K:
            pos.append([a,b,c])
# for a in pos:
#     print(a)
print(len(pos))

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

Submission status: Time Limit Exceeded

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




n=0

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

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):
      sum = i + j + k
      if sum == b:
        count +=1
      if sum > b:
        break

print(count)

Submission status: Time Limit Exceeded

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

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

print(c)

Submission status: Time Limit Exceeded

Solution code:
# Problem: https://atcoder.jp/contests/abc051/tasks/abc051_b
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(K, S):
    result = 0
    # algorithm
    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:
                    result = result + 1
    return result


if __name__ == "__main__":
    K, S = MI()
#    print("K={} S={}".format(K, S))
    print("{}".format(solver(K, S)))

Submission status: Time Limit Exceeded

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

def fact(n):
  return sum([x for x in range(1,n+1)])

ans = 0
r = 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 += 1
        elif (x==y) or (x==z) or (y==z):
          ans += fact(2)
        else:
          ans += fact(3)

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

cnt = 0
for i in range(k+1):
  for m in range(k+1):
    for n in range(k+1):
      if i + m + n == s:
        cnt += 1
        
        
print(cnt)

Submission status: Time Limit Exceeded

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

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

print(Y)

Submission status: Time Limit Exceeded

Solution code:
k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    for iii in range(k+1):
      if i+ii+iii==s:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(n) for n in 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
            elif (X+Y+Z) > S:
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(n) for n 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:
k, s = [int(i) for i 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:
import itertools

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

ilist = list(range(K + 1))
ilist = ilist * 3
comb = set(i for i in list(itertools.combinations(ilist, 3)) if sum(i) == S)

print(len(comb))

Submission status: Time Limit Exceeded

Solution code:

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

count=0

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
x = S if K>S else K

ans = 0
for i in range(x+1):
  x1 = S-i
  for j in range((K if x1>K else x1)+1):
    x2 = S-i-j
    for k in range((K if x2>K else x2)+1):
      if i+j+k==S:
        #print("{} {} {}".format(i,j,k))
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#from scipy.misc import comb

K, S = map(int, input().split())
x = S if K>S else K

#a = comb(3*K, S, exact=True)
#print(a)

ans = 0
for i in range(x+1):
  for j in range(x+1):
    for k in range(x+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):
        if (S-(x+y) <= K)&(S-(x+y) >= 0):
            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:
l = [int(x) for x in input().split()]
k = l[0]
s = l[1]
output = 0
for i in range(0,k+1):
  for n in range(0,k+1):
  	for m in range(0,k+1):
            if i + n + m == s:
              output += 1
print(output)

Submission status: Time Limit Exceeded

Solution code:
k,s=input().split()
K=int(k)
S=int(s)
count =0
for p in range(K+1):
    for q in range(K+1):
        for r in range(K+1):
            if p+q+r==S:
                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):
        if i + j > S:
            break
        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())
print([x+y+z for x in range(k+1) for y in range(k+1) for z in range(k+1)].count(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        if x + y > S:
            break
        z = S - (x + y)
        if z > K:
            continue
        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())
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:
def main():
    k, s = input().split()
    k, s = int(k), int(s)

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

    print(count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

ans = 0

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

            if x + y + z == s:
                ans = ans + 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
l = [a+b for a in range(k+1) for b in range(k+1)]
sum = 0
for i in range(k+1):
  sum += l.count(s-i)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
l = [a+b+c for a in range(k+1) for b in range(k+1) for c in range(k+1)]
print(l.count(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
        z = s-x-y
        if 0 <= z <= k and 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:
if __name__ == '__main__':
    (k, s) = tuple(map(int, input().split()))
    print(len([s for i in range(k+1) for j in range(k+1) for e in range(k+1) if i + j + e == s]))

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:
k, s = map(int, input().split())
arr = [[x, y, s-x-y] for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(len(arr))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
vec = input().split(' ')
k = int(vec[0])
s = int(vec[1])
count = 0
for x in range(k + 1):
    if x <= s:
        for y in range(k + 1):
            if x + y <= s:
                z = s - x - y
                if z >= 0 and z <= k:
                    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
vec = input().split(' ')
k = int(vec[0])
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        z = int(vec[1]) - x - y
        if z >= 0 and z <= k:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
vec = input().split(' ')
k = int(vec[0])
s = int(vec[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:
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)

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= input().split()
intK = int(K)
intS = int(S)
sum = 0
for X in range(intK+1):
    for Y in range(intK+1):
        Z = intS - (X+Y)
        if (Z < 0) or Z > intK:
            continue
        if Z >= 0 and (X+Y+Z) == intS:
            sum += 1
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
b = []
for i in range(k+1):
    for j in range(k+1):
        if i + j <= s:
            b.append(i+j)

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

K,S = list(map(int,input().split()))
l = set(range(K+1))
ans = 0

for x, y, z in itertools.product(l,l,l):
    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)