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

Submission status: Accepted

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

    count = 0
    for x in range(0, K + 1):
        for y in range(0, 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 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())
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 = 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=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] = 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 in range(K+1):
            count+=1
print(count)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

K, S = inm()


def solve():
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                count += 1
    return count


print(solve())

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for x in range(K+1):
  for y in range(K+1):
    if K>=S-x-y>=0:
      C+=1
        
print(C)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    K, S = mi()
    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)

if __name__ == '__main__':
    main()

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(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=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 p in range(k+1):
  for q in range(k+1):
    r=s-p-q
    if 0<=r<=k:
      cnt+=1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

    n = 0

    for zz in range(k+1):
        for yy in range (k+1):
                if (0 <= s-(yy+zz) <= k):
                    n += 1

    print(n)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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())

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

Submission status: Accepted

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

# for文を3つ回すと間に合わない
# a + b + c = s が決まるとき a, b, s が決まれば c が決まる

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

print(cnt)

Submission status: Accepted

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

for i in range(k+1):
    for j in range(k+1):
        #print(i,j)
        if (s - (i + j)) <= k and (i + j) <= s:
            c += 1

print(c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, S = il()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

# 変数の初期化
x = 0
y = 0
z = 0

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

print(count)

Submission status: Accepted

Solution code:
from math import factorial
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


k, s = LI()
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())
a = 0

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

print(a)

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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 S-i-j<=K and 0<=S-i-j: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())
print(sum(S - K <= X + Y <= S for X in range(K + 1) for Y in range(K + 1)))

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

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:
a,b=map(int,input().split())
ans=0
for i in range(a+1):
    for j in range(a+1):
        if 0<=(b-i-j)<=a:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(K+1) for Y in range(K+1)]))

Submission status: Accepted

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

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

print(a)

Submission status: Accepted

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

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

print(a)

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:
# abc051_b.py
K, S = map(int, input().split())
ans = 0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if k <= K and i <= K and j <= K and k >= 0:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def main(k,s):
    count=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            #print(x,y,z)
            if 0<=z and z<=k:
                count+=1
    return count

if __name__=='__main__':
    k,s=readinput()
    ans=main(k,s)
    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 <= 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())
count=0
for i in range(K+1):
    for j in range(K+1):
        if((S-i-j)<=K and 0<=S-i-j):
            count=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 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 i in range(k+1):
  for j in range(k+1):
    z = (s - i - j)
    if 0<= z <= k:
      ans += 1
        
print(ans)

Submission status: Accepted

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

  print(counter)


if(__name__ == '__main__'):
  main()

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 <= k and s - x - y >= 0:
        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(max(k+1,min(s-k,k+1))):
        ans += 1 if 0<=s-i-j<=k else 0
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<=K and S-x-y>=0:
            cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
k,s = list(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

from itertools import product
for x,y in product(range(k+1), repeat=2):
    if 0 <= s-x-y <= k:
        ans +=1
print(ans)

Submission status: Accepted

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

'''from itertools import product
for x,y,z in product(range(k+1), repeat=3):
    #print(x,y,z)
    if x+y+z == s:
        ans += 1'''
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())
def two_sum(k, s):
    if s < 0:
        return 0
    elif k >= s:
        return s + 1
    elif s//2 > k:
        return 0
    else:
        return s + 1 - 2 * (s - k)

ans = 0
for x in range(k+1):
    ans += two_sum(k, s - x)
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, 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:
"""
int #整数
float #小数

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

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

exit(0) #強制終了
"""
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z=S-i-j
        if 0<=Z<=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())
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
if 3*K < S:
  pass
else:
  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())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 15 13:34:38 2020

@author: NEC-PCuser
"""

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

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

print(count)

Submission status: Accepted

Solution code:
K, S = list(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 = set()
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:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    k, s = i_map()

    count = 0

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

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
[K, S] = list(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
    else:
      continue
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())

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:
#! env python
# -*- coding: utf-8 -*-

import os
import sys


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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

n_int = 0

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

print(n_int)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

Submission status: Accepted

Solution code:
def resolve():
    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)
resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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(min(s-x+1, k+1)):
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(K + 1):
    for j in range (K + 1):
        r = S - i - j
        if r <= K and r >= 0:
            ans += 1
        
print(ans)

Submission status: Accepted

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

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

def modelAnswer():
   return
def main():
   K,S = map(int,input().split())
   print(myAnswer(K,S))
if __name__ == '__main__':
   main()

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

k, s = [int(i) for i in input().split()]

kotae = 0

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


print(kotae)

Submission status: Accepted

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

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

if __name__=="__main__":
    main2()

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 <= K and S - x- y >=0:
      cnt+=1
print(cnt)

Submission status: Accepted

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


def calculate(k, s):
    result = 0
    for x in range(k, -1, -1):
        if x > s:
            continue

        for y in range(k, -1, -1):
            if y > s:
                continue
            z = s - x - y

            if z > k:
                continue

            if z < 0:
                continue

            result = result + 1


    print(result)


calculate(K, S)

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

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

a = min(k,s)

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

print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
from collections import deque
a,b=map(int,input().split())
count=0
for i in range(a+1):
  for j in range(a+1):
    if 0<=b-i-j<=a:
      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 0 <= Z <= K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
nums = [int(e) for e in input().split()]

count=0
for i in range(nums[0]+1):
    for j in range(nums[0]+1):
        if 0<=nums[1]-i-j<=nums[0]:
            count=count+1

print(count)

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=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        com=S-(X+Y)
        if(com>=0 and com<=K):
            count+=1
        else:
            pass
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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 = [int(n) for n in input().split()]

count = 0

for x in range(min(S, K)+1):
    for y in range(x+1):
        z = S - x - y
        if z <= y and z >= 0:
            num_distinct = len({x,y,z})
            if num_distinct == 1:
                count += 1
            if num_distinct == 2:
                count += 3
            if num_distinct == 3:
                count += 6

print(count)

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:
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                count += 1
    print(count)
    return


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

if __name__ == '__main__':
    main()

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

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:
#SumofThreeIntegers
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
  for y in range(k+1):
    a = s - (x + y)
    if 0 <= a <= k :
      cnt += 1
print(cnt)