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())
ans=0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k,s=map(int,input().split())
cnt=0
for i in range(min(k,s)+1):
  for j in range(min(k,s-i)+1):
    if s-i-j<=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:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
import math


def main():
    K, S = map(int, input().split())
    cnt = 0
    for x in range(S+1):
        if x > K:
            continue
        res = S - x
        for y in range(res + 1):
            if y > K:
                continue
            z = res - y
            if z > K:
                continue
            else:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, s = map(int, input().split(' '))
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if s - k <= x + y <= s:
            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:
# Problem: https://atcoder.jp/contests/abc051/tasks/abc051_b
# Python  3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(maxNum, totalNum):
    result = 0
    for x in range(0,maxNum+1):
        for y in range(0,maxNum+1):
            z = totalNum - x - y
            if 0 <= z and z <= maxNum:
                result = result + 1
    return result


if __name__ == "__main__":
    K, S = MI()
    print("{}".format(solver(K, S)))

Submission status: Accepted

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

out = 0

# 全探査だと間に合わない
# zはあるかないかの２択なので外せる
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            out += 1
print(out)

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
X = (S + 2) * (S + 1)
if S - K - 1 >= 0:
  X -= 3 * (S - K + 1) * (S - K)
if S - 2 * K - 2 >= 0:
  X += 3 * (S - 2 * K) * (S - 2 * K - 1)

print(X // 2)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = input().split()
N = int(N)
M = int(M)

sum = 0

for i in range(N + 1):
    for j in range(N + 1):
        if  0 <= M - i - j <= N:
            sum += 1
            
print(sum)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	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:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  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)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,N = map(int,input().rstrip().split(" "))
ans = 0
for i in range(K + 1):
  for i2 in range(K + 1):
    if i + i2 <= N and N - i - i2 <= K:
      ans += 1
print(ans)

Submission status: Accepted

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

      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# Problem:
# Python  Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
intm1 = lambda x: int(x) - 1
intp1 = lambda x: int(x) + 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(intm1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(limitno, giventotal):
    result = 0
    for x in range(0, limitno+1):
        for y in range(0, limitno+1):
            z = giventotal - x - y
            if ( 0 <= z ) and (z <= limitno):
#                print("{} + {} + {} = {}".format(x,y,z,giventotal))
                result = intp1(result)
    return result


if __name__ == "__main__":
    K, S = MI()
    print("{}".format(solver(K, S)))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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 i in range(k+1):
    for j in range(k+1):
        l = s - i - j
        #print('{} {} {}'.format(i,j,l))
        if  l >= 0 and k >= l:
            ans +=  1
            
print(ans)

Submission status: Accepted

Solution code:
K, S = [int(i) for i in input().split()]
t = 0
for a in range(K+1):
    for b in range(a, K+1):
        c = S - a - b
        if 0 <= c <= K and c >= a and c >= b:
            if a == b == c:
                t += 1
            elif a == b or b == c:
                t += 3
            else:
                t += 6
print(t)

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())
cnt = 0
for z in range(min(k, s) + 1):
  if s - z <= k:
    cnt += s - z + 1
  else:
    cnt += max(0, 2*k + z - s + 1)
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

k, s = map(int, input().split())
cnt = 0
max_v = max(2 * (k + 2), s + 1)
memo = [0] * max_v
for i in range(k + 1):
  for j in range(k + 1):
    v = i + j
    if v > s:
      break
    memo[v] += 1
for i in range(k + 1):
  for j in range(max_v):
    v = i + j
    if v > s:
      break
    elif v == s:
      cnt += memo[j]
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import combinations

def main():
    k, s = map(int, input().split())
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                yield 1

print(sum(main()))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

c=0
for i in range(K+1):
  for j in range(K+1):
    if S <= i+j+K and i+j<=S:
      # print("{} {}".format(i,j))
      c+=1

print(c)

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc051/tasks/abc051_b
# Python 1st Try
# CalcTime O^2 Edition

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(K, S):
    result = 0
    # algorithm
    for x in range(0, K+1):
        for y in range(0, K+1):
            z = S - x - y
            if ((0 <= z) and ( z <= K)):
                result = result + 1
    return result


if __name__ == "__main__":
    K, S = MI()
#    print("K={} S={}".format(K, S))
    print("{}".format(solver(K, S)))

Submission status: Accepted

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

Submission status: Accepted

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

def fact(n):
  return sum([x for x in range(1,n+1)])

ans = 0
r = 0
for x in range(k+1):
  for y in range(x,k+1):
    if 0 <= s - (x+y) <= k:
      if (x==y):
          ans += 1
      else:
          ans += 2

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
# 標準入力の取得
K,S = list(map(int, input().split()))

# 全探索を行う
available_value_list = range(K+1)

result = 0
for x in available_value_list:
    for y in available_value_list:
        z = S - x - y # x + y + z = Sより算出
        if 0 <= z and z <= K:
            result += 1

# 結果出力
print(result)

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

print(ans)

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(Y)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    if 0<=s-i-ii<=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):
    if s-x < 0 or s-x > 2*k:
        # no answer (y,z)
        continue
    elif 0 <= s-x <= k:
        ans += 1+s-x
    else:
        ans += k - (s-x-k) + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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):
        if -1 < s-i-j < k+1:
            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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k,s=MI()
    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)

main()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

count = 0
for x in range(k,-1,-1):
    a = s - x
    if a > 2*k:
        break
    elif a == 0:
        count += 1
        continue

    if a >= k:
        tmp = k
    else:
        tmp = a

    for y in range(tmp, -1, -1):
        z = a - y
        if z > k :
            break
        else:
            count += 1

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

count=0

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

print(count)

Submission status: Accepted

Solution code:
K, S = map(int, input().split())
x = S if K>S else K

ans = 0
for i in range(x+1):
  x1 = S-i
  for j in range((K if x1>K else x1)+1):
    if 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):
        z = S-x-y
        if 0 <= z <= K:
            cnt += 1
print(cnt)

Submission status: Accepted

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

for y in range(K+1):
    for z in range(K+1):
        x = S - y - z
        
        if x < 0 or x > K:
            continue
        else:
            ans += 1
            continue
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)&(z<=K):
            count += 1
print(count)

Submission status: Accepted

Solution code:
#ABC.B(51-60)
K,S = map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    K, S = [int(x) for x in input().split()]
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z < 0 or z > K:
                continue
            else:
                ans += 1

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
k, s = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for x in range(min(k+1, s+1)):
    for y in range(min(k+1, s - x + 1)):
        if s - x - y <= k:
            cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

    count = 0
    for x in range(k+1):

        if k*2 + x < s:
            continue

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

    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

cnt=0
if K*3==S:
    cnt+=1
elif K*3<S:
    pass
else:
    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()) 
print(len([True for x in range(K+1) for y in range(K+1) if (S-x-y>=0) and (S-x-y<=K)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
K = t[0]
S = t[1]
counter = 0

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

Submission status: Accepted

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

count = 0
for i in range(0, k + 1):
    if i > s:
        break
    for j in range(0, k + 1):
        if i + j > s:
            break
        if s - i - j <= k:
            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(i,k+1):
        c = s-i-j
        if k >= c and c >=j:
            if i == j and j == c:
                ans += 1
            elif i!=j and j!=c and c!=j:
                ans += 6
            else:
                ans += 3
        
print(ans)

Submission status: Accepted

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

for i in range(k + 1):
    x = i
    tmp = s - x

    if tmp < 0:
        break

    if 2 * k >= tmp:
        if k >= tmp:
            ans = ans + tmp + 1
        else:
            ans = ans + ((k + 1) - (tmp - k))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import math
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

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

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 18 20:25:04 2020

@author: naoki
"""

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s3 = s // 3
m = max(k, s3)
for x in range(0, m + 1):
    # print(x)
    for y in range(0, m + 1):
        ad = s - x - y
        if ad <= k and ad >= 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys

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

print("{}".format(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    K,S=MI()
    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)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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