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:
import itertools

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

print('K:{} S:{}'.format(K, S))

cnt = 0
for x, y, z in itertools.product(range(K + 1), repeat=3):
    if x + y + z == S:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:

k,s=map(int,input().split())
count=0
same=0

nums=[i for i in range(k+1)]

for i in range(len(nums)):
  for j in range(i,len(nums)):
    for k in range(j,len(nums)):
      if nums[i]+nums[j]+nums[k]==s:
        count+= 1
        if i==j==k:
          same+=1
print((count*3-2*same))

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split(" "))
print(int((S+2)*(S+1)/2))

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

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

Submission status: Wrong Answer

Solution code:
k,s = [int(x) for x in input().split()]
ans = 0
for x in range(k+1):
    for y in range(x, k+1):
        z = s - x - y
        if x <= y <= z <= k:
            ans += [ None, 1, 3, 6 ][ len(set([ x, y, z ])) ]

Submission status: Wrong Answer

Solution code:
k,s = [int(x) for x in input().split()]
a = 0
n = 0
while a <= k:
  b = 0
  while b <= k:
    z = s-a+b
    if 0<=z and z <= k:
      n += 1
    b += 1
  a += 1
print(n)

Submission status: Wrong Answer

Solution code:
import math
k,s = [int(x) for x in input().split()]
print(math.factorial(k+s-1) // ((math.factorial(k)*math.factorial(2))) )

Submission status: Wrong Answer

Solution code:
import math
k,s = [int(x) for x in input().split()]
print(math.factorial(s)//(math.factorial(k)*math.factorial(2)))

Submission status: Wrong Answer

Solution code:
def abc051_b():
    limit, sum_of_three_int = map(int, input().split())
    ans = 0

    for x in range(limit):
        for y in range(limit):
            z = sum_of_three_int - x + y
            
            if x + y + z == sum_of_three_int:
                ans += 1
    
    return ans 


if __name__ == '__main__':
    print(abc051_b())

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 s-x-y <= 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(x, k+1):
		if s-x-y <= k:
			count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
K, S = map(int, input().split())
cnt=0
for x in range(K+1):
        yz = S - x
        if yz > 2*K:
                continue
        else:
                cnt += yz + 1 - 2 * max(0, yz - K)
print(cnt)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

for i in range(min(0, s - 2 * k), min(s, k) + 1):
  c += min(k, s - i) - max(0, s - i - k) + 1

print(c)

Submission status: Wrong Answer

Solution code:
K, S = list(map(int, input().split()))
if 3 * K == S:
	print(1)
elif 3 * K - 1 == S:
	print(3)
else:
	print(int((3 * K - S ) * (3 * K - S - 1) / 2))

Submission status: Wrong Answer

Solution code:
K, S = list(map(int, input().split()))
if 3 * K == S:
	print(1)
else:
	print(int((3 * K - S ) * (3 * K - S - 1) / 2))

Submission status: Wrong Answer

Solution code:
K, S = list(map(int, input().split()))
if 3 * K == S:
	print(0)
else:
	print(int((3 * K - S ) * (3 * K - S - 1) / 2))

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

Submission status: Wrong Answer

Solution code:
k,s = map(int, input().split())
a = (s+2)*(s+1)/2
b = (s-k+2)*(s-k+1)/2
c = (s-2*k+2)*(s-2*k+1)/2

if s <= k:
    print(int(a))
elif s <= 2*k:
    print(int(a-3*b))
elif s <= 3*k:
    print(int(a-3*b+3*c))

Submission status: Wrong Answer

Solution code:
k,s = map(int, input().split())
a = (s+2)*(s+1)/2
b = (s-k+2)*(s-k+1)/2
c = (s-2*k+2)*(s-2*k+1)/2

if s <= k:
    print(int(a))
elif s <= 2*k:
    print(int(a-3*b))
elif s <= 3*s:
    print(int(a-3*b+3*c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
if S / K <= 1:
    if S % 3 == 0:
        print(S * 3 + 1)
    else:
        print(S *3)
elif S / K == 3:
    print(1)
else:
    if S / K == 2:
        print(3)
    else:
        if S % 3 == 0:
            print(S * 3 + 1)
        else:
            print(S * 3)

Submission status: Wrong Answer

Solution code:
k, s = map(int, input().split())
n = 0
a = k + 1
if k == s:
    n += 3
if k*2 > s:
    n += s*3
for i in range(1,k + 1):
    if (s-i)/2 > k:
        continue
    for j in range(1,k + 1):
        if s-i-j > k:
            continue
        for l in range(1,k + 1):
            if i + j + l == s:
                n += 1
print(n)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
if S / K <= 1:
    if S % 3 == 0:
        print(S * 3 + 1)
    else:
        print(S *3)
elif S / K == 3:
    print(1)
else:
    if S / K == 2:
        print(3)
    else:
        print(3 * (K + 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ct)

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 >= 0 and s - i - j <= k:
			cnt += 1
			print(i,j,s-i-j)

print(cnt)

Submission status: Wrong Answer

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

def solve_2(num):
    if num > k:
        return k - (num-k) + 1
    else:
        return num + 1
ans = 0
first = 0
if s > 2*k:
    first = s -2*k
while first <= k:
    ans += solve_2(s - first)
    first += 1

print(ans)

Submission status: Wrong Answer

Solution code:
K,S=map(int,input().split())
count=0
for X in range(K,-1,-1):
  if S-X>2*K:
    break    
  for Y in range(S-X,-1,-1):
    if 0<=S-(X+Y)<=K:
       count+=1
    elif 0>S-(X+Y):
       continue
    else:    
       break
print(count)

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

Submission status: Wrong Answer

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

for x in range(k+1):
    for z in range(x):
        if 2*x + z == s:
            ans += 1

for x in range(k+1):
    for y in range(x):
        if x + 2*y == s:
            ans += 1

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import os
import sys
import math
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y > s:
                break
            z = s - (x + y)
            if(z>=0):
                ans.append([x,y,z])

    # for i in itertools.product(xrange(k+1), repeat=2):
    #     x, y = i
    #     z = s - sum(i)
    #     if(z >= 0 and z<=k and sum([x,y,z])==s):
    #         ans.append((x,y,z))
    sys.stdout.write("%d" % len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0

if S // K == 3:
    count = 1
else:
    for z in range(K, -1, -1):
        for y in range(K, -1, -1):
            if z >= y and y >= S - z - y and S - z - y >= 0:
                count += 1
    count *= 3

print(count)

Submission status: Wrong Answer

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

count = 0

if S // K == 3:
    count = 1
else:
    for z in range(K, -1, -1):
        for y in range(K, -1, -1):
            if z >= y and y >= S - z - y and S - z - y >= 0:
                print(S - z - y, y, z)
                count += 1
    count *= 3

print(count)

Submission status: Wrong Answer

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

count = 0

for z in range(K, 0, -1):
    for y in range(K - z, -1, -1):
        if y >= S - z - y:
            count += 1

print(count*3)

Submission status: Wrong Answer

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

xyz = [0, 0, 0]
index = 0
while min(k, s) != 0:
    xyz[index] = min(k, s)
    s = s - min(k, s)
    index = index + 1

count = 0

def cal(lis, n, m):
    lis[n] = lis[n] - 1
    lis[m] = lis[m] + 1

while xyz[0] >= 0:
    xyzCopy = list(xyz)

    while xyzCopy[1] >= 0 and xyzCopy[2] <= k:
        count = count + 1
        print(xyzCopy)
        cal(xyzCopy, 1, 2)

    if xyz[1] == k:
        cal(xyz, 0, 2)
    else:
        cal(xyz, 0, 1)

print(count)

Submission status: Wrong Answer

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

xyz = [0, 0, 0]
index = 0
while min(k, s) != 0:
    xyz[index] = min(k, s)
    s = s - min(k, s)
    index = index + 1
    
count = 0

def cal(lis, n):
    lis[n] = lis[n] - 1
    lis[n+1] = lis[n+1] + 1

while xyz[0] >= 0 and xyz[0] <= k:
    xyzCopy = list(xyz)
    while xyzCopy[1] >= 0 and xyzCopy[1] <= k:
        if xyzCopy[0] <= k and xyzCopy[1] <= k and xyzCopy[2] <= k:
            count = count + 1
        cal(xyzCopy, 1)
    cal(xyz, 0)

print(count)

Submission status: Wrong Answer

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

count = 0
xyz = [0, 0, 0]
index = 0
while min(k, s) != 0:
    xyz[index] = min(k, s)
    s = s - min(k, s)
    index = index + 1

while xyz[0] >= xyz[1]:
    xyzCopy = list(xyz)

    while xyzCopy[1] >= xyzCopy[2]:
        if xyzCopy[0] == xyzCopy[1] == xyzCopy[2]:
            count = count + 1
        elif xyzCopy[0] == xyzCopy[1] or xyzCopy[1] == xyzCopy[2]:
            count = count + 3
        else:
            count = count + 6
        
        xyzCopy[1] = xyzCopy[1] - 1
        xyzCopy[2] = xyzCopy[2] + 1
        
    xyz[0] = xyz[0] - 1
    xyz[1] = xyz[1] + 1

print(count)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
    if S - x > 2 * K:
        continue
    for y in range(K+1):
        if S - x - y > K:
            break
        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 = map(int, input().split())
ret = 0

for x in range(s // 3 , k + 1):
    for y in range(s // 3, k + 1):
        if x + y <= s and x + y + k >= s:
            ret += 1
print(ret)

Submission status: Wrong Answer

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

ret = 0
if k * 3 < s:
    print(0)
elif k * 3 == s:
    print(1)
else:    
    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:
                    ret += 1
    print(ret)

Submission status: Wrong Answer

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

ret = 0
a = min(k + 1, 3 * s)
for x in range(a):
    for y in range(a):
        for z in range(a):
            if x + y + z == s:
                ret += 1
print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
k, s = map(int, raw_input().split())

counter = 0
flag = 0

for i in range(0, k+1):
        for j in range (i, k+1):
                for l in range (j, k+1):
                        if (i+j+l == s):
                                counter+=1
if (3*k == s):
        counter = 1
else:
        counter=counter*3
# 出力
print(counter)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
k, s = map(int, raw_input().split())

counter = 0

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

#counter=counter*3
# 出力
print(counter)

Submission status: Wrong Answer

Solution code:
# vim: set fileencoding=utf-8 :


def main():
    k, s = map(int, raw_input().split())
    patterns = []

    # x = iに固定して、のこりの２つを探す実装
    for x in range(k + 1):
        nokori_pattern(x, s, k, patterns)

    print(patterns)
    print(len(patterns))


# 組み合わせを考慮しないパターン数をサーチする。
def nokori_pattern(x, s, k, patterns):
    nokori = s - x
    # 残り２つのやつを満たす組み合わせはいくつあるか？
    for y in range(k + 1):
        if 0 <= nokori - y <= k:
            z = nokori - y
            patterns.append([x, y, z])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

p = 0
for X in range(max(0, S - 2*K), min(K, S) +1):
  Y = S - X
  p += min(Y, K) - max(Y - K, 0) + 1
  print(X, Y, p)
  
print(p)

Submission status: Wrong Answer

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

p = 0
for X in range(max(0, S - 2*K), K+1):
  Y = S - X
  p += min(Y, K) - max(Y - K, 0) + 1
  
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
counter = 0
third_counter = 0
for x in range(K+1):
    for y in range(x+1):
        for z in range(y+1):
            if (x == y and y == z and z == x) and x + y + z == S:
                counter += 1
            elif (x != y or y != z or z != x) and x + y + z == S:
                third_counter += 1
            else:
                pass
print(counter + third_counter*3)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
import itertools
third_counter = 0
temp_list = list(range(K +1))
for i in itertools.combinations(temp_list,3):
    if sum(i) == S:
        third_counter += 1
    else:
        pass

third_counter = 0
for i in itertools.combinations(temp_list,2):
    if sum(i) + i[0] == S:
        third_counter += 1
    if sum(i) + i[-1] == S:
        third_counter += 1

first_counter = 0
for i in temp_list:
    if i*3 == S:
        first_counter += 1
    else:
        pass
    
print(third_counter*3  + first_counter)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
import itertools
counter = 0
a = list(itertools.product(list(range(K +1)), list(range(K +1)), list(range(K +1))))
for i in a:
    if sum(i) == S:
        counter += 1
    else:
        pass
print(counter*3)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
import itertools
counter = 0
temp_list = list(range(K +1))
for i in list(itertools.combinations_with_replacement(temp_list, 3)):
    if sum(i) == S:
        counter += 1
    else:
        pass
print(counter*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    if (S - i) <= 2 * K:
        n = K - i
        ans += (n + 1)
    else:
        pass
print(ans)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ans = 0
for remainder in range(S - K, S + 1):
    if remainder > K * 2:
        continue
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ans = 0
for remainder in range(S - K, min(S, K * 2) + 1):
    ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    remainder = S - x
    if K * 2 < remainder < 0:
        break
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def check(x, y, S):
  if x + y > S:
    return False
  else:
    return True

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
if int(s / 3) == 0:
    for x in range(s + 1):
        for y in range(s + 1):
            for z in range(s + 1):
                if x + y + z == s:
                    count += 1
else:
    count = (k - int(s/3)) * 3
    if count == 0:
        count += 1
    # for x in range(max(k, int(s / 3) + 1)):
    #     for y in range(max(k, int(s / 3) + 1)):
    #         for z in range(max(k, int(s / 3) + 1)):
    #             if x + y + z == s:
    #                 count += 1

print(count)

Submission status: Wrong Answer

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

count = 0
if int(s / 3) == 0:
    for x in range(s + 1):
        for y in range(s + 1):
            for z in range(s + 1):
                if x + y + z == s:
                    count += 1
else:
    for x in range(int(s / 3) + 1):
        for y in range(int(s / 3) + 1):
            for z in range(int(s / 3) + 1):
                if x + y + z == s:
                    count += 1

print(count)

Submission status: Wrong Answer

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

count = 0
for x in range(int(s / 3), k + 1):
    for y in range(int(s / 3), k + 1):
        for z in range(int(s / 3), k + 1):
            if x + y + 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-i):
    if(s-i-j>=0):
      count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = raw_input().split()
K = int(a[0])
S = int(a[1])

number = []

for i in range(0,K+1):
  for j in range(0,i):
    for k in range(0,j):
      if i+j+k == S:
        number.append((i,j,k))
        number.append((i,k,j))
        number.append((j,i,k))
        number.append((j,k,i))
        number.append((k,i,j))
        number.append((k,j,i))

        
print(len(list(set(number))))

Submission status: Wrong Answer

Solution code:
a = raw_input().split()
K = int(a[0])
S = int(a[1])

number = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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):
      for k in range(k+1):
         if i + j + k == s:
            cnt += 1
         elif i + j + k >s:
            break

print(cnt)

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
k,s=[int(i) for i in input().split()]
count = 0
for x in range(k+1):
    for y in range(x,k+1):
        z = s - x - y
        if z < 0 or z > k or y > x:
            continue
        if x == y and y == z:
            count += 1
        elif x != y and y != z and z != x:
            count += 6
        else:
            count += 3
print(count)

Submission status: Wrong Answer

Solution code:
k,s=[int(i) for i in input().split()]
count = 0
for x in range(k+1):
    for y in range(x,k+1):
        z = s - x - y
        if z < 0 or z > k or y > x:
            continue
        if(x == y and y == z):
            count += 1
        elif(x != y and y != z and z != x):
            count += 6
        else:
            count += 3
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

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

Submission status: Wrong Answer

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


def main():
    k, s = map(int, input().split())
    answer = solve(k, s)
    return answer


def solve(k, s):
    count = 0
    for i in range(k + 1):
        v = 0
        v += i
        if v == s:
            count += 1
            continue
        for j in range(k + 1):
            v += j
            if v == s:
                count += 1
                continue
            for k in range(k + 1):
                v += k
                if v == s:
                    count += 1
                    continue
    return count

print(main())

Submission status: Wrong Answer

Solution code:
def main():
    ans = 0
    k, s = map(int, input().split())
    list_ = list(range(s+1))

    for i in range(k+1):
        for j in range(k+1):
            if i + j - s in list_:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ls = [(x + 1) * (x + 2) // 2 for x in range(k * 3 // 2 + 1)]
if k % 2 == 0:
    lls = ls + ls[-2::-1]
else:
    lls = ls + ls[::-1]

print(lls[s])

Submission status: Wrong Answer

Solution code:
import itertools

if __name__ == '__main__':
    k, s = list(map(int,input().split()))

    a = []
    d = -9999
    count = 0
    flag = True
    for i in itertools.product(range(0, k+1), range(0, k+1), range(0, k+1)):
        if sum(i) == s:
            a.append(i)
            if flag:
                d = count
                flag = False

        count += 1

        if count == d * 3:
            break;

    ret = 0
    for i in a:
        ret += len(set(itertools.permutations(i)))
    print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
K, S = map(int, input().split(" "))
l = [i for i in range(K + 1)]
cnt = 0
for x, y in itertools.combinations_with_replacement(l, 2):
    z = S - (x + y)
    if 0 <= z <= K:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
K, S = map(int, input().split(" "))
l = [i for i in range(K+1)]
cnt = 0
for x, y, z in itertools.combinations_with_replacement(l, 3):
    if x + y + z == S:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
K, S = map(int, raw_input().split())
ans = 0
for X in range(K+1):
    s = S - X
    if s > 2 * K:
        pass
    elif s <= K:
        ans += s + 1
    else:
        ans += 2 * K - s + 1
print ans

Submission status: Wrong Answer

Solution code:
import itertools
K, S = map(int, input().split())
s = set([x for x in itertools.combinations_with_replacement(range(K+1), 3) if sum(x) == S]) 
print(len(s) * 3 - (S % 3 == 0) * 2)

Submission status: Wrong Answer

Solution code:
import itertools
K, S = map(int, input().split())
s = set([x for x in itertools.combinations_with_replacement(range(K+1), 3) if sum(x) == S]) 
print(len(s)*3 - (S % 3 == 0) * 2)

Submission status: Wrong Answer

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

import numpy as np
import scipy.misc as scm

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

allp = scm.comb(K+2,2)
partp = scm.comb(K-S,2)

ans = allp-3*partp
if ans < 0:
    ans=0

if 3*K<S:
    ans =0

print int(ans)