Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)


Fixed submission:
import collections

N = int(input())

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

x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)

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

N = int(input())
x, y = [], []
for _ in range(N):
    _x, _y = map(int, input().split())
    x.append(_x)
    y.append(_y)

pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x[j] - x[i], y[j] - y[i]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - x)


Fixed submission:
import collections

N = int(input())

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

x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
dp = [0] * N
for i in range(N-2, -1, -1):
    dp[i] = dp[i+1]
    if S[i:i+2] == 'AC':
        dp[i] += 1
for _ in range(Q):
    l, r = map(int, input().split())    print(dp[l-1] - dp[r-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
dp = [0] * N
for i in range(N-2, -1, -1):
    dp[i] = dp[i+1]
    if S[i:i+2] == 'AC':
        dp[i] += 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(dp[l-1] - dp[r-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        cand.append(max(int(str(dp[i - mp[x]]) + str(x)), int(str(x) + str(dp[i - mp[x]]))))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])

Fixed submission:
import math
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        if dp[i-mp[x]] == '':
            cand.append(x)
        else:
            before = dp[i - mp[x]]
            pre = (int(math.log10(before)) + 1) * 10 * x + before
            suf = before * 10 + x
            cand.append(max(pre, suf))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        cand.append(max(int(str(dp[i - mp[x]]) + str(x)), int(str(x) + str(dp[i - mp[x]]))))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])

Fixed submission:
import math
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        if dp[i-mp[x]] == '':
            cand.append(x)
        else:
            before = dp[i - mp[x]]
            pre = (int(math.log10(before)) + 1) * 10 * x + before
            suf = before * 10 + x
            cand.append(max(pre, suf))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X.sort()

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

li = [[0, 0]] * M
for i in range(1, M):
    li[i] = [i, X[i] - X[i-1]]
li.sort(key=lambda x: x[1], reverse=True)
cnt = 0
tmp = []
while cnt < N-1:
    tmp.append(li[cnt][0])
    cnt += 1
prev = 0
ans = 0
for t in tmp:
    ans += abs(X[t-1] - X[prev])
    prev = t
ans += abs(X[-1] - X[tmp[-1]])
print(ans)

Fixed submission:
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X.sort()

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

r = [X[i] - X[i-1] for i in range(1, M)]
r.sort(reverse=True)

print((X[-1] - X[0]) - sum(r[:N-1]))
Buggy python submission (verdict: Time Limit Exceeded):
s = [i for i in input()]
f = True
i = 0
cnt = 0
while True:
    if s[i] == 'B' and s[i+1] == 'W':
        cnt += 1
        s[i] = 'W'
        s[i+1] = 'B'
        i += 1
        f = False
    else:
        i += 1
    if i >= len(s) - 1:
        if f:
            break
        i = 0
        f = True
print(cnt)

Fixed submission:
s = [i for i in input()]
B_pos_ls = []
for i, x in enumerate(s):
    if x == 'B':
        B_pos_ls.append(i)
res = 0
B_pos_ls.sort(reverse=True)
last_B_pos = len(s) - 1
for B_pos in B_pos_ls:
    res += last_B_pos - B_pos
    last_B_pos -= 1
print(res)

Buggy python submission (verdict: Runtime Error):
 = [i for i in input()]
f = True
i = 0
cnt = 0
while True:
    if s[i] == 'B' and s[i+1] == 'W':
        cnt += 1
        s[i] = 'W'
        s[i+1] = 'B'
        i += 1
        f = False
    else:
        i += 1
    if i >= len(s) - 1:
        if f:
            break
        i = 0
        f = True
print(cnt)

Fixed submission:
s = [i for i in input()]
B_pos_ls = []
for i, x in enumerate(s):
    if x == 'B':
        B_pos_ls.append(i)
res = 0
B_pos_ls.sort(reverse=True)
last_B_pos = len(s) - 1
for B_pos in B_pos_ls:
    res += last_B_pos - B_pos
    last_B_pos -= 1
print(res)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

dic = {}
dic_rev = {}


def solve():
    for s, t in zip(S, T):
        if t in dic.keys():
            if s != dic[t]:
                print('No')
                return
        else:
            dic[t] = s
    for s, t in zip(S, T):
        if t in dic_rev.keys():
            if t != dic_rev[s]:
                print('No')
                return
        else:
            dic_rev[s] = t
    print('Yes')
    return


solve()


Fixed submission:
S = input()
T = input()

dic = {}
dic_rev = {}


def solve():
    for s, t in zip(S, T):
        if t in dic.keys():
            if s != dic[t]:
                print('No')
                return
        else:
            dic[t] = s
    for s, t in zip(S, T):
        if s in dic_rev.keys():
            if t != dic_rev[s]:
                print('No')
                return
        else:
            dic_rev[s] = t
    print('Yes')
    return


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

def gcd(a, b):
    if a == b:
        return a
    if a > b:
        return gcd(a-b, b)
    else:
        return gcd(a, b-a)

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

delta = [abs(X-i) for i in x]
print(reduce(gcd, delta))

Fixed submission:
from functools import reduce

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)

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

delta = [abs(X-i) for i in x]
print(reduce(gcd, delta))
Buggy python submission (verdict: Runtime Error):
a_b = []
for _ in range(M):
    a, b = map(int, input().split())
    a_b.append((a, b))
a_b.sort(key=lambda x: x[0])

r = a_b[0][1]
ans = 1
for a, b in a_b[1:]:
    if a >= r:
        r = b
        ans += 1
        continue
    if b < r:
        r = b
print(ans)

Fixed submission:
N, M = map(int, input().split())
a_b = []
for _ in range(M):
    a, b = map(int, input().split())
    a_b.append((a, b))
a_b.sort(key=lambda x: x[0])

r = a_b[0][1]
ans = 1
for a, b in a_b[1:]:
    if a >= r:
        r = b
        ans += 1
        continue
    if b < r:
        r = b
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

tmp = {a: 0 for a in 'abcdefghijklmnopqrstuvwxyz'}

for x in S:
    tmp[x] += 1

tmp2 = []
if all(x == 1 for x in tmp.values()):
    for i in range(len(S)-1, 0, -1):
        if S[i-1] < S[i]:
            print(S[:i-1] + min(tmp2))
            exit()
        tmp2.append(S[i])
else:
    for k, v in tmp.items():
        if v == 0:
            tmp2.append(k)
    print(S+min(tmp2))

Fixed submission:
S = input()

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

tmp = {a: 0 for a in 'abcdefghijklmnopqrstuvwxyz'}

for x in S:
    tmp[x] += 1

tmp2 = []
if all(x == 1 for x in tmp.values()):
    for i in range(len(S)-1, 0, -1):
        tmp2.append(S[i])
        if S[i-1] < S[i]:
            tmp2 = [x for x in tmp2 if x > S[i-1]]
            print(S[:i-1]+min(tmp2))
            exit()
else:
    for k, v in tmp.items():
        if v == 0:
            tmp2.append(k)
    print(S+min(tmp2))

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

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

tmp = {a: 0 for a in 'abcdefghijklmnopqrstuvwxyz'}

for x in S:
    tmp[x] += 1

tmp2 = []
if all(x == 1 for x in tmp.values()):
    for i in range(len(S)-1, 0, -1):
        if S[i-1] < S[i]:
            print(S[:i-1] + min(tmp2))
            exit()
        tmp2.append(S[i])
else:
    for k, v in tmp.items():
        if v == 0:
            print(S+k)
            break

Fixed submission:
S = input()

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

tmp = {a: 0 for a in 'abcdefghijklmnopqrstuvwxyz'}

for x in S:
    tmp[x] += 1

tmp2 = []
if all(x == 1 for x in tmp.values()):
    for i in range(len(S)-1, 0, -1):
        tmp2.append(S[i])
        if S[i-1] < S[i]:
            tmp2 = [x for x in tmp2 if x > S[i-1]]
            print(S[:i-1]+min(tmp2))
            exit()
else:
    for k, v in tmp.items():
        if v == 0:
            tmp2.append(k)
    print(S+min(tmp2))
Buggy python submission (verdict: Runtime Error):
 N = int(input())
a = [int(x) for x in input().split()]

summary = {}
for x in a:
    if x not in summary.keys():
        summary[x] = 1
    else:
        summary[x] += 1

res = 0
for k, v in summary.items():
    if k > v:
        res += v
    else:
        res += min(v - k, v)

print(res)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]

summary = {}
for x in a:
    if x not in summary.keys():
        summary[x] = 1
    else:
        summary[x] += 1

res = 0
for k, v in summary.items():
    if k > v:
        res += v
    else:
        res += min(v - k, v)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

summary = {}
for a in A:
    if a not in summary.keys():
        summary[a] = 1
    else:
        summary[a] += 1
s_list = list(summary.values())
s_list.sort()
res = 0
while len(s_list) > K:
    res += s_list.pop(0)
print(res)

Fixed submission:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

summary = {}
for a in A:
    if a not in summary.keys():
        summary[a] = 1
    else:
        summary[a] += 1
s_list = list(summary.values())
s_list.sort()
res = 0
i = 0
while len(s_list)-i > K:
    res += s_list[i]
    i += 1
print(res)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

summary = {}
for a in A:
    if a not in summary.keys():
        summary[a] = 1
    else:
        summary[a] += 1
s_list = list(summary.values())
s_list.sort()
res = 0
i = 0
while len(s_list) > K:
    res += s_list.pop(i)
    i += 1
print(res)

Fixed submission:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

summary = {}
for a in A:
    if a not in summary.keys():
        summary[a] = 1
    else:
        summary[a] += 1
s_list = list(summary.values())
s_list.sort()
res = 0
i = 0
while len(s_list)-i > K:
    res += s_list[i]
    i += 1
print(res)
Buggy python submission (verdict: Runtime Error):
import sys
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print(f'{A}{sgn[0]}{B}{sgn[1]}{C}{sgn[2]}{D}=7')
        sys.exit()

Fixed submission:
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print('{0}{1}{2}{3}{4}{5}{6}=7'.format(A, sgn[0], B, sgn[1], C, sgn[2], D))
        exit()

Buggy python submission (verdict: Runtime Error):
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print(f'{A}{sgn[0]}{B}{sgn[1]}{C}{sgn[2]}{D}=7')
        exit()

Fixed submission:
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print('{0}{1}{2}{3}{4}{5}{6}=7'.format(A, sgn[0], B, sgn[1], C, sgn[2], D))
        exit()
Buggy python submission (verdict: Runtime Error):
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
l = 0
r = -1 if core == [] else len(core) - 1
while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1
while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)


Fixed submission:
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
if core == []:
    print(0)
    exit()
l = 0
r = len(core) - 1

while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1

while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
l = 0
r = 0 if core == [] else len(core) - 1
while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1
while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)


Fixed submission:
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
if core == []:
    print(0)
    exit()
l = 0
r = len(core) - 1

while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1

while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
l = 0
r = len(core) - 1
while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1
while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)


Fixed submission:
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
if core == []:
    print(0)
    exit()
l = 0
r = len(core) - 1

while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1

while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

ans = 0
for i in range(N):
    for j in range(N):
        via_k = float('inf')
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            via_k = min(via_k, A[i][k] + A[k][j])
        if i <= j:
            continue
        if A[i][j] < via_k:
            ans += A[i][j]
print(ans)


Fixed submission:
import heapq

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

ans = 0
for i in range(N):
    for j in range(N):
        via_k = float('inf')
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            via_k = min(via_k, A[i][k] + A[k][j])
        if i <= j:
            continue
        if A[i][j] < via_k:
            ans += A[i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
used = [[False] * N for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        via = i
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            if A[i][j] == A[i][k] + A[k][j]:
                via = k
        if i >= j:
            continue
        if not (used[i][via] and used[via][i]):
            used[i][via] = True
            used[via][i] = True
            ans += A[i][via]
        if not (used[via][j] and used[j][via]):
            used[via][j] = True
            used[j][via] = True
            ans += A[via][j]
print(ans)


Fixed submission:
import heapq

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

ans = 0
for i in range(N):
    for j in range(N):
        via_k = float('inf')
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            via_k = min(via_k, A[i][k] + A[k][j])
        if i <= j:
            continue
        if A[i][j] < via_k:
            ans += A[i][j]
print(ans)
Buggy python submission (verdict: Runtime Error):
def dfs(i):
    if all(visited):
        global ans
        ans += 1
        return
    for j in range(N):
        if g[i][j] and not visited[j]:
            visited[j] = True
            dfs(j)
            visited[j] = False

N, M = map(int, input().split())
g = [[False] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1][b-1] = True
    g[b-1][a-1] = True

ans = 0
visited = [False] * N
visited[0] = True
dfs(0)
print(ans)

Fixed submission:
def dfs(i):
    if all(visited):
        global ans
        ans += 1
        return
    for j in range(N):
        if g[i][j] and not visited[j]:
            visited[j] = True
            dfs(j)
            visited[j] = False

N, M = map(int, input().split())
g = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1][b-1] = True
    g[b-1][a-1] = True

ans = 0
visited = [False] * N
visited[0] = True
dfs(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
def dfs(i):
    if all(visited):
        global ans
        ans += 1
        return
    for j in range(N):
        if g[i][j] and not visited[j]:
            visited[j] = True
            dfs(j)
            visited[j] = False
    return

N, M = map(int, input().split())
g = [[False] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1][b-1] = True
    g[b-1][a-1] = True

ans = 0
visited = [False] * N
visited[0] = True
dfs(0)

Fixed submission:
def dfs(i):
    if all(visited):
        global ans
        ans += 1
        return
    for j in range(N):
        if g[i][j] and not visited[j]:
            visited[j] = True
            dfs(j)
            visited[j] = False

N, M = map(int, input().split())
g = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1][b-1] = True
    g[b-1][a-1] = True

ans = 0
visited = [False] * N
visited[0] = True
dfs(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
fq = [0] * (N + 10)
A = list(map(int, input().split()))
for a in A:
    fq[a] += 1
fq = [f if f % 1 == 0 else 1 for f in fq]
cnt_even = 0
cnt_odd = 0
for f in fq:
    if f & 1 == 0 and f != 0:
        cnt_even += 1
    if f & 1 == 1:
        cnt_odd += 1
if cnt_even & 1 == 0:
    print(cnt_even + cnt_odd)
else:
    print(cnt_even - 1 + cnt_odd)

Fixed submission:
N = int(input())
fq = [0] * int(10**5 + 10)
A = list(map(int, input().split()))
for a in A:
    fq[a] += 1
fq = [f if f % 1 == 0 else 1 for f in fq]
cnt_even = 0
cnt_odd = 0
for f in fq:
    if f & 1 == 0 and f != 0:
        cnt_even += 1
    if f & 1 == 1:
        cnt_odd += 1
if cnt_even & 1 == 0:
    print(cnt_even + cnt_odd)
else:
    print(cnt_even - 1 + cnt_odd)
Buggy python submission (verdict: Runtime Error):
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)
curT = T[0]
curA = A[0]
for i in range(1, N):
    if curT > curA:
        if curT % T[i] != 0:
            curT += T[i] - curT % T[i]
        curA = curT // T[i] * A[i]
    else:
        if curA % A[i] != 0:
            curA += A[i] - curA % A[i]
        curT = curA // A[i] * T[i]
print(curT+curA)

Fixed submission:
def ceil(a, b):
    return (a + b - 1) // b

N = int(input())
T = []
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)
curT = T[0]
curA = A[0]
for i in range(1, N):
    m1 = ceil(curT, T[i])
    m2 = ceil(curA, A[i])
    m = max(m1, m2)
    curT = m * T[i]
    curA = m * A[i]
print(curT+curA)
Buggy python submission (verdict: Runtime Error):
N=int(input())
mydict={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(N):
  mydict[input()]+=1
printlist=["AC","WA","TLE","RE"]
for p in printlist:
  print("{} x {}".format(p,mydict[p])

Fixed submission:
N=int(input())
data=[input() for _ in range(N)]
for d in ["AC","WA","TLE","RE"]:
  print("{} x {}".format(d,data.count(d)))