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: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import itertools

K, S = map(int, input().split())
num = list(range(K+1))
count = 0
for i in itertools.combinations_with_replacement(num, 3):
    x, y, z = i[0], i[1], i[2]
    if x + y + z == S:
        if x == y and y == z:
            count +=1
        else:
            count +=3
print(count)

Submission status: Wrong Answer

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

if S%3==0:
    x=int(S/3)
elif S%2==0:
    x=int(S/2)
else:
    x=int(S)

ans=0

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

print(ans)

Submission status: Wrong Answer

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

# if S%3==0:
#     x=int(S/3)
# elif S%2==0:
#     x=int(S/2)
# else:
#     x=int(S)

ans=0

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

print(ans)

Submission status: Wrong Answer

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

if S%3==0:
    x=int(S/3)
elif S%2==0:
    x=int(S/2)
else:
    x=int(S)

ans=0

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

print(ans)

Submission status: Wrong Answer

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

if S%3==0:
    x=int(S/3)
elif S%2==0:
    x=int(S/2)
else:
    x=int(S)

print("x=",x)
ans=0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

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

c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1):
    if s<x+y:
      break
    else:
      c+=1
print(c)

Submission status: Wrong Answer

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

c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1-x):
    for z in range(m+1-x-y):
      if x+y+z==s:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
k, s = 5, 15
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: Wrong Answer

Solution code:
k, s = 2, 2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and x+y+z == s:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
if S == 0:
  print(1)
  exit()
z = 0
o = 0
t = 0
start = min(S,K)
for i in reversed(range(start+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    print(num)
    if num == 1:
      if (S-i) % 2 == 0 or min(S-i,i) == i:
        z -= 1
        o += 1
    else:
      if (S-i) % 2 == 0:
        z -= 1
        o += 1
      if min(S-i,i) == i:
        z -= 1
        o += 1
        
      
if S % 3 == 0:
  t += 1
  o -= 1
print(z*6 + o*3 + t)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
if S == 0:
  print(1)
  exit()
z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if num == 1:
      if (S-i) % 2 == 0 or min(S-i,i) == i:
        z -= 1
        o += 1
    else:
      if (S-i) % 2 == 0:
        z -= 1
        o += 1
      if min(S-i,i) == i:
        z -= 1
        o += 1
        
      
if S % 3 == 0:
  t += 1
  o -= 1
print(z*6 + o*3 + t)

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
if S == 0:
  print(1)
  exit()
z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if (S-i) % 2 == 0:
      z -= 1
      o += 1
    if num > 1 and min(S-i,i) == i:
      z -= 1
      o += 1
if S % 3 == 0:
  t += 1
  o -= 1
print(z*6 + o*3 + t)

Submission status: Wrong Answer

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

z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if (S-i) % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1
if S % 3 == 0:
  t += 1
  o -= 1
#print(z,o,t)
print(z*6 + o*3 + t)

Submission status: Wrong Answer

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

z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    #print(num)
    if S-i % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1 
if S % 3 == 0:
  t += 1
  o -= 1
#print(o,z,t)
print(z*6 + o*3 + t)

Submission status: Wrong Answer

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

z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    print(num)
    if S-i % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1 
if S % 3 == 0:
  t += 1
  o -= 1
print(o,z,t)
print(z*6 + o*3 + t)

Submission status: Wrong Answer

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

ans = 0
for i in range(K+1):
  mod = S - i
  if mod-K <= K:
    plus = min(2*K+1-mod, mod+1)
    ans += plus
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    k,s = map(int, stdin.readline().rstrip().split())
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(k+1):
        if i>s:
            break
        for j in range(i,k+1):
            z = s-i-j
            if z <= k:
                ans += 1
    print(ans)








if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
k, s = 2,2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if k >= z >= 0:
            	ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
k, s = 2,2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if z >= 0:
            	ans += 1
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
k, s = 2,2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if s-x-y >= 0:
            if x+y+(s-x-y) == s:
            	ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
cnt = 0
for i in range(n+1):
  for j in range(n+1):
    if m-i-j <= n:
      cnt += 1	
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
cnt = 0
for i in range(n+1):
  for j in range(n+1):
    if m-i+j <= n:
      cnt += 1	
print(cnt)

Submission status: Wrong Answer

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

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if 0 <= S - X - Y <= S:
            res += 1
print(res)

Submission status: Wrong Answer

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

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if S - X - Y >= 0:
            res += 1
print(res)

Submission status: Wrong Answer

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)
print(res)

Submission status: Wrong Answer

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)*2
print(res)

Submission status: Wrong Answer

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)*(S-ed)//2 # Σ^n{k} = n*(n+1)/2
print(res)

Submission status: Wrong Answer

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed)*(S-ed-1)//2 # Σ^n{k} = n*(n+1)/2
print(res)

Submission status: Wrong Answer

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

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

k, s = rm()
li = list(range(s//3, k+1))
cnt = 0
for i in list(itertools.product(li, repeat=3)):
  if sum(i) == s:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        l = s-(i+j)
        print(i,j,l)
        if i+j+l == s and l >= 0 and l <= k and i <= k and j <= k:
            #print("解：",i,j,l)
            count += 1
print(count)

Submission status: Wrong Answer

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

cnt = 0

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

Submission status: Wrong Answer

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

cnt = 0

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

Submission status: Wrong Answer

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

cnt = 0

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
ans=0
for i in range(S+1):
  if S-i<i:
    break
  for j in range(i,S+1):
    if S-i-j<j:
      break
    for k in range(j,S+1):
      if i+j+k==S:
        if i==j==k:
          ans+=1
        else:
          if i==j or j==k or k==i:
            ans+=3
          else:
            ans+=6
print(ans)

Submission status: Wrong Answer

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 <= k and z<=k:
            ans += 1 
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    tmp=s-i
    if tmp<=k:
        ans+=tmp+1
    elif 2*k<tmp:
        pass
    else:
        tmp1=2*k-tmp
        ans+=tmp1+1
    # print(tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    tmp=s-i
    if tmp<=k:
        ans+=tmp+1
    else:
        tmp1=2*k-tmp
        if tmp1>=0:
            ans+=tmp1+1
    # print(tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(K+1) :
    if S-i>2*K :
        continue
    elif S-i<=K :
        ans+=S-i+1
    elif S-i<0 :
        break
    else :
        ans+=2*K+i-S+1

print(ans)

Submission status: Wrong Answer

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

for i in range(K+1) :
    if S-i>2*K :
        continue
    if S-i<=K :
        ans+=S-i+1
    else :
        ans+=2*K+i-S+1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

ins = lambda: map(int,sys.stdin.readline().split(' '))

k,s = ins()

result = 0

for x in range(k+1):
    for y in range(k+1):
        if (s-x-y)<=k:
            result+=1
        
            
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def fact(n):
  factorial = 1
  for i in range(1, n + 1):
    factorial *= i
  return factorial

def ncr(n, r):
  return fact(n) / (fact(r) * fact(n - r))


k, s = input().split()
k = int(k)
s = int(s)
count = 0
count += ncr(s + 3 - 1, 3 - 1)
count -= 3 * ncr(s - k - 1 + 3 - 1, 3 - 1)
count += 3 * ncr(s - 2*k - 2 + 3 - 1, 3 - 1)
print(int(count))

Submission status: Wrong Answer

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

count = 0
for i in range(K+1):
    for j in range(K+1):
        count += max(0, S-i-j+1)

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

p = (min(2*K, S) - max(0, S-K) +1)

ans = 0
while p>0:
    ans += p
    p -=1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
K, S = map(int, input().split())

n_int = 0

for z in range(min(K, S)+1):
    for y in range(min(K, S-z)+1):
        n_int += 1

print(n_int)

Submission status: Wrong Answer

Solution code:
k,s = list(map(int,input().strip().split()))
res = 0
for a in range(k+1):
  res += (s-a)+1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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):
            com=X+Y+Z
            if(com==S):
                count+=1
            else:
                pass
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = 0

if s <= k:
  l = int((k+2)*(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 0
for x in range(K+1):
  tmp = x
  if tmp > S:
    continue
    for y in range(K+1):
      tmp = x+y
      if tmp > S:
        continue
        for z in range(K+1):
            ans = x+y+z
            if ans == S:
                count += 1
                
print(count)

Submission status: Wrong Answer

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(S-i-j):
            if i+j+k == S:
                counter += 1
            else:
                continue

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


ans_ls = [0 for _ in range(K*3+1)]

for n in range(K+1):
  if n <= K:
    ans_ls[n] = (n+1)*(n+2)//2
    ans_ls[-1*n-1] = (n+1)*(n+2)//2

sum_ans = sum(ans_ls)

if K%2 == 0:
  ans_ls[(K//2)*3] = (K+1)**3-sum_ans
else:
  ans_ls[(K*3//2)] = ((K+1)**3-sum_ans)//2
  ans_ls[(K*3//2)+1] = ((K+1)**3-sum_ans)//2

print(ans_ls[S])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = c*3
        else:
            num = num*3
    print(num)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num*3
    print(num)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = c*3
    print(num)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num
    print(num)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = b *3
    print(num)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num *3
    print(num)

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
# init (x<=y<=z)
if k<s:
    z=k
    if k<s-z:
        y=k
        x = s-2*k
    else:
        y=s-z
        x=0
else:
    z=s
    x,y = 0, 0
print(len(sum([[None for j in range(z-x-i+1)] for i in range(z-y+1)], [])))

Submission status: Wrong Answer

Solution code:

import itertools

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

for x,y in list(itertools.product(X, X)):
    if x+y <= S and x+y+K>=S:
        count+=1
        print(x,y)

print(count)

Submission status: Wrong Answer

Solution code:

import itertools

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

for x,y in list(itertools.product(X, X)):
    if x+y >= S-K:
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
# 2017-01-07
import itertools

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

for x,y,z in list(itertools.product(X, Y, Z)):
    if x+y+z == S:
        print(x,y,z)
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import itertools

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

for x,y,z in list(itertools.product(X, Y, Z)):
    if x+y+z == K:
        count+=1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

for i in range(1,k+1):
  for j in range(1,k+1):
    if s - i -j >= 0 and  s - i -j <= k:
      cnt += 1

print(cnt)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = []
for x in range(k + 1):
    for y in range(x, k + 1):
        if 0 <= s - x - y <= k:
            ans.append((x, y, s - x - y))

print(ans)

Submission status: Wrong Answer

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

idx = 0

#for x in range(int(k/3)+1):
for x in range(k+1):
    if x > s/3:
        continue
    for y in range(x, k+1):
        if (s - x) < 2 * y:
            # z = s - x - y
            # z >= y
            # =>
            # subject to : s - x - y >= y
            continue
        for z in range(y, k+1):
            if s == x+y+z:
                if len(set((x,y,z))) == 1:
                    idx += 1 # 3 = 1+1+1 # 1組み合わせのみ
                else:
                    idx += 3 # 2=1+1+0 # 0の位置によって3パターン

print(idx)

Submission status: Wrong Answer

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

idx = 0

for x in range(k+1):
    for y in range(x, k+1):
    #for y in range(k+1):
        if x+y > s:
            continue
        for z in range(y, k+1):
        #for z in range(k+1):
            if s == x+y+z:
                #idx += 1
                if len(set((x,y,z))) == 1:
                    idx += 1 # 3 = 1+1+1 # 1組み合わせのみ
                else:
                    idx += 3 # 2=1+1+0 # 0の位置によって3パターン

print(idx)

Submission status: Wrong Answer

Solution code:
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    ret=0
    k,s = map(int,input().split())
    for x in range(k+1):
        for y in range(k+1):
            if s-x-y <= k:
                ret+=1
    print(ret)
 
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(k + 1):
    rest = s - i
    if rest < 0:
        break
    elif rest > 2 * k:
        continue
    else:
        for j in range(k + 1):
            rest2 = rest - j
            if rest2 < 0:
                break
            elif rest2 > k:
                continue
            else:
                ans += k - rest2 + 1
                break

print(ans)

Submission status: Wrong Answer

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

if k * 3 < s:
    print(0)
else:
    r = k * 3 - s
    r = min(k, r, s)
    ans = (r + 2) * (r + 1) // 2

print(ans)

Submission status: Wrong Answer

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

if k * 3 < s:
    print(0)
else:
    r = k * 3 - s
    r = min(r, s)
    ans = (r + 2) * (r + 1) // 2

print(ans)

Submission status: Wrong Answer

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

ans = 0
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z >= 0 and z >= k):
      ans += 1
        
print(ans)