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

Fixed submission:
N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
x = list(map(lambda y: abs(y - X),x))


# gcd
def gcd (a,b):
    if a < b:
        a,b = b,a
    return a if b == 0 else gcd(b,a%b)

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

print(ans)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
x = list(map(lambda y: abs(y - X),x))


# gcd
def gcd (a,b):
    if a < b:
        a,b = b,a
    return a if b == 0 else gcd(b,a%b)

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

print(ans)
Problem p03331 (python)

Fixed submission:
N = int(input())
ans = float('inf')
for i in range(1,N):
	num = i
	j = N - num
	d = 0
	while num != 0:
		d += (num % 10)
		num //= 10
	while j != 0:
		d += (j % 10)
		j //= 10

	ans = min(d,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)
Problem p03421 (python)

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

if N < (A + B - 1) or N > (A * B):
	print(-1)
	exit(0)

if B == 1 and A == N:
	seq = [str(n) for n in range(1,N+1)]
	print(' '.join(seq))
	exit(0)

seq = [str(num)for num in range(N-A+1,N+1)]
dif = (A * B - N)
div = A - (dif // (B-1))
mer = (dif % (B-1))

n = N - A
for i in range((B-1) - mer):
	for j in range(n-(div)+1,n+1):
		seq.append(str(j))
	n -= (div)

for i in range(mer):
	for j in range(n-div+2,n+1):
		seq.append(str(j))
	n -= (div - 1)

print(' '.join(seq))

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

if N < A + B - 1 and N > A * B:
	print(-1)
	exit(0)

if B == 1 and A == N:
	seq = [str(n) for n in range(1,N+1)]
	print(' '.join(seq))
	exit(0)

seq = [str(num)for num in range(N-A+1,N+1)]
dif = (A * B - N)
div = A - (dif // (B-1))
mer = (dif % (B-1))

n = N - A
for i in range((B-1) - mer):
	for j in range(n-(div)+1,n+1):
		seq.append(str(j))
	n -= (div)

for i in range(mer):
	for j in range(n-div+2,n+1):
		seq.append(str(j))
	n -= (div + 1)

print(' '.join(seq))
Problem p03434 (python)

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

a.sort(reverse=True)

al = 0
bo = 0

if N % 2 == 1:
	N -= 1
	al += a[-1]

for i in range(0,N,2):
	al += a[i]
	bo += a[i+1]

print(al-bo)

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

a.sort(reverse=True)

al = 0
bo = 0
for i in range(0,N,2):
	al += a[i]
	bo += a[i+1]

print(al-bo)
Problem p03437 (python)

Fixed submission:
X,Y = map(int,input().split(" "))
if Y == 1:
	print(-1)
	exit(0)

if X < Y:
	print(X)
	exit(0)

if X % Y == 0:
	print(-1)
else:
	print(X)

Buggy submission (verdict: Runtime Error):
if Y != 1:
	print(X * (Y-1))
else:
	print(-1)
Problem p03439 (python)

Fixed submission:
N = int(input())
ans = float('inf')
print(0)
s = input()
if s == "Male":
	pre = 1
elif s == "Female":
	pre = 0
else:
	ans = 0

if ans == 0:
	exit(0)

ran = [0,N-1]
for i in range(19):	
	n = (ran[1] - ran[0]) // 2
	print(ran[0] + n)
	s = input()
	if s == "Male":
		flg = 1
	elif s == "Female":
		flg = 0
	else:
		exit(0)

	if (pre + n) % 2 != flg:
		ran[1] = ran[0] + n - 1
	else:
		ran[0] = ran[0] + n + 1
		pre = (flg + 1) % 2

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

ans = float('inf')
print(0)
s = input()
if s == "Male":
	pre = 1
elif s == "Female":
	pre = 0
else:
	ans = 0

if ans == 0:
	exit(0)

ran = [0,N-1]
for i in range(19):	
	print(ran)
	n = (ran[1] - ran[0]) // 2
	print(ran[0] + n)
	s = input()
	if s == "Male":
		flg = 1
	elif s == "Female":
		flg = 0
	else:
		exit(0)

	if (flg + n%2) != pre:
		ran[1] = ran[0] + n - 1
	else:
		ran[0] = ran[0] + n + 1
		pre = flg
Problem p03504 (python)

Fixed submission:
L = 100005
n,c = map(int,input().split(" "))

# arr[col] には、区間の始まり ==> 1,区間中 ==> 0,区間終わり ==> -1
# 連続した区間は結合した形で表現される

arr = [[0]*L for _ in range(c)]

for i in range(n):
    s,t,col = map(int,input().split(" "))
    arr[col-1][s-1] += 1
    arr[col-1][t-1] -= 1

imos = [0]*L

#全チャンネルを同時に考えたいもす法
for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1    
        if arr[i][p] == -1: imos[p+1] -= 1


#累積和をとれば、区間内の最大のrec数は値のmax.
ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)

Buggy submission (verdict: Runtime Error):
L = 100005
n,c = map(int,input().split(" "))

# arr[col] には、区間の始まり ==> 1,区間中 ==> 0,区間終わり ==> -1
# 連続した区間は結合した形で表現される

arr = [[0]*L for j in range(c)]
for i in range(n):
    s,t,col = map(int,input().split(" "))
    arr[col][s] += 1
    arr[col][t] -= 1

imos = [0]*L

#全チャンネルを同時に考えたいもす法
for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1    
        if arr[i][p] == -1: imos[p+1] -= 1


#累積和をとれば、区間内の最大のrec数は値のmax.
ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)

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

# arr[col] には、区間の始まり ==> 1,区間中 ==> 0,区間終わり ==> -1
# 連続した区間は結合した形で表現される

arr = [[0]*L for j in range(c)]
for i in range(n):
    s,t,col = map(int,input().split(" "))
    arr[col][s] += 1
    arr[col][t] -= 1

imos = [0]*L

#全チャンネルを同時に考えたいもす法
for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1    
        if arr[i][p] == -1: imos[p+1] -= 1


#累積和をとれば、区間内の最大のrec数は値のmax.
ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)

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

# arr[col] には、区間の始まり ==> 1,区間中 ==> 0,区間終わり ==> -1
# 連続した区間は結合した形で表現される
arr = [[0]*L for j in range(c)]
for _ in range(n):
    s,t,col = map(lambda x:int(x)-1, input().split())
    arr[col][s] += 1
    arr[col][t] -= 1

imos = [0]*L

#全チャンネルを同時に考えたいもす法
for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1    
        if arr[i][p] == -1: imos[p+1] -= 1


#累積和をとれば、区間内の最大のrec数は値のmax.
ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)
Problem p03535 (python)

Fixed submission:
N = int(input())
D = list(map(int,input().split(" ")))

ans = D[:]
D.sort()
D_1 = []
D_2 = []

for i in range(N):
	if i % 2 == 0:
		D_1.append(24-D[i])
		D_2.append(D[i])
	else:
		D_2.append(24-D[i])
		D_1.append(D[i])


for i in range(N):
	for j in range(i+1,N):
		df1 = abs(D_1[j] - D_1[i])
		df2 = abs(D_2[j] - D_2[i])
		
		df1 = min([df1,24-df1])
		df2 = min([df2,24-df2])
			
		ans.append(df1)
		ans.append(df2)

print(min(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int,input().split(" ")))

ans = D[:]


D.sort()

for i in range(N):
	if i % 2 == 0:
		D_1.append(24-D[i])
		D_2.appned(D[i])
	else:
		D_2.append(24-D[i])
		D_1.appned(D[i])


for i in range(N):
	for j in range(i+1,N):
		df1 = abs(D_1[j] - D_1[i])
		df2 = abs(D_2[j] - D_2[i])
		
		df1 = min([df1,24-df1])
		df2 = min([df2,24-df2])
			
		ans.append(df1)
		ans.append(df2)

print(min(df1))
Problem p03550 (python)

Fixed submission:
# D問題

N,Z,W =  map(int,input().split(" "))

a = list(map(int,input().split(" ")))

if N == 1:
	ans = abs(a[-1]-W)
else:
	ans = max(abs(a[-1]-a[-2]),abs(a[-1]-W))


print(ans)

Buggy submission (verdict: Runtime Error):
N,Z,W = map(int,input().split(" "))
a = list(map(int,input().split(" "))
print(abs(a[-1]-W))
Problem p03565 (python)

Fixed submission:
S_raw = input()
T_raw = input()

S = list(S_raw)
T = list(T_raw)

i = 0
j = 0

j_list = []
S_list = []

lt = len(T)
ls = len(S)

while True:
	if (j >= ls) or (i >= lt):
		if i < lt  :
			if j_list == []:
				print("UNRESTORABLE")
				exit(0)
			else:
				break
		elif j < ls:
			j_list.append(j)
			i = 0
			j = j - lt + 1

		else:
			j_list.append(j)
			break

	if T[i] == S[j]:
		i += 1
		j += 1
	elif S[j] == '?':
		i += 1
		j += 1
	else:
		j -= (i - 1)
		i = 0

for k in j_list:
	M = S[:]
	for i,c in zip(range(k-lt,k),T):
		M[i] = c

	S_tmp = ''

	for i in range(ls):
		if M[i] == '?':
			S_tmp += 'a'
		else:
			S_tmp += M[i]

	S_list.append(S_tmp)

S_list.sort()
print(S_list[0])

Buggy submission (verdict: Runtime Error):
S_raw = input()
T_raw = input()

S = list(S_raw)
T = list(T_raw)

i = 0
j = 0

j_list = []
S_list = []

lt = len(T)
ls = len(S)

while True:
	if j == ls or i == lt:
		if not i == lt:
			print("UNRESTORABLE")
			exit(0)
		elif j != ls:
			j_list.append(j)
			i = 0
			j = j - lt + 2
		else:
			j_list.append(j)
			break

	if T[i] == S[j]:
		i += 1
		j += 1
	elif S[j] == '?':
		i += 1
		j += 1
	else:
		i = 0
		j += 1


for j in j_list:
	for i,c in zip(range(j-lt,j),T):
		S[i] = c

	S_tmp = ''

	for i in range(ls):
		if S[i] == '?':
			S_tmp += 'a'
		else:
			S_tmp += str(S[i])

	S_list.append(S_tmp)

S_list.sort()
print(S_list[0])
Problem p03567 (python)

Fixed submission:
#! usr/bin/env python3

# A :

S = input()

if "AC" in S:
	print("Yes")

else:
	print("No")

Buggy submission (verdict: Runtime Error):
#! usr/bin/env python3

# A :

S = input()

if "AC" in S:
	print("Yes")

else:
Problem p03568 (python)

Fixed submission:
#! usr/bin/env python3
#B:

N = int(input())

A = list(map(int,input().split(" ")))

count = 1

for i in A:
	if i % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)

Buggy submission (verdict: Runtime Error):
#! usr/bin/env python3
#B:

N = int(input())

A = list(map(int,input().split(" ")))

count = 1

for i in A:
	if A % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)
Problem p03591 (python)

Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()

S = S[0:4]

if "YAKI" in S:
	print("Yes")

else:
	print("No")

Buggy submission (verdict: Runtime Error):
! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()
if S in "YAKI":
	print("Yes")

else:
	print("No")

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-S = input()
if S in "YAKI":
	print("Yes")

else:
	print("No")
Problem p03695 (python)

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

free = 0
arr = [0] * 8

for i in a:
	limit = 400
	while (limit <= 3200):
		if i < limit:
			arr[(limit // 400)-1] +=  1
			break
		else:
			limit += 400

	if limit== 3600:
		free += 1

color =  0
for i in arr:
	if i > 0:
		color += 1


print(str(max(1,color)) + " " + str(color + free))

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

free = 0
arr = [0] * 8

for i in a:
	limit = 400
	while (limit <= 3200):
		if i < limit:
			arr[(limit // 400)-1] +=  1
			break
		else:
			limit += 400

	if limit== 3600:
		free += 1

color =  0
for i in arr:
	if i > 0:
		color += 1


print(str(max(1,str(color))) + " " + str(min(color + free,8)))

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

free = 0
arr = [0] * 8

for i in a:
	limit = 400
	while (limit <= 3200):
		if i < limit:
			arr[(limit // 400)-1] +=  1
			break
		else:
			limit += 400

	if limit== 3600:
		free += 1

color =  0
for i in arr:
	if i > 0:
		color += 1


print(max(1,str(color)) + " " + str(min(color + free,8)))
Problem p03731 (python)

Fixed submission:
N,T = map(int,input().split(" "))
t = list(map(int,input().split(" ")))
scope = [[t[0],t[0]+T]]

for i in range(1,N):
	if t[i] < scope[-1][1]:
		scope[-1][1] = t[i] + T

	else:
		scope.append([t[i],t[i]+T])

total = 0
for begin,end in scope:
	total += (end - begin)

print(total)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split(" "))
t = list(map(int,input().split(" ")))
scope = [[t[0],t[0]+T]]

for i in range(1,N):
	if t[i] < scope[-1][1]:
		scope[-1][1] = t[i] + T

	else:
		scope.appned([t[i],t[i]+T])

total = 0
for begin,end in scope:
	total += (end - begin)

print(total)
Problem p03779 (python)

Fixed submission:
X = int(input())

sumval = 0
for i in range(1,X+1):
	sumval += i
	if sumval >= X:
		ans = i
		break

print(ans)

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

sumval = 0
for i in range(1,X):
	sumval += i
	if sumval >= X:
		ans = i
		break

print(ans)
Problem p03844 (python)

Fixed submission:
A,op,B = map(str,input().split(" "))
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))

Buggy submission (verdict: Runtime Error):
s,op,s2 = map(str,input().split(" "))

if op == '+':
  print(s+s2)

else:
  print(s-s2)

Buggy submission (verdict: Runtime Error):
s,op,s2 = map(int,input().split(" "))

if op == '+':
  print(s+s2)

else:
  print(s-s2)
Problem p04039 (python)

Fixed submission:
import bisect
n,K = map(str,input().split(" "))
D = list(map(int,input().split(" ")))
N = list(n)

D_bar = []
for i in range(10):
	if not i in D:
		D_bar.append(i)

mv = str(D_bar[0])
ld = 10 - int(K)
l = len(N)
index = -1
for i in range(l):
	if int(N[i]) in D:
		index = i
		break

if index == (-1):
	print(n)
	exit(0)

for i in range(index,-1,-1):
	p = bisect.bisect_left(D_bar,int(N[i]))
	if p == ld:
		N[i] = mv
		if i == 0:
			m = str(D_bar[0]) if D_bar[0] != 0 else str(D_bar[1])
			N[0] = mv
			N.insert(0,m)
		else:
			N[i-1] = str(int(N[i-1]) + 1)
	else:
		N[i] = str(D_bar[p])
		break

for i in range(index+1,len(N)):
	N[i] = mv
print(''.join(N))

Buggy submission (verdict: Runtime Error):
import bisect
N,K = map(str,input().split(" "))
D = list(map(int,input().split(" ")))
D_bar = []
for i in range(1,10):
	if not i in D:
		D_bar.append(i)
D_bar.sort()

l = len(N)
ans = N
if int(N[0]) in D:
	if N[0] == '9':
		ans = '10' + '0'*(l-1)
	else:
		p = bisect. bisect_left(D_bar,int(N[0]))
		ans = str(D_bar[p]) + '0'*(l-1)

else:
	for i in range(1,l):
		num = int(N[i])
		if num in D:
			index = i
			if N[i] == '9':
				ans = N[:i-1] + '10' + ('0'*max(0,l-i-1))
			else:
				p = bisect. bisect_left(D_bar,num)
				ans = N[:i] + str(D_bar[p]) + ('0'*max(0,l-i-1))

			break

print(ans)
Problem p02748 (python)

Fixed submission:
AC, BC, MC = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
M = [tuple(map(int, input().split())) for _ in range(MC)]

ans = min(A) + min(B)
for x, y, c in M:
    ans = min(ans, A[x - 1] + B[y - 1] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
AC, BC, MC = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
M = [tuple(map(int, input().split())) for _ in range(MC)]

ans = min(A) + min(B)
for x, y, c in M:
    ans = min(ans, A[x - 1] + B[x - 1] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
AC, BC, MC = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

M = [[0 for _ in range(AC)] for __ in range(BC)]
for i in range(MC):
    x, y, c = map(int, input().split())
    M[x-1][y-1] = max(M[x-1][y-1], c)

ans = 10**8
for a in range(AC):
    for b in range(BC):
        ans = min(ans, A[a-1] + B[b-1] - M[a-1][b-1])
print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque

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

reversing = False

for i in range(Q):
    query = list(input().split())
    if query[0] == '1':
        reversing = not reversing
    else:
        if query[1] == '1':
            if not reversing:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if reversing:
                S.appendleft(query[2])
            else:
                S.append(query[2])

print(''.join(S)) if not reversing else print(''.join(reversed(S)))

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

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

reversing = False

for i in range(Q):
    query = list(input().split())
    if query[0] == '1':
        reversing = not reversing
    else:
        if query[1] == '1':
            if not reversing:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if reversing:
                S.appendleft(query[2])
            else:
                S.append(query[2])

print(''.join(S)) if not reversing else print(''.join(S[::-1]))
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
gates = [tuple(map(int, input().split())) for _ in range(M)]

lmax = max(gates, key=lambda x: x[0])[0]
rmin = min(gates, key=lambda x: x[1])[1]

print(max(rmin-lmax+1, 0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
gates = [tuple(map(int, input().split())) for _ in range(M)]

lmax = max(gates, key=lambda x: x[0])[0]
rmin = min(gates, key=lambda x: x[1])[1]

print(max(rmin-lmax+1), 0)
Problem p03047 (python)

Fixed submission:
N, K = map(int, input().split())
print(N-K+1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().aplit())
print(N - K + 1)
Problem p03050 (python)

Fixed submission:
N = int(input())

ans = 0
for i in range(1, int(N**0.5)+1):
  if (N-i)%i == 0:
    tmp = (N-i)/i
    if tmp != 0 and N%tmp == i:
      ans += int(tmp)
print(ans)

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

ans = 0
for i in range(1, int(N**0.5)+1):
  if (N-i)%i == 0:
    tmp = (N-i)/i
    if N%tmp == i:
      ans += int(tmp)
print(ans)
Problem p03109 (python)

Fixed submission:
import datetime
 
d0 = datetime.date(2019, 4, 30)
d = datetime.date(*map(int, input().split('/')))
 
if d <= d0:
  print('Heisei')
else:
  print('TBD')

Buggy submission (verdict: Runtime Error):
import datetime

d0 = datetime.date(2019, 4, 30)
d = datetime.date(map(int, *input().split('/')))

if d <= d0:
  print('Heisei')
else:
  print('TBD')
Problem p03238 (python)

Fixed submission:
if int(input()) == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)

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

print('Hello World') if N == 1 else print(A+B)
Problem p03244 (python)

Fixed submission:
import collections


n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]

ce = collections.Counter(leven)
co = collections.Counter(lodd)
ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != co[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])

Buggy submission (verdict: Runtime Error):
import collections


n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]

ce = collections.Counter(leven)
co = collections.Counter(lodd)
ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != ce[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])

Buggy submission (verdict: Runtime Error):
import collections


n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != ce[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - ce[-1][1])
else:
    print(n - ce[-1][1] - ce[-2][1])
Problem p02761 (python)

Fixed submission:
def solve(n, m):
    ans = [-1] * n
    for _ in range(m):
        s, c = input().split()
        s = int(s) - 1
        if ans[s] == c:
            continue
        elif ans[s] == -1:
            ans[s] = c
        else:
            return -1

    if ans[0] == '0':
        if n == 1:
            return '0'
        else:
            return -1
    elif ans[0] == -1:
        if n == 1:
            return '0'
        else:
            ans[0] = '1'
    for i in range(1, n):
        if ans[i] == -1:
            ans[i] = '0'
    return ''.join(ans)


n, m = list(map(int, input().split()))
print(solve(n, m))

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

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N,M = nm()
digits = [-1] * N
# print(N,M)
for i in range(M):
    s,c = nm()
    # print(s,c)
    ii = s -1 
    # print("A",ii,c)
    if digits[ii] == -1:
        digits[ii] = c
    elif digits[ii] != c:
        print(-1)
        exit(0)

# print(digits)
if N == 1:
    if digits[0] == -1:
        print(0)
    else:
        print(digits[0])
    exit(0)

if digits[0] == -1:
    digits[0] = 1
elif digits[0] == 0:
    print(-1)
    exit(0)

for i in range(1,M):
    if digits[i] == -1:
        digits[i] = 0

xx = "".join(list(map(str,digits)))
print(xx)

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

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N,M = nm()
digits = [-1] * N
# print(N,M)
for i in range(M):
    s,c = nm()
    # print(s,c)
    ii = s -1 
    # print("A",ii,c)
    if digits[ii] == -1:
        digits[ii] = c
    elif digits[ii] != c:
        print(-1)
        exit(0)

# print(digits)
if N == 1:
    if digits[0] == -1:
        print(0)
    else:
        print(digits[0])
    exit(0)

if digits[0] == -1:
    digits[0] = 1
elif digits[0] == 0:
    print(-1)
    exit(-1)

for i in range(1,M):
    if digits[i] == -1:
        digits[i] = 0

xx = "".join(list(map(str,digits)))
print(xx)
Problem p02795 (python)

Fixed submission:
import math
import sys

H = int(input())
W = int(input())
N = int(input())
s = max(H,W)
print((N-1) // s + 1 )

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

m=10**9 + 7 
H = int(input())
W = int(input())
N = int(input())
s = max(H,W)
print((N-1) // s + 1 )[myoden@ubuntu002 A]$ cat testA.py ; echo ;echo 
import math
import sys

m=10**9 + 7 
H = int(input())
W = int(input())
N = int(input())
s = max(H,W)
print((N-1) // s + 1 )
Problem p02814 (python)

Fixed submission:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def log2N (x):
    c = 0
    while True:
        if x % 2 != 0:
            return c
        x = x // 2
        c = c + 1


def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
            return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

p = log2N(B[0])
# print(p)
for i in range(1,len(B)):
    # print(log2N(B[i]))
    if p != log2N(B[i]):
        print(0)
        exit(0)
        
x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)

Buggy submission (verdict: Runtime Error):
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
        return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)