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

Fixed submission:
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            if k in false:
                break
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * 3
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)
Problem p02882 (python)

Fixed submission:
from math import atan, degrees

a, b, x = map(float, input().split())

if a * a * b == x:
    print(0)
elif x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))

Buggy submission (verdict: Runtime Error):
from math import atan, degrees

a, b, x = map(float, input().split())

if x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))
Problem p02902 (python)

Fixed submission:
import sys

read = sys.stdin.read

N, M = map(int, input().split())
if M != 0:
    AB = list(map(int, read().split()))
else:
    print(-1)
    exit()

graph = [[] for _ in range(N + 1)]
A = AB[::2]
B = AB[1::2]
A_s = set(A)
# 出次数が0の頂点はいらない。
needless = set(range(1, N + 1)) - A_s

for i, j in zip(A, B):
    if j not in needless:
        graph[i].append(j)


# cycleを少なくとも一つ検出する
def dfs(original_stack):
    checked = [False] * (N + 1)
    while original_stack:
        start = original_stack.pop()
        if checked[start]:
            continue
        checked[start] = True
        stack = [(start, [start])]
        while stack:
            v, route = stack.pop()
            for i in graph[v]:
                if i in route:
                    return route[route.index(i):]
                else:
                    stack.append((i, route + [i]))
                    checked[i] = True


v = dfs([i for i in range(1, N + 1) if graph[i]])
if not v:
    print(-1)
    exit()

while True:
    v_s = set(v)
    length = len(v)
    for i, (v_i, v_j) in enumerate(zip(v, v[1:] + [v[0]])):
        for j in graph[v_i]:
            if j != v_j and j in v_s:
                idx = v.index(j)
                if i < idx:
                    v = v[:i + 1] + v[idx:]
                else:
                    v = v[idx:i + 1]
                break
        else:
            continue
        break
    else:
        print(len(v))
        print('\n'.join(map(str, v)))
        exit()

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

read = sys.stdin.read

N, M = map(int, input().split())
if M != 0:
    AB = list(map(int, read().split()))
else:
    print(-1)
    exit()

graph = [[] for _ in range(N + 1)]
A = AB[::2]
B = AB[1::2]
A_s = set(A)
# 出次数が0の頂点はいらない。
needless = set(range(1, N + 1)) - A_s

for i, j in zip(A, B):
    if j not in needless:
        graph[i].append(j)

for i in A_s:
    if not graph[i]:
        print(-1)
        exit()

stack = [i for i in range(1, N + 1) if len(graph[i]) == 1]
answer = []
while stack:
    v = stack.pop()
    queue = deque([(v, [v])])
    while queue:
        v_1, route = queue.popleft()
        for i in graph[v_1]:
            if i in route:
                route = route[route.index(i):]
                answer.append((len(route), route))
            else:
                queue.append((i, route + [i]))

K, a = min(answer)
print(K)
print('\n'.join(map(str, a)))
Problem p02937 (python)

Fixed submission:
s = input()
t = input()
t_long = len(t)
position = [0] * t_long
rep = 0

if set(t) <= set(s):
    position[0] = s.find(t[0])
    for i in range(1, t_long):
        if s.find(t[i], position[i - 1] + 1) > -1:
            position[i] = s.find(t[i], position[i - 1] + 1)
        else:
            position[i] = s.find(t[i])
    for k in range(t_long - 1):
        if position[k + 1] <= position[k]:
            rep += 1
    print(rep * len(s) + position[t_long - 1] + 1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ss = s * (len(t))
ans = 0

if set(t) <= set(s):
    for i in range(len(t)):
        ans = ss.find(t[i], ans)
    print(ans + 1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ss = s * (len(t))
ans = 0

if set(t) <= set(s):
    for i in range(len(t)):
        ans = ss.find(t[i], ans)
    print(ans + 1)
else:
    print(-1)
Problem p02939 (python)

Fixed submission:
S = list(input())
l = [S.pop()]

while S:
    if S[-1] != l[-1]:
        l.append(S.pop())
    else:
        if len(S) == 1:
            break
        else:
            a = S.pop()
            b = S.pop()
            l.append(b + a)

print(len(l))

Buggy submission (verdict: Runtime Error):
S = list(input())
l = [S.pop()]

while S:
    if S[-1] != l[-1]:
        l.append(S.pop())
    else:
        if len(S) == 1:
            break
        else:
            a = S.pop()
            b = S.pop()
            l.append(b + a)
    print(l)

print(len(l))
Problem p02952 (python)

Fixed submission:
N = int(input())
number = len(str(N))
count = 0

if number % 2 == 0:
    for i in range(1, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(count)
else:
    for i in range(2, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(N - count)

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

N = int(input())
A = np.array(list(map(float, input().split())))

print(np.reciprocal(np.sum(np.reciprocal(A))))
Problem p02957 (python)

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

if (A + B) % 2 == 0:
    print(int((A + B) / 2))
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import sympy as sp

A, B = map(int, input().split())
K = sp.Symbol('K')

ans = sp.solve((A - K) **2 - (B - K) ** 2, K)

if isinstance(ans[0], int) == True:
    print(ans[0])
else:
    print('IMPOSSIBLE')
Problem p02963 (python)

Fixed submission:
S = int(input())

if S != 10 ** 18:
    q = S // 10 ** 9 + 1
    r = 10 ** 9 * q - S
else:
    q = S // 10 ** 9
    r = 10 ** 9 * q - S

print(0, 0, q, r, 1, 10 ** 9)

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


def prime_factorize(n):
    a = 1
    while n % 2 == 0:
        n //= 2
        a *= 2

    if n <= 10 ** 9:
        return n
    f = 3
    while f * f <= n:
        if S // a <= 10 ** 9:
            return a
        if n % f == 0:
            n //= f
            a *= f
        else:
            f += 2


if S <= 10 ** 9:
    print(0, 0, 1, 0, 0, S)
else:
    x = prime_factorize(S)
    y = S // x
    print(0, 0, x, 0, 0, y)

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


def prime_factorize(n):
    a = 1
    if n <= 10 ** 9:
        return n

    while n % 2 == 0:
        n //= 2
        a *= 2

    if n <= 10 ** 9:
        return n
    f = 3
    while f * f <= n:
        if n // a <= 10 ** 9:
            return a
        if n % f == 0:
            n //= f
            a *= f
        else:
            f += 2


if S <= 10 ** 9:
    print(0, 0, 1, 0, 0, S)
else:
    x = prime_factorize(S)
    y = S // x
    print(0, 0, x, 0, 0, y)

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


def prime_factorize(n):
    if n <= 10 ** 9:
        return n
    while n % 2 == 0:
        n //= 2
        if n <= 10 ** 9:
            return n
    f = 3
    while f * f <= n:
        if n <= 10 ** 9:
            return n
        if n % f == 0:
            n //= f
        else:
            f += 2


if S <= 10 ** 9:
    print(0, 0, 1, 0, 0, S)
else:
    x = prime_factorize(S)
    y = S // x
    print(0, 0, x, 0, 0, y)

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


def prime_factorize(n):
    while n % 2 == 0:
        n //= 2
    if n <= 10 ** 9:
        return n
    f = 3
    while f * f <= n:
        if n <= 10 ** 9:
            return n
        if n % f == 0:
            n //= f
        else:
            f += 2


x = prime_factorize(S)
y = S // x
print(0, 0, x, 0, 0, y)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
m = max(A)
p = A.index(m)
A.remove(m)
n = max(A)

for i in range(N):
    if i == p:
        print(n)
    else:
        print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
m1, m2 = sorted(A, reverse=True)[:2]

for i in range(N):
    if i == p:
        print(m2)
    else:
        print(m1)
Problem p03006 (python)

Fixed submission:
import sys
from itertools import combinations
from collections import Counter
read = sys.stdin.read

N, *xy = map(int, read().split())

if N == 1:
    print(1)
    exit()

pq = []
for (a1, b1), (a2, b2) in combinations(zip(*[iter(xy)] * 2), 2):
    p = a1 - a2
    q = b1 - b2
    pq.append((p, q))
    pq.append((-p, -q))

print(N - Counter(pq).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import sys
from itertools import combinations
from collections import Counter
read = sys.stdin.read

N, *xy = map(int, read().split())
pq = []
for (a1, b1), (a2, b2) in combinations(zip(*[iter(xy)] * 2), 2):
    p = a1 - a2
    q = b1 - b2
    pq.append((p, q))
    pq.append((-p, -q))

print(N - Counter(pq).most_common()[0][1])
Problem p03014 (python)

Fixed submission:
import numpy as np
import sys
buf = sys.stdin.buffer

H, W = map(int, buf.readline().split())
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = np.where(np.array(list(map(list, buf.read().decode('utf-8').split()))).reshape(H, W) == '.', 1, 0)
grid_v = grid.T

right = np.maximum.accumulate(np.where(grid < 1, np.arange(W + 2), 0), axis=1)
left = np.fliplr(np.minimum.accumulate(np.fliplr(np.where(grid < 1, np.arange(W + 2), 10 ** 10)).copy(), axis=1))
down = np.maximum.accumulate(np.where(grid_v < 1, np.arange(H + 2), 0), axis=1).T
up = np.fliplr(np.minimum.accumulate(np.fliplr(np.where(grid_v < 1, np.arange(H + 2), 10 ** 10)).copy(), axis=1)).T

print(np.max((left - right) + (up - down)) - 3)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
buf = sys.stdin.buffer

H, W = map(int, buf.readline().split())
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = np.where(np.array(list(map(list, buf.read().decode('utf-8').split()))).reshape(H, W) == '.', 1, 0)
grid_v = grid.T

right = np.maximum.accumulate(np.where(grid < 1, np.arange(W + 2), 0), axis=1)
left = np.flip(np.minimum.accumulate(np.flip(np.where(grid < 1, np.arange(W + 2), 10 ** 10), axis=1), axis=1), axis=1)
down = np.maximum.accumulate(np.where(grid_v < 1, np.arange(H + 2), 0), axis=1).T
up = np.flip(np.minimum.accumulate(np.flip(np.where(grid_v < 1, np.arange(H + 2), 10 ** 10), axis=1), axis=1), axis=1).T

print(np.max((left - right) + (up - down)) - 3)
Problem p03029 (python)

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

print((A * 3 + P) // 2)

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

print(A * 3 // P)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
L = [0] * M
R = [0] * M

for i in range(M):
    L[i], R[i] = map(int, input().split())
LL = max(L)
RR = min(R)
ans = 0
for i in range(N):
    if LL <= i + 1 <= RR:
        ans += 1
    else:
        pass
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
ID = [0] * N
N = {i for i in range(1, N + 1)}
for i in range(M):
    L[i], R[i] = map(int, input().split())
    ID[i] = {j for j in range(L[i], R[i] + 1)}

for i in range(M):
    N = N & ID[i]

print(len(N))
Problem p03046 (python)

Fixed submission:
M, K = map(int, input().split())
m = 1 << M

if K >= m:
    print(-1)
    exit()

if M == 0:
    print(0, 0)
    exit()

if M == 1:
    if K == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
    exit()

k = str(K)
seq = list(map(str, range(m)))
seq.remove(k)
answer = seq + [k] + seq[::-1] + [k]

print(' '.join(answer))

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

if K >= 2 ** M:
    print(-1)
    exit()

if M == 0:
    print(0)
    exit()

if M == 1:
    if K == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
    exit()

k = str(K)
seq = list(map(str, range(2 ** M)))
seq.remove(K)
answer = seq + [k] + seq[::-1] + [k]

print(' '.join(answer))
Problem p03050 (python)

Fixed submission:
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = make_divisors(N)
answer = 0
for i in n[::-1]:
    if i == 1:
        continue
    q, r = divmod(N, i - 1)
    if q == r:
        answer += i - 1
    else:
        break

print(answer)

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = make_divisors(N)
answer = 0
for i in n[::-1]:
    q, r = divmod(N, i - 1)
    if q == r:
        answer += i - 1
    else:
        break

print(answer)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0

for i in range(N):
    d = V[i] - C[i]
    if d > 0:
        ans += d

print(ans)

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

ans = 0

for i in range(N):
    t = 0
    p = i + 1
    while K > p:
        t += 1
        p *= 2
    ans += (0.5 ** t) / N
print(ans)
Problem p03085 (python)

Fixed submission:
b = input()

if b == 'A':
    b = 'T'
elif b == 'C':
    b = 'G'
elif b == 'T':
    b = 'A'
elif b == 'G':
    b = 'C'

print(b)

Buggy submission (verdict: Runtime Error):
b = input()

if b == 'A':
    b = 'T'
elif b == 'C':
    b = 'G'
elif b == 'T':
    b = 'A'
elif b == G:
    b = 'C'

print(b)
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

table = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
a = [table[i] for i in A]

# ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
INF = float('inf')
dp = [-INF] * (N + 1)
dp[0] = 0
cost = set(a)

for i in range(1, N + 1):
    for j in cost:
        if i - j >= 0 and dp[i] < dp[i - j] + 1:
            dp[i] = dp[i - j] + 1

answer = []
for i in A:
    x = table[i]
    while N - x >= 0 and dp[N] == dp[N - x] + 1:
        answer.append(i)
        N -= x

print(''.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

table = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
a = [table[i] for i in A]

# ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
INF = float('inf')
dp = [-INF] * (N + 1)
dp[0] = 0
cost = set(a)

for i in range(1, N + 1):
    for j in cost:
        if i - j >= 0 and dp[i] < dp[i - j] + 1:
            dp[i] = dp[i - j] + 1

answer = []
for i in A:
    x = table[i]
    while dp[N] == dp[N - x] + 1:
        answer.append(i)
        N -= x

print(''.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

table = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
a = [table[i] for i in A]

# ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
INF = 10 ** 9
dp = [-INF] * (N + 1)
dp[0] = 0
cost = set(a)

for i in range(1, N + 1):
    for j in cost:
        if i - j >= 0 and dp[i] < dp[i - j] + 1:
            dp[i] = dp[i - j] + 1

answer = []
for i in A:
    x = table[i]
    while N:
        if dp[N] == dp[N - x] + 1:
            answer.append(i)
            N -= x
        else:
            break

print(''.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

table = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
a = [table[i] for i in A]

# ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
INF = float('inf')
dp = [-INF] * (N + 1)
dp[0] = 0
cost = set(a)

for i in range(1, N + 1):
    for j in cost:
        if i - j >= 0 and dp[i] < dp[i - j] + 1:
            dp[i] = dp[i - j] + 1

answer = []
for i in A:
    while N:
        if dp[N] == dp[N - table[i]] + 1:
            answer.append(i)
            N -= table[i]
        else:
            break

print(''.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

table = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
a = [table[i] for i in A]

# ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
INF = float('inf')
dp = [-INF] * (N + 1)
dp[0] = 0
cost = set(a)

for i in range(1, N + 1):
    for j in cost:
        if i - j >= 0 and dp[i] < dp[i - j] + 1:
            dp[i] = dp[i - j] + 1

answer = []
for i in A[::-1]:
    while N:
        if dp[N] == dp[N - table[i]] + 1:
            answer.append(i)
            N -= table[i]
        else:
            break

print(''.join(map(str, answer)))
Problem p03164 (python)

Fixed submission:
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, W = map(int, readline().split())
    wv = map(int, read().split())
    dp = np.full(10 ** 5 + 1, W + 1, np.int64)
    dp[0] = 0

    for w, v in zip(wv, wv):
        np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

    print(np.where(dp <= W)[0].max())


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, W = map(int, readline().split())
    wv = map(int, read().split())
    dp = np.zeros(W + 1, np.int64)

    for w, v in zip(wv, wv):
        np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])

    print(dp.max())


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

Fixed submission:
import sys

read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)


def solve():
    n, *a = map(int, read().split())
    a = tuple(a)
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = a[i]
    for i in range(n - 2, -1, -1):
        for j in range(i + 1, n):
            L = a[i] - dp[i + 1][j]
            R = a[j] - dp[i][j - 1]
            if L > R:
                dp[i][j] = L
            else:
                dp[i][j] = R
    return dp[0][n - 1]


print(solve())

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
sys.setrecursionlimit(10 ** 10)

N, *a = map(int, read().split())

memo = [[0] * N for _ in range(N)]
r = N % 2


def f(i, j):
    n = j - i + 1
    if i == j:
        if n % 2 == r:
            s = a[i]
            memo[i][j] = s
            return s
        else:
            s = -a[i]
            memo[i][j] = s
            return s
    if n % 2 == r:
        s = max(f(i, j - 1) + a[j], f(i + 1, j) + a[i])
    else:
        s = min(f(i, j - 1) - a[j], f(i + 1, j) - a[i])
    memo[i][j] = s
    return s


f(0, N - 1)
print(memo[0][N - 1])

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, *a = map(int, read().split())

memo = [[0] * N for _ in range(N)]
r = N % 2


def f(i, j):
    n = j - i + 1
    if i == j:
        if n % 2 == r:
            s = a[i]
            memo[i][j] = s
            return s
        else:
            s = -a[i]
            memo[i][j] = s
            return s
    if n % 2 == r:
        s = max(f(i, j - 1) + a[j], f(i + 1, j) + a[i])
    else:
        s = min(f(i, j - 1) - a[j], f(i + 1, j) - a[i])
    memo[i][j] = s
    return s


f(0, N - 1)
print(memo[0][N - 1])
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(float, input().split())
H = list(map(float, input().split()))
ans = [0] * N
for i in range(N):
  ans[i] = abs(T - H[i] * 0.006 - A)

print(ans.index(min(ans)) + 1)

Buggy submission (verdict: Runtime Error):
N = float(input())
T, A = map(float, input().split())
H = list(map(float, input().split()))
l = [i for i in H abs(T - i * 0.006)]

print(min(l))
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))

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

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(s) == 1 or len(b) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))