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:
k,s = map(int,input())
cnt = 0

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

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 x+y+z<=s:
      ans+=1
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):
    if x + y > s:
      break
    a = s - x - y
    if a >= 0 && a <= 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):
  a=s-k-x
  a=0 if a < 0
  for y in range(a,k+1):
    if x + y > s:
      break
    for z in range(k+1):
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break

print(count)

Submission status: Runtime Error

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

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

print(count)

Submission status: Runtime Error

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

count = 0
for x in range(k+1):
  a = s-k-x
  a = 0 if a < 0 else a
  for y in range(a,k+1):
    if x + y > s:
      break
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break

print(count)

Submission status: Runtime Error

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

count = 0
num = range(k+1)
for x in num:
  for y in num:
    if x + Y > s:
      break:
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break:

print(count)

Submission status: Runtime Error

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

count = 0
num = range(k+1)
for x in num:
  for y in num:
    if x + Y > s:
      break
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

def count_true(matrix:np.array, s:int):
    return np.count_nonzero(matrix == s)


def unk(k:int, s:int):
    # 条件チェック
    if all([(2 <= k <= 2000), (0 <= s <= 3*k)]):

        x = y = z = np.array([range(0,k+1)])
        c = count_true(np.ravel(x.T+y)+ z.T, s)

        print(c)


if __name__ == '__main__':
    data = input().split(" ")
    data = list(map(int, data))
    unk(data[0], data[1])

Submission status: Runtime Error

Solution code:
import numpy as np

def count_true(matrix:np.array, s:int):
    return np.count_nonzero(matrix == s)


def unk(k:int, s:int):
    # 条件チェック
    if all([(2 <= k <= 2000), (0 <= s <= 3*k)]):

        x = y = z = np.array([range(0,k+1)])
        c = count_true(np.ravel(x.T+y)+ z.T, s)

        print(c)


if __name__ == '__main__':
　　　　data = input().split(" ")
　　　　data = list(map(int, data))
　　　　unk(data[0], data[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      temp = x + y + z
      if temp == 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):
    z = S - x - y
    if 0 <= z and 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 y in range(K + 1):
    z = S - x - y
    if 0 <= z and 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 y in range(K + 1):
    if 0 <= S - x - y <= 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 y in range(K + 1):
    for z in range(K + 1):
      total = x + y + z
      if total = S:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
n=int(input())

sum=0
for _ in range(n):
  a,b=map(int,input().split())
  sum+=b-a+1
print(sum)

Submission status: Runtime Error

Solution code:
import bisect
N = 1000
memo = [[0] * N for i in range(N)]
def pascal(x,y):
    if memo[x][y] != 0:
        return memo[x][y]
    elif y == 1:
        return x
    elif x == y or y == 0 or x ==1:
        return 1
    else:
        return pascal(x-1,y) + pascal(x-1,y-1)

    
K,S =  list(map(int,input().split()))
sum_list = sorted([i+j for i in range(0,K+1) for j in range(0,K+1)])

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

Submission status: Runtime Error

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
from math import factorial
K, S = map(int, input().split())
S = S if K * 3 / 2 > S else K * 3 - S
count = int(factorial(S+2) / factorial(2) / factorial(S+2 - 2))
print(str(count))

Submission status: Runtime Error

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
from scipy.special import comb
K, S = map(int, input().split())
S = S if K * 3 / 2 - S > 0 else K * 3 - S
count = comb(S + 2, 2, exact=True)
print(str(count))

Submission status: Runtime Error

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

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

print(count)

Submission status: Runtime Error

Solution code:
for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            break
        for z in range(k + 1):
            count += (x + y + z == s)

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

def solve(K, 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 = count + 1
                if x + y + z > S:
                    break
    return count


if __name__ == '__main__':
    K, S = input().split()
    print(solve(K, S))

Submission status: Runtime Error

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

count = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + J + K == S:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      if i+j+k=S:
        count=count+1
print(count)

Submission status: Runtime Error

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

ans = 0

for x in range(k+1):
  if x > s:
    break
  for y in range(k+1):
    if sum(x, y) > s:
      break
    for z in range(k+1):
      if sum(x, y, z) > s:
        break
      if sum(x, y, z) == s:
        ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())
one = 0
three = 0
six = 0
if S%3==0:
    one = 1
else:
    one = 0
for l in range(K+1):
    if (S-l)%2==0 and (S-l)//2 =< K:
        three += 1
for m in range(K-1):
    for n in range(m+1,K):
        rest = S-(m+n)
        if rest>n and rest<=K:
          six += 1
print(one+3*(three-one)+6*six)

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())
div = (K+1)//3
one = 0
three = 0
six = 0
for l in range(div):
  for m in range(l+1,div):
    for n in range(m+1,div):
      if l+m+n == S:
        six +=1
if S%3 == 0:
  one = 1
for i in range(K+1):
  if (S-i)%2 ==0 and S%3!=0:
    two +=1

print(one+3*three+6*six)

Submission status: Runtime Error

Solution code:
K=int(input())
S=int(input())
cnt= 0

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

print(cnt)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
k = a[0]
s = a[1]
num=0
for l in range(k+1):
    for m in range(l,k+1):
        n = s-l-m
        if(n <= k & n >= 0):
            if(l!=m and l!= n and m!=n):
                num+=3
            else if (l==m and m==n):
                num+=1
            else:
                num+=2
                
print(num)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= k):
            num+=1

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= k):
            num++

Submission status: Runtime Error

Solution code:
k,s = input().split()
for l in range(k):
    for m in range(k):
        if(s-l-m <= k):
            print(l,m,s-l-m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(lambda x: sp(x), inputs))
    N = len(points)
    distances = []
    for i, _ in enumerate(points):
        for j in range(i + 1, N):
            distances.append(
                math.sqrt(
                    (points[i][0] - points[j][0]) ** 2
                    + (points[i][1] - points[j][1]) ** 2
                )
            )
    max = 0
    for d in distances:
        max = d if max < d else max
    return "%.6f" % max


def sp(s):
    new_s = s.split()
    return list(map(lambda x: int(x), new_s))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
    s = input()
    print(s.replace(',', ' '))

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

Submission status: Runtime Error

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

ar = itertools.product(range(K+1), repeat=2)

ans = 0
for a,b in ar:
  if S - a-b <= K and S-a-b >=: ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

ans = [[x,y] for x in range(2, K+1) for y in range(2, K+1) if (0<=(S-X-Y)) and ((S-X-Y)<=K)]
print(len(ans))

Submission status: Runtime Error

Solution code:
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int K, S;
    cin >> K >> S;

    int cnt = 0;

    rep (X, K+1)
    {
        rep (Y, K+1)
        {
            rep (Z, K+1)
            {
                if (X + Y + Z == S)
                {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << "\n";

    return 0;
}

Submission status: Runtime Error

Solution code:
from itertools import product
k,s = (int(i) for i in input().split())
cnt = 0
for a in product(range(min(k+1,s+1),repeat=3):
    if sum(a) == s:
        cnt += 1
print(cnt)

Submission status: Runtime Error

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

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,s;
	cin >> k >> s;
	int soma = 0;
	for(int i = 0;i<=k;i++){
		for(int j = 0;j<=k;j++){
			if(s-i-j >=0 and s -i - j<=k)
				soma ++;
		}
	}
	
	cout<<soma<<endl;

	
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for a in range(0, K + 1):
  for b in range(0, K + 1):
    for c in range(0, K + 1):
      if a + b + c == S:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
def f(K, S):
    #ここに処理を書いてください
    res = 0
    for i in range(K+1):
      for j in range(K+1):
        if i + j <= S and S-i-j <= K:
          res += 1
    return res

in = list(map(int, input().split()))
print(f(in[0], in[1]))

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())
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:
import math
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))

M = 0
for i in range(N):
    for j in range(1,N):

        M = max(M, math.sqrt((P[i][0]-P[j][0]) ** 2 + (P[i][1]-P[j][1]) ** 2))

print("{:.6f}".format(M))

Submission status: Runtime Error

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

for x,y in product(range(n+1), range(n+1)):
    if 0 <= s - x - y <= n:
        ans += 1
print(ans)

Submission status: Runtime Error

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

c = 0

if s == 3*k:
  c = 1
elif s >= 2*k:
  c = (5 - s % k) * 3
elif s >= k:
  c = pass
else:
  c = 3 * k
  
print(c)

Submission status: Runtime Error

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

print(cnt)

Submission status: Runtime Error

Solution code:
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

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

    print(count(k, s))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      i+j+l=M
      if (M==S):
        counter = counter + 1
      else:
        None
print(counter)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if (i+j+l==S):
        counter = counter + 1
      else:
        None
print(counter)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if (i+j+l==S):
        counter += 1
      else:
        None
print(counter)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if (i+j+l==S):
        counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0
for i in range(K):
  for j in range(K):
    for l in raneg(K):
      if (i+j+l==S):
        counter += 1
print(counter)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S,K = map(int,input().split)
counter = 0
for i in range(K):
  for j in range(K):
    for l in raneg(K):
      if (i+J+l==S):
        counter+=1
print(counter)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;


int main(){
  int n;
  cin >> k >> s;
  count=0;
  for(int x=0; x<<k+1; x++){
    for(int y=0; y<<k+1; y++){
      for(int z=0; z<<k+1; z++){
        if(x+y+z==s){
          count++;
        }
      }  
    }
  }
  cout << count << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
k,s= list(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 = (int(_) for _ in input().split())

out = 0

for x in range(K+1):
    for y in range(x):
        for z in range(y)
            if x + y + z == S :
                if x == y and y == z:
                    out += 1
                elif x == y or y == z or z == x:
                    out += 3
                else:
                    out += 6

print(out)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

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

Submission status: Runtime Error

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0]
s = x[1]

#k = 5
#s = 15

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

Submission status: Runtime Error

Solution code:
K, S = int(input().split())
ans = 0
for o in range(2, K):
    for p in range(2, K-o):
        for q in range(2, K-o-p):
            if o + p + q == S:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
K, S = int(input().split())
ans = 0
for o in range(2, K):
    for p in range(2, K):
        for q in range(2, K):
            if o + p + q == S:
                ans += 1
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
k,s=map(int,input().split());k+=1;print(sum(k>=s-x//k-y%k>=0for I in range(k**2)))

Submission status: Runtime Error

Solution code:
K,S = map(int,input().split())
print(sum(range(S+1))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
k,s = map(int,input().split())
if s/k == 3 or k/s == 3:
    print(1)
elif k < s:
    print(int((1/2)*(k+1)*(k+2)))
elif k >= s:
    print(int((1/2)*(s+1)*(s+2)))

Submission status: Runtime Error

Solution code:
k,s = map(int,input().split())
Xm = k
Ym = k
Zm = k
count = 0
for i in range(Xm+1):
  for j in range(Ym+1):
    for m in range(Zm+1):
      if i+j+m = s:
        count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int K, S; cin >> K >> S;
    long long ans = 0;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            for (int z = 0; z <= K; ++z) {
                if (x + y + z == S) ans++;
            }
        }
    }
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
k,s=int(input())
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: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
K, S = map(int, input().split())
ans = [i for i in itertools.product(range(K + 1), repeat=3)]
print([sum(i) for i in ans].count(S))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys

K, S = sys.stdin.readlines()[0].strip().split(' ')
total_pattern = 0

def recursive_solver(state):
  for k in K:
    s = recursive_solver(state - k)
    if s == 0:
      total_pattern += 1
    elif s < 0:
      return -1
    else:
      return recursive_solver(s)

recursive_solver(S)
print(total_patter)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest051-B
#  https://atcoder.jp/contests/abc051/tasks/abc051_b
def  queueAnswer(maxValue,sumNumber):
	counter = 0
	for x in range(0,maxValue+1,1):
		for y in range(0,maxValue+1,1):
			for z in range(0,maxValue+1,1):
				thisSum = x+y+z
				if  thisSum=sumNumber:
					counter = counter + 1
	answer = counter
	return answer


if __name__ == '__main__':
	k,s = map(int,input().strip().split(' '))
	solution=queueAnswer(k,s)
	print(solution)

Submission status: Runtime Error

Solution code:
K,S = int(input())
c=0
L=list(range(0,K+1))
for i in L:
    for j in L:
        for k in L:
            if i+j+k == S:
                c+=1
print(c)

Submission status: Runtime Error

Solution code:
import math
k,s = input().split()
print(math.factorial(s)//(math.factorial(k)*math.factorial(2)))

Submission status: Runtime Error

Solution code:
k,s = input().split()
a = 0
n = 0
while a <= k:
  b = 0
  while b <= k:
    c = 0
    while c <= k:
      if (a+b+c) == s:
        n += 1
      c += 1
    b += 1
  a += 1
print(n)

Submission status: Runtime Error

Solution code:
k,s = input().split()
a = 0
n = 0
while a <= k:
  b = 0
  while b <= k:
    c = 0
    while c <= k:
      if (a+b+c) == s:
        n += 1
print(n)

Submission status: Runtime Error

Solution code:
k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(s-i+1):
        if s-i-j > k:
            continue
        elif j > k:
            break
        z = s - i - j
        if 0<= z <= k
print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(ct)

Submission status: Runtime Error

Solution code:
K = int(input())
S = int(input())
counter = 0

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