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())
n=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            n+=1
print(n)

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 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:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read

K, S = map(int, read().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:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
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:
from itertools import product
k, s = list(map(int, input().split()))
count = 0
for i, j in product(range(k + 1), 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 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:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    K, S = map(int, input().split())
    ret = 0
    for z in range(K+1):
        ret += max(min(S-z, K)-max(S-z-K, 0) + 1, 0)
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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 and s-i-j <= 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())

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:
import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
k = K + 1
ans = 0
for x in range(k):
    for y in range(k):
        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 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())
#k=2
#s=2
result=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:
            result+=1
            
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

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

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

K, S = map(int, sys.stdin.readline().strip().split())

N_MAX = min(K, S)

ans = 0
for i in range(N_MAX+1):
    for j in range(N_MAX+1):
        if 0 <= S - (i + j) <= 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())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= 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())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(min(s,k)+1):
    for j in range(i,min(s-i,k)+1):
        l = s - i - j
        if k >= l >= j: 
            if i == j and j == l:
                ans += 1
            elif i != j and j!= l and i != l:
                ans += 6
            else:
                ans += 3

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())
temp=[1 for y in range(k+1) for x in range(k+1) if 0<=s-x-y<=k]
print(len(temp))

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

K,S = inputIL()

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for l in range(k+1):
  for m in range(k+1):
    n = s - l - m
    if 0 <= n <= k:
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# B - Sum of Three Integers

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

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc051/tasks/abc051_b

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:
            #print(x,y,z)
            count+=1

print(count)

Submission status: Accepted

Solution code:
k,s = [int(x) for x in 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())
cnt=0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if -1 < k <=K:
            cnt+=1
print(cnt)

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

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(max(s-2*k, 0), min(s, k)+1):
    for y in range(max(s-x-k, 0), min(s-x, k)+1):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353

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

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

Submission status: Accepted

Solution code:
K, S = list(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())
num = 0

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

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:
import sys
input = sys.stdin.readline
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())
a = 0
for x in range(k+1):
  for y in range(k+1):
      if s-(x+y) <= k and s-(x+y) >= 0:
        a += 1
        
print(a)

Submission status: Accepted

Solution code:
def main():
    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 z <= k and z >= 0:
                res += 1
        
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import product

K, S = map(int, input().split(' '))
zero_to_k = tuple(range(K + 1))
max_k = min(K, S) + 1

print(len([0 for x, y in product(range(max_k), range(max_k)) if 0 <= S - (x + y) <= K]))

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:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())

ans = []
 
for i in range(K+1):
  s_z = S - i

  if s_z < 0:
    pass

  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K - s_z + 1)
      
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

Solution code:
k, s = map(int, input().split())
xmin=0
xmax=0
if k>=s:
    xmin=0
    xmax=s
else:
    xmin=max(0,s-2*k)
    xmax=k
xs=[]
for i in range(xmin, xmax+1):
    xs.append(i)
#print(xs)
ymin=0
ymax=0
res=0
for i in xs:
    ymin=max(0,s-i-k)
    ymax=min(s-i,k)
    res+=ymax-ymin+1
    #print(str(ymax-ymin+1)+" for x="+str(i))
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
ans = []
if S > K:
  for i in range(K+1):
    s_z = S - i
    if s_z < 0:
      pass
    elif K < s_z:
      if (K + 1) > (s_z - K):
        ans.append(K*2 - s_z + 1)
    else:
      ans.append(s_z + 1)

else:
  for i in range(S+1):
    s_z = S - i
    if s_z < 0:
      pass
    elif K < s_z:
      if (K + 1) > (s_z - K):
        ans.append(K*2 - s_z + 1)
    else:
      ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
ans = []

if S > K:
  for i in range(K+1):
    s_z = S - i
    if s_z < 0:
      pass
    elif K < s_z:
      if (K + 1) > (s_z - K):
        ans.append(K*2 - s_z + 1)
    else:
      ans.append(s_z + 1)

else:
  for i in range(S+1):
    s_z = S - i
    if s_z < 0:
      pass
    elif K < s_z:
      if (K + 1) > (s_z - K):
        ans.append(K*2 - s_z + 1)
    else:
      ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
ans = []
 
for i in range(K+1):
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
ans = []

if S > K:
   z = list(range(K+1))
else:
  z = list(range(S+1))
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())

if S < K:
  K = S
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:

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

    print(cnt)


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

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

print(count)

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K + 1 - s_z)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
z = list(range(K+1))
ans = []
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(2*K - s_z + 1)
  else:
    ans.append(s_z + 1)
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
z=list(range(K+1))
ans=[]
for i in z:
  s_z=S-i
  if s_z<0:
    pass
  elif K<s_z:
    if (K+1)>(s_z-K):
      ans.append(2*K-s_z+1)
  else:
    ans.append(s_z+1)
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(2*K - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.extend([2*K - s_z + 1])
  else:
    ans.extend([s_z + 1])
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(2*K + 1 - s_z)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(0,K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

z = list(range(0,K+1))
ans = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

Solution code:
K,S=map(int,input().split())
z = list(range(0,K+1))
ans = []
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
print(sum(ans))

Submission status: Accepted

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

z = list(range(0,K+1))
ans = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print(sum(ans))

Submission status: Accepted

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

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)

print(sum(answer))

Submission status: Accepted

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

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

print(num)

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:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    k, s = ns()
    ans = 0
    for x in range(k + 1):
        for y in range(k + 1):
            if k >= s - x - y >= 0:
                ans += 1
    print(ans)

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:
K,S=map(int,input().strip().split())

cnt=0
for a in range(K+1):
    for b in range(K+1):
        if S-K<=a+b<=S:
            cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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):
        ans+=1*(0<=S-X-Y<=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 - k <= x + y <= 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):
        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((max(s-2*k,0)),(min(s,k)+1)):
  ans += (min(s-x,k)-max(s-x-k,0)+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:
            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):
        z = s-j-i
        if (z<=k and z>=0):
            ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
limit, sum_xyz = map(int, input().split())

pair = list()

ans = 0
for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        else:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in 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)
 
if __name__ == '__main__':
    main()

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

print(cnt)

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

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):
    x=s-i-j
    if x <= k and 0 <= x:
      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:
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)