Problem:


Score : 200 points

Problem Statement

You are given two integers K and S.

Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.

How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?  

Constraints

2≤K≤2500 

0≤S≤3K 

K and S are integers.  

Input

The input is given from Standard Input in the following format:

K S

Output

Print the number of the triples of X, Y and Z that satisfy the condition.

Sample Input 1

2 2

Sample Output 1

6

There are six triples of X, Y and Z that satisfy the condition:

X = 0, Y = 0, Z = 2 

X = 0, Y = 2, Z = 0 

X = 2, Y = 0, Z = 0 

X = 0, Y = 1, Z = 1 

X = 1, Y = 0, Z = 1 

X = 1, Y = 1, Z = 0

Sample Input 2

5 15

Sample Output 2

1

The maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z.



Sample input:
2 2


Sample output:
6

Submission status: Time Limit Exceeded

Solution code:


def solve(k, s, x=[]):
    if len(x) < 3:
        ans = 0
        for i in range(k+1):
            nx = x.copy()
            nx.append(i)
            ans += solve(k, s, nx)
        return ans
    return 1 if sum(x) == s else 0


(k, s) = map(int, input().split())
print(solve(k, s))

Submission status: Time Limit Exceeded

Solution code:
l = input() #test:l = '2 2'
(k,s) = [int(x) for x in l.split()] 
x_cand = y_cand = z_cand = [x for x in range(k+1)]
alloc_cnt = 0
for x_loop in x_cand:
    for y_loop in y_cand:
        for z_loop in z_cand:
            if x_loop + y_loop + z_loop == s:
                alloc_cnt += 1
            else:
                pass
print(alloc_cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0
for a in range(k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            if a + b + c == s:
                if a == b == c:
                    count += 1
                else:
                    if a == b or b == c:
                        count += 3
                    else:
                        count += 6
print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
k, s = list(map(int, input().split()))
count = 0
n = range(k+1)
for i in itertools.product(n, repeat=3):
	if sum(i)==s:
		count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

line = input().split(" ")
k = int(line[0])
s = int(line[1])
k = s if k > s else k

count = 0
for x, y, z in itertools.product(range(0, k+1), range(0, k+1), range(0, k+1)):
    if (x + y + z) == s : count = count +1 

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []
count = int(0)

for x in range(k+1)[::-1]:
    yz = s - x
    for y in range(k+1)[::-1]:
        z = yz - y
        if x >= y >= z >= 0:
            xyz_l.append([x, y, z])
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)

Submission status: Time Limit Exceeded

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

for x in range(k+1):
	if x > s:
		break
	for y in range(k+1):
		if (x+y) > s:
			break
		for z in range(k+1):
			if (x+y+z) == s:
				total += 1
			elif (x+y+z) > s:
				break
print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def getInput():
    nums = list(map(int, input().split()))
    k, s = nums[0], nums[1]
    return k, s

if __name__ == '__main__':
    k, s = getInput()
    count = 0
    calced = []
    for x in range(k + 1):
        for y in range(k + 1):
            for z in range(k + 1):
                for c in calced:
                    if x in c and y in c and z in c:
                        break
                if (x + y + z) == s:
                    count += 1
                    calced.append([x, y, z])
    print(count)

Submission status: Time Limit Exceeded

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

result = []

for X in range(K + 1):
    for Y in range(K + 1):
        for Z in range(K + 1):
            if X + Y + Z == S:
                result.append(0)

print(len(result))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
mapping = {}
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            mapping[(x, y, z)] = x+y+z
c = list(mapping.values()).count(s)
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def getInput():
    nums = list(map(int, input().split()))
    k, s = nums[0], nums[1]
    return k, s

if __name__ == '__main__':
    k, s = getInput()
    count = 0
    for x in range(k + 1):
        for y in range(k + 1):
            for z in range(k + 1):
                if (x + y + z) == s:
                    count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
#! -*- coding: UTF-8 -*-

import itertools

k, s = map(int, input().strip().split())
result = [i for i in itertools.product(range(k+1), repeat=3) if sum(i) == s]
print(len(result))

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0
sz_list = []
for i in range(k+1):
    sz_list.append(s-i)

for x in range(k+1):
    for y in range(k+1):
        s = x +y
        if s in sz_list:
            count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
r_k = range(k+1)[::-1]
count = int(0)

for x in r_k:
    a = s-x
    if a > k*2:
        break
    for y in r_k:
        b = a - y
        if b > k:
            break
        for z in r_k:
            c = b - z
            if c == 0:
                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = list(map(int, input().split()))
# ok_list = []
cnt = 0
for x in range(K + 1):
    if S - x > K:
        y_max = K + 1
    else:
        y_max = S - x + 1

    for y in range(y_max):
        if S - x - y > K:
            z_max = K + 1
        else:
            z_max = S - x - y + 1
        for z in range(z_max):
            # print((x, y, z))
            if x + y + z == S:
                # print((x, y, z))
                # ok_list.append((x, y, z))
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K, S = list(map(int, input().split()))
ok_list = []
for x in range(K + 1):
    if S - x > K:
        y_max = K + 1
    else:
        y_max = S - x + 1

    for y in range(y_max):
        if S - x - y > K:
            z_max = K + 1
        else:
            z_max = S - x - y + 1
        for z in range(z_max):
            # print((x, y, z))
            if x + y + z == S:
                # print((x, y, z))
                ok_list.append((x, y, z))

print(len(ok_list))

Submission status: Time Limit Exceeded

Solution code:
k, s = list(map(int, input().split()))
xyz_l = []
r_k = range(k+1)[::-1]

for x in r_k:
    a = s-x
    if a > k*2:
        break
    for y in r_k:
        b = a - y
        if b > k:
            break
        for z in r_k:
            c = b - z
            if c == 0:
                xyz_l.append([x, y, z])
print(len(xyz_l))

Submission status: Time Limit Exceeded

Solution code:
[a, b] = map(int, input().split())
cnt = 0
for x in range(a+1):
    for y in range(a+1):
        for z in range(a+1):
            if x+y+z == b:
                cnt += 1
                break
            elif x+y+z > b:
                break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s = input().strip().split(' ')
k,s = [int(k),int(s)]
cnt = 0
for i in range(k+1):
	if i>s:	
		break;
	for j in range(k+1):
		if i+j>s:
			break;
		for l in range(k+1):			
			if i+j+l==s:
				cnt+=1
			elif i+j+l>s:
				break;		
print (cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s=[int(i) for i in input().split()]
ans=0
chk=set([])
for i in range(k+1):
    for j in range(i,k+1):
        tmp=s-i-j
        x=[i,j,tmp]
        x.sort()
        x=tuple(x)
        if 0<=tmp<=k and x not in chk:
            chk.add(x)
            if i==j==tmp:
                ans+=1
            elif i==j or i==tmp or j==tmp:
                ans+=3
            else:
                ans+=6
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#! -*- coding: UTF-8 -*-

import itertools

k, s = map(int, input().strip().split())
result = 0
for i in itertools.product(range(k + 1), repeat=3):
    if sum(i) == s:
        result += 1
print(result)

Submission status: Time Limit Exceeded

Solution code:
#input
K, S = map(int,raw_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

print cnt

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

k, s = map(int, stdin.readline().split())

result = set()


def get_variants(target, maximum):
    result = []
    for x in range(maximum, -1, -1):
        y = target - x
        if 0 <= y <= maximum:
            result.append([x, y])
    return result

for z in range(k+1):
    variants = get_variants(s - z, k)
    for var in variants:
        result.add((z, var[0], var[1]))

print(len(result))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        k, s = line.rstrip("\n").split(" ")
        k = int(k)
        s = int(s)
        counter = 0
        for x in xrange(0, k + 1):
            for y in xrange(x, k + 1):
                for z in xrange(y, k + 1):
                    if (x+y+z) == s:
                        if x == y and y == z:
                            counter += 1
                        elif x == y or y == z or x == z:
                            counter += 3
                        else: 
                            counter += 6
        print counter

if __name__ == "__main__":
    main(sys.argv)

Submission status: Time Limit Exceeded

Solution code:
v = input().split()
k = int(v[0])
s = int(v[1])

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

Submission status: Time Limit Exceeded

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

N = list(map(int, input().split()))
# print(N[0], N[1])
X = N[0]
Y = N[0]
Z = N[0]
cnt = 0

for x in range(X+1):
    for y in range(Y+1):
        for z in range(Z+1):
            if((x + y + z) == N[1]):
                # print(x, y, z)
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

z_list = []

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

count = 0

for i in z_list:
    z = i
    for x in range(k+1):
        for y in range(k+1):
            if (x+y) == (s - z):
                count+=1

print(count)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
K, S = map(int, input().split())
cnt = 0
for i in itertools.product(range(K+1), repeat=3):
    cnt += sum(i) == S
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        k, s = line.rstrip("\n").split(" ")
        k = int(k)
        s = int(s)
        counter = 0
        for x in xrange(0, k + 1):
            for y in xrange(0, k + 1):
                for z in xrange(0, k + 1):
                    if (x+y+z) == s:
                        counter += 1
        print counter

if __name__ == "__main__":
    main(sys.argv)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().strip().split(' '))
cnt = 0
for X in range(0, K+1):
	for Y in range(0, K+1):
		for Z in range(0, K+1):
			if X+Y+Z == S:
				cnt += 1
print(cnt)

Submission status: Memory Limit Exceeded

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 0 <= S-x-y <= K:
        count+=1

print(count)

Submission status: Memory Limit Exceeded

Solution code:
def resolve():
    K, S = map(int, input().split())
    print(
        len(
            [
                (x, y)
                for x in range(K + 1)
                for y in range(K + 1)
                if S - K <= x + y <= S and max(x, y) <= K
            ]
        )
    )


if __name__ == "__main__":
    resolve()

Submission status: Memory Limit Exceeded

Solution code:
import itertools

K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
count = 0
for i, j in list(itertools.product(X, repeat=2)):
  if 0 <= S - i - j <= K:
    count += 1
print(count)

Submission status: Memory Limit Exceeded

Solution code:
import itertools

"""
整数K,S
2 <= K <= 2500, 0 <= S <= 3K

0 <= X,Y,Z <= K
X + Y + Z = Sを満たすX,Y,Zの割り当ては何通り？

(1ミス後)
Z = S - X - Yとすれば制限時間は越えない！
"""
K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
count = 0
for i, j in list(itertools.product(X, repeat=2)):
  if 0 <= S - i - j <= K:
    count += 1
print(count)

Submission status: Memory Limit Exceeded

Solution code:
import itertools

"""
整数K,S
2 <= K <= 2500, 0 <= S <= 3K

0 <= X,Y,Z <= K
X + Y + Z = Sを満たすX,Y,Zの割り当ては何通り？

(1ミス後)
Z = S - X - Yとすれば制限時間は越えない！
"""
K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
Y = list(range(K + 1))
count = 0

for i, j in list(itertools.product(X,Y)):
  if 0 <= S - i - j <= K:
    count += 1
print(count)

Submission status: Memory Limit Exceeded

Solution code:
import itertools

"""
整数K,S
2 <= K <= 2500, 0 <= S <= 3K

0 <= X,Y,Z <= K
X + Y + Z = Sを満たすX,Y,Zの割り当ては何通り？

(1ミス後)
Z = S - X - Yとすれば制限時間は越えない！
"""
K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))
count = 0

for i, j in list(itertools.product(X,Y)):
  if 0 <= S - i - j <= K:
    count += 1
print(count)

Submission status: Memory Limit Exceeded

Solution code:
K,S = map(int, input().split())
print(len([(A,B,S-A-B) for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K]))

Submission status: Memory Limit Exceeded

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


def calc_xyz(target, limit):
    xyz_list = []
    for x in range(min(limit, target) + 1):
        yz_sum = target - x
        for y in range(min(limit, yz_sum) + 1):
            z = target - x - y
            if 0 <= z <= limit:
                xyz_list.append([x, y, z])
    return xyz_list


print(len(calc_xyz(s, k)))

Submission status: Memory Limit Exceeded

Solution code:
import bisect
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1
    
K,S =  list(map(int,input().split()))
sum_list = sorted([i+j for i in range(0,K+1) for j in range(0,K+1)])

cnt = 0
for X in range(0,K+1):
    if S-X == 2*K:
        cnt += 1
    else:
        ans = index(sum_list,S-X)
        if ans == -1:
            continue
        else:
            cnt += index(sum_list,S-X+1) - index(sum_list,S-X)
      
print(cnt)

Submission status: Memory Limit Exceeded

Solution code:
from itertools import chain
# import numpy as np
# N = int(input())
# L,N = map(int,input().split())
# X = [list(map(int,input().split())) for x in range(N)]
K,S = map(int,input().split())
patterns = 0

arr = [[x+y for y in range(min(S-x+1,K+1))] for x in range(K+1)]
farr = list(chain.from_iterable(arr))
for z in farr:
    temp_z = S - z
    if temp_z <= K and temp_z >=0:
        patterns += 1
# print(farr)
# print(farr.count(S))
print(patterns)

Submission status: Memory Limit Exceeded

Solution code:
import itertools
K,S=map(int,raw_input().split())
l=list( itertools.product(range(K+1), repeat=2 ) )

cnt=0
for x,y in l:
	z=S-x-y
	if z>=0 and z<=K:
		cnt+=1
print cnt

Submission status: Memory Limit Exceeded

Solution code:
import itertools

field = input().split()
k, s = int(field[0]), int(field[1])

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

result = 0
for row in list(itertools.product(ls, ls, ls)):
    if sum(row) == s:
        result += 1
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import math
def comb(M, N):
    if M<0: return 0
    if M<N: return 0
    return (math.factorial(M)//(math.factorial(M-N)*math.factorial(N)))

print(comb(S+2, 2)-3*(comb(S+2-K-1, 2))+3*(comb(S+2-2*(K+1), 2)))

Submission status: Accepted

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

ans = 0
for i1 in range(min(k+1, s+1)):
    for i2 in range(0, min(k+1, s - i1 + 1)):
        if s - (i1 + i2) <= k:
            ans += 1

print(ans)

Submission status: Accepted

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) <= K:
            cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def answer(k: int, s: int) -> int:
    count = 0
    
    for x in range(k + 1):
        y_max = min(k, s - x)
        y_min = max(0, s - x - k)
        comb = y_max - y_min + 1
        
        if 0 < comb:
            count += comb

    return count


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=0
for i in range(k+1):
    for q in range(k+1):
        if i+q+k>=s and i+q<=s:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
def input():
  return sys.stdin.readline().rstrip()

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 0<=Z<=K:
      cnt+=1

print(cnt)

Submission status: Accepted

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 and s<=k+i+j:
            count += 1

print(count)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
counter = 0
for i in range(k + 1):
    counter += max(min(k, s - i) - max(0, s - k - i) + 1, 0)

print(counter)

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
counter = 0
for x in range(k + 1):
    for y in range(x, k + 1):
        z = s - x - y
        if y <= z <= k:
            if x == y == z:
                counter += 1
            elif x == y or y == z:
                counter += 3
            else:
                counter += 6

print(counter)

Submission status: Accepted

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

print(counter)

Submission status: Accepted

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

kotae = 0
for Z in range(K + 1):
    X_plus_Y = S - Z
    for Y in range(K + 1):
        X = X_plus_Y - Y
        if 0 <= X <= K:
            kotae += 1

print(kotae)

Submission status: Accepted

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

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

if k*3==s:
  print(1)
  exit()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

for i in range(k+1):
  for j in range(k+1):
    if s-k<=i+j<=s:
      cnt+=1
      
print(cnt)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    if s-i>2*k:
        continue
    else:
        for j in range(k+1):
            if s-i-j>k or s-i-j<0:
                continue
            else:
                ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#91 B - Sum of Three Integers
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 K >= z >= 0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

success = 0

for x in range (K + 1):
    for y in range (K + 1):
        if S - x - y >= 0 and S - x - y <= K:
            success = success + 1

print(success)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for y in range(a+1):
  for z in range(a+1):
      p=b-y-z
      if 0<=p and p<=a:
        n+=1
print(n)

Submission status: Accepted

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

Submission status: Accepted

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 and S - i - j >= 0):
            count += 1

print(count)

Submission status: Accepted

Solution code:
k_num, s_num = map(int, input().split())

cnt = 0
for x in range(k_num+1):
    l = s_num - x
    for y in range(k_num+1):
        z = l - y
        if 0 <= z <= k_num:
            cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(Sum)

Submission status: Accepted

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 0 <= z <= k:
            cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = 0

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

Submission status: Accepted

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

Submission status: Accepted

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