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

Fixed submission:
import collections
import math

def C(n):
    if n-2 < 0:
        return 0
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
#d = {}
d = [-1]*200010
Cf = [C(i) for i in range(200010)]
sm = 0
for k,v in c.most_common():

    d[k] = v
    sm += C(v)

for a in A:
    print (sm - Cf[d[a]] + Cf[d[a]-1])

Buggy submission (verdict: Runtime Error):
import collections
import math

def C(n, r):
    if n-r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
#d = {}
d = [-1]*100000
sm = 0
for k,v in c.most_common():

    d[k] = v
    sm += C(v,2)

for a in A:
    print (sm - C(d[a],2) + C(d[a]-1,2) )
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
cand = ['*'] * N
mn = ''
for m in range(M):
    s, c = map(int, input().split())
    if s==1 and c==0 and N > 1:
        mn = '-1'

    if cand[s-1] == '*' or cand[s-1] == str(c):
        cand[s-1] = str(c)
    else:
        mn = '-1'
if mn == '-1':
    print (mn)
    exit()

for i in range(N):
    if cand[i]=='*':
        if i==0 and N > 1:
            mn+='1'
        else:
            mn+='0'
    else:
        mn+=cand[i]
print (mn)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cand = ['*'] * M
mn = ''
for m in range(M):
    s, c = map(int, input().split())
    if s==1 and c==0 and N > 1:
        mn = '-1'

    if cand[s-1] == '*' or cand[s-1] == str(c):
        cand[s-1] = str(c)
    else:
        mn = '-1'
if mn == '-1':
    print (mn)
else:  
    for i in range(N):
        if cand[i]=='*':
            if i==0:
                mn+='1'
            else:
                mn+='0'
        else:
            mn+=cand[i]
    print (mn)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cand = ['*'] * M
mn = ''
for m in range(M):
    s, c = map(int, input().split())
    if s==1 and c==0 and N > 1:
        mn = '-1'

    if cand[s-1] == '*' or cand[s-1] == str(c):
        cand[s-1] = str(c)
    else:
        mn = '-1'
if mn == '-1':
    print (mn)
    exit()

for i in range(N):
    if cand[i]=='*':
        if i==0:
            mn+='1'
        else:
            mn+='0'
    else:
        mn+=cand[i]
print (mn)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cand = ['*'] * M
mn = ''
for m in range(M):
    s, c = map(int, input().split())
    if s==1 and c==0:
        mn = '-1'

    if cand[s-1] == '*' or cand[s-1] == str(c):
        cand[s-1] = str(c)
    else:
        mn = '-1'
if mn == '-1':
    print (mn)
    exit()

for i in range(N):
    if cand[i]=='*':
        if i==0:
            mn+='1'
        else:
            mn+='0'
    else:
        mn+=cand[i]
print (mn)
Problem p02814 (python)

Fixed submission:
#from math import gcd
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a * b // gcd(a,b)
def ls_lcm(A):
    return reduce(lcm ,A)
def ls_gcd(A):
    return reduce (gcd, A)

def check_two(A):
    old = None
    for n in A:
        cnt = 0
        while(n & 1 == 0):
            cnt += 1
            n = n >> 1
        if old is None:
            old = cnt
        else:
            if old!=cnt:
                return False
    return True

N, M = map(int, input().split())
A = list(map(int, input().split()))
if not check_two(A):
    print (0)
    exit()
A = [a//2 for a in A]
half = ls_lcm(A)
print ((M + half) // (2*half))

Buggy submission (verdict: Runtime Error):
from math import gcd
#from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a * b // gcd(a,b)
def ls_lcm(A):
    return reduce(lcm ,A)
def ls_gcd(A):
    return reduce (gcd, A)

N, M = map(int, input().split())
A = list(map(int, input().split()))
half = ls_lcm(A) // 2
#print (((M // half) + 1) // 2)
print ((M + half) // (2*half))
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1E+7)
def main():
    N, Q = map(int, input().split())
    link = [[] for _ in range(N+1)]
    for n in range(N-1):
        a, b = map(int, input().split())
        link[a].append(b)
        link[b].append(a)
    V = [0] * (N+1)
    ans = [0] * (N+1)
    for q in range(Q):
        p, x = map(int, input().split())
        V[p] += x

    def dfs(i, parent, acc):
        V[i] += acc
        for j in link[i]:
            if j != parent:
                dfs(j,i,V[i])
    cur = 1
    parent = 0
    acc = 0
    dfs(cur, parent , acc)
    V = [str(v) for v in V]
    print (" ".join(V[1:]))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
#link = [[0]*(N+1) for _ in range(N+1)]
link = [[] for _ in range(N+1)]
for n in range(N-1):
    a, b = map(int, input().split())
    # link[a][b] = 1
    # link[b][a] = 1
    link[a].append(b)
    link[b].append(a)
V = [0] * (N+1)
ans = [0] * (N+1)
for q in range(Q):
    p, x = map(int, input().split())
    V[p] += x

def dfs(i, parent, acc):
    V[i] += acc
    # for j in range(1,N+1):
    #     if link[i][j] == 1 and parent!=j:
    #         dfs(j,i,V[i])
    for j in link[i]:
        if j==parent:
            continue
        dfs(j,i,V[i])
cur = 1
parent = 0
acc = 0

dfs(cur, parent , acc)
V = [str(v) for v in V]
print (" ".join(V[1:]))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
#link = [[0]*(N+1) for _ in range(N+1)]
link = [[] for _ in range(N+1)]
for n in range(N-1):
    a, b = map(int, input().split())
    # link[a][b] = 1
    # link[b][a] = 1
    link[a].append(b)
    link[b].append(a)
V = [0] * (N+1)
ans = [0] * (N+1)
for q in range(Q):
    p, x = map(int, input().split())
    V[p] += x

def dfs(i, parent, acc):
    V[i] += acc
    # for j in range(1,N+1):
    #     if link[i][j] == 1 and parent!=j:
    #         dfs(j,i,V[i])
    for j in link[i]:
        if j!=parent:
            dfs(j,i,V[i])
cur = 1
parent = 0
acc = 0

dfs(cur, parent , acc)
V = [str(v) for v in V]
print (" ".join(V[1:]))
Problem p02973 (python)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N+1)
lis[0] = -1
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
print (bisect.bisect_left(lis, INF) - 1)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N)
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
    #print (lis)
print (bisect.bisect_left(lis, INF)) a
Problem p03014 (python)

Fixed submission:
import numpy as np
H , W = list(map(int, input().split()))
S = np.array([list(input().rstrip()) for _ in range(H)]) == '.'
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
for h in range(1, H):
    U[h] = (U[h - 1] + 1) * S[h - 1]
for h in reversed(range(H - 1)):
    D[h] = (D[h + 1] + 1) * S[h + 1]
for w in range(1, W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w - 1]
for w in reversed(range(W - 1)):
    R[:, w] = (R[:, w + 1] + 1) * S[:, w + 1]
print(np.max((U+D+L+R) * S) + 1)

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
S = np.array([list(input().rstrip()) for _ in range(H)]) == '.'
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
for h in range(1, H):
    U[h] = (U[h - 1] + 1) * S[h - 1]
for h in reversed(range(H - 1)):
    D[h] = (D[h + 1] + 1) * S[h + 1]
for w in range(1, W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w - 1]
for w in reversed(range(W - 1)):
    R[:, w] = (R[:, w + 1] + 1) * S[:, w + 1]
print(max((U+D+L+R) * S) + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int,input().split())
S = []
for h in range(H):
   S.append(input())
def calc(LR,RL,H,W,S):
   for h in range(H):
       for w in range(W):
           if S[h][w]==".":
               LR[h+1][w+1] = LR[h+1][w] + 1
           else:
               LR[h+1][w+1] = 0
           if S[h][W-w-1]==".":
               RL[h+1][W-w] = RL[h+1][W-w+1] + 1
           else:
               RL[h+1][W-w] = 0
   return LR, RL
LR = np.zeros((H+2,W+2)).astype(np.int)
RL = np.zeros((H+2,W+2)).astype(np.int)
UD = np.zeros((H+2,W+2)).astype(np.int)
DU = np.zeros((H+2,W+2)).astype(np.int)
LR, RL = calc(LR,RL,H,W,S)
S2 = ["" for i in range(len(S[0]))]
for i in range(len(S[0])):
   for j in range(len(S)):
       S2[i]+=(S[j][i])

UD, DU = calc(UD.T,DU.T,W,H,S2)
mx = 0
for h in range(H):
   for w in range(W):
       p = 0
       if (S[h][w]=="."):
           p = LR[h+1][w]+RL[h+1][w+2] + UD.T[h][w+1]+DU.T[h+2][w+1] + 1
           mx = max(mx,p)
print (mx)
Problem p03145 (python)

Fixed submission:
#coding:utf-8
a,b,c = map(int,input().split())
s = (a+b+c)/2.0
S = (s * (s-a) * (s-b) * (s-c)) ** 0.5
print (int(S))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import copy
N, K = map(int,input().split())
T = []
D = []
ls_td = []
for n in range(N):
    t, d = map(int,input().split())
    ls_td.append([t,d])
ls_td = sorted(ls_td, key=lambda x: x[1])[::-1]
head = ls_td[:K]
tail = ls_td[K:]
def get_set(mat):
    st = set()
    for t,d in mat:
        st.add(t)
    return st
def score(mat):
    r = 0
    ls_t = set()
    for t,d in mat:
        ls_t.add(t)
        r += d
    r += len(ls_t)**2
    return r

def search_del(mat):
    idx = -1
    st = set()
    for i,(t,d) in enumerate(mat):
        if t in st:
            idx = i
        st.add(t)
    return idx
st = get_set(head)
current_score = score(head)
idx = search_del(head)
for t,d in tail:
    if idx == -1:
        break

    if t in st:
        pass
    else:
        new = copy.deepcopy(head)
        new[idx] = t,d
        candidate_score = score(new)
        if current_score < candidate_score:
            head = new
            st.add(t)
            current_score = candidate_score
            idx = search_del(head)
print (current_score)
Problem p03215 (python)

Fixed submission:
#coding:utf-8
n,k  = map(int,input().split())
ls_a  = list(map(int,input().split()))
target = int(k*(k+1)/2)
ls_target = []
i = 1
while(1):
    for j in range(i):
        temp = ls_a[j:(len(ls_a)-i+j+1)]
        ls_target.append(sum(temp))
    if i==n:
        break
    i+=1

def check(num):
    for i in range(50):
        if (num < 2**i):
            return i-1, 2**(i-1)
mx = ls_target[0]
digit, mx_bin = check(mx)
ans = 0
for d in range(digit+1):
#    print (mx_bin)
#    print (ls_target)
    new_idx = []
    cnt = 0
    for idx,ls in enumerate(ls_target):
        if ls & mx_bin > 0:
            cnt += 1
            new_idx.append(idx)
    if cnt >= k:
        ls_target = [ls_target[i] for i in new_idx]
        ans += mx_bin
    mx_bin = int(mx_bin/2)
print (ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n,k  = map(int,input().split())
ls_a  = list(map(int,input().split()))
target = int(k*(k+1)/2)
ls_target = []
i = 1
while(1):
    for j in range(i):
        temp = ls_a[j:(len(ls_a)-i+j+1)]
        ls_target.append(sum(temp))
    if i==n:
        break
    i+=1

def check(num):
    for i in range(100):
        if (num < 2**i):
            return i-1, 2**(i-1)
mx = sum(ls_target[0])
digit, mx_bin = check(mx)
ans = 0
for d in range(digit+1):
#    print (mx_bin)
#    print (ls_target)
    new_idx = []
    cnt = 0
    for idx,ls in enumerate(ls_target):
        if ls & mx_bin > 0:
            cnt += 1
            new_idx.append(idx)
    if cnt >= k:
        ls_target = [ls_target[i] for i in new_idx]
        ans += mx_bin
    mx_bin = int(mx_bin/2)
print (ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n,k  = map(int,input().split())
ls_a  = list(map(int,input().split()))
target = int(k*(k+1)/2)
ls_target = []
i = 1
while(1):
    for j in range(i):
        temp = ls_a[j:(len(ls_a)-i+j+1)]
        ls_target.append(sum(temp))
    if i==n:
        break
    i+=1

def check(num):
    for i in range(100):
        if (num < 2**i):
            return i-1, 2**(i-1)
mx = sum(ls_target[0])
digit, mx_bin = check(mx)
ans = 0
for d in range(digit+1):
#    print (mx_bin)
#    print (ls_target)
    new_idx = []
    cnt = 0
    for idx,ls in enumerate(ls_target):
        if ls & mx_bin > 0:
            cnt += 1
            new_idx.append(idx)
    if cnt >= k:
        ls_target = [ls_target[i] for i in new_idx]
        ans += mx_bin
    mx_bin = int(mx_bin/2)
print (ans)
Problem p03231 (python)

Fixed submission:
#coding:utf-8
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
n,m = map(int,input().split())
s=input()
t=input()
lcm = lcm(n,m)
a = int(lcm/n)
b = int(lcm/m)
for i in range(fractions.gcd(n,m)):
    if s[i*b]==t[i*a]:
        pass
    else:
        print (-1)
        exit()
print (lcm)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n,m = map(int,input().split())
s=input()
t=input()
lcm = lcm(n,m)
a = int(lcm/n)
b = int(lcm/m)
for i in range(math.gcd(n,m)):
    if s[i*b]==t[i*a]:
        pass
    else:
        print (-1)
        exit()
print (lcm)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n,m = map(int,input().split())
s=input()
t=input()
lcm = lcm(n,m)
a = int(lcm/n)
b = int(lcm/m)
for i in range(math.gcd(n,m)):
    if s[i*b]==t[i*a]:
        pass
    else:
        print (-1)
        exit()
print (lcm)
Problem p03240 (python)

Fixed submission:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
narr = np.array(arr)
x_min  = narr[:,0].min()
x_max = narr[:,0].max()
y_min = narr[:,1].min()
y_max =  narr[:,1].max()
mx = narr[:,2].max()
for k in range(mx+100,mx-1,-1):
    for i in range(x_min,x_max+1):
        for j in range(y_min,y_max+1):
            for x,y,h in arr:
                h_ = max(k-abs(i-x)-abs(j-y),0)
                if h_ != h:
                    break
            else:
                print (i,j,k)
                exit()

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
x_min  = arr[:,0].min()
x_max = arr[:,0].max()
y_min = arr[:,1].min()
y_max =  arr[:,1].max()
mx = arr[:,2].max()
s = max(dx,dy)+1
for k in range(mx+100,mx-1,-1):
    for i in range(x_min,x_max+1):
        for j in range(y_min,y_max+1):
            for x,y,h in arr:
                h_ = max(k-abs(i-x)-abs(j-y),0)
                if h_ != h:
                    break
            else:
                print (i,j,k)
                exit()
Problem p03244 (python)

Fixed submission:
#coding:utf-8
import numpy as np
import collections
N = 1000000
_ = int(input())
ls = list(map(int,input().split()))
ls.append(N)
ls.append(N)
array = np.array(ls).reshape(-1,2).T
c_even = collections.Counter(array[0])
c_odd = collections.Counter(array[1])
if len(set(ls))==2:
    print (int((len(ls)-2)/2))
elif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:
    print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)
else:
    print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np
import collections
N = 1000000
ls = list(map(int,input().split()))
ls.append(N)
ls.append(N)
array = np.array(ls).reshape(-1,2).T
c_even = collections.Counter(array[0])
c_odd = collections.Counter(array[1])
if len(set(ls))==2:
    print (int((len(ls)-2)/2))
elif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:
    print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)
else:
    print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np
import collections
N = 1000000
ls = list(map(int,input().split()))
ls.append(N)
ls.append(N)
array = np.array(ls).reshape(-1,2).T
c_even = collections.Counter(array[0])
c_odd = collections.Counter(array[1])
if len(set(ls))==2:
    print (int((len(ls)-2)/2))
elif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:
    print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)
else:
    print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))
Problem p03282 (python)

Fixed submission:
#coding:utf-8
s = input()
k = int(input())
idx = 1e+19
for i,char in enumerate(s):
    if int(char)>1:
        x = char
        idx = i
        break
#print (x,idx)
if k>idx:
    print (x)
else:
    print (1)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
s = input()
k = int(input())
for i,char in enumerate(s):
    if int(char)>1:
        x = char
        idx = i
        break
#print (x,idx)
if k>idx:
    print (x)
else:
    print (1)
Problem p03476 (python)

Fixed submission:
import bisect
N = 10**6
dp = [0] * (N+1)
dp[0], dp[1] = 1, 1
prime = []
for i in range(2,N+1):
    if dp[i]==0:
        prime.append(i)
        for j in range(N//i+1):
            dp[j*i] = 1

like2017 = []
for p in prime:
    query = (p+1)//2
    idx = bisect.bisect_left(prime, query)
    if prime[idx] == query:
        like2017.append(p)
    

Q = int(input())
for q in range(Q):
    l, r = map(int,input().split())
    l = bisect.bisect_left(like2017, l)
    r = bisect.bisect_right(like2017, r)
    print (r-l)

Buggy submission (verdict: Runtime Error):
import bisect
N = 10**6
dp = [1] * (N+1)
dp[0] =  dp[1] =  0
prime = []
for i in range(2,N+1):
    if dp[i]:
        for j in range(i*i, N+1, i):
            dp[j] = 0
like2017 = [0] * (N+1)
for n in range(N+1):
    if dp[n]==0:
        continue
    query = (p+1)//2
    if dp[query]==1:
        like2017[n] = 1


for n in range(N):
    line2017[n+1] += like2017[n]
    
Q = int(input())
for q in range(Q):
    l, r = map(int,input().split())
    print (like2017[r]-like2017[l])

Buggy submission (verdict: Runtime Error):
import bisect
N = 10**6
dp = [1] * (N+1)
dp[0] =  dp[1] =  0
prime = []
for i in range(2,N+1):
    if dp[i]:
        for j in range(i*i, N+1, i):
            dp[j] = 0
like2017 = [0] * (N+1)
for n in range(N+1):
    if dp[n]==0:
        continue
    query = (p+1)//2
    if dp[query]==1:
        like2017[n] = 1


for n in range(N):
    line2017[n+1] += like2017[n]
    
Q = int(input())
for q in range(Q):
    l, r = map(int,input().split())
    print (like2017[r]-like2017[l])
Problem p03600 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7

N = int(input())
INF = 10**10
cost = [[INF]*N for _ in range(N)]

for i in range(N):
    C = list(map(int, input().split()))
    for j in range(N):
        cost[i][j] = C[j]
    cost[i][i] = INF

ans = 0
for j in range(N):
    for k in range(j+1,N):
        mn = INF
        for i in range(N):
            mn = min(mn, cost[j][i]+cost[i][k])    
        if (cost[j][k] > mn):
            print (-1)
            exit()
        elif (cost[j][k] < mn):
            ans += cost[j][k]                      
print (ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
INF = 10**10
cost = [[INF]*N for _ in range(N)]

for u in range(N):
    C = list(map(int, input().split()))
    for v in range(N):
        if u==v: # INFのままにする
            continue
        cost[u][u] = C[u]
 
ans = 0
for u in range(N):
    for v in range(j+1,N):
        mn = INF # u-w-vのような経路の中で最小の距離を求める
        for w in range(N):
            mn = min(mn, cost[u][w]+cost[w][v])    
        if (cost[u][v] > mn): # 与えられた行列が最短経路ではない
            print (-1)
            exit()
        elif (cost[u][v] < mn): # 等しくない場合はu-vを直接結ぶ橋が必要 
            ans += cost[u][v]                      
print (ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
INF = 10**10
cost = [[INF]*N for _ in range(N)]

for u in range(N):
    C = list(map(int, input().split()))
    for v in range(N):
        if u==v: # INFのままにする
            continue
        cost[u][v] = C[u]
 
ans = 0
for u in range(N):
    for v in range(j+1,N):
        mn = INF # u-w-vのような経路の中で最小の距離を求める
        for w in range(N):
            mn = min(mn, cost[u][w]+cost[w][v])    
        if (cost[u][v] > mn): # 与えられた行列が最短経路ではない
            print (-1)
            exit()
        elif (cost[u][v] < mn): # 等しくない場合はu-vを直接結ぶ橋が必要 
            ans += cost[u][v]                      
print (ans)
Problem p03838 (python)

Fixed submission:
#coding:utf-8
x, y = map(int, input().split())
def func(a):
    if a<0:
        return 1e+10
    else:
        return a
ls = [func(y-x),func(y+x)+1,func(-y-x)+1,func(-y+x)+2]
print (min(ls))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import math
x, y = map(int, input().split())
ls = [y-x,y+x+1,-y-x+1,-y+x+2]
ls = [math.inf if i<0 else i for i in ls]
#print (ls)
print (min(ls))
Problem p02630 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*(10**5+1)
res=sum(A)
for i in A:
    numList[i] += 1

for i in range(Q):
    dev = B[i][1]-B[i][0]
    res += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*10**5
res=sum(A)
for i in A:
    numList[i] += 1



for i in range(Q):
    dev = B[i][1]-B[i][0]
    res += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*10**5
sum=0
for i in A:
    numList[i] += 1
    sum+=i



for i in range(Q):
    dev = B[i][1]-B[i][0]
    sum += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*10**5
sum=0
for i in A:
    numList[i] += 1
    sum+=i



for i in range(Q):
    dev = B[i][1]-B[i][0]
    sum += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
numList = [0]*10**5
sum=0
for i in A:
    numList[i] += 1
    sum+=i

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

for i in range(Q):
    dev = B[i][1]-B[i][0]
    sum += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(sum)