Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
xyh = []
xyh0 = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    if h != 0:
        xyh.append((X,Y,h))
    else:
        xyh0.append((X,Y))
ans = []
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        if len(xyh)>0:
            x,y,h = xyh[0]
            H = h + abs(x-i)+abs(y-j)
            flag = "t"
        for x,y,h in xyh:
            if H !=  h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans.append((i,j,H))
if len(ans) > 0:
    for i,j,H in ans:
        flag == "f":
        for x,y in xyh0:
            flag = "t"
            if H < h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans = [(i,j,H)]
        if len(ans) == 1:
            break
print(x,y,h)













#


Fixed submission:
n = int(input())
xyh = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    xyh.append((X,Y,h))
from operator import itemgetter
xyh.sort(key=itemgetter(2))
xyh.reverse()

ans = ()
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        x,y,h = xyh[0]
        H = h + abs(x-i)+abs(y-j)
        for x,y,h in xyh:
            if H ==  h + abs(x-i)+abs(y-j) and h != 0:
                flag = "t"
            elif H <=  h + abs(x-i)+abs(y-j) and h == 0:
                flag = "t"
            else:
                flag = "f"
                break
        if flag == "t":
            ans = (i,j,H)
Cx,Cy,H = ans
print(Cx,Cy,H)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
ans = 0
flag = True
for i in range(n):
    A = int(input())
    a.append(A)
next = 0
for i in range(n-1,-1,-1):
    if a[i] == 0:
        next = 0
        continue
    if next - a[i] == 1:
        next = a[i]
        continue
    if next - a[i] >= 2:
        flag = False
        break
    next = a[i]
    ans += a[i]
if a[0] != 0:
    flag = False
if flag:
    #print(ans)
else:
    #print(-1)
print(-1)


Fixed submission:
n = int(input())
a = []
ans = 0
flag = True
for i in range(n):
    A = int(input())
    a.append(A)
next = 0
for i in range(n-1,-1,-1):
    if next - a[i] >= 2:
        flag = False
        break
    if a[i] == 0:
        next = 0
        continue
    if next - a[i] == 1:
        next = a[i]
        continue
    next = a[i]
    ans += a[i]
if a[0] != 0:
    flag = False
if flag:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    if len(part) >= 2:
        part2 = []
        for i in part:
            part2.append(p[i-1])
        for i in part:
            if i in part2:
                ans += 1
    else:
        if(i == p[i] - 1):
            ans += 1
print(ans)


Fixed submission:
n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    part2 = []
    for i in part:
        part2.append(p[i-1])
    ans += len(list(set(part) & set(part2)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    part2 = []
    for i in part:
        part2.append(p[i-1])
    for i in part:
        if i in part2:
            ans += 1
print(ans)


Fixed submission:
n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    part2 = []
    for i in part:
        part2.append(p[i-1])
    ans += len(list(set(part) & set(part2)))
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
c = [[] for i in range(0,h+2)]
ans = "Yes"
c[0] = ["#"for i in range(0,w+2)]
c[h+1] = ["#"for i in range(0,w+2)]
for i in range(1,h+1):
    d = []
    d = list(input())
    d.append("#")
    d.insert(0,"#")
    c[i] = d
for i in range(1,h+1):
    for j in range(1,w+1):
        if c[j][i] == "#":
            flag = "No"
            if(c[j][i-1] == "#"):
                flag = "Yes"
            if(c[j][i+1] == "#"):
                flag = "Yes"
            if(c[j-1][i] == "#"):
                flag = "Yes"
            if(c[j+1][i] == "#"):
                flag = "Yes"
            if(flag == "No"):
                ans = "No"
print(ans)


Fixed submission:
h,w = map(int,input().split())
c = [[] for i in range(0,h+2)]
ans = "Yes"
c[0] = ["."for i in range(0,w+2)]
c[h+1] = ["."for i in range(0,w+2)]
for i in range(1,h+1):
    d = []
    d = list(input())
    d.append(".")
    d.insert(0,".")
    c[i] = d
for j in range(1,h+1):
    for i in range(1,w+1):
        if c[j][i] == "#":
            flag = "No"
            if(c[j][i-1] == "#"):
                flag = "Yes"
            if(c[j][i+1] == "#"):
                flag = "Yes"
            if(c[j-1][i] == "#"):
                flag = "Yes"
            if(c[j+1][i] == "#"):
                flag = "Yes"
            if(flag == "No"):
                ans = "No"
print(ans)

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
c = [[] for i in range(0,h+2)]
ans = "Yes"
c[0] = ["."for i in range(0,w+2)]
c[h+1] = ["."for i in range(0,w+2)]
for i in range(1,h+1):
    d = []
    d = list(input())
    d.append(".")
    d.insert(0,".")
    c[i] = d
for i in range(1,h+1):
    for j in range(1,w+1):
        if c[j][i] == "#":
            flag = "No"
            if(c[j][i-1] == "#"):
                flag = "Yes"
            if(c[j][i+1] == "#"):
                flag = "Yes"
            if(c[j-1][i] == "#"):
                flag = "Yes"
            if(c[j+1][i] == "#"):
                flag = "Yes"
            if(flag == "No"):
                ans = "No"
print(ans)


Fixed submission:
h,w = map(int,input().split())
c = [[] for i in range(0,h+2)]
ans = "Yes"
c[0] = ["."for i in range(0,w+2)]
c[h+1] = ["."for i in range(0,w+2)]
for i in range(1,h+1):
    d = []
    d = list(input())
    d.append(".")
    d.insert(0,".")
    c[i] = d
for j in range(1,h+1):
    for i in range(1,w+1):
        if c[j][i] == "#":
            flag = "No"
            if(c[j][i-1] == "#"):
                flag = "Yes"
            if(c[j][i+1] == "#"):
                flag = "Yes"
            if(c[j-1][i] == "#"):
                flag = "Yes"
            if(c[j+1][i] == "#"):
                flag = "Yes"
            if(flag == "No"):
                ans = "No"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int,input()
a = list(map(int, input().split()))
wa = []
ans = 0
wa.append(a[0])
for i in range(1,len(a)):
    wa.append(wa[i-1] + a[i])
ans += wa.count(0)
for i in range(0,len(a)):
    wa2 = []
    wa2 = list(map(lambda x: x-wa[i], wa))
    wa3 = wa2[i+1:]
    ans += wa3.count(0)
print(ans)


Fixed submission:
n = int,input()
a = list(map(int, input().split()))
total = []
ans = 0
dic = {0:1}
for i in range(0,len(a)):
    if(i == 0):
        total.append(a[0])
    else:
        total.append(total[i-1] + a[i])
    ans += dic.get(total[i],0)
    if total[i] in dic:
        dic[total[i]] += 1
    else:
        dic[total[i]] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
a =  list(map(int, input().split()))
while len(a) != 0:
    b = 0
    b = a.count(a[0])
    c = 0
    c = a[0]
    if c > b:
        count += b
    if c < b:
        count += b - c
    while a.count(c) != 0:
        a.remove(c)    
print (count)


Fixed submission:
n = int(input())
a = []
a =  list(map(int, input().split()))
d = {}
c = 0
for x in a:
    d[x] = d.get(x, 0) + 1
for y,z in d.items():
    if y < z:
        c += z-y
    if y > z:
        c += z
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
b = 0
a =  list(map(int, input().split()))
while len(a) != 0:
    b = a.count(a[0])
    if a[0] > b:
        count += b
    if a[0] < b:
        count += b - a[0]
    a = [item for item in a if item is not a[0]]
print (count)


Fixed submission:
n = int(input())
a = []
a =  list(map(int, input().split()))
d = {}
c = 0
for x in a:
    d[x] = d.get(x, 0) + 1
for y,z in d.items():
    if y < z:
        c += z-y
    if y > z:
        c += z
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n,m,R = map(int,input().split())
r = list(map(int,input().split()))
data = []
for i in range(0,m):
    a,b,c = map(int,input().split())
    data.append((a,b,c))
    data.append((b,a,c))

d = [[] for _ in range(0,R)]

def bellmanFord(start,num):
    g = [float("inf") for _ in range(0,n+1)]
    g[start] = 0
    for i in range(0,n):
        for j in range(0,m*2):
            a,b,c = data[j]
            if g[a] != float("inf") and g[b] > g[a] + c:
                g[b] = g[a] + c
    for i in range(0,R):
        d[num].append(g[r[i]])

for i in range(0,R):
    bellmanFord(r[i],i)
    # print(d[i])
ans = float("inf")
seq = itertools.permutations([i for i in range(0,R)])
for i in seq:
    dis = 0
    for j in range(0,len(i)-1):
        dis += d[i[j]][i[j+1]]
    if ans > dis:
        ans = dis
print(ans)

Fixed submission:
import itertools

n,m,R = map(int,input().split())
r = list(map(int,input().split()))
data = [[]for _ in range(0,n+1)]
d = [[] for _ in range(0,R)]

for i in range(0,m):
    a,b,c = map(int,input().split())
    data[a].append((b,c))
    data[b].append((a,c))

def dijkstra(start,num):
    g = [float("inf") for _ in range(0,n+1)]
    used = ["false" for _ in range(0,n+1)]
    g[start] = 0
    queue= []
    queue.append((start,data[start]))
    while queue:
        start,edge = queue.pop(0)
        for to,cost in edge:
            if g[to] > g[start] + cost:
                g[to] = g[start] + cost
                queue.append((to,data[to]))
    for i in range(0,R):
        d[num].append(g[r[i]])
    # print(g)
# dijkstra(1,0)

for i in range(0,R):
    dijkstra(r[i],i)
    # print(d[i])
ans = float("inf")
seq = itertools.permutations([i for i in range(0,R)])
for i in seq:
    dis = 0
    for j in range(0,len(i)-1):
        dis += d[i[j]][i[j+1]]
    if ans > dis:
        ans = dis
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
answer=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            #print(i,j,k)
            answer+=gcd(i,j,k)
                
                
print(answer)

Fixed submission:
import math
from functools import reduce
answer=0
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            #print(i,j,k)
            answer+=gcd(i,j,k)
                
                
print(answer)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
#print(N,A,B)

moji="b"*A+"r"*B
#print(moji)

if A==B==0:
    print(0)
elif A==0:
    print(0)
else:

    if N==A+B:
        print(A)
    elif N>A+B:
        if N%(A+B)>A:
            print((N//(A+B))*A+A)
        else:
            print((N//(A+B))*A+N%(A+B))
    else:
        print(A)

Fixed submission:
N,A,B=map(int,input().split())
#print(N,A,B)

#moji="b"*A+"r"*B
#print(moji)

if A==B==0:
    print(0)
elif A==0:
    print(0)
else:

    if N==(A+B):
        print(A)
    elif N>A+B:
        if N%(A+B)>A:
            print((N//(A+B))*A+A)
        else:
            print((N//(A+B))*A+N%(A+B))
    else:
        if N<A:
            print(N)
        else:
            print(A)

Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
#print(N,A,B)

moji="b"*A+"r"*B
#print(moji)

if N==A+B:
    print(A)
elif N>A+B:
    if N%(A+B)>A:
        print((N//(A+B))*A+A)
    else:
        print((N//(A+B))*A+N%(A+B))
else:
    print(A)

Fixed submission:
N,A,B=map(int,input().split())
#print(N,A,B)

#moji="b"*A+"r"*B
#print(moji)

if A==B==0:
    print(0)
elif A==0:
    print(0)
else:

    if N==(A+B):
        print(A)
    elif N>A+B:
        if N%(A+B)>A:
            print((N//(A+B))*A+A)
        else:
            print((N//(A+B))*A+N%(A+B))
    else:
        if N<A:
            print(N)
        else:
            print(A)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
mylist=list(map(int,input().split()))
    
#print(mylist)
answer=0

#2重forループでは重すぎるのでTLEになる。

i=0
while i<N:
    flag=0
    
    for j in range(i):
        #print("iは")
        #print(i)
        #print("jは")
        #print(j)
        if mylist[i]>mylist[j]:
            #一つでも条件満たさないjがあればflagを-1にする
            flag=-1
            break

    if flag==0:
        #flagが0であれば、そのiに対して答えを+1する
        answer+=1
    
    i+=1
        
print(answer)

Fixed submission:
N=int(input())
lt=list(map(int,input().split()))
#print(lt)

temp=0
answer=0

for i in range(N):
    if i==0:
        answer+=1
        temp=lt[i]
    elif temp>=lt[i]:
        answer+=1
        temp=lt[i]
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
mylist=list(map(int,input().split()))
    
#print(mylist)
answer=0

#2重forループでは重すぎるのでTLEになる。

for i in range(N):
    flag=0
    
    for j in range(i):
        if mylist[i]>mylist[j]:
            #一つでも条件満たさないjがあればflagを-1にする
            flag=-1
            break
    if flag==0:
        #flagが0であれば、そのiに対して答えを+1する
        answer+=1
        
print(answer)

Fixed submission:
N=int(input())
lt=list(map(int,input().split()))
#print(lt)

temp=0
answer=0

for i in range(N):
    if i==0:
        answer+=1
        temp=lt[i]
    elif temp>=lt[i]:
        answer+=1
        temp=lt[i]
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
mylist=list(map(int,input().split()))
    
#print(mylist)
answer=0

#2重forループでは重すぎるのでTLEになる。

for i in range(N):
    flag=0
    
    for j in range(i):
        if mylist[i]>mylist[j]:
            #一つでも条件満たさないjがあればflagを-1にする
            flag=-1
            break
    if flag==0:
        #flagが0であれば、そのiに対して答えを+1する
        answer+=1
        
print(answer)

Fixed submission:
N=int(input())
lt=list(map(int,input().split()))
#print(lt)

temp=0
answer=0

for i in range(N):
    if i==0:
        answer+=1
        temp=lt[i]
    elif temp>=lt[i]:
        answer+=1
        temp=lt[i]
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
mylist=list(map(int,input().split()))
    
#print(mylist)
answer=0

for i in range(N):
    flag=0
    
    for j in range(i):
        if mylist[i]>mylist[j]:
            #一つでも条件満たさないjがあればflagを-1にする
            flag=-1
    
    if flag==0:
        #flagが0であれば、そのiに対して答えを+1する
        answer+=1
        
print(answer)

Fixed submission:
N=int(input())
lt=list(map(int,input().split()))
#print(lt)

temp=0
answer=0

for i in range(N):
    if i==0:
        answer+=1
        temp=lt[i]
    elif temp>=lt[i]:
        answer+=1
        temp=lt[i]
        
print(answer)
Buggy python submission (verdict: Runtime Error):
第六回ドワンゴからの挑戦状　A

N=int(input())

largelist=[]

for i in range(N):
    S=input().split()
    #print(S)
    largelist.append(S)

#print(largelist)

X=input()
answer=0

for i in range(N):
    if X==largelist[i][0]:
        for j in range(i+1,N):
            answer+=int(largelist[j][1])
        
    else:
        temp=0

print(answer)

Fixed submission:
#第六回ドワンゴからの挑戦状　A

N=int(input())

largelist=[]

for i in range(N):
    S=input().split()
    #print(S)
    largelist.append(S)

#print(largelist)

X=input()
answer=0

for i in range(N):
    if X==largelist[i][0]:
        for j in range(i+1,N):
            #print("now j")
            #print(j)
            answer+=int(largelist[j][1])
        
    else:
        temp=0

print(answer)
Buggy python submission (verdict: Runtime Error):
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N-1):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        print(i)
        result+=1
    else:
        print("after"+str(i))
        p=1

print(result)

Fixed submission:
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N-2):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        #print(i)
        result+=1
    else:
        #print("after"+str(i))
        p=1

print(result)

Buggy python submission (verdict: Runtime Error):
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        #print(i)
        result+=1
    else:
        #print("after"+str(i))
        p=1

print(result)

Fixed submission:
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N-2):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        #print(i)
        result+=1
    else:
        #print("after"+str(i))
        p=1

print(result)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())



def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Fixed submission:
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
mylist=[]
pointlist=[]
for i in range(Q):
    mylist.append(int(input()))
    
#print(N,K,Q)    
#print(mylist)

for i in range(N):
    pointlist.append(K)

i=0
while i<Q:
    winner=mylist[i]-1
    #winner以外のポイントを減らす
    for j in range(N):
        if j==winner: #jがwinnerの番号のときは何もしない
            pass
        else:
            pointlist[j]-=1
    #print(i)
    #print(pointlist)
    i+=1
    
for i in range(N):
    if pointlist[i]<=0:
        print("No")
    else:
        print("Yes")

Fixed submission:
N,K,Q=map(int,input().split())
mylist=[]
pointlist=[]
for i in range(Q):
    mylist.append(int(input()))
    
for i in range(N):
    #全員にKポイント与えるが、Qポイント引く
    pointlist.append(K-Q)
    
#正解者に1ぽいんとずつ足す。

for i in range(Q):
    #mylist[i]をjとしたら、j番目の人が勝者ということ。pointlist[j-1]に1を足す。
    j=mylist[i]
    pointlist[j-1]+=1
    
for i in range(N):
    if pointlist[i]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S,C=map(int,input().split())
#start=time.time()
scc=0
count=0

while (S>0 or C>=4): #and count<max(S,C*44301):
    if S>0 and C>=2:
        S-=1
        C-=2
        scc+=1
        
        count+=1
        #print(count)
        
    elif S<=0 and C>=4:
        C-=4
        scc+=1
        
        count+=1
        #print(count)
    else:
        count+=1
        #print(count)
    
print(scc)

Fixed submission:
S,C=map(int,input().split())
scc=0

if 2*S<=C:
    scc+=S
    C-=S*2
    scc+=C//4
else:
    scc=C//2
    
print(scc)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
A=[]
for i in range(K):
    d = int(input())
    for i in range(d):
        a = int(input())
        A.append(a)

 
ans = len(list(set(A)))
print(N-ans)

Fixed submission:
N,K = map(int, input().split())
A=[]
for i in range(K):
    d = int(input())
    a=list(map(int, input().split()))
    for i in range(d):
        A.append(a[i])

ans = len(list(set(A)))
print(N-ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
for i in range(K):
    d = int(input())
    for i in range(d):
        a = int(input())
        A.append(a) 
ans = len(list(set(A)))
print(N-ans)

Fixed submission:
N,K = map(int, input().split())
A=[]
for i in range(K):
    d = int(input())
    a=list(map(int, input().split()))
    for i in range(d):
        A.append(a[i])

ans = len(list(set(A)))
print(N-ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split(',')
print(a,b,c)

Fixed submission:
k,s=map(int,input().split())
ret=0
k+=1
for i in range(k):
  for j in range(k):
    d=s-i-j
    if k>d>=0:
      ret+=1
print(ret)

Buggy python submission (verdict: Runtime Error):
def solve(K: int, S: int):
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                cnt += 1
    print(cnt)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)
 
if __name__ == '__main__':
    main()
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                cnt += 1
    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()
提出情報

Fixed submission:
k,s=map(int,input().split())
ret=0
k+=1
for i in range(k):
  for j in range(k):
    d=s-i-j
    if k>d>=0:
      ret+=1
print(ret)