Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math


def factors(n):
    fhead = []
    ftail = []
    for x in range(1, int(math.sqrt(n)) + 1):
        if n % x == 0:
            fhead.append(x)
            if x * x != n:
                # This check is to not insert sqrt(n) twice in head and tail portion of the list
                ftail.append(n // x)
    return fhead + ftail[::-1]


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

freq = Counter(A)
count = 0
for x in A:
    bad = False
    for d in factors(x):
        if (d == x and freq[d] >= 2) or (d != x and freq[d]):
            bad = True
            break

    if not bad:
        count += 1
print(count)


Fixed submission:
from collections import Counter
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

freq = Counter(A)
if freq[1] == 1:
    print(1)
elif freq[1] >= 2:
    print(0)
else:
    bad = set()
    for k, v in freq.items():
        if v >= 2:
            bad.add(k)

    mx = max(A)

    for x in freq.keys():
        for times in range(2, 10 ** 6 + 1):
            if x * times > mx:
                break
            if x * times in freq:
                bad.add(x * times)

    count = 0
    for x in A:
        if x not in bad:
            count += 1
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque


input = iter(sys.stdin.readlines()).__next__

R, C, K = [int(x) for x in input().split()]
X1, Y1, X2, Y2 = [int(x) - 1 for x in input().split()]  # 0 indexed

grid = [input().rstrip() for r in range(R)]

source = (X1, Y1)
q = deque([source])
dist = {source: 0}


def getNbr(node):
    r, c = node
    ret = []
    for dr, dc in [(0, 0), (-1, 0), (0, -1), (0, 1), (1, 0)]:
        for k in range(1, K + 1):
            nr = r + dr * k
            nc = c + dc * k
            if not (0 <= nr < R and 0 <= nc < C):
                break
            if grid[nr][nc] == "@":
                break
            ret.append((nr, nc))
    return ret


while q:
    node = q.popleft()
    d = dist[node]
    for nbr in getNbr(node):
        if nbr not in dist:
            q.append(nbr)
            dist[nbr] = d + 1


if False:
    for row in grid:
        print(row)
    print()
    for r in range(R):
        for c in range(C):
            print(dist.get((r, c), "?"), end=" ")
        print()


if (X2, Y2) in dist:
    print(dist[(X2, Y2)])
else:
    print(-1)


Fixed submission:
import sys
from collections import deque


input = iter(sys.stdin.readlines()).__next__

R, C, K = [int(x) for x in input().split()]
X1, Y1, X2, Y2 = [int(x) - 1 for x in input().split()]  # 0 indexed

grid = [input().rstrip() for r in range(R)]

source = (X1, Y1)
q = deque([source])
dist = {source: 0}


def getNbr(node, currDist):
    r, c = node
    ret = []
    for dr, dc in [(0, 0), (-1, 0), (0, -1), (0, 1), (1, 0)]:
        for k in range(1, K + 1):
            nr = r + dr * k
            nc = c + dc * k
            if not (0 <= nr < R and 0 <= nc < C):
                break
            if grid[nr][nc] == "@" or ((nr, nc) in dist and dist[(nr, nc)] <= d):
                break
            ret.append((nr, nc))
    return ret


while q:
    node = q.popleft()
    d = dist[node]
    for nbr in getNbr(node, d):
        if nbr not in dist:
            q.append(nbr)
            dist[nbr] = d + 1


if False:
    for row in grid:
        print(row)
    print()
    for r in range(R):
        for c in range(C):
            print(dist.get((r, c), "?"), end=" ")
        print()


if (X2, Y2) in dist:
    print(dist[(X2, Y2)])
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):

N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = 1
for x in A:
    ans *= x
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)


Fixed submission:
N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
if 0 in A:
    print(0)
    exit()
ans = 1
for x in A:
    ans *= x
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

numLeafs = A
minNonLeafs = [None for i in range(N + 1)]
maxNonLeafs = [None for i in range(N + 1)]

maxNonLeafs[0] = 1
for i in range(1, N + 1):
    maxNonLeafs[i] = 2 * maxNonLeafs[i - 1] - numLeafs[i]

minNonLeafs[N] = 0
maxNonLeafs[N] = 0
if minNonLeafs[N] + numLeafs[N] > 2 ** N:
    print(-1)
    exit()

for i in range(N - 1, -1, -1):
    minNonLeafs[i] = (minNonLeafs[i + 1] + numLeafs[i + 1] + 1) // 2
    if minNonLeafs[i] + numLeafs[i] > 2 ** i:
        print(-1)
        exit()
    maxNonLeafs[i] = min(maxNonLeafs[i], maxNonLeafs[i + 1] + numLeafs[i + 1])
    if minNonLeafs[i] > maxNonLeafs[i]:
        assert False # TODO: do i need this case?
        print(-1)
        exit()

count = 0
for i in range(N + 1):
    count += maxNonLeafs[i] + numLeafs[i]
print(count)


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

numLeafs = A
minNonLeafs = [None for i in range(N + 1)]
maxNonLeafs = [None for i in range(N + 1)]

maxNonLeafs[0] = 1
for i in range(1, N + 1):
    maxNonLeafs[i] = 2 * maxNonLeafs[i - 1] - numLeafs[i]

minNonLeafs[N] = 0
maxNonLeafs[N] = 0
if minNonLeafs[N] + numLeafs[N] > 2 ** N:
    print(-1)
    exit()

for i in range(N - 1, -1, -1):
    minNonLeafs[i] = (minNonLeafs[i + 1] + numLeafs[i + 1] + 1) // 2
    if minNonLeafs[i] + numLeafs[i] > 2 ** i:
        print(-1)
        exit()
    maxNonLeafs[i] = min(maxNonLeafs[i], maxNonLeafs[i + 1] + numLeafs[i + 1])
    if minNonLeafs[i] > maxNonLeafs[i]:
        print(-1)
        exit()

count = 0
for i in range(N + 1):
    count += maxNonLeafs[i] + numLeafs[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

from functools import lru_cache

sys.setrecursionlimit(2 * 10 ** 5)

N = int(input())

A = [int(x) for x in input().split()]
A = sorted((a, i) for i, a in enumerate(A))


@lru_cache(maxsize=None)
def dp(l, r):
    if l > r:
        return 0
    a, x = A[r - l]
    return max(a * abs(x - l) + dp(l + 1, r), a * abs(x - r) + dp(l, r - 1))


print(dp(0, N - 1))

Fixed submission:
import sys

sys.setrecursionlimit(2 * 10 ** 5)

N = int(input())

A = [int(x) for x in input().split()]
A = sorted((a, i) for i, a in enumerate(A))

cache = [[None for i in range(N + 1)] for j in range(N + 1)]


def dp(l, r):
    if l > r:
        return 0
    if cache[l][r] is None:
        a, x = A[r - l]
        cache[l][r] = max(a * abs(x - l) + dp(l + 1, r), a * abs(x - r) + dp(l, r - 1))
    return cache[l][r]


print(dp(0, N - 1))

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

N = int(input())

A = [int(x) for x in input().split()]
A = sorted((a, i) for i, a in enumerate(A))


@lru_cache(maxsize=None)
def dp(l, r):
    if l > r:
        return 0
    a, x = A[r - l]
    return max(a * abs(x - l) + dp(l + 1, r), a * abs(x - r) + dp(l, r - 1))


print(dp(0, N - 1))

Fixed submission:
import sys

sys.setrecursionlimit(2 * 10 ** 5)

N = int(input())

A = [int(x) for x in input().split()]
A = sorted((a, i) for i, a in enumerate(A))

cache = [[None for i in range(N + 1)] for j in range(N + 1)]


def dp(l, r):
    if l > r:
        return 0
    if cache[l][r] is None:
        a, x = A[r - l]
        cache[l][r] = max(a * abs(x - l) + dp(l + 1, r), a * abs(x - r) + dp(l, r - 1))
    return cache[l][r]


print(dp(0, N - 1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict, deque

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


def bfs(source):
    q = deque([source])
    dist = {source: 0}
    while q:
        i = q.popleft()
        d = dist[i]
        nbr = []
        if i - 1 >= 1:
            nbr.append(i - 1)
        if i + 1 <= N:
            nbr.append(i + 1)
        if i == X:
            nbr.append(Y)
        if i == Y:
            nbr.append(X)
        for j in nbr:
            if j not in dist:
                q.append(j)
                dist[j] = d + 1
    return dist


count = Counter()
for i in range(1, N + 1):
    dist = bfs(i)
    assert len(dist) == N
    for j, d in dist.items():
        if i < j:
            count[d] += 1

for k in range(1, N):
    print(count[k])


Fixed submission:
import sys

from collections import Counter, defaultdict, deque

input = sys.stdin.readline

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


def bfs(source):
    q = deque([source])
    dist = {source: 0}
    while q:
        i = q.popleft()
        d = dist[i]
        nbr = []
        if i - 1 >= 1:
            nbr.append(i - 1)
        if i + 1 <= N:
            nbr.append(i + 1)
        if i == X:
            nbr.append(Y)
        if i == Y:
            nbr.append(X)
        for j in nbr:
            if j not in dist:
                q.append(j)
                dist[j] = d + 1
    return dist


count = Counter()
for i in range(1, N + 1):
    dist = bfs(i)
    assert len(dist) == N
    for j, d in dist.items():
        if i < j:
            count[d] += 1

ans = []
for k in range(1, N):
    ans.append(str(count[k]))
print('\n'.join(ans))
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

X, Y, A, B, C = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
R = [int(x) for x in input().split()]

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
best = sum(red) + sum(green)

for x in R:
    a1, a2 = red, green
    if a1[-1] > a2[-1]:
        a1, a2 = a2, a1
    assert a1[-1] <= a2[-1]
    if a1[-1] < x:
        best -= a1.pop()
        best += x
print(best)


Fixed submission:
from functools import lru_cache

X, Y, A, B, C = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
R = [int(x) for x in input().split()]

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
best = sum(red) + sum(green)

for x in R:
    a1, a2 = red, green
    if not a1 and not a2:
        break
    if not a1:
        a1 = a2
    if a1 and a2 and a1[-1] > a2[-1]:
        a1, a2 = a2, a1
    if a1[-1] < x:
        best -= a1.pop()
        best += x
print(best)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations

ABC = [input().rstrip(), input().rstrip(), input().rstrip()]

cache = [-1] * (3 * 3)


def canMatchShifted(index1, index2, shift):
    # Whether ABC[index1] can match with ABC[index2] shifted to the right by `shift`
    k = 3 * index1 + index2
    if cache[k] == -1:
        S1 = ABC[index1]
        S2 = ABC[index2]
        temp = [True] * (4001)
        for s in range(len(S1)):
            temp[s] = all(x == y or x == "?" or y == "?" for x, y in zip(S1[s:], S2))
        cache[k] = temp

    return cache[k][shift]


# Try all permutation orders of ABC
best = float("inf")
for a, b, c in permutations(range(3)):
    A = ABC[a]
    B = ABC[b]
    C = ABC[c]
    # Match A with `('?' * i) + B`
    for i in range(len(A) + 2):
        if not canMatchShifted(a, b, i):
            continue
        # Match B with `('?' * j) + C`
        # Match A with `('?' * (i + j)) + C`
        for j in range(len(B) + 2):
            if canMatchShifted(b, c, j) and canMatchShifted(a, c, i + j):
                l = max(len(A), i + len(B), i + j + len(C))
                best = min(best, l)
print(best)


Fixed submission:
from itertools import permutations

ABC = [input().rstrip(), input().rstrip(), input().rstrip()]

cache = [-1] * (3 * 3)


def canMatchShifted(index1, index2, shift):
    # Whether ABC[index1] can match with ABC[index2] shifted to the right by `shift`
    k = 3 * index1 + index2
    if cache[k] == -1:
        S1 = ABC[index1]
        S2 = ABC[index2]
        temp = [True] * (4001)
        for s in range(len(S1)):
            temp[s] = all(x == y or x == "?" or y == "?" for x, y in zip(S1[s:], S2))
        cache[k] = temp

    return cache[k][shift]


# Try all permutation orders of ABC
best = float("inf")
for a, b, c in permutations(range(3)):
    A = ABC[a]
    B = ABC[b]
    C = ABC[c]
    # Match A with `('?' * i) + B`
    for i in range(2001):
        if not canMatchShifted(a, b, i):
            continue
        # Match B with `('?' * j) + C`
        # Match A with `('?' * (i + j)) + C`
        for j in range(2001):
            if canMatchShifted(b, c, j) and canMatchShifted(a, c, i + j):
                l = max(len(A), i + len(B), i + j + len(C))
                best = min(best, l)
print(best)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, Counter, deque

NA, NB, NM = list(map(int, input().split()))

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

coupons = defaultdict(list)
for i in range(NM):
    x, y, c = list(map(int, input().split()))
    coupons[(x, y)].append(c)

best = float('inf')
for i, a in enumerate(A):
    for j, b in enumerate(B):
        cost = a + b
        if (i + 1, j + 1) in coupons:
            cost -= max(coupons[(i + 1, j + 1)])
        best = min(cost, best)
print(best)

Fixed submission:
from collections import defaultdict, Counter, deque

NA, NB, NM = list(map(int, input().split()))

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


best = min(A) + min(B)

for i in range(NM):
    x, y, c = list(map(int, input().split()))
    best = min(best, A[x - 1] + B[y - 1] - c)


print(best)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, P = list(map(int, input().split()))
S = [int(c) for c in input().rstrip()]


if P in [2, 5]:
    total = 0
    for i, x in enumerate(S):
        if x % P == 0:
            # If P == 2
            # all substring ending here with last digit even
            # If P == 5
            # all substring ending here with last digit 5 or 0
            total += i + 1
    print(total)
else:
    # Note P is relatively prime with 10

    # If S is '1234'
    # Want suffixes:
    # s[4] = 1234
    # s[3] =  234
    # s[2] =   34
    # s[1] =    4
    # s[0] =    0
    #
    # Then s[j] - s[i] gives the value of the number int(S[-j:-i]) * 10**(N -i)
    # Since P doesn't divide 10, if P divides s[j] - s[i] it also divides the number

    suf = [0]
    power = 1
    for x in reversed(S):
        suf.append(suf[-1] + x * power)
        power *= 10
    if False:
        # Check
        N = len(S)
        for i in range(N):
            for j in range(i + 1, N + 1):
                print(
                    i,
                    j,
                    int("".join(map(str, S[N - j : N - i]))) * (10 ** i),
                    suf[j] - suf[i],
                )
        print(suf)

    # Count number of s[j] - s[i] pairs that are 0 mod P
    total = 0
    counts = Counter()
    for x in suf:
        x = x % P
        total += counts[x]
        counts[x] += 1
    print(total)


Fixed submission:
from collections import Counter

N, P = list(map(int, input().split()))
S = [int(c) for c in input().rstrip()]


if P in [2, 5]:
    total = 0
    for i, x in enumerate(S):
        if x % P == 0:
            # If P == 2
            # all substring ending here with last digit even
            # If P == 5
            # all substring ending here with last digit 5 or 0
            total += i + 1
    print(total)
else:
    # Note P is relatively prime with 10

    # If S is '1234'
    # Want suffixes:
    # s[4] = 1234
    # s[3] =  234
    # s[2] =   34
    # s[1] =    4
    # s[0] =    0
    #
    # Then s[j] - s[i] gives the value of the number int(S[-j:-i]) * 10**(N -i)
    # Since P doesn't divide 10, if P divides s[j] - s[i] it also divides the number

    CHECK = False
    suf = [0]
    power = 1
    for x in reversed(S):
        suf.append(suf[-1] + x * power)
        power *= 10
        if not CHECK:
            # Don't mod when checking
            suf[-1] %= P
            power %= P
    if CHECK:
        # Check
        N = len(S)
        for i in range(N):
            for j in range(i + 1, N + 1):
                print(
                    i,
                    j,
                    int("".join(map(str, S[N - j : N - i]))) * (10 ** i),
                    suf[j] - suf[i],
                )
        print(suf)

    # Count number of s[j] - s[i] pairs that are 0 mod P
    total = 0
    counts = Counter()
    for x in suf:
        x = x % P
        total += counts[x]
        counts[x] += 1
    print(total)
Buggy python submission (verdict: Time Limit Exceeded):
S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]

f = [
    None,
    [None] * len(digits),
    [None] * len(digits),
]  # f[sign][place] where sign is 1 or -1


for place in reversed(range(len(digits))):
    for sign in [-1, 1]:
        if place == len(digits) - 1:
            if sign > 0:
                exact = digits[place]
            else:
                exact = 10 - digits[place]
            f[sign][place] = exact
            continue

        if sign > 0:
            exact = digits[place]
            overpay = exact + 1  # Overpaying flips the sign of the balance
        else:
            assert sign < 0
            exact = 10 - digits[place] - 1
            overpay = exact + 1
        f[sign][place] = min(exact + f[sign][place + 1], overpay + f[-sign][place + 1])
print(f[1][0])


Fixed submission:
S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]
N = len(digits)

# Track number of bills necessary to create digits[:i]
# Can either pay exact or overpay by one bill to flip the sign of the balance
dpPos = [None] * len(digits)
dpNeg = [None] * len(digits)

dpPos[-1] = digits[-1]
dpNeg[-1] = 10 - digits[-1]

for place in reversed(range(len(digits) - 1)):
    # Positive balance case
    exact = digits[place]
    overpay = exact + 1
    dpPos[place] = min(exact + dpPos[place + 1], overpay + dpNeg[place + 1])
    # Negative balance case
    exact = 10 - digits[place] - 1
    overpay = exact + 1
    dpNeg[place] = min(exact + dpNeg[place + 1], overpay + dpPos[place + 1])
print(dpPos[0])

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]


@lru_cache(maxsize=None)
def f(sign, place):
    if place == len(digits) - 1:
        if sign > 0:
            exact = digits[place]
        else:
            exact = 10 - digits[place]
        return exact

    if sign > 0:
        exact = digits[place]
        overpay = exact + 1  # Overpaying flips the sign of the balance
    else:
        assert sign < 0
        exact = 10 - digits[place] - 1
        overpay = exact + 1

    return min(exact + f(sign, place + 1), overpay + f(-sign, place + 1))


for sign in [-1, 1]:
    for place in reversed(range(len(digits))):
        f(sign, place)

print(f(1, 0))


Fixed submission:
S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]
N = len(digits)

# Track number of bills necessary to create digits[:i]
# Can either pay exact or overpay by one bill to flip the sign of the balance
dpPos = [None] * len(digits)
dpNeg = [None] * len(digits)

dpPos[-1] = digits[-1]
dpNeg[-1] = 10 - digits[-1]

for place in reversed(range(len(digits) - 1)):
    # Positive balance case
    exact = digits[place]
    overpay = exact + 1
    dpPos[place] = min(exact + dpPos[place + 1], overpay + dpNeg[place + 1])
    # Negative balance case
    exact = 10 - digits[place] - 1
    overpay = exact + 1
    dpNeg[place] = min(exact + dpNeg[place + 1], overpay + dpPos[place + 1])
print(dpPos[0])
Buggy python submission (verdict: Time Limit Exceeded):
r1, c1, r2, c2 = list(map(int, input().split()))

MOD = 10 ** 9 + 7


def nCr(n, r):
    num = den = 1
    for i in range(r):
        num = num * (n - i)
        den = den * (i + 1)
    return num // den


def hockey(n, m):
    # sum i=0 to m of nCr(n + i, i) == nCr(n + m + 1, m)
    return nCr(n + m + 1, m)


if False:

    def f(r, c):
        return nCr(r + c, c)

    tot = 0
    for r in range(r1, r2 + 1):
        innerLoopSum = 0
        for c in range(c1, c2 + 1):
            innerLoopSum += f(r, c)
        # Via hockey stick identity
        assert innerLoopSum == nCr(r + c2 + 1, c2) - nCr(r + c1 - 1 + 1, c1 - 1)
        assert innerLoopSum == nCr(r + c2 + 1, r + 1) - nCr(r + c1, r + 1)
        tot += innerLoopSum
    print(tot)
    
    tot1 = 0
    for r in range(r1 + 1, r2 + 2):
        tot1 += nCr(r + c2, r)
    assert tot1 == hockey(c2, r2 + 1) - hockey(c2, r1)
    tot2 = 0
    for r in range(r1 + 1, r2 + 2):
        tot2 += nCr(r + c1 - 1, r)
    assert tot2 == hockey(c1 - 1, r2 + 1) - hockey(c1 - 1, r1)
    print((tot1 - tot2) % MOD)
else:
    tot1 = hockey(c2, r2 + 1) - hockey(c2, r1)
    tot2 = hockey(c1 - 1, r2 + 1) - hockey(c1 - 1, r1)
    print((tot1 - tot2) % MOD)

Fixed submission:
r1, c1, r2, c2 = list(map(int, input().split()))

MOD = 10 ** 9 + 7


def modInverse(x, p):
    # Fermat's little theorem
    return pow(x, p - 2, p)


def nCr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return num * modInverse(den, p) % p


def hockey(n, m):
    # sum i=0 to m of nCr(n + i, i) == nCr(n + m + 1, m)
    return nCr(n + m + 1, m, MOD)


tot1 = hockey(c2, r2 + 1) - hockey(c2, r1)
tot2 = hockey(c1 - 1, r2 + 1) - hockey(c1 - 1, r1)
print((tot1 - tot2) % MOD)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = map(int, input().split())
H = H[:-K]
print(sum(H))

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if K != 0:
    H = H[:-K]
print(sum(H))
Buggy python submission (verdict: Runtime Error):
if(int(input())<30: print('No')
else: print('Yes')

Fixed submission:
if int(input())<30: print('No')
else: print('Yes')

Buggy python submission (verdict: Runtime Error):
if int(input())<30: print('No')
  else: print('Yes')

Fixed submission:
if int(input())<30: print('No')
else: print('Yes')
Buggy python submission (verdict: Runtime Error):
d = {AC:0; WA:0; TLE:0; RE:0}
for i in range(int(input())): d[input()]+=1
for i in d: print(i+' x', d[i])

Fixed submission:
d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(int(input())): d[input()]+=1
for i in d: print(i+' x', d[i])
Buggy python submission (verdict: Runtime Error):
def printer(n):
    if n%10 in [2,4,5,7,9]:print"hon"
    elif n%10 in[0,1,6,8]:print"pon"
    else:print"bon"
printer(int(input()))

Fixed submission:
def printer(n):
    if n%10 in [2,4,5,7,9]:print("hon")
    elif n%10 in[0,1,6,8]:print("pon")
    else:print("bon")
printer(int(input()))

Buggy python submission (verdict: Runtime Error):
def printer(n):
    if n%10 in [2,4,5,7,9]:print"hon"
    elif n%10 in[0,1,6,8]:print"pon"
    else:print"bon"
printter(int(input()))

Fixed submission:
def printer(n):
    if n%10 in [2,4,5,7,9]:print("hon")
    elif n%10 in[0,1,6,8]:print("pon")
    else:print("bon")
printer(int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
n=input()
a=map(int,raw_input().split())
for i in xrange(1,n+1):
    print a.count(i)

Fixed submission:
n=input();a=map(int,raw_input().split());d={}
for i in xrange(1,n+1):d[i]=0
for i in a:d[i]+=1
for i in xrange(1,n+1):print d[i]