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())
print(sum([1 for a in range(k+1) for b in range(k+1) for c in range(k+1) if a+b+c == s]))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
i = list(map(int, input().split()))
k = i[0]
s = i[1]
#print("k=",k,"s=",s)
ans = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
#      print("x=",x,"y=",y,"z=",z)
      if x+y+z == s:
#        print("clear!")
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if x <= k and y <= k and z <= k and z >= 0:
                count +=1



print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
#s =int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

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

print(count,flush=True)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = sum([x + y + z == s for x in range(k + 1) for y in range(k + 1) for z in range(k + 1)])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=input().split()
K=int(a[0])
S=int(a[1])
cnt=0
for X in range(0,K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            if X+Y+Z==S and X==Y and Y==Z:
                cnt+=1
            elif X+Y+Z==S and (X==Y or Y==Z or Z==X):
                cnt+=3
            elif X+Y+Z==S:
                cnt+=6
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a=input().split()
K=int(a[0])
S=int(a[1])
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:
a = list(map(int,input().split()))
k = int(a[0])
s = int(a[1])
count = 0

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

print(count)

Submission status: Time Limit Exceeded

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

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

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 == s-z:
                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:
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

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
k += 1
for x in range(k):
    for y in range(k):
        for z in range(k):
            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 i in range(k+1):
  if i>s:
    continue
  for j in range(k+1):
    if i+j>s:
      continue
    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 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())
l=[x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1)]
print(l.count(True))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  5 14:58:17 2019

@author: Owner
"""

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())
import itertools
count = 0
for pattern in list(itertools.product(range(K+1), repeat=2)):
    #print(pattern)
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
import itertools
count = 0
for pattern in list(itertools.product(range(K+1), repeat=3)):
    #print(pattern)
    if sum(pattern) == S:
        
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
ks = input()
count = 0
k, s = [int(x) for x in ks.split(" ")]
for i in range(min(k + 1,s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
ks = input()
count = 0
k, s = [int(x) for x in ks.split(" ")]
for i in range(s + 2):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import bisect
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    lx = [x for x in range(k)]
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right(lx, s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import bisect
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right([x for x in range(k)], s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        if i > s:
            break
        for j in range(i, k):
            if i + j > s:
                break
            for x in range(j, k):
                if i + j + x == s:
                    if i != j and j != x and x != i:
                        cnt += 6
                    elif i == j and j == x:
                        cnt += 1
                    else:
                        cnt += 3
                elif i + j + x > s:
                    break
    print(cnt)
resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s=list(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 = [int(v) for v in input().split()]

cnt = 0
for x in range(K + 1):
    if x > S:
        break
    for y in range(K + 1):
        if x + y > S:
            break
        for z in range(K + 1):
            if x + y + z > S:
                break
            if x + y + z == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, raw_input().split())
xs = ys = zs = range(k + 1)
cnt = 0
for x in xs:
    if s < x:
        continue
    for y in ys:
        if s < y:
            continue
        for z in zs:
            if s < z:
                continue
            if sum([x, y, z]) == s:
                cnt += 1
print cnt

Submission status: Time Limit Exceeded

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

count = int(0)

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

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        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)

if __name__ == '__main__':
    AtCoder().main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

l = [i for i in range(0,k+1)]

c = [i for i in itertools.product(l,repeat=3) if sum(i) == s]

print(len(c))

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0 
x_flg = bool()
out = int()
for x in range(0,K+1):
  for y in range(0,K+1):
    if 0 <= S - x < K:
      cnt += S - x + 1
      break
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
    elif z < 0:
      break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0 
x_flg = bool()
out = int()
for x in range(0,K+1):
  for y in range(0,K+1):
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
    elif z < 0:
      break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in input().split()]
cnt = 0 
for x in range(0,K+1):
  for y in range(0,K+1):
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

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

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

count = 0
num = range(k+1)
for x in num:
  for y in num:
    for z in num:
      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())

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

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

matched = []

for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            matched.append((x, y, z))

# print(matched)
print(len(matched))

Submission status: Time Limit Exceeded

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

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

matched = []

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:
                matched.append((x, y, z))

# print(matched)
print(len(matched))

Submission status: Time Limit Exceeded

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

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        x = min(K+1, S-i+1)
        for j in range(x):
            y = min(K+1, S-i-j+1)
            for k in range(y):
                if i+j+k == S:
                    n += 1
    print(n)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    K,S = map(int, input().split())
    c = itertools.product([i for i in range(K+1)], repeat=3)
    n = 0
    for i in c:
        if sum(i) == S:
            n += 1
    print(n)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        if i + 2*K < S:
            continue
        for j in range(K+1):
            if i+j +K < S:
                continue
            for k in range(K+1):
                if i+j+k == S:
                    n += 1
    print(n)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
total = 0
for i in range(k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            if s == i+j+l:
                if(i == j and j == l):
                    total += 1
                elif((i == j and j != l) or (i != j and j == l) or (i == l and j != l)):
                    total += 3
                else:
                    total += 6
print(total)

Submission status: Time Limit Exceeded

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

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:
a, b = map(int, input().split())
cnt = 0
for i in range(a+1):
    if i > b: break
    for j in range(a+1):
        if i + j > b: break
        for k in range(a+1):
            if i + j + k > b: break
            if i + j + k == b:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

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

count = 0
for x in range(k+1):
    if s - x > 2 * k:
        continue
    for y in range(k+1):
        if s - (x+y) > k:
            continue
        for z in range(k+1):
            if x + y + z == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k+1):
    if s - x > 2 * k:
        continue
    for y in range(k+1):
        if x - (x+y) > k:
            continue
        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 i in range(0,K+1):
    for j in range(0,K+1):
        for _ in range(0,K+1):
            if i+j+_ == 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 s == x + y + z:
              ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

count = 0

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

print(count)

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
###
#Sum of Three Integers
###
k, s = map(int, input().split())
count = 0

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

print(count)

Submission status: Time Limit Exceeded

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

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count=0
if k < s/3:
  print(0)
  quit()
for a in range(0, k+1):
  if a == s:
    print(count+1)
    quit()
  for b in range(0, k+1):
    if a+b == s:
      count+=1
      break
    elif a+b > s:
      break
    for c in range(0, k+1):
      if a+b+c == s:
        count+=1
      elif a+b+c > s:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
k, s = map(int, input().split())
count=0
if k < s/3:
  print(0)
  quit()
for a in range(0, k+1):
  if a == s:
    print(count+1)
    quit()
  for b in range(0, k+1):
    if a+b == s:
      count+=1
      break
    elif a+b > s:
      break
    for c in range(0, k+1):
      if a+b+c == s:
        count+=1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    k, s = map(int, input().split())
    ans = 0
    for x in range(max(0, s-2*k), k + 1):
        for y in range(max(0, s-2*k), k + 1):
            for z in range(k + 1):
                if x + y + z == s:
                    ans += 1
                    break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

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

count = [1 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(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
if 3*k==s:
  print(1)
else:
  for x in range(k+1):
    if x+2*k<s:continue
    for y in range(k+1):
      if x+y+k<s:continue
      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())
if 3*k==s:
  print(1)
else:
  list = [ x + y + z for x in range(k+1) for y in range(k+1) for z in range(k+1)] 
  print(list.count(s))

Submission status: Time Limit Exceeded

Solution code:
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        for k in range(j+1):
            if i+j+k==S:
                if i==j==k:
                    ans+=1
                elif i==j or j==k:
                    ans+=3
                else:
                    ans+=6
                break
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(i+1):
        if i+j>S:
            break
        for k in range(j+1):
            if i+j+k==S:
                if i==j==k:
                    ans+=1
                elif i==j or j==k:
                    ans+=3
                else:
                    ans+=6
                break
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):
        if i+j>S:
            break
        for k in range(K+1):
            if i+j+k==S:
                ans+=1
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S= 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
                break
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 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())

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:
ks = input().split()

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

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)