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

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, x):
        for z in range(0, y):
            if x + y + z == s:
                count += 6

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
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 = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
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:
import itertools
k, s = map(int, input().split())
lst1 = [x for x in range(k+1)]
lst2 = [x for x in range(k+1)]
lst3 = [x for x in range(k+1)]
data = list(itertools.product(lst1, lst2, lst3))
lst4 = [sum(i) for i in (data)]
print(lst4.count(s))

Submission status: Time Limit Exceeded

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

for i in itertools.product(range(K+1), repeat=2):
    if (S - sum(i)>=0) and (S - sum(i)<=K):
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

for i in itertools.product(range(K+1), repeat=3):
    if sum(i) == S:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
K, S = map(int, input().split())
ans = 0
for i in itertools.product(range(S+1), repeat=2):
  if all([j <= K for j in i]):
    Z = S - sum(i)
    if 0 <= Z <= K:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
K, S = map(int, input().split())
ans = 0
for i in itertools.product(range(S+1), repeat=3):
  if sum(i) == S and all([j <= K for j in i]):
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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


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+=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:
k, s = [int(n) for n in 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(k+1):
    for y in range(k+1):
        for z in range(k+1):
            sum = x+y+z
            if sum == 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 m in range(k + 1):
            if i + j + m == s:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(K+1) :
    for j in range(K+1) :
        if S-i-j>K or S-i-j<0 :
             continue
        A.append([i,j,S-i-j])

print(len(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):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                count+=1
                break
                
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
for x in range(k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            if x+y+z==s:
                if x==y and y==z:
                    count += 1
                elif x==y or y==z or z==x:
                    count += 3
                else:
                    count += 6
print(count)
print("\n")

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
K,S = map(int,input().split())
print(sum([i+j+k==S for i,j,k in itertools.product(range(0,K+1),range(0,K+1),range(0,K+1))]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

K, S = map(int, input().split())
count = 0
for v in itertools.combinations(range(S + 2), 2):
    x = v[0]
    y = v[1] - v[0] - 1
    if max(x, y, S - x - y) <= 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())

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

print(ans)

Submission status: Time Limit Exceeded

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

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

def resolve():
    ks = input().split(" ")
    k = int(ks[0])
    s = int(ks[1])

    n = 0

    for zz in range(k+1):
        for yy in range (k+1):
            for xx in range (k+1):
                if (xx+yy+zz == s):
                    n += 1

    print(n)

if __name__ == "__main__":
    resolve()

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

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 = list(map(int,input().split()))
counter = 0
counter_d = 0
counter_tri =0
for i in range(K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            if i+j+k ==S:
                counter +=6
for i in range(K+1):
    for k in range(K+1):
       if 2*i+k== S:
           if i == k:
               counter += 1
           else:
               counter +=3
print(counter)

Submission status: Time Limit Exceeded

Solution code:
K,S = list(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 i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):ans+=1 if i+j+k==S else 0
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# 組み合わせをカウントする変数
count = 0

# 変数の初期化
x = 0
y = 0
z = 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 l in range(k+1):
      if i+j+l==s:
        ans += 1
        
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
from itertools import product
ans = 0
for x,y,z in product(range(k+1), repeat=3):
    #print(x,y,z)
    if x+y+z == s:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                count += 1
print(count)

Submission status: Time Limit Exceeded

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

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

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:
# B - Sum of Three Integers(https://atcoder.jp/contests/abc051/tasks/abc051_b)
k, s = map(int, input().split())
cnt = 0
for a in range(0, k + 1):
    for b in range(0, k + 1):
        for c in range(0, k + 1):
            if a + b + c == s:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
K,S = map(int,input().split())
if K < 2 or K > 2500:
  sys.exit()

X = 0
count = 0
while X <= K:
  Y = 0
  while Y <= K:
    Z = S - X - Y
    if Z <= K and Z >= 0:
      count += 1
    Y += 1
  X += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
K,S = map(int,input().split())
X,Y,Z = 0,0,0
if K < 2 or K > 2500:
  sys.exit()
if X > K or Y > K or Z > K:
  sys.exit()
 
X = 0
count = 0
while X <= K:
  Y = 0
  while Y <= K:
    Z = 0
    while Z <= K:
      if X + Y + Z == S:
        count += 1
      Z += 1
    Y += 1
  X += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
X = 0
count = 0
while X <= K:
  Y = 0
  while Y <= K:
    Z = 0
    while Z <= K:
      if X + Y + Z == S:
        count += 1
      Z += 1
    Y += 1
  X += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools
 
k,s = map(int, input().split())
l = np.arange(k+1)
 
p = np.array(list(itertools.product(l,repeat=2)))
p = np.array(s - np.sum(p,axis=1))
p = np.array(p[p>=0])
print(np.count_nonzero(p<=k))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools

k,s = map(int, input().split())
l = np.arange(k+1)
ans = 0

p = np.array(list(itertools.combinations_with_replacement(l,3)))
p = p[np.sum(p,axis=1)==s]
p = np.array([np.unique(row).size for row in p])

print(np.count_nonzero(p==1)+np.count_nonzero(p==2)*3+np.count_nonzero(p==3)*6)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools

k,s = map(int, input().split())
l = np.arange(k+1)

p = np.array(list(itertools.product(l,repeat=3)))

print(np.count_nonzero(np.sum(p,axis=1)==s))

Submission status: Time Limit Exceeded

Solution code:
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/16
# Filename: main 
# Author: acto_mini

def main():
    K, S = map(int, input().split())

    ans = 0
    for i in range(K + 1):
        for j in range(K + 1):
            for p in range(K + 1):
                if (i + j + p) == S: ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools

def main():
    k,s=map(int,input().split())
    count = 0
    for x,y,z in itertools.product(range(k+1), repeat=3):
        if x + y + z == s:
            count += 1
    print(count)
        
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

dic = {}
for i in range(K + 1):
    for j in range (K + 1):
        r = S - i - j
        if r in dic.keys():
            dic[r].append((i, j))
        else:
            dic[r] = [(i, j)]

ans = 0
for k in range(K + 1):
    if k in dic.keys():
        ans += len(dic[k]) 

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for x in range(a + 1):
    # print("Xです{}".format(x))
    for y in range(a + 1):
        # print("Yです{}".format(y))
        for z in range(a + 1):
            # print("Zです{}".format(z))
            if x + y + z ==b:
                flag +=1
print(flag)

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-*-

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


if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

a = min(k,s)

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

print(ans)

Submission status: Time Limit Exceeded

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

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):
    for Z in range(0,K+1):
      if X+Y+Z==S:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
k,s=map(int,input().split())
x=(x for x in range(0,k+1))
y=(y for y in range(0,k+1))
z=(z for z in range(0,k+1))
data=list(itertools.product(x,y,z))
ans=[sum(i) for i in (data)]
print(ans.count(s))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys
input = sys.stdin.readline
k,s=map(int,input().split())
x=[x for x in range(0,k+1)]
y=[y for y in range(0,k+1)]
z=[z for z in range(0,k+1)]
data=list(itertools.product(x,y,z))
ans=[sum(i) for i in (data)]
print(ans.count(s))

Submission status: Time Limit Exceeded

Solution code:
import itertools
k,s=map(int,input().split())
x=[x for x in range(0,k+1)]
y=[y for y in range(0,k+1)]
z=[z for z in range(0,k+1)]
data=list(itertools.product(x,y,z))
ans=[sum(i) for i in (data)]
print(ans.count(s))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    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)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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:
#SumofThreeIntegers
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:
from sys import stdin
K, S = map(int, stdin.readline().rstrip().split())
l = list(i for i in range(K+1))
def binary_search(list, item):
    count = 0
    low = 0
    high = len(list) - 1
    while low <= high:
        if (low + high) % 2 == 0:
            mid = (low + high) // 2
        else:
            mid = (low + high) // 2 - 1
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1
    return None
count = 0
for i in range(K+1):
    for j in range(K+1):
        if binary_search(l, S - i - j):
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

count1 = 0
count2 = 0
count3 = 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:
                count1 += 1
                if x == y or y == z or z == x:
                    count2 += 1
                    if x == y and y == z:
                        count3 += 1
                
print(count1*6 - count2*3 - count3*2)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
K, S = map(int, stdin.readline().rstrip().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(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())
c=0

for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s:
                c+=1
            elif l+m+n>s:
                break
print(c)

Submission status: Time Limit Exceeded

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

for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s:
                c+=1
                
print(c)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = 0
three = [0, 0, 0]

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

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int, input().split());
ans=int(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:
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

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

Submission status: Time Limit Exceeded

Solution code:
import sys

num = sys.stdin.readline().split(' ')
K = int(num[0])
S = int(num[1])

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
            else:
                continue

print(counter)

Submission status: Time Limit Exceeded

Solution code:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            if x+y == b:
                ans += 1
            elif  x + y < b:
                for z in range(a+1):
                    if x + y + z == b:
                         ans += 1
                    elif x + y + z > b:
                        break

    return ans

print(main())

Submission status: Time Limit Exceeded

Solution code:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            if x+y == b:
                ans += 1
            elif  x + y < b:
                for z in range(a+1):
                    if x + y + z == b:
                         ans += 1

    return ans

print(main())

Submission status: Time Limit Exceeded

Solution code:
def main():
    ans = 0
    a,b = map(int,input().split())
    for x in range(a+1):
        for y in range(a+1):
            for z in range(a+1):
                if x + y + z == b:
                      ans += 1
    return ans

print(main())

Submission status: Time Limit Exceeded

Solution code:
ks = list(map(int, input().split()))
k = min(ks)
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if ks[1] == x + y + z:
                ans += 1
            else:
                pass

print(ans)