Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03106 (python)

Fixed submission:
a,b,k = map(int,input().split())

ans=[]
m=min(a,b)

for i in range(1,m+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

ans.sort(reverse=True)
print(ans[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

ans=[]

if a>=b:
    for i in range(1,a//2+1):
        if a%i == 0 and b%i == 0:
            ans.append(i)
else:
    for i in range(1,b//2+1):
        if a%i == 0 and b%i == 0:
            ans.append(i)

print(ans[k-1])
Problem p03433 (python)

Fixed submission:
n=int(input())
a=int(input())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=n%500

if amari<=a:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=n%500

if amari=<a:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')
Problem p03455 (python)

Fixed submission:
#a,bの入力
a,b=map(int,input().split())
#a,bの積を演算する
a_to_b_no_seki=a*b
#a,b,の積を2で割った余りを計算し、余りが0なら偶数と出力、1なら奇数と出力
if a_to_b_no_seki%2==0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
#a,bの入力
a=int(input())
b=int(input())
#a,bの積を演算する
a_to_b_no_seki=a*b
#a,b,の積を2で割った余りを計算し、余りが0なら偶数と出力、1なら奇数と出力
if a_to_b_no_seki%2==0:
    print("Even")
else:
    print("Odd")
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split()) #n枚,y円
a = -1
b = -1
c = -1
for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and k >= 0 :
            a = i
            b = j
            c = k
            break

print(a,b,c)

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split()) #n枚,y円
a = -1
b = -1
c = -1


for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and z >= 0 :
            a = i
            b = j
            c = k
print(a,b,c)
Problem p03494 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
while True:
    if [i for i in a if i % 2 == 1]:
        break
    a=[i/2 for i in a]
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split())
ans=0

while True:
  if[i for i in a if i%2==1]:
    break
  a=[i/2 for i in a]
  ans+=1
print(ans)
Problem p03545 (python)

Fixed submission:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        # フラグが立っていれば "+" 、なければ "-"
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()

Buggy submission (verdict: Runtime Error):
 s=input()

for bit in range(1 << 3):#
    ans=int(s[0])
    f=s[0]
    
    for j in range(3):
        if bit & (1 << j):
            ans+=int(s[j+1])
            f+='+'
            
        else:
            ans-=int(s[j+1])
            f+='-'
        
        f+=s[j+1]
    
    if ans == 7:
        print(f + "=7")
        exit()
Problem p03680 (python)

Fixed submission:
n=int(input())
num=[0]
ans=0
count=0
k=1
for i in range(n):
    a=int(input())
    num.append(a)

for i in range(n+1):
    k=num[k]
    count+=1
    if k==2:
        ans=1
        break
if ans==1:
    print(count)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
n=int(input())
num=[0]
ans=0
count=0
k=1
for i in range(n):
    a=int(input())
    num.append(a)
 
 for i in range(n+1):
    k=num[k]
    count+=1
    if k==2:
        ans=1
        break
if ans==1:
    print(count)
else:
    print("-1")
# coding: utf-8
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
x = min(n, b - 1)
print(int((a * x) / b) - a * int(x / b))

Buggy submission (verdict: Runtime Error):
import math
def func(i):
    return math.floor(a * i * 1.0 / b) - a * math.floor(i * 1.0 / b);
 
a, b, n = map(int, input().split())
 
print (max(func(b), func(n))
Problem p02741 (python)

Fixed submission:
arr="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
list=arr.split(", ")

k=int(input())
print(list[k-1])

Buggy submission (verdict: Runtime Error):
arr = input().split()
h=int(arr[0])
w=int(arr[1])

if w%2!=0:
    if h%2!=0:
        ans=(w+1)//2*(h+1)//2+(w-1)//2*(h-1)//2
    else:
        ans=(w+1)//2*h//2+(w-1)//2*h//2
else:
    ans=w//2*h
print(ans)
Problem p02742 (python)

Fixed submission:
arr = input().split()
h=int(arr[0])
w=int(arr[1])
 
if w*h%2!=0 and h!=1 and w!=1:
    ans=(w*h+1)//2
elif h==1 or w==1:
    ans=1
else:
    ans=w*h//2
print(ans)

Buggy submission (verdict: Runtime Error):
arr = input().split()
h=int(arr[0])
w=int(arr[1])

if w%2!=0:
    if h%2!=0:
        ans=(w+1)//2*(h+1)//2+(w-1)//2*(h-1)//2
    else:
        ans=(w+1)//2*h//2+(w-1)//2*h//2
else:
    if h%2!=0:
        ans=w//2*h
print(ans)
Problem p03281 (python)

Fixed submission:
N = int(input())

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Buggy submission (verdict: Runtime Error):
N=input()

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Buggy submission (verdict: Runtime Error):
answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Buggy submission (verdict: Runtime Error):
answer=0
count=0

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        count+=1
if count==4:
    answer+=1

print(answer)

Buggy submission (verdict: Runtime Error):
N=input()

answer=0
count=0

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        count+=1
if count==4:
    answer+=1

print(answer)
Problem p02841 (python)

Fixed submission:
# 2019 12/01
# A November 30

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if int(D2) == 1:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
# 2019 12/01
# A November 30

M1, D1 = map(int, input())
M2, D2 = map(int, input())

if int(D2) == 1:
    print(1)
else:
    print(0)
Problem p02922 (python)

Fixed submission:
# 2019 9.1
# Power Socket

A, B = map(int, input().split())

kuti = 1
cnt = 0

while kuti < B:
    kuti += A - 1
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
# 2019 9.1
# A Tenki

S = list(input())
T = list(input())

cnt = 0

for i in range(3):
    if S[i] == T[i]:
        cnt += 1

print(cnt)
Problem p02713 (python)

Fixed submission:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def gcd2(a,b,c):
	a=gcd(a,b)
	a=gcd(a,c)
	return a

K = int(input())
ans = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			ans += gcd2(i,j,k)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

# def gcd2(a,b,c):
# 	a=gcd(a,b)
# 	a=gcd(a,c)
# 	return a

K = int(input())
ans = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			ans += gcd2(i,j,k)
print(ans)
Problem p02732 (python)

Fixed submission:
from operator import mul
from functools import reduce

n = int(input())
a = [[] for i in range(n)]

a = [int(i) for i in input().split()]
b = [0]*(n+1)

for i in a:
    b[i] +=1

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def ans(N):
    if N >= 2:
        return(cmb(N,2))
    else: return(0)

cnt=0
for j in b: cnt += ans(j)
for i in a:
    temp = cnt
    temp = temp - (ans(b[i])- ans(b[i]-1))
    print(temp)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

n = int(input())
a = [[] for i in range(n)]

a = [int(i) for i in input().split()]
b = [0]*(n+1)

for i in a:
    b[i] +=1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def ans(N):
    if N >= 2:
        return(cmb(N,2))
    else: return(0)

cnt=0
for j in b: cnt += ans(j)
for i in a:
    temp = cnt
    temp = temp - (ans(b[i])- ans(b[i]-1))
    print(temp)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[] for i in range(n)]

a = [int(i) for i in input().split()]
b = [0]*(n+1)

for i in a:
    b[i] +=1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def ans(N):
    if N >= 2:
        return(cmb(N,2))
    else: return(0)

cnt=0
for j in b: cnt += ans(j)
for i in a:
    temp = cnt
    temp = temp - (ans(b[i])- ans(b[i]-1))
    print(temp)
Problem p02755 (python)

Fixed submission:
import math

A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = math.ceil(A / 0.08)
tmax = (B + 1) / 0.1
tmin = B / 0.1

if emin < tmax and emin >= tmin:
    print(emin)
elif tmin < emax and tmin >= emin:
    print(int(tmin))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = A / 0.08
tmax = (B + 1) / 0.08
tmin = B / 0.1

if emin < tmax and emin >= tmin:
    print(int(emin))
elif tmin < emax and tminn >= emin:
    print(int(tmin))
else:
    print(-1)
Problem p02756 (python)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())

sign = 1
head = ""
tail = ""
for i in range(Q):
    Q = input().split()
    if Q[0] == "1":
        sign *= -1
    else:
        if int(Q[1]) * sign == 1:
            S.appendleft(Q[2])
        elif int(Q[1]) * sign == -1:
            S.append(Q[2])
        elif int(Q[1]) * sign == 2:
            S.append(Q[2])
        elif int(Q[1]) * sign == -2:
            S.appendleft(Q[2])

if sign==1:
    print("".join(S))
elif sign==-1:
    S.reverse()
    print("".join(S))

Buggy submission (verdict: Runtime Error):
import math

A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = math.ceil(A / 0.08)
tmax = (B + 1) / 0.1
tmin = B / 0.1

print(emax,emin)
print(tmax,tmin)

if emin < tmax and emin >= tmin:
    print(emin)
elif tmin < emax and tmin >= emin:
    print(int(tmin))
else:
    print(-1)
Problem p02797 (python)

Fixed submission:
N,K,S=[int(i) for i in input().split()]
res=[S%10**9+1]*N
for i in range(K):
    res[i]=S
print(*res)

Buggy submission (verdict: Runtime Error):
N,K,S=[int(i) for i in input().split()]
res=[S%10**9+1]*N
for i in range(K):
    res[i]=S
print(*res)

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

Buggy submission (verdict: Runtime Error):
N,K,S=[int(i) for i in input().split()]
res=[10**9-1]*N
for i in range(K):
    res[i]=S
print(*res)

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

Buggy submission (verdict: Runtime Error):
N,K,S=[int(i) for i in input().split()]
res=[10**9]*N
for i in range(K+1):
    res[i]=S
print(res)
Problem p02801 (python)

Fixed submission:
z="ABCDEFGHIJKLMNOPQRSTUVWXYZ".lower()
c=input()
print(z[z.find(c)+1])

Buggy submission (verdict: Runtime Error):
from collections import deque

H,W=[int(i) for i in input().split()]
# c=[[i for i in input().split()] for _ in range(h)]
C=list(input() for _ in range(H))
C=list(list(i) for i in C) #visited_listを用いずに壁にしていく方法ではリスト化が必要

def bfs(maze,s1,s2,g1,g2):
    for y in range(H):
        for x in range(W):
            if maze[y][x]!='#':
                maze[y][x]=10**9

    maze[s1][s2]=0
    que=deque([[s1,s2]])
    while que:
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            nexty,nextx=y+i,x+j
            if nexty >= 0 and nexty < H and nextx >= 0 and nextx < W:
                dist=maze[nexty][nextx]
                if dist!='#':
                    if dist>maze[y][x]+1:
                        maze[nexty][nextx]=maze[y][x]+1
                        que.append([nexty,nextx])
    return maze[g1][g2]

ans=0
for s1,c_w in enumerate(C):
    for s2,c in enumerate(c_w):
        if C[s1][s2]!="#":
            for g1,c_w in enumerate(C):
                for g2,c in enumerate(c_w):
                    if C[g1][g2]!="#":
                        temp=bfs(C,s1,s2,g1,g2)
                        ans=max(temp,ans)
print(ans)
Problem p02813 (python)

Fixed submission:
import itertools

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

D=list(range(1,N+1))
dict=[]

for i,j in enumerate(itertools.permutations(D)):
    j=list(j)
    if j==P:
        p=i
    if j==Q:
        q=i
print(abs(p-q))

Buggy submission (verdict: Runtime Error):
import itertools

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

D=list(range(1,N+1))
dict=[]

for i,j in enumerate(itertools.permutations(D)):
    P,Q,j=list([*P]),list([*Q]),list([*j])
    if j==P:
        p=i
    if j==Q:
        q=i
print(abs(p-q))

Buggy submission (verdict: Runtime Error):
import itertools

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

D=list(range(1,N+1))
dict=[]

for i,j in enumerate(itertools.permutations(D)):
    P,Q,j=[*P],[*Q],[*j]
    if j==P:
        p=i
    if j==Q:
        q=i
print(abs(p-q))
Problem p02823 (python)

Fixed submission:
n,a,b=map(int,input().split())

a_length=a-1
b_length=n-b

if not (b-a)%2:
    print((b-a)//2)
elif b_length>=a_length:
    print(a+(b-a-1)//2)
elif b_length<a_length:
    print(n-b+1+(b-a-1)//2)

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


def dfs(n,a,b,count):
    if not (b-a)%2:
        return (b-a)//2
    if a==1:
        return math.ceil(b//2)+count
    if b==n:
        return math.ceil((n-a)//2)+count
    if n-b<a:
        return dfs(n,a+1,b+1,count+1)
    if n-b>=a:
        return dfs(n,a-1,b-1,count+1)
print(dfs(n,a,b,0))
Problem p02865 (python)

Fixed submission:
import math
print(math.ceil(int(input())/2)-1)

Buggy submission (verdict: Runtime Error):
import math
print(math.celi(int(input()))-1)

Buggy submission (verdict: Runtime Error):
import math
print(math.celi(int(input())-1)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b

def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
n,q= [int(i) for i in input().split()]

edge = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

def dfs(now, last, x):
    global node
    node[now]+=x
    for nxt in edge[now]:
        if nxt == last: continue
        if nxt > now: dfs(nxt, now, x)

node=[0] * (n)
for _ in range(q):
    p,x=[int(i) for i in input().split()]
    dfs(p-1, -1, x)
print(node)
Problem p02983 (python)

Fixed submission:
l,r=map(int,input().split())
count=2019
for i in range(l,r):
    for j in range(i+1,r+1):
        count=min(count,(i*j)%2019)
        if i*j%2019==0:
            break
    if i*j%2019==0:
        break
print(count)

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
for i in range(l,r):
    for j in range(i+1,r+1):
        count=min(count,(i*j)%2019)
        if i*j%2019==0:
            break

print(count)

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
print(l,r)
for i in range(l,r):
    for j in range(i+1,r+1):
        count=min(count,(i*j)%2019)
        if i*j%2019==0:
            break

print(count)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

a,b,c,d=map(int,input().split())
b_num=b//c + b//d - b//lcm(d,c)
a_num=(a-1)//c + (a-1)//d - (a-1)//lcm(d,c)

print(b-(a-1)-(b_num-a_num))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
x=b-(b//c+b//d-b//(c*d/math.gcd(c,d)))
y=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(c*d/math.gcd(c,d)))

print(int(x-y))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
x=b-(b//c+b//d-b//(c*d/math.gcd(c,d)))
y=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(c*d/math.gcd(c,d)))

print(int(x-y))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b,c,d=map(int,input().split())
ab=np.array(range(a,b+1))
print(np.count_nonzero((ab%c)*(ab%d)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b,c,d=map(int,input().split())
ab=np.array(range(a,b+1))
print(np.count_nonzero((ab%c)*(ab%d)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b,c,d=map(int,input().split())
ab=np.array(range(a,b+1))
print(np.count_nonzero((ab%c)*(ab%d)))
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
food=set(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    food &= set(a)
print(len(food))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
food=list(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    food &= set(a)
print(len(food))
Problem p03240 (python)

Fixed submission:
def get_H(Cx, Cy):
    for x, y, h in L:
        if h > 0:
            return abs(x - Cx) + abs(y - Cy) + h


def check_H(Cx, Cy, H):
    for x, y, h in L:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True


N = int(input())

L = [(list(map(int, input().split()))) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check_H(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))
            exit(0)

Buggy submission (verdict: Runtime Error):
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if h>=1:
        return(H)
 
def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True
 
N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]
 
for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break

Buggy submission (verdict: Runtime Error):
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if h>=1:
        return(H)
 
def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
        # if H==decide_H(Cx,Cy,x,y,h) and H!=None and h!=0:
        #     continue
            return False
    return True
 
N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]
 
for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if H>=1:
        return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
        # if H==decide_H(Cx,Cy,x,y,h) and H!=None and h!=0:
        #     continue
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break
提出情報

Buggy submission (verdict: Runtime Error):
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if H>=1:
        return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
        # if H==decide_H(Cx,Cy,x,y,h) and H!=None and h!=0:
        #     continue
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break
Problem p03378 (python)

Fixed submission:
n,m,x,*a=map(int,open(0).read().split())
map=[0]*(n+1)
for i in a: map[i]=1
print(min(sum(map[0:x]),sum(map[x:n])))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
food=list(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    food &= set(a)
print(len(food))
Problem p03408 (python)

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]

result=0
for item in s:
    temp=s.count(item)-t.count(item)
    if result<temp:
        result=temp

print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
l=list(set(s))

esult=max(0,max(s.count(i)-t.count(i) for i in l))
print(result)
Problem p03436 (python)

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

H,W=[int(i) for i in input().split()]
C=[input() for _ in range(H)]
C=[list(i) for i in C] 

ans = 10**9

visited_list = [[10**9]*W for _ in range(H)]
stack = deque([[0, 0, 0]])
visited_list[0][0] = 0

w_cnt=0
for c in C: w_cnt += c.count(".")

def dfs(town, visited_list, stack):
    global ans
    flag = 0
    while len(stack) > 0:
        h, w, cnt = stack.pop()
        if h == H-1 and w == W-1 and ans > cnt:
            ans = cnt
            flag = 1
            continue
        for j, k in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or new_w < 0 or new_w >= W:
                continue
            if  town[new_h][new_w] != "#" and visited_list[new_h][new_w] > cnt + 1:
                visited_list[new_h][new_w] = cnt + 1
                stack.append([new_h, new_w, cnt+1])
    if flag: 
        ans = w_cnt-(ans+1)
        return ans
    else: return -1

print(dfs(C, visited_list, stack))

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

H,W=[int(i) for i in input().split()]
C=[input() for _ in range(H)]
C=[list(i) for i in C] 

ans = 10**9

visited_list = [[10**9]*W for _ in range(H)]
stack = deque([[0, 0, 0]])
visited_list[0][0] = 0

w_cnt=0
for c in C: w_cnt += c.count(".")

def seek(, visited_list, stack):
    global ans
    flag = 0
    while len(stack) > 0:
        h, w, cnt = stack.pop()
        if h == H-1 and w == W-1 and ans > cnt:
            ans = cnt
            flag = 1
            continue
        for j, k in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or new_w < 0 or new_w >= W:
                continue
            if  [new_h][new_w] != "#" and visited_list[new_h][new_w] > cnt + 1:
                visited_list[new_h][new_w] = cnt + 1
                stack.append([new_h, new_w, cnt+1])
    if flag: 
        ans = w_cnt-(ans+1)
        return ans
    else: return -1

print(seek(C, visited_list, stack))