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

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

aaa = list(range(L, N + L))
n = sum(aaa)
if n == 0:
    print(0)
elif n < 0:
    print(n - max(aaa))
else:
    print(n - max(0,min(aaa)))

Buggy submission (verdict: Runtime Error):
N,L=map(int, input().split())
aaa = [*range(L, N + L)]
n = sum(aaa)
if n == 0:
    print(n)
elif n < 0:
    print(n - max(aaa))
else:
    print(n - min(aaa))
Problem p03037 (python)

Fixed submission:
N,M=map(int, input().split())
L=[]
R=[]
for _ in range(M):
	l,r=map(int, input().split())
	L.append(l)
	R.append(r)

l = max(L)
r = min(R)

res = 0
for i in range(1,N+1):
	if l<=i and i<=r:
		res+=1
print(res)

Buggy submission (verdict: Runtime Error):
L=[]
R=[]
for _ in range(M):
	l,r=map(int, input().split())
	L.append(l)
	R.append(r)

l = max(L)
r = min(R)

res = 0
for i in range(1,N+1):
	if l<=i and i<=r:
		res+=1
print(res)
Problem p03043 (python)

Fixed submission:
N,K=map(int, input().split())
#N,K=100000,5

l=[]
for i in range(1,N+1):
    n=0
    while i < K:
        i *= 2
        n+=1
    l.append(1/N * (1/2)**n)

print(round(sum(l), 12))

Buggy submission (verdict: Runtime Error):
N,K=map(int, input().split())
#N,K=100000, 100000

l=[]
for i in range(1,N+1):
    n=0
    while i =< K:
        i *= 2
        n+=1
    l.append(1/N * (1/2)**n)

print(str(sum(l))[:14])
Problem p03062 (python)

Fixed submission:

#_N = 5
#A = [10, -4, -8, -11, 3]
_N = int(input())
A = list(map(int, input().split(" ")))

n = len(list(filter(lambda a:a<=-1, A)))
a = list(map(abs, A))
res = sum(a)
if n % 2 == 1:
    res -= min(a) * 2
print(res)

Buggy submission (verdict: Runtime Error):

#_N = 5
#A = [10, -4, -8, -11, 3]
_N = int(input())
A = map(int, input().split(" "))

n = len([*filter(lambda a:a<=-1, A)])
a = [*map(abs, A)]
res = sum(a)
if n % 2 == 1:
    res -= min(a) * 2
print(res)
Problem p03087 (python)

Fixed submission:
#N,Q=8,3
#S="ACACTACG"
#L = [3,2,1]
#R = [7,3,8]

N, Q = map(int, input().split(" "))
S = input()
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split(" "))
    L.append(l)
    R.append(r)

sh = [0]
n = 0
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        n += 1
    sh.append(n)
for (l, r) in zip(L, R):
    print(sh[r - 1] - sh[l - 1])

Buggy submission (verdict: Runtime Error):
#N,Q=8,3
#S="ACACTACG"
#L = [3,2,1]
#R = [7,3,8]

N,Q=map(int, input().split(" "))
S=input()
L=[]
R=[]
for _ in range(Q):
    l,r=map(int,input.split(" "))
    L.append(l)
    R.append(r)


sh=[0]
n=0
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        n+=1
    sh.append(n)
for (l,r) in zip(L, R):
    print(sh[r-1]-sh[l-1])
Problem p03246 (python)

Fixed submission:
#! /usr/bin/python
from collections import Counter
N = int(input())
V = list(map(int, input().split()))
#N = 4
#V = list(map(int, "1 2 3 2 2 2 2 2 1 1 2 3 4 5 2 12 1 1".split()))


def func(l, aa):
    counter = Counter(l)
    if counter[aa] == 0:
        c, count = counter.most_common()[0]
    else:
        c, count = counter.most_common()[1]
    #print(l, c, len(l) - count)
    return (c, len(l) - count)


if len(set(V)) == 1:
    print(N // 2)
else:
    c, count = func(V[::2], -1)
    c2, count2 = func(V[1::2], c)
    a = count + count2
    c2, count2 = func(V[1::2], -1)
    c, count = func(V[::2], c2)
    print(min(a, count + count2))

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
from collections import Counter
N = int(input())
V = list(map(int, input().split()))


def func(l):
    if len(l) == 0:
        return 0
    nanka = Counter(l).most_common()[0][1]
    return len(l) - nanka


if len([*set(V)]) == 1:
    print(N // 2)
else:
    print(func(V[::2]) + func(V[1::2]))

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
from collections import Counter
N = int(input())
V = list(map(int, input().split()))


def func(l):
    nanka = Counter(l).most_common()[0][1]
    return len(l) - nanka


if len([*set(V)]) == 1:
    print(N // 2)
else:
    print(func(V[::2]) + func(V[1::2]))
Problem p03260 (python)

Fixed submission:
#! /usr/bin/python
from operator import mul
print("Yes" if mul(*map(int,input().split()))%2==1 else "No")

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
from operator import mul
print("Yes" if mul(map(int,input().split()))%2==1 else "No")
Problem p03261 (python)

Fixed submission:
#! /usr/bin/python
from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
from sys import stdin
n = int(input())
w = list(map(int, stdin.read().splitlines()))
print("Yes" if n == len(set(w)) else "No")

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
n = int(input())
w = list(map(int, stdin.read().splitlines()))
print("Yes" if n == len(set(w)) else "No")
Problem p03262 (python)

Fixed submission:
#! /usr/bin/python
#from math import gcd
from fractions import gcd
from functools import reduce
#N, X = 3, 3
#CITY = [1, 7, 11]
#
#N, X = 3, 81
#CITY = [33, 105, 57]

N,X= map(int,input().split())
CITY = list(map(int,input().split()))

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))

Buggy submission (verdict: Runtime Error):
#! /usr/bin/python
from math import gcd
from functools import reduce
#N, X = 3, 3
#CITY = [1, 7, 11]
#
#N, X = 3, 81
#CITY = [33, 105, 57]

N,X= map(int,input().split())
CITY = list(map(int,input().split()))

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))
Problem p02830 (python)

Fixed submission:
'''input
2
ip cc
'''
# A coding delight
from sys import stdin
from collections import defaultdict


# main starts
n = int(stdin.readline().strip())
s, t = stdin.readline().split()
ans = []
for i in range(n):
	ans.append(s[i])
	ans.append(t[i])
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
'''input
3
4
1 2 3 6
1
8
2
1 1
'''
# A coding delight
from sys import stdin
from collections import defaultdict


# main starts
n = int(stdin.readline().strip())
s = stdin.readline().strip()
t = stdin.readline().strip()
ans = []
for i in range(n):
	ans.append(s[i])
	ans.append(t[i])
print(''.join(ans))
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)
  
a = [int(i) for i in input().split()]
k = a[1]//a[2] - (a[0] - 1)//a[2]
r = a[1]//a[3] - (a[0] - 1)//a[3]
s = a[1]//(int(lcm(a[2],a[3]))) - (a[0] - 1)//int((lcm(a[2],a[3])))
print((a[1] - a[0] + 1 - (k + r - s)))

Buggy submission (verdict: Runtime Error):
import math 
def lcm(a, b):
    return (a*b)/math.gcd(a, b)
a = [int(i) for i in input().split()]
k = a[1]//a[2] - (a[0] - 1)//a[2]
r = a[1]//a[3] - (a[0] - 1)//a[3]
s = a[1]//(int(lcm(a[2],a[3]))) - (a[0] - 1)//int((lcm(a[2],a[3])))
print((a[1] - a[0] + 1 - (k + r - s)))
Problem p02786 (python)

Fixed submission:
a = int(input())

def f(n):
    sum = 0
    if (n == 1):
        return 1
    else:
        sum += f(int(n/2)) * 2 + 1
        return sum

print(f(a))

Buggy submission (verdict: Runtime Error):
a = int(input())
s = '1' + '0' * (a-1)
print(int(s, 2) -1)
Problem p03005 (python)

Fixed submission:
N, K = map(int, input().split())
if(K==1):
  print("0")
else:
  print(N-K)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
if(K==1):
  print(0)
  else:
    print(N-K)
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [0] + [-1] * h
INF = 10**18
for hp in range(1, h+1):
    ret = INF
    for i in range(n):
        if hp - a[i] >= 0:
            ret = min(ret, dp[hp-a[i]] + b[i])
        else:
            ret = min(ret, b[i])
    dp[hp] = ret
print(dp[h])

Buggy submission (verdict: Runtime Error):
def f(hp):
    if hp <= 0: return 0
    if dp[hp] >= 0: return dp[hp]
    ret = f(hp - a[0]) + b[0]
    for i in range(1, n):
        ret = min(ret, f(hp-a[i]) + b[i])
    dp[hp] = ret
    return ret

h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [0] + [-1] * h
print(f(h))
Problem p02991 (python)

Fixed submission:
N, M = map(int, input().split())
G = [[] for i in range(N+1)]
for i in range(M):
    u, v = map(int, input().split())
    G[u].append(v)
s, t = map(int, input().split())

d = [-1] * (N + 1)

S = set()
S.add(s)
d[s] = 0
x = 1
while len(S) > 0:
    Q1 = set()
    for u in S:
        for v in G[u]:
            Q1.add(v)
    Q2 = set()
    for u in Q1:
        for v in G[u]:
            Q2.add(v)
    Q3 = set()
    for u in Q2:
        for v in G[u]:
            if d[v] < 0:
                d[v] = x
                Q3.add(v)
    x += 1
    S = Q3

print(d[t])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = [[] for i in range(M+1)]
for i in range(M):
    u, v = map(int, input().split())
    G[u].append(v)
s, t = map(int, input().split())

d = [-1] * (N + 1)

S = set()
S.add(s)
d[s] = 0
x = 1
while len(S) > 0:
    Q1 = set()
    for u in S:
        for v in G[u]:
            Q1.add(v)
    Q2 = set()
    for u in Q1:
        for v in G[u]:
            Q2.add(v)
    Q3 = set()
    for u in Q2:
        for v in G[u]:
            if d[v] < 0:
                d[v] = x
                Q3.add(v)
    x += 1
    S = Q3

print(d[t])
Problem p03061 (python)

Fixed submission:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
fw = [0] * n
bw = [0] * n

g = 0
for i in range(n):
    g = gcd(a[i], g)
    fw[i] = g

g = 0
for i in range(n-1, -1, -1):
    g = gcd(a[i], g)
    bw[i] = g

gmax = max(bw[1], fw[n-2])
for i in range(1, n-1):
    g = gcd(fw[i-1], bw[i+1])
    if gmax < g:
        gmax = g

print(gmax)

Buggy submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = list(map(int, input().split()))
fw = [0] * n
bw = [0] * n

g = 0
for i in range(n):
    g = gcd(a[i], g)
    fw[i] = g

g = 0
for i in range(n-1, -1, -1):
    g = gcd(a[i], g)
    bw[i] = g

gmax = max(bw[1], fw[n-2])
for i in range(1, n-1):
    g = gcd(fw[i-1], bw[i+1])
    if gmax < g:
        gmax = g

print(gmax)
Problem p03128 (python)

Fixed submission:
m = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] + [-N] * N
for x in range(1, N + 1):
    mx = -N
    for j in range(M):
        num = x - m[A[j]]
        if num >= 0:
            if mx < dp[num] + 1:
                mx = dp[num] + 1
    if mx < 0:
        dp[x] = -N
    else:
        dp[x] = mx

A.sort(reverse=True)
nd = dp[N]
n = N
for i in range(N):
    for a in A:
        if n >= m[a] and dp[n - m[a]] == nd - 1:
            nd -= 1
            n -= m[a]
            print(a, end="")
            break
print()

Buggy submission (verdict: Runtime Error):
m = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] + [-N] * N
for x in range(1, N + 1):
    mx = -N
    for j in range(M):
        num = x - m[A[j]]
        if num >= 0:
            if mx < dp[num] + 1:
                mx = dp[num] + 1
    if mx < 0:
        dp[x] = -N
    else:
        dp[x] = mx

A.sort(reverse=True)
nd = dp[N]
n = N
for i in range(N):
    for a in A:
        if dp[n - m[a]] == nd - 1:
            nd -= 1
            n -= m[a]
            print(a, end="")
            break
print()
Problem p03281 (python)

Fixed submission:
n = int(input())
d = [1] * (n + 1)
for i in range(2, n+1):
    for j in range(i, n+1, i):
        d[j] += 1
ans = 0
for i in range(1, n+1, 2):
  if d[i] == 8:
    ans += 1
 
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [1] * (n + 1)
for i in range(2, n+1):
    for j in range(i, n+1, i)
        d[j] += 1
ans = 0
for i in range(1, n, 2):
  if d[i] == 8:
    ans += 1

print(ans)
Problem p03287 (python)

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

S = [0]
w = 0
for a in A:
    w += a
    S.append(w % M)

S.sort()
ans = 0
prev = S[0]
c = 1
for i in range(1, N+1):
    if S[i] != prev:
        prev = S[i]
        ans += c * (c - 1) // 2
        c = 1
    else:
        c += 1
ans += c * (c - 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
c = [0] * M
A = map(int, input().split())

S = [0]
w = 0
for a in A:
    w += a
    S.append(w % M)

S.sort()
ans = 0
prev = S[0]
c = 1
for i in range(1, N+1):
    if S[i] != prev:
        prev = S[i]
        ans += c * (c - 1) // 2
        c = 1
    else:
        c += 1
ans += c * (c - 1) // 2
print(ans)
Problem p03352 (python)

Fixed submission:
from math import log
x = int(input())
lx = log(x)
ans = 1
for b in range(2, int(x**(1/2))+1):
    h = b
    while h*b <= x:
        h *= b
    if h > ans: ans = h

print(ans)

Buggy submission (verdict: Runtime Error):
from math import log
x = int(input())
lx = log(x)
ans = 1
for b in range(2, int(b**(1/2))+1):
    h = int(lx/log(b))
    if b**h > ans: ans = b**h
 
print(ans)

Buggy submission (verdict: Runtime Error):
from math import log
x = int(input())
lx = log(x)
ans = 1
for b in range(2, int(b**(1/2))+1):
    h = int(lx/log(b))
    if b**h > ans: ans = b**h

print(ans)
Problem p02817 (python)

Fixed submission:
s, t = input().split()
print(t + s)

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

print(t + s)
Problem p02882 (python)

Fixed submission:
from math import degrees
from math import atan

a, b, x = map(int, input().split())
s1 = degrees(atan(2*b/a - 2*x/(a*a*a)))
s2 = 90 - degrees(atan(2 * x / (a * b * b)))

if(a*a*b/2 <= x):
    print(s1)
else:
    print(s2)

Buggy submission (verdict: Runtime Error):
import fractions

a, b, x = map(int, input().split())
s1 = fractions.degrees(fractions.atan(2*b/a - 2*x/(a*a*a)))
s2 = 90 - fractions.degrees(fractions.atan(2 * x / (a * b * b)))

if(a*a*b/2 <= x):
    print(s1)
else:
    print(s2)
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
if (x < a):
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x, a = map(int, input())
if (x < a):
    print(0)
else:
    print(10)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
result = []

left = [0] * (n+1)
right = [0] * (n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for j in range(n-1, -1, -1):
    right[j] = gcd(right[j+1], a[j])
for i in range(n):
    result.append(gcd(left[i], right[i+1]))

print(max(result))

Buggy submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = list(map(int, input().split()))
result = []

left = [0] * (n+1)
right = [0] * (n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for j in range(n-1, -1, -1):
    right[j] = gcd(right[j+1], a[j])
for i in range(n):
    result.append(gcd(left[i], right[i+1]))

print(max(result))

Buggy submission (verdict: Runtime Error):
mport fractions

n = int(input())
a = list(map(int, input().split()))
t = []
l = 0
r = 0

for i in range(n):
    for j in range(i-1):
        l = fractions.gcd(l, a[j])
        r = fractions.gcd(r, a[n-j-1])
    t.append(fractions.gcd(l, r))

print(max(t))

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

n = int(input())
a = list(map(int, input().split()))
t = []
a.sort()

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

for i in range(int(n/2) +1):
    aa = a[i]
    a[i] = a[i+1]
    t.append(gcd(*a))
    a[i] = aa
    
print(max(t))
Problem p03076 (python)

Fixed submission:
lst = []
total = 0
for i in range(5):
    n = int(input())
    lst.append([(n-1) % 10, n])
lst.sort()

for i in range(len(lst)):
    if i == 0:
        total += lst[i][1]
    else:
        total += ((lst[i][1] + 9) // 10) * 10
print(total)

Buggy submission (verdict: Runtime Error):
times = [int(input()) for i in range(5)]
rest = [times[i] % 10 for i in range(len(times))]
m = rest.index(min(rest))
total = 0
for n in len(times):
    if n == m:
        total += times[n]
    else:
        total += ((times[n]+9) // 10) * 10

print(total)
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
ac_list = [0] * (n+1)
for i in range(n):
    ac_list[i+1] = ac_list[i] + (1 if s[i:i+2] == 'AC' else 0)
# print(ac_list)
for i in range(q):
    print(ac_list[lr[i][1]-1] - ac_list[lr[i][0]-1])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    print(s[lr[i][0] - 1:lr[i][1]])
    print(s[lr[i][0] - 1:lr[i][1]].count('AC'))
Problem p03103 (python)

Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort(key=lambda x: x[0])

count = 0
money = 0
while True:
    count += ab[0][1]
    if count < m:
        money += ab[0][0] * ab[0][1]
        del ab[0]
    else:
        money += ab[0][0] * (m - count + ab[0][1])
        break

print(money)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort(key=lambda x: x[0])

count = 0
money = 0
while True:
    count += ab[0][1]
    if count <= m:
        money += ab[0][0] * ab[0][1]
        del ab[0]
    else:
        money += ab[0][0] * (m - count + ab[0][1])
        break

print(money)
Problem p03206 (python)

Fixed submission:
print('Christmas' + ' Eve' * (25 - int(input())))

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

for i in range(n):
    h.append(int(input()))
h.sort()

for i in range(n-k+1):
    ans.append(h[i+k-1] - h[i])

print(min(ans))
Problem p03240 (python)

Fixed submission:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()

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

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

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


for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
      
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]
print(xyh)

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        print(height)
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()
Problem p03244 (python)

Fixed submission:
import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = []
ki_row = []

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()

if len(gu_count) > 1 and len(ki_count) > 1:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:
        ans = n - gu_count[0][1] - ki_count[1][1]
    elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:
        ans = n - gu_count[1][1] - ki_count[0][1]
    else:
        ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])
else:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    else:
        ans = gu_count[0][1]

print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = [] * (int(n/2))
ki_row = [] * (int(n/2))

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()


if gu_count[0][0] != ki_count[0][0]:
    ans = n - gu_count[0][1] - ki_count[0][1]
else:
    ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])

print(ans)
Problem p03274 (python)

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus = []
minus.append(0)
plus = []
plus.append(0)

for n in x:
    if n < 0:
        minus.append(n)
    else:
        plus.append(n)
minus.sort(reverse=True)
totals = []

for i in range(len(minus)):
    if (k-i < len(plus)) and (k-i >= 0):
        if i == 0:
            totals.append(plus[k-i])
        else:
            totals.append(2 * abs(minus[i]) + plus[k-i])
            # print(i)
            # print(abs(minus[i]))
            # print(plus[k-i])
for i in range(len(plus)):
    if (k-i < len(minus)) and (k-i >= 0):
        if i == 0:
            totals.append(abs(minus[k-i]))
        else:
            totals.append(2 * plus[i] + abs(minus[k-i]))
# print(totals)
print(min(totals))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus = []
minus.append(0)
plus = []
plus.append(0)

for n in x:
    if n < 0:
        minus.append(n)
    else:
        plus.append(n)
minus.sort(reverse=True)
totals = []

for i in range(len(minus)):
    if k-i < len(plus):
        if i == 0:
            totals.append(plus[k-i])
        else:
            totals.append(2 * abs(minus[i]) + plus[k-i])
            # print(i)
            # print(abs(minus[i]))
            # print(plus[k-i])
for i in range(len(plus)):
    if k-i < len(minus):
        if i == 0:
            totals.append(abs(minus[k-i]))
        else:
            totals.append(2 * plus[i] + abs(minus[k-i]))
# print(totals)
print(min(totals))
Problem p02848 (python)

Fixed submission:
N=int(input())
S=list(input())
P=list()
jia= N%26
for i in range(len(S)):
  xin= ord(S[i])+jia
  if xin > ord("Z"):
   xin-=26
  zimu=chr(xin)
  P+=zimu
p=''.join(P)
print(p)

Buggy submission (verdict: Runtime Error):
S=list(input())
N=int(input())
P=list()
jia= N%26
for i in range(len(S)):
  xin= ord(S[i])+jia
  if xin > ord("Z"):
   xin-=26
  zimu=chr(xin)
  P+=zimu
p=''.join(P)
print(p)