Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,m,k=map(int, input().split())

f=np.full((n, n), 1,dtype=int)
f=f-np.eye(n,dtype=int)


for i in range(m):
    a,b = map(int, input().split())
    f[a-1][b-1]=0
    f[b-1][a-1]=0
    
for i in range(k):
    c,d = map(int, input().split())
    f[c-1][d-1]=0
    f[d-1][c-1]=0
    
print(*f.sum(axis=0))

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m,k=map(int,input().split())
uf = UnionFind(n)
friend=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friend[a]+=1
    friend[b]+=1
    uf.union(a,b)

block=[0]*n
for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if uf.same(c,d):
        block[c]+=1
        block[d]+=1

ans=[0]*n
for i in range(n):
    ans[i]=uf.size(i)-friend[i]-block[i]-1

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d={}
for i in range(n):
    tmp = input()
    if tmp in d:
        d[tmp]+=1
    else:
        d[tmp]=1
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)
    

Fixed submission:
n=int(input())
d={}
for i in range(n):
    tmp = input()
    if tmp in d:
        d[tmp]+=1
    else:
        d[tmp]=1
max_k_list=[]
max_d = max(d.values())
for k,v in d.items():
    if v == max_d:
        max_k_list.append(k)
max_k_list.sort()
for i in max_k_list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s = [0]*n
for i in range(n):
    s[i]=input()
d = Counter(s)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)


Fixed submission:
n=int(input())
d={}
for i in range(n):
    tmp = input()
    if tmp in d:
        d[tmp]+=1
    else:
        d[tmp]=1
max_k_list=[]
max_d = max(d.values())
for k,v in d.items():
    if v == max_d:
        max_k_list.append(k)
max_k_list.sort()
for i in max_k_list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s = [0]*n
for i in range(n):
    s[i]=input()
d = Counter(s)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Fixed submission:
n=int(input())
d={}
for i in range(n):
    tmp = input()
    if tmp in d:
        d[tmp]+=1
    else:
        d[tmp]=1
max_k_list=[]
max_d = max(d.values())
for k,v in d.items():
    if v == max_d:
        max_k_list.append(k)
max_k_list.sort()
for i in max_k_list:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((a*b) // math.gcd(a,b))

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print((a*b) // gcd(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
p=0
for i in range(n):
    try:
        p+=a[p:].index(i+1)
    except:
        ans=i
        break
else:
    ans=n
print(n-ans if ans>0 else -1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
p=ans=0
for i in range(1,n+1):
    for j in range(p,n):
        if i==a[j]:
            p=j
            break
    else:
        ans=i-1
        break
else:
    ans=n
print(n-ans if ans>0 else -1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
p=0
for i in range(n):
    if i+1 in a[p:]:
        p+=a[p:].index(i+1)
    else:
        ans=i
        break
else:
    ans=n
print(n-ans if ans>0 else -1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
p=ans=0
for i in range(1,n+1):
    for j in range(p,n):
        if i==a[j]:
            p=j
            break
    else:
        ans=i-1
        break
else:
    ans=n
print(n-ans if ans>0 else -1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
while(i<len(a)):
    if a[i]==i+1:
        i+=1
    else:
        a.pop(i)
        ans+=1
print(ans if ans!=n else -1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
p=ans=0
for i in range(1,n+1):
    for j in range(p,n):
        if i==a[j]:
            p=j
            break
    else:
        ans=i-1
        break
else:
    ans=n
print(n-ans if ans>0 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s= input()
ans=0
for x in range(1000):
    num=str("{0:03d}".format(x))
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if(num==s[i]+s[j]+s[k]):
                    ans+=1
                    break
            else:
                continue
            break
        else:
            continue
        break
print(ans)

Fixed submission:
n = int(input())
s= input()
ans=0
for x in range(1000):
    num=str("{0:03d}".format(x))
    s1=s.find(num[0])
    if(s1!=-1):
        s2=s.find(num[1],s1+1)
        if(s2!=-1):
            s3=s.find(num[2],s2+1)
            if(s3!=-1):
                ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
s= input()
l=list(s)
c = list(itertools.combinations(l, 3))
ans=len(set(c))
print(ans)

Fixed submission:
n = int(input())
s= input()
ans=0
for x in range(1000):
    num=str("{0:03d}".format(x))
    s1=s.find(num[0])
    if(s1!=-1):
        s2=s.find(num[1],s1+1)
        if(s2!=-1):
            s3=s.find(num[2],s2+1)
            if(s3!=-1):
                ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))

len=sum(a)
len_l=0
for i in range(n):
    if len/2>len_l:
        len_l+=a[i]
    else:
        center=i-1
        break
len_r=len-len_l
len_l-=a[center]

#半分との差
d=len/2-max(len_r,len_l)

print(int(d*2))

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

len=sum(a)
len_l=0
for i in range(n):
    if len/2>len_l:
        len_l+=a[i]
    else:
        center=i-1
        break
else:
    center=n-1
    
len_r=len-len_l
len_l-=a[center]
#半分との差
d=len/2-max(len_r,len_l)

print(int(d*2))
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

n = int(input())
root = int(math.sqrt(n))
for i in reversed(range(root)):
    if(n%i == 0):
        j=int(n/i)
        print(i+j-2)
        break

Fixed submission:
import math

n=int(input())

root = int(math.sqrt(n))
for i in reversed(range(root+1)):
    if(n%i == 0):
        j=int(n/i)
        print(i+j-2)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int, input().split()))

tmp=0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a,b,c = l[i],l[j],l[k]
            if((a+b>c) & (b+c>a) & (c+a>b)):
                tmp+=1
print(tmp)


Fixed submission:
n=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for c in range(n-1,1,-1):
    a=0
    b=c-1
    while(a<b):
        #cが一番長い
        if(L[a]+L[b]>L[c]):
            ans+=b-a
            b-=1
        else:
            a+=1
            
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
a,b=map(int, input().split())

cd=[1]
for i in range(2,gcd(a,b)+1):
    if((a%i == 0)and(b%i == 0)):
        cd.append(i)
        
ans=[1]
for i in range(1,len(cd)):
    for j in range(len(ans)):
        if(gcd(cd[i],ans[j]) != 1):
            break
    else:
        ans.append(cd[i])
print(len(ans))



Fixed submission:
from fractions import gcd
from collections import Counter

def prime_factorize(n):
    a=[]
    while n%2 == 0:
        a.append(2)
        n//=2
    f=3
    while f*f <= n:
        if n%f ==0:
            a.append(f)
            n//=f
        else:
            f+=2 # +1だと2の倍数にもなっちゃうからね
    if n!=1:
        a.append(n)
    return a

a,b=map(int, input().split())

ab = gcd(a,b)
soinsu = prime_factorize(ab)
sosu = Counter(soinsu).keys()

print(len(sosu)+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n,k,q=map(int, input().split())
p = np.full(n,k)

for i in range(q):
    a=int(input())
    p[a-1]+=1
    p-=1
    
for i in range(n):
    if(p[i]>0):
        print("Yes")
    else:
        print("No")


Fixed submission:
import numpy as np
import sys

n,k,q=map(int, input().split())
p = np.full(n,k-q)

for i in range(q):
    a=int(sys.stdin.readline())
    p[a-1]+=1
    
for i in range(n):
    if(p[i]>0):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


n=int(input())

s=[]
cnt=[]

for i in range(n):
    tmp=input()
    tmp = ''.join(sorted(tmp))
    
    for j in range(len(s)):
        if tmp==s[j]:
            cnt[j]+=1
            break
    else:
        s.append(tmp)
        cnt.append(1)
ans=0
for c in cnt:
    if(c>1):
        ans+=combinations_count(c, 2)
    
print(ans)


Fixed submission:
def main():
    n=int(input())
    d={}
    for i in range(n):
        tmp = ''.join(sorted(input()))
        
        if tmp in d:
            d[tmp]+=1
        else:
            d[tmp]=1
    ans=0
    for i in d.values():
        ans+=i*(i-1)//2
    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(n)]
for i in range(n):
    print(max(a[:i]+a[i+1:]))

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
a_copy=a[:]
first=max(a)
a_copy.remove(first)
second=max(a_copy)

for i in range(n):
    if a[i]!=first:
        print(first)
    else:
        print(second)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
j=0
for i in range(1,n+1):
    if i == a[j]:
        dp[i]=0
        j=min(m-1,j+1)
    else:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])


Fixed submission:
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
NG=[False]*n
for i in range(m):
    NG[a[i]-1]=True

for i in range(1,n+1):
    if NG[i-1]==False:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])


Fixed submission:
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
NG=[False]*n
for i in range(m):
    NG[a[i]-1]=True

for i in range(1,n+1):
    if NG[i-1]==False:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m=map(int,input().split())
A=np.ones(n)
for i in range(m):
    L,R=map(int,input().split())
    A[:L-1]=0
    A[R:]=0
print(int(sum(A)))

Fixed submission:
import numpy as np
n,m=map(int,input().split())
X=1
Y=n
for i in range(m):
    L,R=map(int,input().split())
    X=max(X,L)
    Y=min(Y,R)
print(max(0,Y-X+1))
Buggy python submission (verdict: Runtime Error):
x = [int(input()) for _ in range(5)]
r = list(map(lambda a: a%10,x))
min = min(filter(lambda x: x>0, r))
ans=0
for i in range(5):
    ans+=-(-x[i]//10)*10
ans+= min-10
print(ans)

Fixed submission:
x=[int(input()) for _ in range(5)]
r=list(map(lambda a: a%10,x))
min = min(list(filter(lambda x: x>0, r))+[10])
ans=0
for i in range(5):
    ans+=-(-x[i]//10)*10
ans+= min-10
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=list(input())
t=[0]*n
for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        t[i]=1
for i in range(q):
    l,r=map(int,input().split())
    print(sum(t[l-1:r-1]))

Fixed submission:
import numpy as np
n,q=map(int,input().split())
s=list(input())
t=np.zeros(n+1,dtype=int)
for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        t[i+1]=1
t=t.cumsum()
for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for _ in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
import numpy as np
n,q=map(int,input().split())
s=list(input())
t=np.zeros(n+1,dtype=int)
for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        t[i+1]=1
t=t.cumsum()
for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
k=min(n,k)
for i in range(n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j])
print(dp[-1])

Fixed submission:
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype=int)
for i in range(1,n):
    s=max(0,i-k)
    dp[i]=min(dp[s:i]+abs(h[s:i]-h[i]))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n,w=map(int, input().split())
weight=[0]*n
value=[0]*n
for i in range(n):
    weight[i],value[i]=map(int,input().split())

dp=[[0]*(n+10) for i in range(100100)]
for i in range(n):
    for sum_w in range(w+1):
        # i番目の品物を選ぶ場合
        if sum_w -  weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+value[i])
        # i番目の品物を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][w])

Fixed submission:
n,w=map(int, input().split())
weight=[0]*n
value=[0]*n
for i in range(n):
    weight[i],value[i]=map(int,input().split())

dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for sum_w in range(w+1):
        # i番目の品物を選ぶ場合
        if sum_w -  weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+value[i])
        # i番目の品物を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][w])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[0]*n
for i in range(n):
    h[i]=int(input())
h.sort()

ans=10**9
for i in range(n-k+1):
    ans= min(max(h[i:i+k])-min(h[i:i+k]), ans)
print(ans)


Fixed submission:
n,k =map(int,input().split())
h=[0]*n
for i in range(n):
    h[i]=int(input())
h.sort()
ans=10**9
for i in range(n-k+1):
    ans= min(h[i+k-1]-h[i], ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if a[i][-1]%2==1:
        a[i+1][-1]+=1
        ans.append([i+1,j+1,i+2,j+1])

print(len(ans))
for i in ans:
    print(*i)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if a[i][w-1]%2==1:
        a[i+1][w-1]+=1
        ans.append([i+1,w,i+2,w])
print(len(ans))
for i in ans:
    print(*i)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h):
    if a[i][-1]%2==1:
        a[i+1][-1]+=1
        ans.append([i+1,j+1,i+2,j+1])

print(len(ans))
for i in ans:
    print(*i)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if a[i][w-1]%2==1:
        a[i+1][w-1]+=1
        ans.append([i+1,w,i+2,w])
print(len(ans))
for i in ans:
    print(*i)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=n
for i in range(n):
    tmp=s[i+1:].count("E")
    tmp+=s[:i].count("W")
    ans=min(ans,tmp)
print(ans)

Fixed submission:
import numpy as np
n=int(input())
s=input()
w=list(map(lambda x: x=="W",s))
e=list(map(lambda x: x=="E",s))
w = np.array([0]+w).cumsum()
e = np.array([0]+e[::-1]).cumsum()
e = e[::-1]
ans=n
for i in range(n+1):
    tmp=w[i-1]+e[i]
    ans=min(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="#"+maze[i]+"#"
    maze.appendleft("#"*(w+2))
    maze.append("#"*(w+2))
    return list(maze)

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x]==-1:
                visited[new_y][new_x]=visited[y][x]+1
                queue.append([new_y,new_x])

h,w=map(int,input().split())
maze=[input() for _ in range(h)]
kabe=0
for i in range(h):
    kabe+=maze[i].count("#")
maze=make_wall(maze,h,w)
visited=[[-1]*(w+2) for _ in range(h+2)]
sy,sx=1,1
gy,gx=h,w
d=1+bfs(maze, visited, sy, sx, gy, gx)
print(h*w-kabe-d)

Fixed submission:
from collections import deque

def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="#"+maze[i]+"#"
    maze.appendleft("#"*(w+2))
    maze.append("#"*(w+2))
    return list(maze)

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x]==-1:
                visited[new_y][new_x]=visited[y][x]+1
                queue.append([new_y,new_x])
    return -1

h,w=map(int,input().split())
maze=[input() for _ in range(h)]
kabe=0
for i in range(h):
    kabe+=maze[i].count("#")
maze=make_wall(maze,h,w)
visited=[[-1]*(w+2) for _ in range(h+2)]
sy,sx=1,1
gy,gx=h,w
d=1+bfs(maze, visited, sy, sx, gy, gx)
if d==0:
    print(-1)
else:
    print(h*w-kabe-d)
Buggy python submission (verdict: Runtime Error):
s=input()
op=[0]*3
for i in range(2):
    a=calc(s[0],s[1],i)
    for j in range(2):
        b=calc(a,s[2],j)
        for k in range(2):
            c=calc(b,s[3],k)
            if c==7:
                ret=[i,j,k]               
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")


Fixed submission:
def calc(a,b,f):
    a=int(a)
    b=int(b)
    if f==0:
        return a+b
    else:
        return a-b

s=input()
op=[0]*3
for i in range(2):
    a=calc(s[0],s[1],i)
    for j in range(2):
        b=calc(a,s[2],j)
        for k in range(2):
            c=calc(b,s[3],k)
            if c==7:
                ret=[i,j,k]               
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")

Buggy python submission (verdict: Runtime Error):
def calc(a,b,f):
    if f==0:
        return a+b
    else:
        return a-b
s=input()
op=[0]*3
for i in range(2):
    tmp=calc(int(s[0]),int(s[1]),i)
    for j in range(2):
        tmp=calc(tmp,int(s[2]),j)
        for k in range(2):
            tmp=calc(tmp,int(s[3]),k)
            if tmp==7:
                ret=[i,j,k]
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")

Fixed submission:
def calc(a,b,f):
    a=int(a)
    b=int(b)
    if f==0:
        return a+b
    else:
        return a-b

s=input()
op=[0]*3
for i in range(2):
    a=calc(s[0],s[1],i)
    for j in range(2):
        b=calc(a,s[2],j)
        for k in range(2):
            c=calc(b,s[3],k)
            if c==7:
                ret=[i,j,k]               
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")
Buggy python submission (verdict: Runtime Error):
s=input()
if "9" in s:
    print("Yes")
else:
    print("No"

Fixed submission:
s=input()
if "9" in s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

def warshall_floyd(n, d):
    for k in range(n):
        for i in range(n): #始点
            for j in range(n): #終点
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

n,m,R=map(int,input().split())
r=list(map(int,list(input().split())))
g=[[float("inf")]*n for _ in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    g[a-1][b-1]=c
    g[b-1][a-1]=c
for i in range(n):
    g[i][i]=0
g=warshall_floyd(n,g)
ans=float("inf")
for p in list(permutations(r)):
    tmp=0
    for i in range(R-1):
        tmp+=g[p[i]-1][p[i+1]-1]
    ans=min(ans,tmp)
print(ans)

Fixed submission:
from itertools import permutations

def warshall_floyd(n, d):
    for k in range(n):
        for i in range(n): #始点
            for j in range(n): #終点
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

n,m,R=map(int,input().split())
r=list(map(int,list(input().split())))
g=[[float("inf")]*n for _ in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    g[a-1][b-1]=c
    g[b-1][a-1]=c
for i in range(n):
    g[i][i]=0
g=warshall_floyd(n,g)
ans=float("inf")
for p in list(permutations(r)):
    tmp=0
    for i in range(R-1):
        tmp+=g[p[i]-1][p[i+1]-1]
    ans=min(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
col=[0]*9
for i in range(n):
    col[a[i]//400]+=1
zero=0
cnt=0
for c in range(len(col)-1):
    if col[c]==0:
        zero+=1
    else:
        cnt+=1
m=max(cnt,1)
M=cnt+min(zero,col[-1])
print(m,M)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
col=[0]*9
for i in range(n):
    j=min(8, a[i]//400)
    col[j]+=1
zero=0
cnt=0
for c in range(len(col)-1):
    if col[c]==0:
        zero+=1
    else:
        cnt+=1
m=max(cnt,1)
M=cnt+col[-1]
print(m,M)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

dif = B-A
if dif%2 == 0:
  print(int(dif/2))
else:
  print(min(A-1, N-B)+1+int((dif//2))


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

dif = B-A
if dif%2 == 0:
  print(dif//2)
else:
  print(min(A-1, N-B)+1+dif//2)