input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
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)
K,S = list(map(int, input().split())) ans = 0 for x in range(K+1): for y in range(K+1): z = S-(x+y) if(0<=z<=K): ans += 1 print(ans)
p03835
K, S = list(map(int, input().split())) count = 0 for x in range(K+1): for y in range(K+1): if (S-(x+y) <= K)&(S-(x+y) >= 0): count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K+1): for y in range(K+1): z = S-x-y if (z>=0)&(z<=K): count += 1 print(count)
p03835
# -*- coding: utf-8 -*- 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): s = x + y + z if s == S: count += 1 print(count)
# -*- coding: utf-8 -*- K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
p03835
[K, S] = list(map(int, input().split())) count = 0 for X in range(K+1): if X > S and 3*K < S: break for Y in range(K+1): add_xy = X + Y if S < add_xy and add_xy < (2/3) * S: break Z = S - X - Y if 0 <= Z and Z <= K: count +=1 print(count)
[K, S] = list(map(int, input().split())) count = 0 for X in range(K+1): for Y in range(K+1): Z = S - X - Y if 0 <= Z and Z <= K: count +=1 print(count)
p03835
K, S = list(map(int, input().split())) count = 0 for x in range(0, K + 1): if (x > S): break for y in range(0, K + 1): if (x + y > S): break for z in range(0, K + 1): if (x + y + z == S): count = count + 1 elif (x + y + z > S): break print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(0, K+1): if (x > S): break for y in range(0, min(S-x+1, K+1)): if (S-x-y >= 0 and S-x-y <= K): count = count + 1 print(count)
p03835
K,S=list(map(int,input().split())) K+=1 ans=0 a=max(0,S-2*K) for i in range(a,K): if i>S: break for j in range(a,K): if i+j>S : break for k in range (a,K): if i+j+k>S: break if i+j+k==S: ans+=1 print(ans)
K,S=list(map(int,input().split())) ans=0 #a=max(0,S-2*K) for i in range(K+1): for j in range(K+1): if i+j+K>=S and i+j<=S : ans+=1 print(ans)
p03835
r=range;k,s=list(map(int,input().split())) print((len([0 for x in r(k+1) for y in r(k+1) for z in r(k+1) if x+y+z==s])))
r=range;k,s=list(map(int,input().split())) print((len([0 for x in r(k+1) for y in r(k+1) if 0<=s-x-y<=k])))
p03835
import sys num = sys.stdin.readline().split(' ') K = int(num[0]) S = int(num[1]) counter = 0 for i in range(K+1): for j in range(K+1): for k in range(K+1): if i+j+k == S: counter += 1 else: continue print(counter)
import sys num = sys.stdin.readline().split(' ') K = int(num[0]) S = int(num[1]) counter = 0 for i in range(K+1): for j in range(K+1): if 0 <= S-i-j <= K: counter += 1 else: continue print(counter)
p03835
def main(): K, S = list(map(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) if __name__ == "__main__": main()
def main(): 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 and z <= K: cnt += 1 print(cnt) if __name__ == "__main__": main()
p03835
import itertools N, K = list(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)))
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 and z <= k: cnt += 1 print(cnt)
p03835
K, S = list(map(int, input().split())) count = 0 for x in range(S+1): # print("x", x) for y in range(S-x+1): # print("y" , y) z = S - x - y # print("z", z) if (x>=0 and x<=K) and (y>=0 and y<=K) and (z>=0 and z<=K): count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K+1): for y in range(K+1): z = S - x - y if (z>=0) and (z<=K): count += 1 print(count)
p03835
import bisect k,s=list(map(int,input().split())) ans=0 z=[i for i in range(k+1)] for x in range(k+1): for y in range(k+1): a=s-x-y if a<=k and z[bisect.bisect_left(z,a)]==a: ans+=1 print(ans)
k,s=list(map(int,input().split())) ans=0 for x in range(k+1): for y in range(k+1): z=s-x-y if 0<=z<=k: ans+=1 print(ans)
p03835
def main(): K, S = list(map(int, input().split())) count = 0 # X for i in range(K+1): # Y for j in range(K+1): # Z for k in range(K+1)[::-1]: if i + j + k == S: count += 1 if i + j + k < S: break print(count) main()
def main(): K, S = list(map(int, input().split())) count = 0 # X for i in range(K+1): # Y for j in range(K+1): if i + j > S: break if S-i-j > K: continue count += 1 print(count) main()
p03835
def resolve(): ks = input().split(" ") k = int(ks[0]) s = int(ks[1]) n = 0 for zz in range(k+1): for yy in range (k+1): for xx in range (k+1): if (xx+yy+zz == s): n += 1 print(n) if __name__ == "__main__": resolve()
def resolve(): ks = input().split(" ") k = int(ks[0]) s = int(ks[1]) n = 0 for zz in range(k+1): for yy in range (k+1): if (0 <= s-(yy+zz) <= k): n += 1 print(n) if __name__ == "__main__": resolve()
p03835
K, S = list(map(int, input().split())) result = 0 for x in range(K + 1): for y in range(K + 1): for z in range(K + 1): if x + y + z == S: result += 1 print(result)
K, S = list(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)
p03835
k, s = list(map(int, input().split())) arr = [[x, y, s-x-y] for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0] print((len(arr)))
k, s = list(map(int, input().split())) arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0] print((sum(arr)))
p03835
import sys # sys.stdin = open('b1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) def main(): k, s = read_int_list() res = 0 for x in range(0, k + 1): for y in range(0, k + 1): for z in range(0, k + 1): if s == x + y + z: res += 1 print(res) main()
import sys # sys.stdin = open('b1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) def main(): k, s = read_int_list() res = 0 for x in range(0, k + 1): for y in range(0, k + 1): z = s - (x + y) if 0 <= z <= k: res += 1 print(res) main()
p03835
K, S = list(map(int, input().split())) cnt = 0 for x in range(K + 1): pass for y in range(K + 1): pass for z in range(K + 1): if x + y + z == S: cnt += 1 print(cnt)
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 z >= 0 and z <= K: cnt += 1 print(cnt)
p03835
K, S = list(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 S == i + j + k : count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for i in range(K+1) : for j in range(K+1) : if S < i + j : break if S - i - j <= K : count += 1 print(count)
p03835
K, S = list(map(int, input().split())) success = 0 for x in range (K + 1): for y in range (K + 1): for z in range (K + 1): if x + y + z == S: success = success + 1 print(success)
K, S = list(map(int, input().split())) success = 0 for x in range (K + 1): for y in range (K + 1): if S - x - y >= 0 and S - x - y <= K: success = success + 1 print(success)
p03835
import bisect k,s=list(map(int, input().split())) p=[] for i in range(k+1): p.append(i) ans=0 for x in range(k+1): for y in range(k+1): if p[bisect.bisect_right(p,s-x-y)-1]==s-x-y: ans+=1 print(ans)
k,s=list(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)
p03835
K, S = list(map(int, input().split())) ans = 0 for i in range(0,K+1): for j in range (0,K+1): for k in range (0,K+1): if (i + j + k) == S: ans = ans + 1 continue print(ans)
K, S = list(map(int, input().split())) ans = 0 for i in range(0,K+1): for j in range (0,K+1): if (S-K) <= (i + j) <= S: ans = ans + 1 continue print(ans)
p03835
k, s = list(map(int, input().split())) ans = 0 three = [0, 0, 0] for i in range(k+1): for j in range(k+1): for k in range(k+1): g = i + j + k if g == s: ans += 1 print(ans)
k, s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if 0 <= z <= k : ans += 1 print(ans)
p03835
row = input().split() K = int(row[0]) S = int(row[1]) count = 0 for x in range(K+1): for y in range(K+1): for z in range(K+1): if S == x+y+z: count += 1 print(count)
row = input().split() K = int(row[0]) S = int(row[1]) count = 0 for x in range(K+1): for y in range(K+1): if 0 <= S - x - y <= K: count += 1 print(count)
p03835
K,S = list(map(int,input().split())) ans = 0 for x in range(K+1): for y in range(K+1): z = S-x-y if 0<=z<=K: ans += 1 print(ans)
k,s = list(map(int,input().split())) a = ((s+1)*(s+2))//2 b = ((s-k)*(s-k+1))//2 c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2 if s <= k: print(a) elif s <= k*2: print((a-b*3)) elif s <= k*3: print(c)
p03835
import itertools K, S = [int(i) for i in input().split()] count = 0 for i in range(0, K+1): for j in range(0, K+1): for k in range(0, K+1): if i+j+k == S: count += 1 print(count)
K, S = [int(i) for i in input().split()] count = 0 for i in range(0, K+1): for j in range(0, K+1): k = S - i -j if 0 <= k <= K: count += 1 print(count)
p03835
k,s=list(map(int,input().split())) cnt=0 for i in range(k+1): for j in range(k+1): for m in range(k+1): if i+j+m==s: cnt+=1 else: pass print(cnt)
k,s=list(map(int,input().split())) cnt=0 for i in range(k+1): for j in range(k+1): z=s-i-j if z>=0 and z<=k: cnt+=1 print(cnt)
p03835
def solve(): k, s = list(map(int, input().split())) c = 0 for x in range(k + 1): for y in range(k + 1): for z in range(k + 1): if x + y + z == s: c += 1 return c if __name__ == "__main__": print((solve()))
def solve(): k, s = list(map(int, input().split())) c = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - (x + y) <= k: c += 1 return c if __name__ == "__main__": print((solve()))
p03835
cnt = 0 k, s = list(map(int,input().split())) for i in range(k+1): for j in range(k+1): for l in range(k+1): if i + j + l == s: cnt += 1 print(cnt)
k, s = list(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)
p03835
k, s = list(map(int, input().split())) ct = 0 for x in range(k+1): for y in range(x, k+1): if x + y > s: break; for z in range(y, k+1): if x + y + z == s: if x == y and y == z: ct += 1 elif x != y and y != z: ct += 6 else: ct += 3 break; print(ct)
k, s = list(map(int, input().split())) ct = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if 0 <= z <= k: ct += 1 print(ct)
p03835
import sys import copy import string from _bisect import * from collections import * from operator import itemgetter from math import factorial """ from fractions import gcd def lcm(x, y): return (x * y) // gcd(x, y) """ stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() k, s = na() ct = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if 0 <= z <= k: ct += 1 print(ct)
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() k, s = na() ct = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if 0 <= z <= k: ct += 1 print(ct)
p03835
import itertools K,S=list(map(int,input().split())) a=list(range(K+1)) #print(a) combi=list(itertools.product(a,repeat=3)) #print(combi) print(([sum(combi[i]) for i in range(len(combi))].count(S)))
import itertools K,S=list(map(int,input().split())) combi=[] num=0 for i in range(K+1): for j in range(i,K+1): for k in range(j,K+1): if i+j+k==S: combi=[i,j,k] #print(combi) #print(set(itertools.permutations(combi))) t=set(itertools.permutations(combi)) #print(len(t)) num+=len(t) print(num)
p03835
import itertools K,S=list(map(int,input().split())) combi=[] num=0 for i in range(K+1): for j in range(K+1): if 0<=S-i-j<=K: combi=[i,j,S-i-j] #print(combi) #print(set(itertools.permutations(combi))) num+=1 print(num)
K,S=list(map(int,input().split())) num=0 for i in range(K+1): for j in range(K+1): if 0<=S-i-j<=K: num+=1 print(num)
p03835
K, S = list(map(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)
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)
p03835
k, s = (int(i) for i in 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)
k, s = (int(i) for i in input().split()) count = 0 for h in range(k + 1): for i in range(k + 1): j = s - i - h if 0 <= j <= k: count += 1 print(count)
p03835
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)
K,S=list(map(int,input().split())) ans=0 for x in range(K+1): for y in range(K+1): z=S-x-y if 0<=z<=K: ans+=1 print(ans)
p03835
k, s = list(map(int, input().split())) count=0 for i in range(k+1): for j in range(k+1): t = s-i-j if t <= k and t >= 0: count += 1 else: pass print (count)
k, s = list(map(int, input().split())) count=0 for i in range(k+1): for j in range(k+1): t = s-i-j if t <= k and t >= 0: count += 1 print (count)
p03835
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)
r,g=list(map(int,input().split())) X=0 for i in range(r+1): for j in range(r+1): k=g-i-j if k>=0 and k<=r: X+=1 print(X)
p03835
K, S = list(map(int, input().split())) c = 0 for x in range(K+1): for y in range(K+1): for z in range(K+1): if (x + y + z) == S:c+=1 print(c)
K, S = list(map(int, input().split())) c = 0 for x in range(K+1): for y in range(K+1): if 0 <= S - (x + y) <= K:c+=1 print(c)
p03835
k, s = list(map(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)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k+1): for y in range(k+1): if 0 <= s-x-y <= k: cnt += 1 print(cnt)
p03835
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)
k, s = list(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)
p03835
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)
K, S = list(map(int, input().split())) count=0 for x in range(K+1): for y in range(K+1): z = S - (x+y) if (z <= K) & (z >= 0): count += 1 print(count)
p03835
k, s = list(map(int, input().split(' '))) count = 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: count += 1 print(count)
k, s = list(map(int, input().split(' '))) count = 0 for x in range(0,k+1): for y in range(0, k+1): z = s - (x + y) if 0 <= z <= k: count +=1 print(count)
p03835
k,s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(k+1): if x+y > s: break elif s-x-y <= k: ans += 1 print(ans)
k,s = list(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)
p03835
K, S = list(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 <= K: ans += 1 print(ans)
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)
p03835
k, s = list(map(int, input().split())) ans = 0 for x in reversed(list(range(k+1))): for y in reversed(list(range(k+1))): for z in reversed(list(range(k+1))): if x+y+z == s: ans += 1 break elif x+y+z < s: break print(ans)
k, s = list(map(int, input().split())) ans = 0 for x in reversed(list(range(k+1))): for y in reversed(list(range(k+1))): if s-(x+y) >= 0 and s-(x+y) <= k: ans += 1 print(ans)
p03835
import sys K,S = list(map(int,input().split())) X,Y,Z = 0,0,0 if K < 2 or K > 2500: sys.exit() if X > K or Y > K or Z > K: sys.exit() X = 0 count = 0 while X <= K: Y = 0 while Y <= K: Z = 0 while Z <= K: if X + Y + Z == S: count += 1 Z += 1 Y += 1 X += 1 print(count)
import sys K,S = list(map(int,input().split())) if K < 2 or K > 2500: sys.exit() X = 0 count = 0 while X <= K: Y = 0 while Y <= K: Z = S - X - Y if Z <= K and Z >= 0: count += 1 Y += 1 X += 1 print(count)
p03835
k, s = list(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 else: pass print(count)
k, s = list(map(int, input().split())) count = 0 for i in range(k + 1): for j in range(k + 1): if 0 <= s - i - j <= k: count += 1 print(count)
p03835
k, s = list(map(int, input().split())) if s==3*k: print((1)) else: ans=0 for i in range(k+1): if i>s: break for j in range(k+1): if i+j>s: break for jj in range(k+1): if i+j+jj==s: ans+=1 elif i+j+jj>s: break print(ans)
k, s = list(map(int, input().split())) if s==3*k: print((1)) else: ans=0 for i in range(k+1): if i>s: break for j in range(k+1): if i+j+k>=s and s-i-j>=0: ans+=1 print(ans)
p03835
k, s = list(map(int, input().split())) if s==3*k: print((1)) else: ans=0 for i in range(k+1): if i>s: break for j in range(k+1): if i+j+k>=s and s-i-j>=0: ans+=1 print(ans)
k, s = list(map(int, input().split())) if s==3*k: print((1)) else: ans=0 for i in range(k+1): if i>s: break for j in range(k+1): if i+j+k>=s and s-i-j>=0: ans+=1 elif i+j>s: break print(ans)
p03835
k, s = list(map(int, input().split())) ans = 0 for i in range(k+1): for j in range(k+1): for l in range(k+1): if (i + j + l) == s: ans += 1 print(ans)
k, s = list(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)
p03835
# 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)))
# 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)))
p03835
K,S = list(map(int,input().split())) counter = 0 for i in range(K+1): for j in range(K+1): for k in range(K+1): if i+j+k == S: counter += 1 print(counter)
K,S = list(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)
p03835
k, s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(x,k+1): for z in range(y,k+1): if x+y+z == s: if x != y != z : ans += 6 elif x == y != z or x != y == z: ans += 3 elif x == y == z: ans += 1 print(ans)
k, s = list(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)
p03835
K, S = list(map(int, input().split())) ans = 0 for x in range(K+1): for y in range(K+1): if x + y > S: break for z in range(K+1): if x + y + z > S: break if x + y + z == S: ans += 1 print(ans)
K, S = list(map(int, input().split())) ans = 0 for x in range(K+1): for y in range(K+1): x_y = x + y if x_y > S: break if S - x_y <= K: ans += 1 print(ans)
p03835
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)
K,S=list(map(int,input().split())) count=0 for X in range(K+1): for Y in range(K+1): if 0<=S-X-Y<=K: count+=1 print(count)
p03835
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴァージョン def lines(n): return [eval(input()) for _ in range(n)] # Union-Find木 http://at274.hatenablog.com/entry/2018/02/02/173000 class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # 同じ集合に属するか判定 def same_check(self, x, y): return self.find(x) == self.find(y) # 重み付きのUnion-Find木 http://at274.hatenablog.com/entry/2018/02/03/140504 class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 根への距離を管理 self.weight = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: y = self.find(self.par[x]) # 親への重みを追加しながら根まで走査 self.weight[x] += self.weight[self.par[x]] self.par[x] = y return y # 併合 def union(self, x, y, w): rx = self.find(x) ry = self.find(y) # xの木の高さ < yの木の高さ if self.rank[rx] < self.rank[ry]: self.par[rx] = ry self.weight[rx] = w - self.weight[x] + self.weight[y] # xの木の高さ ≧ yの木の高さ else: self.par[ry] = rx self.weight[ry] = -w - self.weight[y] + self.weight[x] # 木の高さが同じだった場合の処理 if self.rank[rx] == self.rank[ry]: self.rank[rx] += 1 # 同じ集合に属するか def same(self, x, y): return self.find(x) == self.find(y) # xからyへのコスト def diff(self, x, y): return self.weight[x] - self.weight[y] """ここからメインコード""" k, s = intline() r = range ans = 0 for x in r(k+1): for y in r(k+1): for z in r(k+1): if x + y + z == s: ans += 1 print(ans)
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴァージョン def lines(n): return [eval(input()) for _ in range(n)] # Union-Find木 http://at274.hatenablog.com/entry/2018/02/02/173000 class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # 同じ集合に属するか判定 def same_check(self, x, y): return self.find(x) == self.find(y) # 重み付きのUnion-Find木 http://at274.hatenablog.com/entry/2018/02/03/140504 class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 根への距離を管理 self.weight = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: y = self.find(self.par[x]) # 親への重みを追加しながら根まで走査 self.weight[x] += self.weight[self.par[x]] self.par[x] = y return y # 併合 def union(self, x, y, w): rx = self.find(x) ry = self.find(y) # xの木の高さ < yの木の高さ if self.rank[rx] < self.rank[ry]: self.par[rx] = ry self.weight[rx] = w - self.weight[x] + self.weight[y] # xの木の高さ ≧ yの木の高さ else: self.par[ry] = rx self.weight[ry] = -w - self.weight[y] + self.weight[x] # 木の高さが同じだった場合の処理 if self.rank[rx] == self.rank[ry]: self.rank[rx] += 1 # 同じ集合に属するか def same(self, x, y): return self.find(x) == self.find(y) # xからyへのコスト def diff(self, x, y): return self.weight[x] - self.weight[y] """ここからメインコード""" k, s = intline() r = range ans = 0 for x in r(k+1): for y in r(k+1): if x + y <= s and s - x - y <= k: ans += 1 print(ans)
p03835
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴァージョン def lines(n): return [eval(input()) for _ in range(n)] # Union-Find木 http://at274.hatenablog.com/entry/2018/02/02/173000 class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # 同じ集合に属するか判定 def same_check(self, x, y): return self.find(x) == self.find(y) # 重み付きのUnion-Find木 http://at274.hatenablog.com/entry/2018/02/03/140504 class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 根への距離を管理 self.weight = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: y = self.find(self.par[x]) # 親への重みを追加しながら根まで走査 self.weight[x] += self.weight[self.par[x]] self.par[x] = y return y # 併合 def union(self, x, y, w): rx = self.find(x) ry = self.find(y) # xの木の高さ < yの木の高さ if self.rank[rx] < self.rank[ry]: self.par[rx] = ry self.weight[rx] = w - self.weight[x] + self.weight[y] # xの木の高さ ≧ yの木の高さ else: self.par[ry] = rx self.weight[ry] = -w - self.weight[y] + self.weight[x] # 木の高さが同じだった場合の処理 if self.rank[rx] == self.rank[ry]: self.rank[rx] += 1 # 同じ集合に属するか def same(self, x, y): return self.find(x) == self.find(y) # xからyへのコスト def diff(self, x, y): return self.weight[x] - self.weight[y] """ここからメインコード""" k, s = intline() r = range ans = 0 for x in r(k+1): for y in r(k+1): if x + y <= s and s - x - y <= k: ans += 1 print(ans)
k,s=list(map(int, input().split())) r=range ans=[1 for x in r(k+1) for y in r(k+1)if x+y<=s and s-x-y<=k] print((sum(ans)))
p03835
k,s=list(map(int, input().split())) r=range ans=[1 for x in r(k+1) for y in r(k+1)if x+y<=s and s-x-y<=k] print((sum(ans)))
k,s=list(map(int,input().split()));r=range;print((sum(1 for x in r(k+1) for y in r(k+1)if x+y<=s and s-x-y<=k)))
p03835
k,s=list(map(int,input().split()));r=range;print((sum(1 for x in r(k+1) for y in r(k+1)if x+y<=s and s-x-y<=k)))
k,s=list(map(int,input().split()));r=range;print((sum(1for x in r(k+1)for y in r(k+1)if 0<=s-x-y<=k)))
p03835
k,s=list(map(int,input().split()));r=range;print((sum(1for x in r(k+1)for y in r(k+1)if 0<=s-x-y<=k)))
k,s=list(map(int,input().split()));r=range;k+=1;print((sum(1for x in r(k)for y in r(k)if 0<=s-x-y<k)))
p03835
K, S = [int(x) for x in 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)
K, S = [int(x) for x in input().split()] ans = 0 for x in range(max(0, S - 2 * K), min(K, S) + 1): ans += min(K, S - x) - max(0, S - x - K) + 1 print(ans)
p03835
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)
k,s=list(map(int,input().split())) count=0 for x in range(k+1): for y in range(k+1): if s-(x+y) <= k and s-(x+y) >= 0: count +=1 print(count)
p03835
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 Z in range(K+1): cnt+=1 print(cnt)
K,S=list(map(int,input().split())) cnt=0 for X in range(K+1): for Y in range(K+1): if 0<=S-X-Y and S-X-Y<=K: cnt+=1 print(cnt)
p03835
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)
K,S = list(map(int,input().split())) ans=0 for x in range(K+1): for y in range(K+1): ans+=1 if K>=S-(x+y)>=0 else 0 print(ans)
p03835
K,S=list(map(int,input().split())) ans=0 for i in range(K+1): for j in range(K+1): for k in range(K+1): if i+j+k==S: ans+=1 print(ans)
K,S=list(map(int,input().split())) ans=0 for i in range(K+1): for j in range(K+1): k=S-i-j if i+j+k==S: if 0<=k<=K: ans+=1 print(ans)
p03835
k,s=list(map(int,input().split())) c=0 for x in range(k+1): if x>s:break for y in range(k+1): if x+y>s:break for z in range(k+1): if x+y+z==s: c+=1 if x+y+z>s: break print(c)
k,s=list(map(int,input().split())) c=0 for i in range(k+1): for j in range(min(k,s-i)+1): if s-i-j<=k:c+=1 print(c)
p03835
k,s = list(map(int,input().split())) ans = 0 for x in range(s+1): for y in range(s+1): z = s - x - y if k >= x and k >= y and k >= z >=0: ans +=1 print(ans)
k,s = list(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)
p03835
K,S=list(map(int,input().split())) #これは立方体の中のどこか一点を選ぶ問題とみなせる #その中で選ばれた座標の各要素の和が、Sに等しければ良い #点の総和は(K+1)*3個あり(※ゼロを含むから)、それらが選択可能なx,y,zの集合である #x,y,zの和がSに達しない場合は、Sを満たす集合はその立方体の外側にある L=[] counter=0 for x in range(K+1): for y in range(K+1): for z in range(K+1): L.append([x,y,z]) if (S==x+y+z):counter+=1 print(counter)
K,S=list(map(int,input().split())) counter=0 for x in range(K+1): for y in range(K+1): if (S-x-y<=K) and (S-x-y>=0):counter+=1 print(counter)
p03835
k,s = list(map(int,input().split())) ans = 0 for i in range(k+1): for j in range(i,k+1): for c in range(j,k+1): if i + j + c == s: if i == j and j == c: ans += 1 elif i!=j and j!=c and c!=j: ans += 6 else: ans += 3 print(ans)
k,s = list(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)
p03835
k,s=list(map(int,input().split())) cnt=0 for i in range(0,k+1): for j in range(0,k+1): for k in range(0,k+1): if i+j+k==s: cnt+=1 print(cnt)
k,s=list(map(int,input().split())) cnt=0 for x in range(0,k+1): for y in range(0,k+1): z = s-x-y if z >= 0 and z <= k: cnt+=1 print(cnt)
p03835
import bisect K, S = list(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)
K, S = list(map(int,input().split())) ans = 0 for x in range(K+1): for y in range(K+1): z = S-x-y if 0 <= z and z <= K: ans += 1 print(ans)
p03835
import itertools k,s=list(map(int,input().split())) x=(x for x in range(0,k+1)) y=(y for y in range(0,k+1)) z=(z for z in range(0,k+1)) data=list(itertools.product(x,y,z)) ans=[sum(i) for i in (data)] print((ans.count(s)))
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)
p03835
import itertools k, s = list(map(int, input().split())) lst1 = [x for x in range(k+1)] lst2 = [x for x in range(k+1)] lst3 = [x for x in range(k+1)] data = list(itertools.product(lst1, lst2, lst3)) lst4 = [sum(i) for i in (data)] print((lst4.count(s)))
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)
p03835
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)
k, s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if 0 <= z <= k and x+y+z == s: ans += 1 print(ans)
p03835
import math import string import itertools import fractions import heapq import collections import re import array import bisect import sys import random import time inf = 10**9 def main(): k, s = list(map(int, input().split())) c = 0 for i in range(k+1): if i > s: break for j in range(k+1): if i + j > s: break for l in range(k + 1): if i + j + l > s: break if i + j + l == s: c += 1 # print(i, j, l) print(c) if __name__ == '__main__': main()
import math import string import itertools import fractions import heapq import collections import re import array import bisect import sys import random import time inf = 10**9 def main(): k, s = list(map(int, input().split())) c = 0 for i in range(k+1): if i > s: break for j in range(k+1): if i + j > s: break if s-i-j <= k: c += 1 print(c) if __name__ == '__main__': main()
p03835
k, s = list(map(int, input().split())) # print(k, s) count = 0 for x in range(k+1): for y in range(k+1): for z in range(k+1): # print(x, y, z) if x + y + z == s: count += 1 print(count)
k, s = list(map(int, input().split())) # print(k, s) count = 0 for x in range(k+1): for y in range(k+1): # print(x, y) if 0 <= s - x - y <= k: count += 1 print(count)
p03835
K, S = list(map(int, input().split())) rcount = 0 for i in range(K+1): for j in range(K+1): x = S - (i + j) if x >= 0 and x<=K: rcount += 1 print(rcount)
k, s = list(map(int, input().split())) count = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if z >= 0 and z <= k: count += 1 print(count)
p03835
K, S = list(map(int, input().split())) cnt = 0 for i in range(K+1): for j in range(K+1): for k in range(K+1): if i+j+k == S: cnt += 1 print(cnt)
K, S = list(map(int, input().split())) cnt = 0 for i in range(K+1): for j in range(K+1): k = S - i -j if 0 <= k and k <= K: cnt += 1 print(cnt)
p03835
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 and z <= K: cnt+=1 print(cnt)
K, S = list(map(int, input().split())) ans = sum(0 <= S-x-y <= K for x in range(K+1) for y in range(K+1)) print(ans)
p03835
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)
k,s=list(map(int, input().split())) count=0 for x in range(k+1): for y in range(k+1): if 0<=s-x-y<=k: count+=1 print(count)
p03835
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)
k,s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if 0 <= z <= k: ans += 1 print(ans)
p03835
# Sum of Three Integers import sys K, S = list(map(int, input().split())) def getAns(k, s) : 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 return cnt print((getAns(K, S)))
# Sum of Three Integers import sys K, S = list(map(int, input().split())) def getAns(k, s) : cnt = 0 for x in range(k + 1) : for y in range(k + 1) : z = s - x - y if 0 <= z <= k : cnt += 1 return cnt print((getAns(K, S)))
p03835
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)
K,S = list(map(int, input().split())) ans = 0 for x in range(K+1): for y in range(K+1): if S-x-y <= K and S-x-y >= 0: ans += 1 print(ans)
p03835
K,S=list(map(int,input().split())) cnt=0 for i in range(K+1): for t in range(i,K+1): for s in range(t,K+1): if i+t+s==S: if i==t==s: cnt+=1 elif i==t or i==s or t==s: cnt+=3 else: cnt+=6 else: continue print(cnt)
K,S=list(map(int,input().split())) cnt=0 for i in range(K+1): for t in range(K+1): s=S-i-t if 0<=s<=K: cnt+=1 else: continue print(cnt)
p03835
k, s = list(map(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)
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)
p03835
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)
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 k >= z >= 0: cnt += 1 print(cnt)
p03835
k, s = list(map(int, input().split(' '))) ans = 0 for i in range(k+1): for j in range(k+1): for k in range(k+1): if i+j+k == s: ans += 1 print(ans)
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)
p03835
K, S = list(map(int , input().strip().split(" "))) count = 0 for x in range(K+1): if x > S : break elif S - x > 2*K: continue for y in range(K+1): if x + y > S: break elif S - (x+y) > K: continue for z in range(K+1): if x + y + z > S: break elif x + y + z == S: count +=1 print(count)
K, S = list(map(int , input().strip().split(" "))) count = 0 for x in range(K+1): if x > S : break elif S - x > 2*K: continue for y in range(K+1): if x + y > S: break elif S - (x+y) > K: continue count+= 1 print(count)
p03835
def resolve(): K, S = list(map(int, input().split())) print(( len( [ (x, y, z) for x in range(K + 1) for y in range(K + 1) for z in range(K + 1) if x + y + z == S and max(x, y, z) <= K ] ) )) if __name__ == "__main__": resolve()
def resolve(): K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): if S - K <= x + y <= S and max(x, y) <= K: count += 1 print(count) if __name__ == "__main__": resolve()
p03835
def resolve(): K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): if S - K <= x + y <= S and max(x, y) <= K: count += 1 print(count) if __name__ == "__main__": resolve()
def resolve(): K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(max(0, S - K - x), min(K + 1, S - x + 1)): count += 1 print(count) if __name__ == "__main__": resolve()
p03835
k, s = list(map(int, input().split())) count=0 if k < s/3: print((0)) quit() for a in range(0, k+1): if a == s: print((count+1)) quit() for b in range(0, k+1): if a+b == s: count+=1 break elif a+b > s: break for c in range(0, k+1): if a+b+c == s: count+=1 elif a+b+c > s: break print(count)
k, s = list(map(int, input().split())) count=0 for a in range(0, k+1): for b in range(0, k+1): if s-a-b >= 0 and s-a-b <= k: count+=1 print(count)
p03835
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)
k,s=list(map(int,input().split())) ans=0 for x in range(k+1): for y in range(k+1): z=s-x-y if 0<=z<=k: ans+=1 print(ans)
p03835
k,s =list(map(int,input().split())) 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)
k,s =list(map(int,input().split())) cnt=0 for x in range(0,k+1): for y in range(0,k+1): z=s-x-y if 0<=z<=k: cnt+=1 print(cnt)
p03835
k,s = list(map(int, input().split())) c = 0 for x in range(k+1): for y in range(x,k+1): for z in range(y,k+1): if x+y+z == s: if x == y == z: c += 1 elif (x == y and y != z) or (x != y and y == z): c += 3 else: c += 6 print(c)
k,s = list(map(int, input().split())) c = 0 for x in range(k+1): for y in range(k+1): if 0 <= s-x-y <= k: c += 1 print(c)
p03835
def binary_search_list(beSearched,wanted) : l = 0 r = len(beSearched) #print("condition = {}".format(r-l)) while r - l >= 1 : s = (l + r) // 2 #print("l={} r={} s={}".format(l,r,s)) if beSearched[s] == wanted : return True if beSearched[s] > wanted : r = s else : l = s + 1 return False K,S = (int(_) for _ in input().split()) num = [_ for _ in range(K+1)] out = 0 for i in range(K+1): for j in range(i+1): #print(num[:j+1]) b = binary_search_list(num[:j+1],S - i - j) #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j)) if b : if i == j and j == S - i - j: out += 1 elif i == j or j == S - i - j or S -i - j == i: out += 3 else : out += 6 print(out)
def binary_search_list(beSearched,wanted) : l = 0 r = len(beSearched) #print("condition = {}".format(r-l)) while r - l >= 1 : s = (l + r) // 2 #print("l={} r={} s={}".format(l,r,s)) if beSearched[s] == wanted : return True if beSearched[s] > wanted : r = s else : l = s + 1 return False K,S = (int(_) for _ in input().split()) num = [_ for _ in range(K+1)] out = 0 for i in range(K+1): for j in range(i+1): if 0 <= S - i - j <= j : if i == j and j == S - i - j: out += 1 elif i == j or j == S - i - j or S -i - j == i: out += 3 else : out += 6 #print(num[:j+1]) #b = binary_search_list(num[:j+1],S - i - j) #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j)) #if b : #if i == j and j == S - i - j: #out += 1 #elif i == j or j == S - i - j or S -i - j == i: #out += 3 #else : #out += 6 print(out)
p03835
# N K, S = list(map(int, input().split())) K+=1 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(i,j,k) print(count)
# N^2 K, S = list(map(int, input().split())) K+=1 count=0 for i in range(K): for j in range(0, K): tmp = S - (i + j) if tmp>=0 and tmp<K: count+=1 # print(i,j,tmp) print(count)
p03835
k, s = list(map(int, input().split())) ans = 0 for z in range(min(k, s)+1): ans += max(0, min(s-z, k)+1-(max(0, s-z-k))) print(ans)
k, s = list(map(int, input().split())) print((sum([max(0, min(s-z, k)+1-max(0, s-z-k)) for z in range(min(k, s)+1)])))
p03835
K, S = list(map(int, input().split())) n = [] for i in range(K + 1): n.append(i) import itertools XYZ = list(itertools.product(n, repeat = 3)) count = 0 for j in range(len(XYZ)): if sum(XYZ[j]) == S: count += 1 print(count)
K, S = list(map(int, input().split())) n = [] for i in range(K + 1): n.append(i) ans = 0 for x in range(K + 1): for y in range(K + 1): for z in range(K + 1): if n[x] + n[y] + n[z] == S: ans += 1 print(ans)
p03835
K, S = list(map(int, input().split())) ans = 0 for i in range(K + 1): for j in range(K + 1): if i + j == S: ans += 1 elif 0 <= S - (i + j) <= K: ans += 1 print(ans)
k, s = list(map(int, input().split())) ans = 0 for i in range(k + 1): for j in range(k + 1): if i + j == s: ans += 1 elif 0 <= s - (i + j) <= k: ans += 1 print(ans)
p03835