Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = map(two_factor, range(1, N + 1))
max_cnt = max(a)
print(a.index(max_cnt) + 1)


Fixed submission:
# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = list(map(two_factor, range(1, N + 1)))
max_cnt = max(a)
print(a.index(max_cnt) + 1)

Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = map(two_factor, range(1, N + 1))
max_cnt = max(a)
print(list(range(1, N + 1)).index(max_cnt) + 1)


Fixed submission:
# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = list(map(two_factor, range(1, N + 1)))
max_cnt = max(a)
print(a.index(max_cnt) + 1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding:utf-8 -*-

# http://arc078.contest.atcoder.jp/tasks/arc078_a

N = int(input())
a = map(int, input().split())

sum_num = sum(a)
current_sum = 0
min_diff = float('inf')
for i in range(0, N - 1):
    current_sum += a[i]
    min_diff = min(min_diff, abs(current_sum - (sum_num - current_sum)))
print(min_diff)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
sum_num = sum(a)
current_sum = 0
min_diff = float('inf')
for i in range(0, N - 1):
    current_sum += a[i]
    min_diff = min(min_diff, abs(current_sum - (sum_num - current_sum)))
print(min_diff)
Buggy python submission (verdict: Runtime Error):

N, P = map(int, input().split())
A = map(int, input().split())

n_even = len(filter(lambda x: x % 2 == 0, A))
n_odd = N - n_even
ans = 2 ** max(0, n_odd - 1) * 2 ** n_even
if P == 0 and n_odd == 0:
    print(0)
else:
    print(ans)


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

n_even = len(list(filter(lambda x: x % 2 == 0, A)))
n_odd = N - n_even
ans = (2 ** max(0, n_odd - 1)) * (2 ** n_even)
if P == 1 and n_odd == 0:
    print(0)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):

N, P = map(int, input().split())
A = map(int, input().split())

n_even = len(filter(lambda x: x % 2 == 0, A))
n_odd = N - n_even
ans = 2 ** max(0, n_odd - 1) * 2 ** n_even
if P == 0 and n_odd == 0:
    print(0)
else:
    print(ans)


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

n_even = len(list(filter(lambda x: x % 2 == 0, A)))
n_odd = N - n_even
ans = (2 ** max(0, n_odd - 1)) * (2 ** n_even)
if P == 1 and n_odd == 0:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
ret = None
for i in range(n - 1, 0, -1):
    if len(s[:i]) % 2 == 1:
        continue
    # print(s[:i // 2], s[i // 2:i][::-1])
    if s[:i // 2] == s[i // 2:i][::-1]:
        ret = s[:i]
        break
print(len(ret))


Fixed submission:
s = input()
n = len(s)
ret = ''
for i in range(n - 1, 0, -1):
    if len(s[:i]) % 2 == 1:
        continue
    # print(s[:i // 2], s[i // 2:i])
    if s[:i // 2] == s[i // 2:i]:
        ret = s[:i]
        break
print(len(ret))
Buggy python submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, i, depth):
    # print(i, visited[i])
    if visited[i] > 0:
        return visited[i]
    elif visited[i] == 0:
        return -1
    if As[i] == 2:
        visited[i] = 1
        return depth
    visited[i] = 0
    visited[i] = rec(visited, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, 1 - 1, 1)
print(ret)



Fixed submission:
n = int(input())
As = [int(input()) for _ in range(n)]
cnt = 0
current_button = 0
for _ in range(n):
    current_button = As[current_button] - 1
    cnt += 1
    if current_button == 1:
        break
if current_button != 1:
    print(-1)
else:
    print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, prev_i, i, depth):
    if visited[i] >= 0:
        return visited[i]
    if As[i] == 2:
        visited[i] = 1
        return depth
    if prev_i == As[i] - 1:
        visited[i] = 0
        return visited[i]
    visited[i] = rec(visited, i, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, -1, 1 - 1, 1)
if ret == 0:
    ret = -1
print(ret)



Fixed submission:
n = int(input())
As = [int(input()) for _ in range(n)]
cnt = 0
current_button = 0
for _ in range(n):
    current_button = As[current_button] - 1
    cnt += 1
    if current_button == 1:
        break
if current_button != 1:
    print(-1)
else:
    print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, prev_i, i, depth):
    if visited[i] > 0:
        return visited[i]
    if As[i] == 2:
        visited[i] = 1
        return depth
    if prev_i == As[i] - 1:
        return visited[i]
    visited[i] = rec(visited, i, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, -1, 1 - 1, 1)
print(ret)


Fixed submission:
n = int(input())
As = [int(input()) for _ in range(n)]
cnt = 0
current_button = 0
for _ in range(n):
    current_button = As[current_button] - 1
    cnt += 1
    if current_button == 1:
        break
if current_button != 1:
    print(-1)
else:
    print(cnt)
Buggy python submission (verdict: Runtime Error):
s UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X = sorted(X)
Y = sorted(Y)
graph = []
for i in range(N - 1):
    graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))
    graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))

graph.sort()
uf = UnionFind(N)

total_cost = 0
for cost, a, b in graph:
    if not uf.is_same(a, b):
        uf.unite(a, b)
        total_cost += cost

print(total_cost)


Fixed submission:
class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X = sorted(X)
Y = sorted(Y)
graph = []
for i in range(N - 1):
    graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))
    graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))

graph.sort()
uf = UnionFind(N)

total_cost = 0
for cost, a, b in graph:
    if not uf.is_same(a, b):
        uf.unite(a, b)
        total_cost += cost

print(total_cost)
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc064/tasks/abc064_a
a = int("".join(input()))
if a % 4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
# https://atcoder.jp/contests/abc064/tasks/abc064_a
a = int(input().replace(' ', ''))
if a % 4 == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc064/tasks/abc064_a

a = int(input().join())
if a % 4 == 0:
    print("YES")
else:
    print("NO")


Fixed submission:
# https://atcoder.jp/contests/abc064/tasks/abc064_a
a = int(input().replace(' ', ''))
if a % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split))
# N = 9
# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]
# N = 7
# A = [1, 2, 3, 2, 1, 999999999, 1000000000]
# N = 6
# A = [1, 2, 3, 2, 2, 1]
# N = 2
# A = [1, 1]
A = A + [A[-1]]

d = 0
i = 0

inc = None
while i < N:
    if inc is None:
        if A[i] < A[i + 1]:
            inc = True
            d += 1
        elif A[i] > A[i + 1]:
            inc = False
            d += 1
        else:
            inc = None
    else:
        if inc:
            if A[i] > A[i + 1]:
                inc = None
        else:
            if A[i] < A[i + 1]:
                inc = None
    i += 1

if inc is None:
    d += 1
print(d)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
# N = 9
# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]
# N = 7
# A = [1, 2, 3, 2, 1, 999999999, 1000000000]
# N = 6
# A = [1, 2, 3, 2, 2, 1]
# N = 2
# A = [1, 1]
A = A + [A[-1]]

d = 0
i = 0

inc = None
while i < N:
    if inc is None:
        if A[i] < A[i + 1]:
            inc = True
            d += 1
        elif A[i] > A[i + 1]:
            inc = False
            d += 1
        else:
            inc = None
    else:
        if inc:
            if A[i] > A[i + 1]:
                inc = None
        else:
            if A[i] < A[i + 1]:
                inc = None
    i += 1

if inc is None:
    d += 1
print(d)
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end]))



Fixed submission:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1, -1):
    if s[i] == 'Z':
        end = i
        break
print(end + 1 - start)

Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end+1]))


Fixed submission:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1, -1):
    if s[i] == 'Z':
        end = i
        break
print(end + 1 - start)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
A = map(int, input().split())
# N = 5
# A = [2, 4, 4, 0, 2]
mod = 10 ** 9 + 7

cnt = Counter(A)
if N % 2 == 0:
    if len(filter(lambda c: c == 2, cnt.values())) != 0:
        print(0)
    else:
        print(2 ** (N // 2))
else:
    if cnt[0] != 1:
        print(0)
    cnt.pop(0)
    if len(filter(lambda c: c == 2, cnt.values())) != 0:
        print(0)
    else:
        print(2 ** (N // 2))


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print((2 ** (N // 2)) % MOD)
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print((2 ** (N // 2)) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N, K, L = map(int, input().split())


class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1

    def group(self):
        d = defaultdict(set)
        for i in range(self.n):
            d[self.root(i)].add(i)
        return d

load_uf = UnionFind(N)
rail_uf = UnionFind(N)

for k in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    load_uf.unite(p, q)

for l in range(L):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    rail_uf.unite(r, s)
ld = load_uf.group()
rd = rail_uf.group()

ans = []
d = defaultdict(int)
for i in range(N):
    lp = load_uf.par[i]
    rp = rail_uf.par[i]
    d[lp, rp] += 1
# print(d)

for i in range(N):
    lp = load_uf.par[i]
    rp = rail_uf.par[i]
    if i == N-1:
        print(d[lp, rp])
    else:
        print(d[lp, rp], end=' ')

#     print(rd[rp])
#     print(ld[lp])
#     ans.append(len(ld[lp] & rd[rp]))
# print(str(ans).replace(',', '')[1:-1])


Fixed submission:
from collections import defaultdict

N, K, L = map(int, input().split())


class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1

load_uf = UnionFind(N)
rail_uf = UnionFind(N)

for k in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    load_uf.unite(p, q)

for l in range(L):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    rail_uf.unite(r, s)

ans = []
d = defaultdict(int)
for i in range(N):
    lp = load_uf.root(i)
    rp = rail_uf.root(i)
    d[lp, rp] += 1

for i in range(N):
    lp = load_uf.par[i]
    rp = rail_uf.par[i]
    if i == N-1:
        print(d[lp, rp])
    else:
        print(d[lp, rp], end=' ')

#     print(rd[rp])
#     print(ld[lp])
#     ans.append(len(ld[lp] & rd[rp]))
# print(str(ans).replace(',', '')[1:-1])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding:utf-8 -*-

s = input()
if len(s) % 2 == 0 ^ s[0] == s[-1]:
    print("Second")
else:
    print("First")


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

s = input()
if (len(s) % 2 == 0) and (s[0] == s[-1]):
    print("First")
elif (len(s) % 2 == 0) or (s[0] == s[-1]):
    print("Second")
else:
    print("First")
Buggy python submission (verdict: Runtime Error):
import sys


H, W = map(int, input().split())
m = [input() for i in range(H)]

valid = True
dx = [0, 0, 1, -1]
dy = [-1, 1, 0, 0]
for y in range(H):
    for x in range(W):
        if m[y][x] != '#':
            continue
        cnt = 0
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx and nx < W and \
               0 <= ny and ny < H and m[ny][nx] == '#':
                cnt += 1
        if cnt >= 3:
            valid = False
            print("Impossible")
            sys.exit()


def rec(x, y):
    if x == W - 1 and y == H - 1:
        return True

    if m[y][x] != '#':
        return False
    dx = [0, 1]
    dy = [1, 0]
    valid = False
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < W and \
           0 <= ny and ny < H and m[ny][nx] == '#':
            ret = rec(nx, ny)
            if ret:
                return ret
    return False


if rec(0, 0):
    print("Possible")
else:
    print("Impossible")


Fixed submission:

H, W = map(int, input().split())
m = [input() for i in range(H)]

cnt = 0
for h in range(H):
    for w in range(W):
        if m[h][w] == '#':
            cnt += 1

def rec(x, y):
    if x == W - 1 and y == H - 1:
        return True

    if m[y][x] != '#':
        return False
    dx = [0, 1]
    dy = [1, 0]

    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < W and \
           0 <= ny and ny < H:
            ret = rec(nx, ny)
            if ret:
                return ret
    return False


if rec(0, 0) and cnt == H + W - 1:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding:utf-8 -*-

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

data = [float('inf')] * (2 * N - 1)

def update(i, val):
    i += N-1
    data[i] = val
    while i > 0:
        i = (i - 1) // 2
        data[i] = min(data[2*i+1], data[i*2+2])

for i in range(N):
    update(i, a[i])

def query(a, b, k, l, r):
    if l <= a and b <= r:
        return data[k]
    elif b <= l or r <= a:
        return float('inf')
    else:
        mid = (a + b) // 2
        lvalue = query(a, mid, 2 * k + 1, l, r)
        rvalue = query(mid, b, 2 * k + 2, l, r)
        return min(lvalue, rvalue)

ans = 0
for l in range(N):
    for r in range(l, N):
        ans += query(0, N, 0, l, r + 1)
print(ans)


Fixed submission:
#!/usr/bin/env python

from collections import defaultdict

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

cnt = 0
d = [0] * (N + 2)
for i in range(N):
    d[a[i]] = i


l = list(range(N + 2))
r = list(range(N + 2))

# print(a)
for i in range(N, 0, -1):
    di = d[i]
    cnt += i * (r[di] - di + 1) * (di - l[di] + 1)
    r[l[di] - 1] = r[di]
    l[r[di] + 1] = l[di]
    # print(i)
    # print(r)
    # print(l)
# print(r)
# print(l)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, x = map(int, input().split())
a = list(map(int, input().split()))

pos = a.index(min(a))
na = [a[pos]] + a[pos+1:] + a[:pos]

ans = sum(a)
for k in range(1, N):
    d = deque([], k + 1)
    b = []
    for i in range(N):
        d.append(na[i])
        # print(d)
        b.append(min(d))
    # print(k, b)
    ans = min(ans, k * x + sum(b))
print(ans)


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

pos = a.index(min(a))
na = [a[pos]] + a[pos+1:] + a[:pos]

ans = sum(a)
old_b = na[:]
for k in range(1, N):
    b = []
    for i in range(N):
        if i - k >= 0:
            b.append(min(old_b[i], na[i - k]))
        else:
            b.append(old_b[i])
    # print(k, b)
    old_b = b
    ans = min(ans, k * x + sum(b))
print(ans)
Buggy python submission (verdict: Runtime Error):
from collectiosn import Counter

c = Counter(input())
valid = True
for key, value in c.items():
    if value % 2 == 1:
        valid = False
        break
if valid:
    print("Yes")
else:
    print("No")


Fixed submission:
from collections import Counter

c = Counter(input())
valid = True
for key, value in c.items():
    if value % 2 == 1:
        valid = False
        break
if valid:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):

N = int(input())
a = map(int, input().split())


total_cost = float('inf')
for n in range(-100, 101):
    cost = 0
    for i in range(N):
        cost += (a[i] - n) ** 2
    total_cost = min(total_cost, cost)
print(total_cost)

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

total_cost = float('inf')
for n in range(-100, 101):
    cost = 0
    for i in range(N):
        cost += (a[i] - n) ** 2
    total_cost = min(total_cost, cost)
print(total_cost)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
D = set(input())

n = N
while True:
    if set(str(n)) in D:
        print(n)
        break
    n += 1


Fixed submission:
N, K = map(int, input().split())
D = set(input())

n = N
while True:
    if len(set(str(n)) & D) == 0:
        print(n)
        break
    n += 1
Buggy python submission (verdict: Runtime Error):
a = raw_input()

if a == "ABC":
  print("ARC")
elif a == "ARC":
  print("ABC")

Fixed submission:
a = input()

if a == "ABC":
  print("ARC")
elif a == "ARC":
  print("ABC")

Buggy python submission (verdict: Runtime Error):
a = raw_input()

if a == "ABC":
  print(ARC)
 elif a == "ARC":
  print(ABC)

Fixed submission:
a = input()

if a == "ABC":
  print("ARC")
elif a == "ARC":
  print("ABC")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > b:
  print("GREATER")
else if:
  print("LESS")
else:
  print("EQUAL")

Fixed submission:
a = int(input())
b = int(input())
 
if a > b:
  print("GREATER")
elif a < b:
  print("LESS")
else:
  print("EQUAL")
Buggy python submission (verdict: Runtime Error):
N = int(input)
ans = []
for _ in range(N):
  s = input()
  ans.append(s)
print(len(list(set(ans)))

Fixed submission:
N = int(input())
ans = []
for _ in range(N):
  s = input()
  ans.append(s)
print(len(list(set(ans))))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = {}
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for unique in list(set(A)):
    cum_count = A.count(unique)
    cum[unique] = cum_count
    ans += couple_combination(cum_count)
for i in A:
    print(max(0,ans - cum[i] + 1))


Fixed submission:
import sys
from collections import defaultdict
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = defaultdict(int)
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for v in A:
    cum[v] += 1
for v in cum.values():
    ans += couple_combination(v)
for v in A:
    print(max(0,ans - cum[v] + 1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
cum = {}
for i in A:
    if i in cum:
        cum[i] += 1
    else:
        cum[i] = 1
for i in A:
    ans = 0
    for k, v in cum.items():
        if k == i:
            v -= 1
        if v >= 2:
            ans += int(v*(v-1)/2)
    print(ans)

Fixed submission:
import sys
from collections import defaultdict
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = defaultdict(int)
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for v in A:
    cum[v] += 1
for v in cum.values():
    ans += couple_combination(v)
for v in A:
    print(max(0,ans - cum[v] + 1))