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: Runtime Error

Solution code:
def comb(n, k):
  if k == 0  or n == k: return 1
  else: return comb(n-1, k) + comb(n-1, k-1)

k, s = map(int, input().split())
print(comb(n-3k+2, 2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
vec = input().split(' ')
k = int(vec[0]) + 1
count = 0

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

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x,y = list(map(int, input().split()))
count=0
for i in range(x):
	for j in range(x):
      for k in range(x):
        a=i+j+K
        if y==a:
          count+=1
print(count)

Submission status: Runtime Error

Solution code:
import itertools

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

cnt = 0

K = list(range(K + 1))

for i, j in itertools.product(K, repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np

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

def main():
    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
                else:
                    pass
            
    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
a,b,c = input().split(',')
print(a,b,c)

Submission status: Runtime Error

Solution code:
def solve(K: int, S: int):
    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)
    return
 
 
# Generated by 1.1.6 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()
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.6 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: Runtime Error

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

ANS = 0

for x in range(K + 1):
    for y in rage(K + 1):
        z = S - x - y
        if (0 <= z) and z <= K:
            ANS += 1

print(ANS)

Submission status: Runtime Error

Solution code:
counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    if S - (x + y) <= K:
      z = S - (x + y)
      if z >= 0 and z <= K:
        counter += 1

print(counter)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
K, S = 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: Runtime Error

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

number_lis = []
ans = 0

for i in range(0,K+1):
    number_lis.append(i)

for j in number_lis:
    for k in number_lis:
        for l in number_lis:
            if 0<= (S　-j -k) <=K:
                ans = ans + 1
                
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split())
from math import factorial
def c(n,k):
  return factorial(n)//factorial(n-k)//factorial(k)
if s<k:
  print(c(s+2,2))
elif 3*k < s:
  print(0)
else:
  # k<=s<=3k の場合
  くっそ～わかんねぇ～

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ts=LIST()
    m=INT()
    xs=[0]*m
    for i in range(m):
        p,x=INTM()
        xs[i]=ts[p-1]-x
    tst=sum(ts)
    for i in range(m):
        #print(xs[i])
        print(tst-xs[i])
    #print(ts)
if __name__ == '__main__':
    do()

Submission status: Runtime Error

Solution code:
def Sumofnum(K,S):
    A = min(K,S) + 1
    a = max(S - 2*K, 0)
    c = 0
    for x in range (a,A):
        B = min(S - x,K) + 1
        b = max(S - x - K,0)
        for y in range (b,B):
            c = c + 1
    print(c)
    
s = list(map(int,input().split()))
Sumofnum(K,S)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
p = 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:
        p+=1
      if (x+y+z) >= s:
        break
    if (x+y+Z) >= s:
      break
print(p)

Submission status: Runtime Error

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

if K == S:
	print( (K+5)*(K+4)//2 )
	sys.exit( ) 

ans = 0
for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += S1 - 2*K + 1
		else:
			continue

print(ans)

Submission status: Runtime Error

Solution code:
fn main() {
    let s: i32 = read();
    let k: i32 = read();
    let mut ans = 0;
    for i in 0..k+1 {
        for j in 0..k+1 {
            for l in 0..k+1 {
                if i+j+l == s {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input()  .split())
candidate = list(range(N+1))
comb = list(itertools.product(candidate, repeat=3))
l = [c for c in comb if sum(c) == K]

print(len(l))

Submission status: Runtime Error

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

ans = 0
for z in range(K+1):
    for y in range(K+1):
        if 0 <= S - z - y <= K:
            ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


ans = 0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <=k:
            ans = ans + 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continu
  for y in range(K, -1, -1):
    if x+y >S:
      continue
    for z in range(K, -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k,s=map(int, input().split())
x+y+z=s
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


for i in x:
	for j in y:
		for k in z:
			if s - i - j <= z and i + j + k == s:
				ans += 1

print(ans)

Submission status: Runtime Error

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: Runtime Error

Solution code:
k, s = input().split()
c = 0
for i range(k+1):
  x = i
  for j range(k+1):
  	y = j
    for h range(k+1):
      z = h
      sum = x + y + z
      if sum == k:
        c += 1
        
print(c)

Submission status: Runtime Error

Solution code:
k, s = input()
c = 0
for i range(k+1):
  x = i
  for j range(k+1):
  	y = j
    for h range(k+1):
      z = h
      sum = x + y + z
      if sum == k:
        c += 1
        
print(c)

Submission status: Runtime Error

Solution code:
k,s = [int(i) for i in input().split()]
def a(n):
return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Submission status: Runtime Error

Solution code:
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Submission status: Runtime Error

Solution code:
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))

Submission status: Runtime Error

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


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:

Submission status: Runtime Error

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


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
else:
  print(a(s + 1) -3 * a(s - k))

Submission status: Runtime Error

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: Runtime Error

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

count = 0

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

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main()
{
    int k, s;
    int x, y, z;
    int cnt = 0;
    cin >> k >> s;
    for (x = 0; x <= k; x++)
    {
        for (y = 0; y <= k; y++)
        {
            if (0 <= s - x - y && s - x - y <= k)
                cnt++;
        }
    }

    cout << cnt << endl;
}

Submission status: Runtime Error

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

print(sum)

Submission status: Runtime Error

Solution code:
[k,s]=list(map(int,input().split()))
counter=0
imax=min(s+1,k+1)
jmax=min(s-i+1,k+1)
for i in range(imax):
	for j in range(0,jmax):
		if i<=k and j<=k and s-i-j<=k:
			counter+=1
print(counter)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
for x in range(K+1):
  num=X
  for y in range(K+1):
    num+=y
    for z in range(K+1):
      num+=z
      if num==S:
        result+=1
print(result)

Submission status: Runtime Error

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

ans = 0
for x in range(K+1):
    xyz = x
    if S > xyz:
        continue
    for y in range(K+1):
        xyz += y
        if S > xyz:
            continue:
        for z in range(K+1):
            xyz += z
            if xyz == S:
                ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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: Runtime Error

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

result = 0

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

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sum = 0
for i in range(0,a+1):
    for j in range(0,a+1):
        if s-i-j <= a:
            sum + = 1
print(sum)

Submission status: Runtime Error

Solution code:
K,S=map(int,input().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            while x+y+z==S:
                count+=1
print(count)

Submission status: Runtime Error

Solution code:
K=int(input())
S=int(input())
conut=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: Runtime Error

Solution code:
K,S=map(int,input().split())
conut=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: Runtime Error

Solution code:
K,S=map(int,inpit().split())
conut=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: Runtime Error

Solution code:
K,S=map(int,inpit().split())
conut=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: Runtime Error

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

Submission status: Runtime Error

Solution code:
K,S = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            V = i + j + k
            if V == S:
                ans += 1
                break
            elif V > S:
                break
    
    
print(ans)

Submission status: Runtime Error

Solution code:
K,S = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            V = i + j + k
            if V = S:
                ans += 1
                break
            elif V > S:
                break
    
    
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: cp932 -*-


import math
import sys
import os
import csv
import pandas as pd






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


i = 0

for n1 in range(k +1):
    for n2 in range(k+1):
        for n3 in range(k+1):            
            if n1 + n2 + n3 == s:
                i = i + 1
print(i,end="")

Submission status: Runtime Error

Solution code:
# -*- coding: cp932 -*-


import math
import sys
import os
import csv
import pandas as pd






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


i = 0

for n1 in range(k +1):
    for n2 in range(k+1):
        for n3 in range(k+1):            
            if n1 + n2 + n3 == s:
                i = i + 1
print(i)

Submission status: Runtime Error

Solution code:
import math
import sys
import os
import csv
import pandas as pd






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


i = 0

for n1 in range(k +1):
    for n2 in range(k+1):
        for n3 in range(k+1):            
            if n1 + n2 + n3 == s:
                i = i + 1
print(i)

Submission status: Runtime Error

Solution code:
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
list2K = [i for i in range(K**2)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

K+=1

count=0
for i in range(K):
    for j in range(0, K-i):
        tmp = S - (i + j)
        if tmp>=0 and tmp<=K:
            count+=1
#             print(i,j,tmp)

print(count)

end = time.time()
print(end-start)

Submission status: Runtime Error

Solution code:
k = int(input())
s = int(input())

x = 0
y = 0
z = 0
i = 0

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

Submission status: Runtime Error

Solution code:
k = int(input())
s = int(input())

x = 0
y = 0
z = 0
i = 0

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

Submission status: Runtime Error

Solution code:
def f(K, S):
    num=0
    for a in range(K+1):
      if S-a>=0 and S-a<=2*K:
        if S-a<=K:
          num+=S-a+1
        else:
          num+=min((S-a)-K,K)+1
    return num

  
(K,S)=input()
print(f(K,S))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(input())
s = int(input())
counter = 0

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

Submission status: Runtime Error

Solution code:
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: Runtime Error

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

ans=[1 for x in (K+1) for y in (K+1) if 0<=S-x-y <= K]

print(len(ans))

Submission status: Runtime Error

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

ans=[1 for x in (K+1) for y in (K+1) if K-x-y <= K]

print(len(ans))

Submission status: Runtime Error

Solution code:
data=int(input().split
b=data[0]
c=data[1]
d=0
e=0
f=0
for i in range(b):	
	for j in range(b):
         for k in range(b):
         	d=i+j+k
         	if d <=15:
         		e=e+1
         	else:
         		pass
print(e)

Submission status: Runtime Error

Solution code:
import random

data=int(input().split
b=data[0]
c=data[1]
count_data=0
random_data=random.randint(0,b)
random_data2=random.randint(0,b)
random_data3=random.randint(0,b)
resalt=random_data+random_data2+random_data3
if resart<= c:
     count_data=count_data+1
else:
	pass
print(count_data)

Submission status: Runtime Error

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

count = 0
for x in K+1:
  for y in K-x:
    z = K - x - y
    if (x>=0) and (y>=0) and (z>=0):
      count += 1
      
print(count)

Submission status: Runtime Error

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

count=0
for i in range(k):
  for j in range(k):
    if s-i-j=k:
      count+=1
      break
print(count)

Submission status: Runtime Error

Solution code:
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if s <= 3*k:
            break;
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            print(x,y,z)

print(count,flush=True)

Submission status: Runtime Error

Solution code:
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

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

print(count,flush=True)

Submission status: Runtime Error

Solution code:
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

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

print(count,flush=True)

Submission status: Runtime Error

Solution code:
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

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

print(count,flush=True)

Submission status: Runtime Error

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: Runtime Error

Solution code:
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    print(x)
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)

Submission status: Runtime Error

Solution code:
ks = input()
count = 0
k, s = [int(x) for x in sk.split(" ")]
count = 0
for i in range(min(k+1, s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
count = 0
for i in range(min(k+1, s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1

Submission status: Runtime Error

Solution code:
count = 0
for i in range(min(k, s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1

Submission status: Runtime Error

Solution code:
sk = input()
count = 0
for i in range(s + 2):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

Submission status: Runtime Error

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