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

Submission status: Time Limit Exceeded

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

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=count+1
                else:
                    pass
print(count)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      break
    elif i == b:
      ans += 1
      continue
    elif i < b:
      if i+2*a < b:
        break
      elif i+2*a == b:
        ans += 1
        continue
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            break
          elif i+j == b:
            ans += 1
            continue
          elif i+j < b:
            if i+j+a < b:
              break
            elif i+j+a == b:
              ans += 1
              continue
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

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

print(ans)

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

print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    elif i < b:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          elif i+j < b:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k > b:
                  break
                elif i+j+k == b:
                  ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
else:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    else:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          else:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            else:
              for k in range(a+1):
                if i+j+k > b:
                  continue
                elif i+j+k == b:
                  ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    else:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          else:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            else:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      if i+2*a < b:
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          else:
            if i+j+a < b:
              continue
            else:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      for j in range(a+1):
        if i+j > b:
          continue
        else:
          if i+j+a < b:
            continue
          else:
            for k in range(a+1):
              if i+j+k == b:
                ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      for j in range(a+1):
        if i+j > b:
          continue
        else:
          for k in range(a+1):
            if i+j+k == b:
              ans += 1
              
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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:
# https://atcoder.jp/contests/abc051/tasks/abc051_b

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

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K + 1 + K + 1 < S:
        continue
    for j in range(K + 1):
        if i + j + K + 1 < S:
            continue
        if 0 <= S - i - j <= K:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_b

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

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K+1 + K+1 < S:
        continue
    for j in range(K + 1):
        if i + j + K+1 < S:
            continue
        for k in range(K + 1):
            if i+j+k == S:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = input().split()

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(int(K) + 1):
    if i + int(K) + 1 + int(K) + 1 < int(S):
        continue
    for j in range(int(K) + 1):
        if j + int(K) + 1 + int(K) + 1 < int(S):
            continue
        for k in range(int(K) + 1):
            xyz = i + j + k
            if xyz == int(S):
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = input().split()

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(int(K)+1):
    for j in range(int(K)+1):
        for k in range(int(K)+1):
            xyz = i + j + k
            if xyz == int(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:
import itertools

N, K = map(int, input().split())
candidate = list(range(N+1))
comb = list(itertools.product(candidate, repeat=3))
l = [c for c in comb if sum(c) == K]

print(len(l))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N, K = map(int, input()  .split())
candidate = list(range(N+1))
comb = list(itertools.product(candidate, repeat=3))
i = 0
for c in comb:
    if sum(c) == K:
        i += 1

print(i)

Submission status: Time Limit Exceeded

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

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

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

print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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
        break

print(a)

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

NUMS = list(range(K+1))

count = 0

for x in NUMS:
  for y in NUMS:
    for z in NUMS:
      if x + y + z == S:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
k,s = list(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:
K, S = map(int, input().split())
answer = 0
for X in range(K + 1):
    for Y in range(K + 1):
        for Z in range(K + 1):
            if X + Y + Z == S:
                answer += 1

print(answer)

Submission status: Time Limit Exceeded

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

import sys
input = sys.stdin.readline

def main():
    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):
                # for make turple (x,y,z)
                # and calculate Sum of turple
                if sum((x,y,z)) == S:
                    count += 1
                    
    print(count)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    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):
                # for make turple (x,y,z)
                # and calculate Sum of turple
                if sum((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())

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(min(S-x, K), -1, -1):
    if x+y >S:
      continue
    for z in range(min(S-x-y, K), -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(K, -1, -1):
    if x+y >S:
      continue
    for z in range(min(S-x-y, K), -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(K, -1, -1):
    if x+y >S:
      continue
    for z in range(K, -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  for y in range(K, -1, -1):
    if x+y >S:
      continue
    for z in range(K, -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
if K*3<S:
  print(0)
  exit()

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(K, -1, -1):
  for y in range(K, -1, -1):
    for z in range(K, -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S = 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
      elif x+y+z >S:
        break
    if x+y >S:
      break

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 入力
k,s=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())
a = [x+y+z for x in range(k+1) for y in range(k+1) for z in range(k+1)\
    if s == x+y+z]
print(len(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in range(K + 1):
    tmp = S
    if tmp - x == 0:
        res += 1
        continue
    for y in range(K + 1):
        if tmp - x - y == 0:
            res += 1
            continue
        for z in range(K + 1):
            if tmp - x - y - z == 0:
                res += 1
                continue
print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = [int(i) for i in input().split()]
AA = [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(AA))

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

Submission status: Time Limit Exceeded

Solution code:
k, s = (int(i) for i in 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 = [int(num) for num 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(' '))
r = 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:
                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 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())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


for i in x:
	for j in y:
		for k in z:
			if s - i - j <= (k+1) and i + j + k == s:
				ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:

k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)

for i in x:
	for j in y:
		for k in z:
			if i + j + k == s:
				ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
line = input().split(" ")
k = int(line[0])
s = int(line[1])
count = 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:
line = input().split(" ")
k = int(line[0])
s = int(line[1])
count = 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:
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())
k += 1
count = 0
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == s:
                count += 1
            elif x + y + z > s:
                continue
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
k += 1
count = 0
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_pattern = 0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      if s == a + b + c:
        cnt_pattern += 1
        if s < a + b + c:
          break
print(cnt_pattern)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
count=0
for i in range(K+1):
  X=i
  if S-i>=0:
    for j in range(K+1):
      Y=j
      Z=S-i-j
      #print(X,Y,Z)
      if S-i-j>=0 and X<=K and Y<=K and Z<=K:
        #print('correct!',X,Y,Z)
        count+=1
      elif Z<0:
        break
  else:
    break
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
count=0
for i in range(K+1):
  X=i
  if S-i>=0:
    for j in range(K+1):
      Y=j
      Z=S-i-j
      #print(X,Y,Z)
      if S-i-j>=0 and X<=K and Y<=K and Z<=K:
        #print('correct!',X,Y,Z)
        count+=1
  else:
    break
print(count)

Submission status: Time Limit Exceeded

Solution code:
KS = list(map(int,input().split()))
K=KS[0]
S=KS[1]

XYZ = [[z,y,x] for z in range(0,K+1) for y in range(0,K+1) for x in range(0,K+1) if (x+y+z)==S]

print(len(XYZ))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S=list(map(int, input().split()))
c=0
d=0
e=0
for x in range(K+1):
    for y in range(x+1):
        for z in range(y+1):
            if x+y+z==S:
                if x!=y and y!=z and z!=x:
                    c+=1
                if (x==y and y!=z) or (y==z and z!=x) or (z==x and x!=y):
                    d+=1
                if x==y==z:
                    e+=1
print(6*c+3*d+e)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, 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:
                cnt += 1
            elif x + y + z > S:
                break

print(cnt)

Submission status: Time Limit Exceeded

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


    if(S<=3725):
        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
    else:
        for x in reversed(range(0, K+1)):
            for y in reversed(range(0, K+1)):
                for z in reversed(range(0, K+1)):
                    if(x+y+z==S):
                        count+=1
    print(count)

main()

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

Submission status: Time Limit Exceeded

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

count = 0

for x in range(k):
    for y in range(k):
        for z in range(k):
            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 x in range(K+1):
    for y in range(K+1):
         for z in range(K+1):
            if S== x+y+z:
                cnt +=1
            else:
                continue

print(cnt)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
count1 = 0
count2 = 0
count3 = 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:
                if x==y and y==z and z==x:
                    count1+=1
                elif x!=y and y!=z and z!=x:
                    count2+=1
                else:
                    count3+=1
sum = count1+count2*6+count3*3
print(sum)

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

Submission status: Time Limit Exceeded

Solution code:
[k,s]=list(map(int,input().split()))
counter=0
for i in range(s+1):
	for j in range(0,s-i+1):
		if i<=k and j<=k and s-i-j<=k:
			counter+=1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

k,s = [int(x) for x in stdin.readline().rstrip().split()]

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

print(point)

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

Submission status: Time Limit Exceeded

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

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

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

print(r)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(K+1):
    xyz = 0
    if S < x:
        break
    for y in range(K+1):
        if S < x+y:
            break
        for z in range(K+1):
            if x+y+z == S:
                ans += 1
            elif S < x+y+z:
                break

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 = 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:

l = list(map(int,input().split()))

count = 0

for x in range(l[0] + 1):
    for y in range(l[0] + 1):
        for z in range(l[0] + 1):
            if x + y + z == l[1]:
                count += 1

print(count)