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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]<sum(a[1:]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]<sum(a[1:]):
  print("Yes"）
else:
  print("No")
Problem p03150 (python)

Fixed submission:
import sys
s=input()

for i in range(len(s)):
    for g in range(i,len(s)):
        if "keyence"==s[:i]+s[g:]:
            print("YES")
            sys.exit()
print("NO")

Buggy submission (verdict: Runtime Error):
s=list(input())
t="keyence"

for i in range(len(s)):
    if s[i]==t[0]:
        t=t[1:]
if t=="":
    print("YES")
else:
    print("NO")
Problem p03192 (python)

Fixed submission:
n=input()
ans=0
for i in range(4):
  if n[i]=="2":
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
ans=0
for i in range(4):
  if n[i]="2":
    ans+=1
print(ans)
Problem p03213 (python)

Fixed submission:
N = int(input())

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if N!=1:
	if _count[0] >= 74:
		ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))

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

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if _count[0] >= 74:
	ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))
Problem p03262 (python)

Fixed submission:
from fractions import gcd

N,X = (int(i) for i in input().split()) 
x = [abs(int(i)-X) for i in input().split()]

ans = x[0]
for i in range(N):
	ans = gcd(ans, x[i])
	if ans == 1:
		break

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = (int(i) for i in input().split()) 
x = [abs(int(i)-X) for i in input().split()]

ans = x[0]
for i in range(N):
	ans = math.gcd(ans, x[i])
	if ans == 1:
		break

print(ans)
Problem p03280 (python)

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

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

N,M,Q=map(int,input().split())

Goal=[defaultdict(int) for _ in range(N)]
for i in range(M):
    L,R=map(int,input().split())
    Goal[L-1][R-1]+=1

Accumlate = [[0]*(N+1) for i in range(N)]
for g in range(N):
    for l in range(N):
        Accumlate[g][l+1]+=Accumlate[g][l]+Goal[g][l]

ans_list=[]
for l in range(Q):
    ans=0
    L,R=map(int,input().split())
    for l in range(L-1,R):
        ans+=Accumlate[l][R]-Accumlate[l][L-1]
    ans_list.append(ans)

for m in range(Q):
    print(ans_list[m])
Problem p03287 (python)

Fixed submission:
from collections import defaultdict
from itertools import accumulate

N,M=map(int,input().split())
A=list(map(int,input().split()))

acc=list(accumulate(A))

d=defaultdict(int)

ans=0
for i in range(N):
    if acc[i]%M==0:
        d[acc[i]%M]+=1
        ans+=d[acc[i]%M]
    else:
        d[acc[i]%M]+=1
        ans+=d[acc[i]%M]-1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()]

a = 0
sum_A = {}

for g in range(N):
	a += A[g]
	amari = a%M
	if amari in sum_A.keys():
		sum_A[amari] += 1
	else:
		sum_A[amari] = 1

ans = sum_A[0]
for l in range(len(sum_A)):
	if sum_A[list(sum_A)[l]] >= 2:
		ans += (sum_A[list(sum_A)[l]]-1)*sum_A[list(sum_A)[l]]/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()]

a = 0
sum_A = {}

for g in range(N):
	a += A[g]
	amari = a%M
	if amari in sum_A.keys():
		sum_A[amari] += 1
	else:
		sum_A[amari] = 1

ans = sum_A[0]
for l in range(len(sum_A)):
	if sum_A[list(sum_A)[l]] >= 2:
		ans += comb(sum_A[list(sum_A)[l]], 2, exact=True)
print(ans)
Problem p03438 (python)

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

aPlus=0
bPlus=0

for i in range(n):
    if a[i]>b[i]:
        aPlus+=(a[i]-b[i])
    elif a[i]<b[i]:
        if (b[i]-a[i])%2==0:
            bPlus+=(b[i]-a[i])//2
        else:
            aPlus+=1
            bPlus+=(b[i]+1-a[i])//2

if aPlus<=bPlus:
    print("Yes")
else:
    print("No")

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

aPlus = 0
bPlus = 0

for i in range(n):
    if b[i] > a[i]:
        if (b[i]-a[i]) % 2 == 0:
            aPlus += b[i]-a[i]
            bPlus += (b[i]-a[i])//2
        else:
            print("No")
            exit()
    else:
        aPlus += 2*(a[i]-b[i])
        bPlus += a[i]-b[i]

if aPlus//bPlus==2:
    print("Yes")
else:
    print("No")
Problem p03476 (python)

Fixed submission:
import math
import bisect
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

prime=set([2])
for i in range(3,100001):
    if i%2!=0 and is_prime(i):
        prime.add(i)

sim_prime=[]
for p in prime:
    if (p+1)//2 in prime:
        sim_prime.append(p)
sim_prime.sort()


q=int(input())
ans_list=[]
for i in range(q):
    l,r=map(int,input().split())
    l_idx=bisect.bisect_left(sim_prime,l)
    r_idx=bisect.bisect_left(sim_prime,r)
    if sim_prime[min(r_idx,len(sim_prime)-1)]==r:
        r_idx+=1
    ans_list.append(r_idx-l_idx)

for g in range(len(ans_list)):
    print(ans_list[g])

Buggy submission (verdict: Runtime Error):
import math
import bisect
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

prime=set([2])
for i in range(3,100001):
    if i%2!=0 and is_prime(i):
        prime.add(i)

sim_prime=[]
for p in prime:
    if (p+1)//2 in prime:
        sim_prime.append(p)
sim_prime.sort()


q=int(input())
ans_list=[]
for i in range(q):
    l,r=map(int,input().split())
    l_idx=bisect.bisect_left(sim_prime,l)
    r_idx=bisect.bisect_left(sim_prime,r)
    if sim_prime[r_idx]==r:
        r_idx+=1
    ans_list.append(r_idx-l_idx)

for g in range(len(ans_list)):
    print(ans_list[g])
Problem p03557 (python)

Fixed submission:
import bisect
from itertools import accumulate
from operator import add

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

AonB=[]
BonC=[]
ans=0
for i in range(n):
    AonB.append(bisect.bisect_left(a,b[i]))

AonB=list(accumulate(AonB,add))

ans=0
for g in range(n):
    search=bisect.bisect_left(b,c[g])-1
    if search>=0:
        ans+=AonB[search]

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
from itertools import accumulate
from operator import add

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

AonB=[]
BonC=[]
ans=0
for i in range(n):
    AonB.append(bisect.bisect_left(a,b[i]))

AonB=list(accumulate(AonB,add))

ans=0
for g in range(n):
    search=bisect.bisect_left(b,c[g])-1
    if search>=0:
        ans+=AonB[search]

print(ans)
Problem p02609 (python)

Fixed submission:
from functools import lru_cache
N = int(input())
S = input()
X = int(S, 2)

P = S.count('1')
if P == 0:
    for i in range(N):
        print(1)
    exit()

Rp = X % (P+1)
if P != 1:
    Rn = X % (P-1)

@lru_cache(None)
def popcnt(x):
    return bin(x).count('1')

for i in range(N):
    if S[i] == '1':
        if P == 1:
            print(0)
            continue
        p = P-1
        x = (Rn - pow(2, N-1-i, p)) % p
    else:
        p = P+1
        x = (Rp + pow(2, N-1-i, p)) % p

    cnt = 1
    while x:
        x %= popcnt(x)
        cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
N = int(input())
S = input()
X = int(S, 2)

P = S.count('1')
if P == 0:
    for i in range(N):
        print(1)
    exit()

Rp = X % (P+1)
Rn = X % (P-1)

@lru_cache(None)
def popcnt(x):
    return bin(x).count('1')

for i in range(N):
    if S[i] == '1':
        if P == 1:
            print(0)
            continue
        p = P-1
        x = (Rn - pow(2, N-1-i, p)) % p
    else:
        p = P+1
        x = (Rp + pow(2, N-1-i, p)) % p

    cnt = 1
    while x:
        x %= popcnt(x)
        cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
N = int(input())
S = input()
X = int(S, 2)

P = S.count('1')
Rp = X % (P+1)
Rn = X % (P-1)


@lru_cache(None)
def popcnt(x):
    return bin(x).count('1')

mask = 1 << N
for i in range(N-1, -1, -1):
    mask >>= 1
    
    x = X ^ mask
    if x == 0:
        print(0)
        continue

    if X & mask:
        p = P-1
        x = (Rn - pow(2, i, p)) % p
    else:
        p = P+1
        x = (Rp + pow(2, i, p)) % p

    cnt = 1
    while x:
        x %= popcnt(x)
        cnt += 1
    print(cnt)
Problem p02639 (python)

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

for i, a in enumerate(A):
    if a == 0:
        print(i+1)

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

def main():
    N = int(input())
    *A, = map(int, input().split())
    A.sort()
    C = Counter(A)

    MAX = 2000005
    T = [0]*MAX

    ans = 0
    for a in A:
        if T[a]:
            continue
        else:
            if C[a] == 1:
                ans += 1
            for i in range(2*a, MAX, a):
                T[i] += 1
    print(ans)

@jit()

if __name__ == '__main__':
    main()
Problem p02642 (python)

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    *A, = map(int, input().split())
    C = Counter(A)

    MAX = 1000005
    T = [0]*MAX

    ans = 0
    for a in C.keys():
        if T[a]:
            continue
        else:
            for i in range(2*a, MAX, a):
                T[i] = 1

    ans = 0
    for a, n in C.items():
        if n == 1 and T[a] == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

def main():
    N = int(input())
    *A, = map(int, input().split())
    A.sort()
    C = Counter(A)

    MAX = 2000005
    T = [0]*MAX

    ans = 0
    for a in A:
        if T[a]:
            continue
        else:
            if C[a] == 1:
                ans += 1
            for i in range(2*a, MAX, a):
                T[i] += 1
    print(ans)

@jit()

if __name__ == '__main__':
    main()
Problem p02727 (python)

Fixed submission:
# E
X, Y, NA, NB, NC = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

A = sorted(A)[-X:]
B = sorted(B)[-Y:]
C = sorted(C)[::-1]

ans = sum(A) + sum(B)


i = 0
j = 0
num_A = len(A)
num_B = len(B)
for c in C:
    if i < num_A and j < num_B:
        if A[i] < B[j] and A[i] < c:

            ans += c - A[i]
            i += 1
        elif A[i] >= B[j] and B[j] < c:

            ans += c - B[j]
            j += 1

    elif i < num_A:
        if A[i] < c:
            ans += c - A[i]
            i += 1

    elif j < num_B:
        if B[j] < c:
            ans += c - B[j]
            j += 1

    else:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
# E
X, Y, NA, NB, NC = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

A = sorted(A)[-X:]
B = sorted(B)[-Y:]
C = sorted(C)[::-1]

ans = sum(A) + sum(B)

i = 0
j = 0
for c in C:
    if A[i] < c or B[j] < c:
        if A[i] < B[j]:
            i += 1
            ans += c - A[i]
        else:
            j += 1
            ans += c - B[j]

print(ans)

Buggy submission (verdict: Runtime Error):
# E
X, Y, NA, NB, NC = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

A = sorted(A)[-X:]
B = sorted(B)[-Y:]
C = sorted(C)[::-1]

ans = sum(A) + sum(B)

i = 0
j = 0
for c in C:
    if A[i] < c or B[j] < c:
        if A[i] < B[j]:
            i += 1
            ans += c - A[i]
        else:
            j += 1
            ans += c - B[i]

print(ans)
Problem p02845 (python)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

col = [0, 0, 0]
ans = 1
for a in A:
    if a not in col:
        print(0)
        break
    ans = ans * col.count(a) % mod
    col[col.index(a)] += 1
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

col = [0, 0, 0]
ans = 1
for a in A:
    ans = ans * col.count(a) % mod
    col[col.index(a)] += 1

print(ans)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)

def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, ans[ei], x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, ans[ei], x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, k, x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)
Problem p02936 (python)

Fixed submission:
# AtCoder Beginner Contest 138
# D - Ki
# https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
sys.setrecursionlimit(10**6)

input = sys.stdin.readline
N, Q = map(int, input().split())

G = [[] for _ in [0]*N]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

counter = [0]*N

for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False]*N


def dfs(v=0, x=0):
    visited[v] = True
    counter[v] += x
    for u in G[v]:
        if visited[u]:
            continue
        dfs(u, counter[v])


dfs()
print(*counter)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

add = [0]*N
for _ in [0]*M:
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
counter = [0]*N

def dfs(v, p, x):
    counter[v] = x
    for u in G[v]:
        if u == p:
            continue
        dfs(u, v, x+add[u])


dfs(0, -1, add[0])

print(*counter)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

cnt = [0]*N
pre = [-1]*N
k = 0


def init(v=0, p=-1):
    global k
    pre[v] = k
    k += 1

    for u in G[v]:
        if u == p:
            continue
        init(u, v)


def dfs(v, x):
    cnt[v] += x
    for u in G[v]:
        if pre[v] > pre[u]:
            continue
        dfs(u, x)
    return


init()
for _ in [0]*Q:
    p, x = map(int, input().split())
    dfs(p-1, x)

print(*cnt)
Problem p02939 (python)

Fixed submission:
S = input()

ans = 0
prev = ''
curr = ''
for s in S:
    curr += s
    if prev != curr:
        ans += 1
        prev = curr
        curr = ''
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

from functools import lru_cache
S = input()
N = len(S)

@lru_cache
def solve(i, prev, K):
    if i >= N:
        return K
    ret = 0
    if S[i] != prev:
        ret = max(ret, solve(i+1, S[i], K+1))
    if S[i:i+2] != prev:
        ret = max(ret, solve(i+2, S[i:i+2], K+1))
    return ret


print(solve(0, '', 0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

from functools import lru_cache
S = input()


@lru_cache
def solve(i, prev, K):
    if i >= N:
        return K
    ret = 0
    if S[i] != prev:
        ret = max(ret, solve(i+1, S[i], K+1))
    if S[i:i+2] != prev:
        ret = max(ret, solve(i+2, S[i:i+2], K+1))
    return ret


print(solve(0, '', 0))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
S = input()


@lru_cache
def solve(i, prev, K):
    if i >= N:
        return K
    ret = 0
    if S[i] != prev:
        ret = max(ret, solve(i+1, S[i], K+1))
    if S[i:i+2] != prev:
        ret = max(ret, solve(i+2, S[i:i+2], K+1))
    return ret


print(solve(0, '', 0))
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [1<<30]*(N)
dp[0] = 0
 
for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))
 
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = [1<<30]*N
dp[0] = 0

for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))

print(dp[N-1])
Problem p03196 (python)

Fixed submission:
from collections import defaultdict

N, P = map(int, input().split())
dic = defaultdict(int)

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
if P > 1:
    dic[P] += 1

ans = 1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)

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

N, P = map(int, input().split())
dic = defaultdict(int)

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
    if P:
        dic[P] += 1

ans = 1
print(dic)1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)
Problem p03244 (python)

Fixed submission:
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

N, *A = map(int, open(0).read().split())

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)


if ev == od and ev_C.most_common()[0][1] == N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most)

    print(ans)

Buggy submission (verdict: Runtime Error):
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

N, *A = map(int, open(0).read().split())

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)

if ev == od and ev_C.most_common()[0][0]==N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most) 

    print(ans)

Buggy submission (verdict: Runtime Error):
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

N, *A = map(int, open(0).read().split())

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)

ev_most = ev_C.most_common()[0][1]
od_most = od_C.most_common()[0][1]
ev_second = ev_C.most_common()[1][1]
od_second = od_C.most_common()[1][1]


if ev == od:
    print(N//2)
else:
    print(min(
        N-ev_most-od_most,
        N-ev_most-od_second,
        N-ev_second-od_most
    ))
Problem p03361 (python)

Fixed submission:
def main():
    H, W = map(int, input().split())
    S = ['.'*(W+2)]+['.'+input()+'.' for _ in range(H)]+['.'*(W+2)]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')

Buggy submission (verdict: Runtime Error):
def main():
    H, W = map(int, input().split())
    S = ['.'*W]+['.'+input()+'.' for _ in range(H)]+['.'*W]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')
Problem p03600 (python)

Fixed submission:

def warshall_floyd(cost):
    ret = [[1]*N for _ in [0]*N]
    for k in range(N):
        for i, c_left in enumerate(cost[i][k] for i in range(N)):
            for j, (c_now, c_right) in enumerate(zip(cost[i], cost[k])):
                if c_left + c_right < c_now:
                    print(-1)
                    exit()
                if i == j or j == k or k == i:
                    continue
                if c_left + c_right == c_now:
                    ret[i][j] = ret[j][i] = 0
    return ret


INF = 10**10
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*N)


E = []
for i in range(N):
    for j in range(i+1, N):
        E.append((A[i][j], i, j))
E.sort()

road = warshall_floyd(A)
ans = 0
for cost, i, j in E:
    if not road[i][j]:
        continue
    ans += cost

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
import numpy as np
N = int(input())
A = np.loadtxt(open(0), dtype=np.int)
D = csgraph_from_dense(A)
D = floyd_warshall(D, directed=False)


if (A == D).all():
    ans = 0
    D += np.identity(N, int) * (1 << 60)
    for i in range(N):
        for j in range(i+1, N):
            a = np.min(D[i]+D[j])
            if a > D[i, j]:
                ans += D[i, j]
    print(int(ans))
else:
    print(-1)