TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
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)


K,S = (int(_) for _ in input().split())

out = 0

for x in range(K):
    for y in range(K):
        for z in range(K):
            if x + y + z == S :
                out += 1

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])
        
        
        #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)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = 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)

K, S = 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)

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

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

K, S = 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)

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

K+=1

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

print(count)

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

# N^2
K, S = 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)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k,s=map(int,input().split())
count=0
if s%3==0:
    count+=1
for i in range(0,s//2+1):
    if 0<=s-2*i<=k and i<=k and s-2*i!=i:
        count+=3
print(count)
for i in range(0,k-1):
    for j in range(i+1,k):
        if k>=s-i-j>j:
            count+=6
print(count)

k,s=map(int,input().split())
count=0
if s%3==0:
    count+=1
for i in range(0,s//2+1):
    if 0<=s-2*i<=k and i<=k and s-2*i!=i:
        count+=3
for i in range(0,k-1):
    for j in range(i+1,k):
        if k>=s-i-j>j:
            count+=6
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys
input = sys.stdin.readline

def main():
    k, s = map(int, input().split())
    vals = [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]
    print(len([vals]))

if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline

def main():
    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 x + y > s:
                break
            if s - (x + y) <= k:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a):
  for k in range(a):
    if a-b<i+k<=a:
      c=c+1
print(c)

a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a+1):
  for k in range(a+1):
    if b-a<=i+k<=b:
      c=c+1
print(c)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int, input().split())
count = 0
for x in range(K+1):
  for y in range(1,K+1):
    for z in range(1,K+1):
      if x + y + z == S:
        count = count + 1
print(count)

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

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

K,S=map(int, input().split())
count = 0
for x in range(min([K+1,S+1])):
  for y in range(min([K+1,S+1-x])):
    if S-x-y<=K:
      count = count + 1
print(count)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s = map(int,input().split())
count = 0
if 3*k==s:
  print(1)
else:
  for x in range(k+1):
    if x+2*k<s:
      continue
    else:
      for y in range(k+1):
        if x+y+k<s:
          continue
        else:
          for z in range(k+1):
            print(z)
            if x+y+z==s:
              count += 1
  print(count)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int,input())
print(S//K)

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

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)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s=map(int,input().split())
a=0
b=0
c=0
l=0
while l*2<=s and l<=k:
    if s-l*2<=k:
        b+=1
    l+=1
if s%3==0:
    a+=1
    b-=1
for x in range(k+1):
    for y in range(x+1,k+1):
        for z in range(y+1,k+1):
            if x+y+z==s:
                c+=1
print(a,b,c,a+3*b+6*c)


k,s=map(int,input().split())
a=0
b=0
c=0
l=0
while l*2<=s and l<=k:
    if s-l*2<=k:
        b+=1
    l+=1
if s%3==0:
    a+=1
    b-=1
for x in range(k+1):
    for y in range(x+1,k+1):
        if k>=s-x-y>y:
            c+=1
print(a+3*b+6*c)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k, s = 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 = 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)

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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

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

k,s=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)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    if x > k:
        break
    for y in range(k + 1):
        if y > k:
            break
        z = s - x - y
        if (z >= 0) & (z <= k):
            ans += 1
            break
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
x,s=map(int(input().split()))
n=x+1
a=0
for i in range(n):
    for j in range(n):
        if 0<=s-(i+j)<=x:
            a+=1
print(a)

x,s=map(int,input().split())
n=x+1
a=0
for i in range(n):
    for j in range(n):
        if 0<=(s-(i+j))<=x:
            a+=1
print(a)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k, s = map(int, input().split())
count = 0
for a in range(k):
  for b in range(k):
    for c in range(k):
      if a + b + c == s:
        count += 1
      else:
        pass
print(count)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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:
            print(x,y,z)
            cnt=cnt+1
        else:
            continue
    
print(cnt)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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;

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    print(i,j)
    if s-i+j<=k:
      c+=1

print(c)        

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:
      c+=1

print(c)   

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

print(c)  

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, s = map(int, input().split())
cnt = 0

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

print(cnt)

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

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

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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 <= K:
            ans += 1

print(ans)


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

print(ans)


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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-x-y
      if 0 <= z <=k:
        count = count +1
print(count)

k, s = map(int, input().split())
x = list(range(k))
y = list(range(k))
z = list(range(k))
count = 0
for l in range(k):
  for m in range(k):
    for n in range(k):
      if x[l]+y[m]+z[n] == s:
        count = count +1
print(count)
      



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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
count = 0
for X in range(0, K+1):
	for Y in range(X, K+1):
		for Z in range(Y, K+1):
			if X > S//3:
				break
			if Y > S:
				break
			if Z > S:
				break
			if X+Y+Z == S:
				print(X, Y, Z)
				i = set([X, Y, Z])
				if len(i) == 1:
					count += 1
				elif len(i) == 2:
					count += 3
				elif count == 3:
					count += 6

print(count)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, n = list(map(int, input().split()))
a = 0
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == n-3:
                a += 1
print(a)

k, n = list(map(int, input().split()))
a = 0
for x in range(k+1):
    for y in range(k+1):
            if n-x-y <= k:
                a += 1
print(a)

k, n = list(map(int, input().split()))
a = 0
for x in range(k+1):
    for y in range(k+1):
            if 0 <= n-x-y <= k:
                a += 1
print(a)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


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

print(ans)

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


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

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(0, K+1):
        if S - (x+y) <= K:
            count += 1
print(count)

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
if __name__ == '__main__':
    sys.setrecursionlimit(10 ** 6)
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num *3
    print(num)




if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c

    count = 0
    for i in range (0,b+1):
        for j in range(0,b+1):
            if c-(i+j)<=b and c-(i+j) >=0:
                count+=1
    print(count)



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
K = input()
S = input()
count = 0

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

K = input()
S = input()
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)

K = input()
S = input()
count = 0

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

print(count)


K = 2
S = 2
count = 0

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

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

K = input()
S = input()
count = 0

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

print(count)


K = input()
S = input()
count = 0

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

print(count)


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

print(count)

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)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
i,j=map(int,input().split())
a=0
for x in range(i+1):
  for y in range(i+1):
    if j-(x+y)<=i:
      a+=1
print(a)

i,j=map(int,input().split())
a=0
for x in range(i+1):
  for y in range(i+1):
    if j-(x+y)<=i:
      if x+y<=j:
        a+=1
print(a)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int, input().split())
print(sum(range(S+1)))


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


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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys
in1 = sys.stdin.readlines()

#in1 = ['5 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if S - idx1 - idx2 <= K:
            RC += 1

print(RC)


import sys
in1 = sys.stdin.readlines()

#in1 = ['10 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if 0 <= S - idx1 - idx2 <= K:
            RC += 1

print(RC)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a = input().split()
k = int(a[0])
s = int(a[1])

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

print(count)

a = input().split()
k = int(a[0])
s = int(a[1])

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        else:
            if (k + 1) > (s - x - y):
                # print(x, y, (s - x - y))
                count = count + 1

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s = map(int,input().split())
a = 0
for x in range(k+1):
  for y in range(k+1):
      if s-(x+y) <= k:
        a += 1
        
print(a)

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

k,s = map(int,input().split())
a = 0
for x in range(k+1):
  for y in range(x+1,k+1):
    for z in range(y+1,k+1):
      if x+y+z == s:
        if x != y and y != z and z != x:
          a += 6
        elif (x == y and y != z) or (x == z and z != y) or (z == y and y!= x):
          a += 3
        else:
          a += 1
        
print(a)


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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

print(r)


#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

print(r)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int, input().split())

count = 0
z = 0
flag = False
for x in reversed(range(0,K+1)):
  for y in reversed(range(0,K+1)):
    for z in reversed(range(0,K+1)):
      if S == x + y + z:    
        count = count + 1
        flag = True
        break
      if flag == True:
      	break
    if flag == True:
      break
  if flag == True:
    break
          
print(count)

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

count = 0
for x in reversed(range(0,K+1)):
  for y in reversed(range(0,K+1)):
    z = S - x - y
    if z >= 0 and z <= K:
      count = count + 1
          
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = map(int, input().split())
a = 0
for x in range(K+1):
  for y in range(K+1):
    if S-x-y<=K :
      a+=1   
print(a)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, s = (int(i) for i in input().split())

cnt = 0
for x in range(k+1):
    c = s-x
    cnt += max(min(k,s)-max(0,c-k)+1,0)

print(cnt)

k, s = (int(i) for i in input().split())

cnt = 0
for x in range(k+1):
    c = s-x
    cnt += max(min(k,c)-max(0,c-k)+1,0)

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import itertools
k, s = map(int, input().split())


# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)
target = s / 3
ans = 0
if (target < k):
    pass
else:
    for x in range(0, k + 1):
        
        
        for y in range(0, k + 1):
            if (0 <= s - (x + y) <= k):
                ans += 1


print(ans)




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


# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)
target = s / 3
ans = 0
if (target < k):
    pass
elif:
    for x in range(0, k + 1):
        
        
        for y in range(0, k + 1):
            if (0 <= s - (x + y) <= k):
                ans += 1


print(ans)




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


# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)

ans = 0
if (k * 3 < s):

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

print(ans)




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)


import numpy as np
K, S = map(int, input().split())

x1 = np.ones(K+1, np.int32)
x2 = np.convolve(x1,x1)
x3 = np.convolve(x1,x2)
ans = x3[S]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k,s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if s-(i+j)<=k:
            cnt += 1
print(cnt)


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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k,s=map(int,input().split())
u=min(k,s)
sum=0
for i in range(u+1):
    sum+=min(s-i,2k)+1
print(sum)


k,s=map(int,input().split())
u=min(k,s)
sum=0
if s-2*k>=0:
    for i in range(s-2*k,u+1):
        if s-i<2*k:
            sum+=2*k-s+i+1
        else:
            sum+=1
    print(sum)
elif s-k>=0:
    for i in range(u+1):
        if s-i<k:
            sum+=s-i+1
        else:
            sum+=2*k-s+i+1
    print(sum)
else:
    for i in range(u+1):
        if s-i<2*k:
            sum+=s-i+1
        else:
            sum+=1
    print(sum)




Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
def 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 S >= 0 and S <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


def 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 Z >= 0 and Z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

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


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


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


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

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

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

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, s=map(int, input().split())
ans=[]
for x in range(k+1):
    for y in range(x+1, k+1):
        for z in range(y+1, k+1):
            if x+y+z==s:
                ans.append((x, y, z))

print(6*len(ans))


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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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)


Verdicts: Wrong Answer

Accepted
Problem: 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?

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

print(sum)

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


print(sum)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
K,S=map(int,input().split())
print(sum(1for x in range(K+1)for y in range(K+1)if0<=S-x-y<=K))


import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

K, S = inm()


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


print(solve())


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
K,S=map(int,input().split())

ans=0

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


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)

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

ans=0

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


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1):
    for y in range(max(x,s-x-k),k+1):
            for z in range(max(y,s-x-y),k+1):
                    if x+y+z==s:
                        if x==y and y==z:
                            count+=1
                        else:
                            count+=3
                        print(x,y,z)
                        break
print(count)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
K, S = list(map(int, input().split()))

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

print(ans)

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

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

print(ans)


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

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

print(ans)


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

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

print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
k, s = map(int, input().split())
cnt=0

for x in range(0,k+1):
    for y in range(0,k+1):
        if x+y+k >= s:
            cnt+=1

print(cnt)

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

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

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
limit, sum_xyz = map(int, input().split())

pair = list()

for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        pair.append([x, y, z])
ans = len(pair)

limit, sum_xyz = map(int, input().split())

pair = list()

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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]))

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

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-


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

X = Y = Z = 0
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)

# -*- coding: utf-8 -*-


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

X = Y = 0
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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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

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

  
K,S=(int(x) for x in input().split())
print(f(K,S))



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys

ins = lambda: map(int,sys.stdin.readline().split(' '))

k,s = ins()

result = 0

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

import sys

k,s = map(int,sys.stdin.buffer.readline().split(' '))

result = 0

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

import sys

k,s = map(int,sys.stdin.readline().split(' '))

result = 0

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

Verdicts: Wrong Answer

Runtime Error

Accepted