Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def bfs(i, j):
    dist = [-1]*N
    dist[i] = 0
    que = collections.deque([])
    que.append(i)
    
    while len(que) != 0:
        v = que.popleft()
        for nv in graph[v]:
            if dist[nv] != -1:continue
            dist[nv] = dist[v]+1
            if nv == j:break
            que.append(nv)
    return dist[j]

graph = {}
for i in range(N):
    graph[i] = set()

for i in range(N-1):
    graph[i].add(i+1)
    graph[i+1].add(i)
graph[X-1].add(Y-1)
graph[Y-1].add(X-1)

ans = [0]*N
for i in range(N):
    for j in range(i+1,N):
        d = bfs(i,j)
        ans[d] += 1
for i in range(N):
    if i == 0:continue
    print(ans[i])

Fixed submission:
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def dist(i,j):
    return min(abs(j-i), abs(X-i)+1+abs(j-Y))

ans = [0]*N
for i in range(N):
    for j in range(i+1, N):
        d = dist(i+1,j+1)
        ans[d] += 1
for i in range(N):
    if i == 0:
        continue
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def bfs(i, j):
    dist = [-1]*N
    dist[i] = 0
    que = collections.deque([])
    que.append(i)
    
    while len(que) != 0:
        v = que.popleft()
        for nv in graph[v]:
            if dist[nv] != -1:continue
            dist[nv] = dist[v]+1
            que.append(nv)
    return dist[j]

graph = {}
for i in range(N):
    graph[i] = set()

for i in range(N-1):
    graph[i].add(i+1)
    graph[i+1].add(i)
graph[X-1].add(Y-1)
graph[Y-1].add(X-1)

ans = [0]*N
for i in range(N):
    for j in range(i+1,N):
        d = bfs(i,j)
        ans[d] += 1
for i in range(N):
    if i == 0:continue
    print(ans[i])

Fixed submission:
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def dist(i,j):
    return min(abs(j-i), abs(X-i)+1+abs(j-Y))

ans = [0]*N
for i in range(N):
    for j in range(i+1, N):
        d = dist(i+1,j+1)
        ans[d] += 1
for i in range(N):
    if i == 0:
        continue
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
m = [X,Y]
ans = 0
while m[0] > 0 or m[1] > 0:
    if m[0] > 0:
        if p[-1] < r[-1]:
            ans += r[-1]
            r.pop()
        else:
            ans += p[-1]
            p.pop()
        m[0] -= 1
    if m[1] > 0:
        if q[-1] < r[-1]:
            ans += r[-1]
            r.pop()
        else:
            ans += q[-1]
            q.pop()
        m[1] -= 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p = p[A-X:]
q.sort()
q = q[B-Y:]
r.sort()
a = p+q+r
a.sort(reverse=True)
print(sum(a[:X+Y]))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline
N, M, K = map(int, input().split())
graph = [[] for _ in range(N)]
block = [[] for _ in range(N)]
connected_components = []
count = 0
counts = [0 for _ in range(N)]
seen = [False for _ in range(N)]
def dfs(v, c, seen, origin):
    global count
    seen[v] = True
    for node in graph[v]:
        if seen[node] == True:
            continue
        if node not in block[origin]:
            count += 1
        dfs(node, c+1, seen, origin)
def dfs_connected(v, order):
    seen[v] = True
    connected_components[order].append(v)
    for node in graph[v]:
        if seen[node] == True:
            continue
        dfs_connected(node, order)
 
for Mi in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
 
for Ki in range(K):
    a, b = map(int, input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
 
for v in range(N):
    if seen[v] == True:
        continue
    connected_components.append([])
    dfs_connected(v, v)
 
for components in connected_components:
    for component in components:
        seen = [False for _ in range(N)]
        count = 0
        dfs(component, count, seen, component)
        counts[component] = count-len(graph[component])
 
print(' '.join(map(str, counts)))

Fixed submission:
N = int(input())
x, y = divmod(N, 2)
print(x + y)

Buggy python submission (verdict: Runtime Error):
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][2] and matched[1][1] and matched[2][0]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
x, y = divmod(N, 2)
print(x + y)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split(' ')))

s = 0
for xi in X:
    s += xi
si = round(s / N)
ps = 0
for xi in X:
    ps += int(math.pow(xi-si, 2))
print(ps)

Fixed submission:
import math
N = int(input())
X = list(map(int, input().split(' ')))

s = 0
for xi in X:
    s += xi
si = round(s / N)
ps = 0
for xi in X:
    ps += int(math.pow(xi-si, 2))
print(ps)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def cmb(n, r, p, fact, factinv):
    if r < 0 or n < r:return 0
    return fact[n] * factinv[r] * factinv[n-r] % p
def main():
    n, a, b = map(int, input().split())
    ans = 0
    p = 10 ** 9 + 7
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    for i in range(1, n+1):
        if i == a or i == b:continue
        ans += cmb(n, i, p, fact, factinv)
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def cmb(n, k, p):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % p
        y = y * (k-i) % p
    return x * pow(y, p-2, p) % p
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    ans = pow(2, n, p) - 1
    ans -= cmb(n, a, p) + cmb(n, b, p)
    print(ans%p)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
n, a, b = map(int, input().split(' '))
s = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    s += cmb(n, n-i)
print(int(s % (math.pow(10, 9)+7)))

Fixed submission:
import sys
input = sys.stdin.readline
def cmb(n, k, p):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % p
        y = y * (k-i) % p
    return x * pow(y, p-2, p) % p
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    ans = pow(2, n, p) - 1
    ans -= cmb(n, a, p) + cmb(n, b, p)
    print(ans%p)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, a, b = map(int, input().split(' '))
s = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    s += cmb(n, n-i)
print(int(s % (math.pow(10, 9)+7)))

Fixed submission:
import sys
input = sys.stdin.readline
def cmb(n, k, p):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % p
        y = y * (k-i) % p
    return x * pow(y, p-2, p) % p
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    ans = pow(2, n, p) - 1
    ans -= cmb(n, a, p) + cmb(n, b, p)
    print(ans%p)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
def count_buttle(h):
    global count
    if h == 1:
        count += 1
        return
    h = h//2
    count += 1
    count_buttle(h)
    count_buttle(h)
H = int(input())
count_buttle(H)
print(count)

Fixed submission:
import math
H = int(input())
count = int((1-2**(math.floor(math.log2(H))+1)) * -1)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip('\r\n')
ans = 0
for i in range(1000):
    target = str(i).zfill(3)
    indices = [-1] * 3
    for m, c in enumerate(target):
        if m == 0:
            idx = S.find(c)
            if idx == -1:
                break
            indices[0] = idx
            continue
        for n in range(indices[m-1]+1, N):
            if c == S[n]:
                # print(target)
                indices[m] = n
                break
        if indices[0] > -1 and indices[1] > -1 and indices[2] > -1:
            ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip('\r\n')
ans = 0
for i in range(1000):
    target = str(i).zfill(3)
    indices = [-1] * 3
    for m, c in enumerate(target):
        if m == 0:
            idx = S.find(c)
            if idx == -1:
                break
            indices[0] = idx
            continue
        for n in range(indices[m-1]+1, N):
            if c == S[n]:
                # print(target)
                indices[m] = n
                break
        if indices[0] > -1 and indices[1] > -1 and indices[2] > -1:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque
import heapq
def main():
    N = int(input())
    graph = {}
    for i in range(1, N+1):
        graph[i] = set()
    ans_order = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        graph[a].add(b)
        graph[b].add(a)
        ans_order.append((a, b))
    K = 0
    for i in range(1, N+1):
        K = max(K, len(graph[i]))
    available_colors = deque([i for i in range(1, K+1)])
    not_available_colors = deque([])
    seen = [0 for _ in range(N)]
    seen[0] = 1
    ans = {i: {} for i in range(1, N+1)}
    que = deque([])
    que.append(1)
    pre_edges = deque([])
    while len(que) != 0:
        v = que.popleft()
        pre_edges.append(len(graph[v]))
        for node in graph[v]:
            if seen[node-1] == 1:continue
            seen[node-1] = 1
            col = available_colors.popleft()
            ans[v][node] = col
            not_available_colors.append(col)
            que.append(node)
        if len(pre_edges) > 1:
            restore_count = pre_edges.popleft()
            for _ in range(restore_count):
                if len(not_available_colors) > 0:
                    available_colors.append(not_available_colors.popleft())
    print(K)
    for pair in ans_order:
        a, b = pair
        print(ans[a][b])
if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
class Edge:
    def __init__(self, to, id):
        self.to = to
        self.id = id
N = int(input())
graph = {}
ans = [0] * (N-1)
def dfs(v, c=-1, p=-1):
    global graph, ans
    k = 1
    for edge in graph[v]:
        nv = edge.to
        if nv == p:continue
        if k == c:k += 1
        ans[edge.id] = k
        dfs(nv, k, v)
        k += 1
def main():
    global N, graph, ans
    for i in range(N):
        graph[i] = set()
    for i in range(N-1):
        a, b = map(int, input().split())
        graph[a-1].add(Edge(b-1, i))
        graph[b-1].add(Edge(a-1, i))
    color_count = 0
    for i in range(N):
        color_count = max(color_count, len(graph[i]))
    dfs(0, 0, -1)
    print(color_count)
    for x in ans:
        print(x)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from math import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
from fractions import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0

def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0
def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect

a,b,q = map(int, input().split())
m = {}
st = []
for _ in range(a):
    num = int(input())
    st.append(num)
    m[num] = "A"
for _ in range(b):
    num = int(input())
    st.append(num)
    m[num] = "B"
st.sort()

def search_left(idx):
    t = {"A": False, "B": False}
    for i in st[:idx][::-1]:
        if m[i] == "A":t["A"]=True
        if m[i] == "B":t["B"]=True
        if t["A"] and t["B"]:return i
    return 0
def search_right(idx):
    t = {"A": False, "B": False}
    for i in st[idx:]:
        if m[i] == "A":t["A"]=True
        if m[i] == "B":t["B"]=True
        if t["A"] and t["B"]:return i
    return 0
def search_left_one(idx, c):
    for i in st[:idx][::-1]:
        if m[i] == c:return i
def search_right_one(idx, c):
    for i in st[idx:]:
        if m[i] == c:return i
for _ in range(q):
    x = int(input())
    idx = bisect.bisect_left(st,x)
    if idx == 0:
        most_right = search_right(0)
        print(abs(x-most_right))
        continue
    elif idx == a+b:
        most_left = search_left(a+b)
        print(abs(x-most_left))
        continue        
    left = st[idx-1]
    right = st[idx]
    c = "A" if m[left]=="B" else "B"
    most_right = search_right_one(idx, c)
    ans = abs(abs(x-left)+most_right-left)
    c = "A" if m[right]=="B" else "B"
    most_left = search_left_one(idx, c)
    ans = min(ans,abs(abs(x-right)+right-most_left))
    most_left = search_left(idx)
    if most_left != 0:ans = min(ans,abs(x-most_left))
    most_right = search_right(idx)
    if most_right != 0:ans = min(ans,abs(x-most_right))
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
import bisect

a,b,q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for _ in range(a)] + [INF]
t = [-INF] + [int(input()) for _ in range(b)] + [INF]
for _ in range(q):
    x = int(input())
    i = bisect.bisect_right(s,x)
    j = bisect.bisect_right(t,x)
    d = INF
    for si in [s[i-1],s[i]]:
        for ti in [t[j-1],t[j]]:
            d1 = abs(x-si)+abs(ti-si)
            d2 = abs(x-ti)+abs(ti-si)
            d = min(d,d1,d2)
    print(d)
Buggy python submission (verdict: Runtime Error):
def chmin(dp, idx, a, b):
    if a > b:
        dp[idx] = b
        return True
    else:
        return False
def rec(dp, i):
    INF = 10**9
    if dp[i] < INF:
        return dp[i]
    if i == 0:
        return 0
    chmin(dp, i, dp[i], rec(dp, i-1) + abs(h[i]-h[i-1]))
    if i > 1:
        chmin(dp, i, dp[i], rec(dp, i-2) + abs(h[i]-h[i-2]))
    return dp[i]
def dp(N, h):
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    rec(dp, N-1)
    return dp
N = int(input())
h = list(map(int, input().split(' ')))
dp = dp(N, h)
print(dp[N-1])

Fixed submission:
def chmin(dp, idx, a, b):
    if a > b:
        dp[idx] = b
        return True
    else:
        return False
def dp(N, h):
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        chmin(dp, i, dp[i], dp[i-1] + abs(h[i]-h[i-1]))
        if i < 2:
            continue
        chmin(dp, i, dp[i], dp[i-2] + abs(h[i]-h[i-2]))
    return dp
N = int(input())
h = list(map(int, input().split(' ')))
dp = dp(N, h)
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())

if N % 500 <= A:
    print('Yes')
else:
    print('No')

Fixed submission:
import math
a, b = map(int, input().split(' '))
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
fn = 0
for i in range(1, 9):
    fn += N // (10*i)
if N % fn == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N = input().rstrip('\r')
fx = 0
for n in N:
    num = int(n)
    fx += num
if int(N) % fx == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

nums = list(map(int, list(input().rstrip('\r'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

nums = list(map(int, list(input().rstrip('\r\n'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)
Buggy python submission (verdict: Runtime Error):
T = [int(input()) for _ in range(N)]
T.sort()

def init_bus():
    global bus, min_t, ans
    bus = []
    bus.append(t)
    min_t = t
    ans += 1

min_t = 0
for t in T:
    if len(bus) == 0:
        init_bus()
        continue
    if t - min_t < K and len(bus) < C:
        bus.append(t)
    else:
        init_bus()
print(ans)

Fixed submission:
N, C, K = map(int, input().split(' '))
bus = []
ans = 0
T = [int(input()) for _ in range(N)]
T.sort()

min_t = 0
i = 0
while i < N:
    ans += 1
    start = i
    while i < N and T[i] - T[start] <= K and i - start < C:
        i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

a, b, x = map(int, input().split(' '))
p = -1
ans = 0
while True:
    p += 1
    num = x * p
    if num < a:
        continue
    if num > b:
        break
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

a, b, x = map(int, input().split(' '))
m = b//x+1
n = 0
if a > 0:
    n = (a-1)//x+1
ans = m - n
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
mlt = 1
for x in l:
    mlt *= x
if mlt > 10 ** 18:
    print('-1')
else:
    print(mlt)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
if 0 in l:
    print(0)
    exit()
mlt = 1
for x in l:
    mlt *= x
    if mlt > 10 ** 18:
        print('-1')
        exit()
print(mlt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
    x = str(input())
    if x not in l:
        l.append(x)
print(len(l))

Fixed submission:
import collections
N = int(input())
l = [str(input()) for i in range(N)]
c = collections.Counter(l)
print(len(c.keys()))
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
for i in range(1, N + 1):
    if A.count(i) > Q - K:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K, Q = map(int, input().split())
A = [0] * N
for i in range(Q):
    A[int(input()) - 1] += 1 
for i in range(N):
    if A[i] > Q - K:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [sorted(list(input())) for i in range(N)]
num = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            num += 1
print(num)

Fixed submission:
import collections
N = int(input())
S = [''.join(sorted(list(input()))) for i in range(N)]
c = collections.Counter(S)
print(sum([int(x * (x - 1) / 2) for x in c.values()]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
I = []
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        I.append(H[i])
I.append(H[N - 1])
N = len(I)
for i in range(N):
    for j in range(i + 1, N):
        if I[i] > I[j] + 1:
            print('No')
            quit()
print('Yes')

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
I = [H[i + 1] - H[i] for i in range(N - 1)]
N = len(I)
for i in range(N):
    if I[i] >= 0:
        continue
    elif I[i] < -1:
        print('No')
        quit()
    else:
        if i == N - 1:
            continue
        for j in range(i + 1, N):
            if I[j] >= 1:
                break
            elif I[j] <= -1:
                print('No')
                quit()
            else:
                continue
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
for i in range(N - 1):
    for j in range(i + 1, N):
        if H[i] > H[j] + 1:
            print('No')
            quit()
print('Yes')

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
I = [H[i + 1] - H[i] for i in range(N - 1)]
N = len(I)
for i in range(N):
    if I[i] >= 0:
        continue
    elif I[i] < -1:
        print('No')
        quit()
    else:
        if i == N - 1:
            continue
        for j in range(i + 1, N):
            if I[j] >= 1:
                break
            elif I[j] <= -1:
                print('No')
                quit()
            else:
                continue
print('Yes')