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

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

    if 0<=z<=k:
        count+=1

print(count)

Submission status: Wrong Answer

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=nums

count=0

for i in x:
    for j in y:
        z=s-(i+j)

    if 0<=z<=k:
        count+=1

print(count)

Submission status: Wrong Answer

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=nums

count=0

for i in x:
    for j in y:
        z=s-(i+j)

    if nums.count(z):
        count+=1
print(count)

Submission status: Wrong Answer

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=z=nums

count=0

for i in x:
    for j in y:
        a=s-(i+j)

    if z.count(a)==1:
        count+=1
print(count)

Submission status: Wrong Answer

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

nums=[]

for i in  range(k+1):
    nums.append(i)

x=y=z=nums

count=0

for i in x:
    for j in y:
        x=s-(i+j)

    if z.count(x)==1:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
            print( i )
            print( j )
            if  S - (i + j) >= K  :
                cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
                if  S - (i + j) <= K :
                    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
                if  S - (i + j) >= K :
                    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
                if  S - i + j <= K :
                    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
K , S = map(int, input().split())
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
    cnt = 1
else :
    for i in range(A):
        for j in range(A):
                if  S - i + j >= K :
                    cnt += 1

print(cnt)

Submission status: Wrong Answer

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

ar = itertools.product(range(K+1), repeat=2)

ans = 0
for a,b in ar:
  if S - a-b <= K and S-a-b >= K: ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

l=[]
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        l.append([i,j,k])

print(itertools.permutations(l))

Submission status: Wrong Answer

Solution code:
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

ans = [[X,Y] for X in range(2, K+1) for Y in range(2, K+1) if (0<=(S-X-Y)) and ((S-X-Y)<=K)]
print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools

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

#if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
#    exit()

ans = [[x,y,z] for x in range(2, K+1) for y in range(2, K+1) for z in range(2, K+1) if (x+y+z)==S]
print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

ans = [[x,y,z] for x in range(2, K+1) for y in range(2, K+1) for z in range(2, K+1) if (x+y+z)==S]
print(len(ans))

Submission status: Wrong Answer

Solution code:
k, s = [int(x) for x in input().split()]
xRange = min(k, s) - max(0, s - (2 * k)) + 1
print(xRange * (xRange + 1) // 2)
# print(*data, sep='\n')

Submission status: Wrong Answer

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

ans = 0
for x in range(K+1):
    if K < (S - x) //2:
        ans +=  0
    elif K < (S - x):
        ans += K * 2 - (S - x) + 1
    else:
        ans += (S - x) + 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x =0

for i in range(min(k+1,s+1)):
    x += max(0, min(s-i,k)+1 - max(0,s-i-k) )
    print(x)
print(x)

Submission status: Wrong Answer

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

x =0

for i in range(min(k+1,s+1)):
	x += max(0, min(k-i,s)+1 - max(0,k-i-s))
print(x)

Submission status: Wrong Answer

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

x =0

for i in range(k+1):
    for j in range(k+1-i):
        for l in range(k+1-i-j):
            if i + j + l == s:
                x +=1

print(x)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(s//3-1, k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
            
print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(s//3+1, k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
            
print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(s//3, k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
        elif z < 0:
            break
            
print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(s//3, k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
            
print(count)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
ks = [_ for _ in range(s//3, k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        for ksk3 in ks:
            if s == ksk1 + ksk2 + ksk3:
                count += 1
            
print(count)

Submission status: Wrong Answer

Solution code:
# 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する

k, s = map(int,input().split())
xmin = (k - 2 * s) if (k - 2 * s) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  ymin = (k - s - x) if (k - s - x) > 0 else 0
  ymax = k if k < s - x else s - x
  for y in range(ymin, ymax+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

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

Submission status: Wrong Answer

Solution code:
#!/bin/python3

ma, target = [int(i) for i in input().split()]

count = 0
ma += 1

for a in range(ma):
    for b in range(ma):
        if (target - a + b) < ma:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
input_data = input().split()

k=int(input_data[0])+1
s=int(input_data[1])
count=0

for i in range(k):
  for j in range(k):
    z = s - i - j
    if (0 <= z and z <= k):
      count= count +1
    else:
      pass

print(count)

Submission status: Wrong Answer

Solution code:
import itertools

K,S=map(int,input().split())
l=[]
for x in range(2,K+1):
    for y in range(2,K+1):
        z=S-x-y
        if 2<=z<=K:
            l.append([x,y,z])
print(len(l))

Submission status: Wrong Answer

Solution code:
from itertools import product
k,s = (int(i) for i in input().split())
cnt = 0
for i in range(k-1,-1,-1):
    for j in product(range(1,k-i+1),repeat=2):
        a = [i]+list(j)
        if sum(a) == s:
            cnt += 1
print(cnt+1)

Submission status: Wrong Answer

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

ans = 0
for z in range(round(S/3), K+1):
    for y in range(round((S-z)/2), K+1):
        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):
        if 0<=i+j-s<=k:
            ans+=1

print(ans)

Submission status: Wrong Answer

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


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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    m=0
    for i in range(K+1):
        s=S-i
        if s<=K:
            m+=s+1
        else:
            c=s-K
            s=s-c
            m+=s+1
    print(m)

else:
    s=3*K-S
    print((s+2)*(s+1)//2)

Submission status: Wrong Answer

Solution code:
import math
K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    s=S-math.ceil(K/3)*3
    print((s+2)*(s+1)//2)
else:
    s=3*K-S
    print((s+2)*(s+1)//2)

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
		print(Z)
		if Z >= 0 and Z <= K:
			ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

K,S = map(int, input().split())
cnt = 0
K += 1
for X in range(K):
    if S - X < 0:
        break
    for Y in range(K):
        if S - X - Y < 0:
            break
        if S - X - Y <= K:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def solve(K, S):
    count = 0
    
    for i in range(K+1):
        for j in range(K+1):
            if(0<= S-i-j <= K):
                print(i, j)
                count += 1
    print(count)

if __name__ == '__main__': 
    K, S = map(int, input().split())
    
    solve(K, S)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      if a + b + c == S:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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


def solve(K: int, S: int):
    ans = 0
    ## TLE
    # for i in range(K+1):
    #     for j in range(K+1):
    #         for r in range(K+1):
    #             if(i+j+r == S):
    #                 ans += 1

    for i in range(K+1):
        for j in range(K*2+1):
            if(i+j == S):
                if(j == 2*K):
                    ans += 1
                else:
                    ans += 2 

    print(ans)
    return


# Generated by 1.1.4 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: Wrong Answer

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

s = 0

X = max(0,S-2*K)
while X <= K:
    s += min(K,S-X) - max(0,S-X-K) + 1
    X += 1

print(s)

Submission status: Wrong Answer

Solution code:
k, s = (int(i) for i in input().split())
t = 0
for i in range(k+1):
    if 2*k > s:
        t += s - i + 1
    else:
        if s - i > 2*k:
            continue
        else:
            t += 2*k - s + i + 1
print(t)

Submission status: Wrong Answer

Solution code:
a, b = (int(i) for i in input().split())  
print(sum([min(2*a+i-b+1,b-i+1) for i in range(a+1) if 2*a+i-b+1 > 0]))

Submission status: Wrong Answer

Solution code:
a, b = (int(i) for i in input().split())  
x = [2*a+i-b+1 for i in range(a+1) if 2*a+i-b+1 > 0]
print(sum(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC51 B
k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
elif s == 0 or s == 1:
    print(0)
else:
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            remainder = s - i - j
            if 0 <= remainder <= k:
                ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
#ABC51 B
k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
elif s == 0 or s == 1:
    print(0)
else:
    ans = 0
    for i in range(k):
        for j in range(k):
            remainder = s - i - j
            if 0 <= remainder <= k:
                ans += 1
    print(ans//2*3)

Submission status: Wrong Answer

Solution code:
#ABC51 B
k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
elif s == 0 or s == 1:
    print(0)
else:
    ans = 0
    for i in range(k):
        remainder = s - i
        for j in range(remainder//2 + 1):
            rer = remainder - j
            sets = [i, j, rer]
            sets.sort()
            if sets not in done:
                done.append(sets)
    print(len(done)*3)

Submission status: Wrong Answer

Solution code:
import itertools
k,s=map(int,input().split())
n=0
l=[a for a in range(k+1)]
for c  in itertools.combinations(l, 3):
	if sum(c)==s:
		n+=1
print(n)

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

Submission status: Wrong Answer

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

#%%
k = 2
s = 2

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

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
n=3*k-s-1
print(n*-~n//2or 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

if K >= S:
    cnt+=3

def cnt2(k, s):
    if 2 * k >= s:
        if s - 1 <= k:
            return s-1
        else:
            return k-(s-k)+1
    else:
        return 0

cnt+=3*cnt2(K, S)

for x in range(1, K+1):
    if S-x <=0:
        break
    cnt += cnt2(K, S-x)

print(cnt)

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split())
if 3*k!=s:
  n=abs(3*k-s-1);
else:
  n=1
print(int(-~n*n/2))

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split());n=abs(3*k-s+1);print(int(-~n*n/2))

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split());n=abs(s-3*k)+1;print(int(-~n*n/2))

Submission status: Wrong Answer

Solution code:
k,s=map(int,input().split());n=abs(s-3*k+1);print(int(-~n*n/2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num = 0
for x in range(sk[0] + 1):
	for y in range(sk[0] + 1):
		if x + y >= sk[1]:
			num += 1
        

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
                break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# カウンター
c=0

for X in range(K+1):
  for Y in range(X,K+1):
    Z=S-(X+Y)

    if Z>=0 and Z<=K:
      # X=Y=Zの場合
      if X==Y and Y==Z:
        c+=1
      # 2つの数が同じ場合
      elif X==Y:
        c+=3
      # 3つの数がバラバラの場合
      elif X!=Y and X!=Z and Y!=Z:
        c+=6

# 出力
print(c)

Submission status: Wrong Answer

Solution code:
k, s = list(map(int, input().split()))
ct = 0
for x in range(k+1):
    for y in range(x, k+1):
        if x + y > s:
            break;
        for z in range(y, k+1):
            if x + y + z == s:
                if x == y and y == z:
                    ct += 1
                elif x != y and y != z and z != x:
                    ct += 3
                else:
                    ct += 2
                break;
print(ct)

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 <= z and z <= K):
           ans += 1;

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<=z<=K):
            ans += 1
        elif(0<z):
            break
print(ans)

Submission status: Wrong Answer

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

c = 0

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

Submission status: Wrong Answer

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

c = 0

if s == 3*k:
  c = 1
elif s >= 2*k:
  c = (5 - s % k) * 3
elif s >= k:
  pass
else:
  c = 3 * k
  
print(c)

Submission status: Wrong Answer

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

print(result)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    ks = input()
    k, s = [int(i) for i in ks.split()]

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

    print(c)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
count = 0
for X in range(0, K+1):
	for Y in range(X, K+1):
		for Z in range(Y, K+1):
			if X > S//3:
				break
			if Y > S:
				break
			if Z > S:
				break
			if X+Y+Z == S:
				print(X, Y, Z)
				i = set([X, Y, Z])
				if len(i) == 1:
					count += 1
				elif len(i) == 2:
					count += 3
				elif count == 3:
					count += 6

print(count)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
count = 0
for X in range(0, K+1):
	for Y in range(X, K+1):
		for Z in range(Y, K+1):
			if X > S//3:
				break
			if X+Y+Z == S:
				# print(X, Y, Z)
				i = set([X, Y, Z])
				if len(i) == 1:
					count += 1
				elif len(i) == 2:
					count += 3
				elif count == 3:
					count += 6

print(count)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
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:
				ans.append(set([X, Y, Z]))
count = 0
for i in ans:
	if len(i) == 1:
		count += 1
	elif len(i) == 2:
		count += 3
	elif count == 3:
		count += 6
print(count)

Submission status: Wrong Answer

Solution code:
#AtCoder Beginner Contest 051 B - Sum of Three Integers
k, s = map(int, input().split())
cnt = 0
for l in range(k+1):
    for m in range(k+1):
        if k<=l+m<=s and s-l-m<=k:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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) :
    tmp = S - i - j 
    if 0 <= tmp and tmp <= K :
      ans += 1
    else:
      break
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):
        if S - (x + y) <= K:
            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 x + y + z == S:
                ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, raw_input().split())
cnt = 0
for i in range(0, K+1):
	if S - i <= 2 * K:
		for j in range(0, K+1):
			if S - i - j <= 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):
    if i>k:
        break
    cnt+= max(0,min(i+k,s)-max(s-k,s-i)+1)
print(cnt)

Submission status: Wrong Answer

Solution code:
def main(input_str):
    nums = list(map(int, input_str.split()))

    result_list = []
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            for num_3 in range(nums[0]+1):
                result = num_1 + num_2 + num_3
                print(result)
                if result == nums[1]:
                    result_list.append(result)

    return len(result_list)


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    K,S = (int(_) for _ in input().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):            
            if(K+1 >= S - x - y and S - x - y >= 0):
                ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
ans = 0
if (K*3//2)>S:
    for i in range((((K*3)//2)-S)+3):
        ans += i
else:
    for i in range((K*3-S)+2):
        ans += i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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