Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    import math
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    r = int(input())
    print(2*r*math.pi)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    A = sum([int(x) for x in input().strip().split()])
    if N - A < 0:
        print(-1)
    else:
        print(N - A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
L = [[i-1, i+1] for i in range(1, N+1)]
L[0] = [L[0][1]]
L[-1] = [L[-1][0]]
L[X-1].append(Y)
L[Y-1].append(X)

def bfs(i):
    ni = deque(L[i-1])
    c = 1
    C = [0] * N
    C[i-1] = -1
    while ni:
        nii = ni
        ni = deque([])
        for niii in nii:
            if C[niii-1] != 0:
                continue
            C[niii-1] = c
            if niii > i:
                D[c] += 1
            ni.extend(L[niii-1])
        c += 1
    return True

for n in range(1, N+1):
    bfs(n)

for n in range(1, N):
    print(D[n])

Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
for k in range(1, N):
    for k2 in range(k+1, N+1):
        D[min(k2 - k, abs(X-k) + 1 + abs(Y-k2), abs(Y-k) + 1 + abs(X-k2))] += 1

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
G = np.zeros((N, N), dtype=int)
D = defaultdict(int)
for k in range(1, N):
    for k2 in range(k+1, N+1):
        D[min(k2 - k, abs(X-k) + 1 + abs(Y-k2), abs(Y-k) + 1 + abs(X-k2))] += 1

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


Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
for k in range(1, N):
    for k2 in range(k+1, N+1):
        D[min(k2 - k, abs(X-k) + 1 + abs(Y-k2), abs(Y-k) + 1 + abs(X-k2))] += 1

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

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
G = np.zeros((N, N), dtype=int)
for k in range(N):
    for k2 in range(k+1, N):
        G[k, k2] = min(k2 - k, G[min(k, X-1), max(k, X-1)]+1+abs(k2 - (Y - 1)))

for k in range(1, N):
    print(sum(sum(G == k)))


Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
for k in range(1, N):
    for k2 in range(k+1, N+1):
        D[min(k2 - k, abs(X-k) + 1 + abs(Y-k2), abs(Y-k) + 1 + abs(X-k2))] += 1

for k in range(1, N):
    print(D[k])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            for ii in range(i+1, N):
                if s[ii] == ss:
                    bits[ii] = i
        if bits not in groups:
            groups.append(bits)
            print(s)
        return
    # for ns in 'abcdefghijklmnopqrstuvwxyz'[:n+1]:
    for ns in 'abcdefghij'[:n+1]:
        dfs(s+ns, n+1)

dfs('', 0)


Fixed submission:
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            for ii in range(i+1, N):
                if s[ii] == ss:
                    bits[ii] = i
        if bits not in groups:
            groups.append(bits)
            print(s)
        return
    for ns in 'abcdefghijklmnopqrstuvwxyz'[:n+1]:
        dfs(s+ns, n+1)

dfs('', 0)


Fixed submission:
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            for ii in range(i+1, N):
                if s[ii] == ss:
                    bits[ii] = i
        if bits not in groups:
            groups.append(bits)
            print(s)
        return
    for ns in 'abcdefghijklmnopqrstuvwxyz':
        dfs(s+ns, n+1)

dfs('', 0)

Fixed submission:
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1

fact = [1] * (n + 1)
for i in range(1, n+1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (n + 1)
inv[-1] = pow(fact[-1], mod-2, mod)
for i in range(1, n+1):
    inv[-1-i] = (inv[-1-i+1] * (n-(i-1))) % mod

ans = (ans - (fact[n] * inv[n-a] * inv[a]) % mod) % mod
ans = (ans - (fact[n] * inv[n-b] * inv[b]) % mod) % mod
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1

fact = [1] * (b + 1)
for i in range(1, b+1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (b + 1)
inv[-1] = pow(fact[-1], mod-2, mod)
for i in range(1, b):
    inv[-1-i] = (inv[-1-i+1] * (b-(i-1))) % mod

def nCr(n, r):
    ret = 1
    for i in range(r):
        ret = (ret * (n - i) % mod) % mod
    return (ret * inv[r]) % mod

ans = (ans - nCr(n, a)) % mod
ans = (ans - nCr(n, b)) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math

input = sys.stdin.readline
n = int(input())
k = int(input())
t = n
m = 0
while t:
    m += 1
    t //= 10

def comb(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 9 ** k * comb(m-1, k)
tk = k

def dfs(i, mt, kt):
    a = i // 10 ** mt
    b = n // 10 ** mt
    if kt < 0:
        return 0
    if mt < kt:
        return 0
    if a < b:
        if mt > 0:
            return 9 ** kt * comb(mt, kt)
        else:
            return 1
    elif a > b:
        return 0
    if i == n and kt == 0:
        return 1
    elif i > n:
        return 0
    ret = 0
    for j in range(10):
        f = 0
        if j != 0:
            f = 1
        ret += dfs(i+j*10**(mt-1), mt-1, kt-f)
    return ret

t_ans = 0
for i in range(1, n // (10 ** (m-1) )+1):
    ti = i * 10 ** (m-1)
    t_ans += dfs(ti, m-1, k-1)

print(int(ans+t_ans))


Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
P = [int(x) for x in input().strip().split()]
q = deque([])
cur = 0
ans = 0
for i, p in enumerate(P):
    e = (1+p) / 2
    q.append(e)
    cur += e
    if i >= K-1:
        ans = max(ans, cur)
        e_ = q.popleft()
        cur -= e_
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
import math

input = sys.stdin.readline
n = int(input())
k = int(input())
t = n
m = 0
while t:
    m += 1
    t //= 10

def comb(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 9 ** k * comb(m-1, k)
tk = k

def dfs(i, mt, kt):
    a = i // 10 ** mt
    b = n // 10 ** mt
    if kt < 0:
        return 0
    if mt < kt:
        return 0
    if a < b:
        if mt > 0:
            return 9 ** kt * comb(mt, kt)
        else:
            return 1
    elif a > b:
        return 0
    if i == n and kt == 0:
        return 1
    elif i > n:
        return 0
    ret = 0
    for j in range(10):
        f = 0
        if j != 0:
            f = 1
        ret += dfs(i+j*10**(mt-1), mt-1, kt-f)
    return ret

t_ans = 0
for i in range(1, n // (10 ** (m-1) )+1):
    ti = i * 10 ** (m-1)
    t_ans += dfs(ti, m-1, k-1)

print(int(ans+t_ans))


Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
P = [int(x) for x in input().strip().split()]
q = deque([])
cur = 0
ans = 0
for i, p in enumerate(P):
    e = (1+p) / 2
    q.append(e)
    cur += e
    if i >= K-1:
        ans = max(ans, cur)
        e_ = q.popleft()
        cur -= e_
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
h, n = [int(x) for x in input().strip().split()]
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(x) for x in input().strip().split()]

dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(1, h+1):
    for aa, bb in zip(a, b):
        dp[i] = min(dp[i], dp[max(0, i-aa)]+bb)
print(dp[h])

Fixed submission:
import sys
input = sys.stdin.readline
h, n = [int(x) for x in input().strip().split()]
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(x) for x in input().strip().split()]

dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(1, h+1):
    for aa, bb in zip(a, b):
        dp[i] = min(dp[i], dp[max(0, i-aa)]+bb)
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
MOD = 10 ** 9 + 7
ans = 0

for i in range(60+1):
    zero = 0
    one = 0
    m = 1 << i
    for a in A:
        if a & m:
            one += 1
        else:
            zero += 1
    ans += (one * zero) * m
    ans = ans % MOD
print(ans % MOD)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    _ = int(input())
    A = [int(x) for x in input().strip().split()]
    MOD = 10 ** 9 + 7
    ans = 0

    for i in range(60+1):
        zero = 0
        one = 0
        m = 1 << i
        for a in A:
            if a & m:
                one += 1
            else:
                zero += 1
        ans += (one * zero) * m
        ans = ans % MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
MOD = 10 ** 9 + 7
ans = 0

for i in range(60+1):
    zero = 0
    one = 0
    for a in A:
        if a >> i & 1 == 1:
            one += 1
        else:
            zero += 1
    ans += (one * zero) * 2 ** i
    ans = ans % MOD
print(ans % MOD)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    _ = int(input())
    A = [int(x) for x in input().strip().split()]
    MOD = 10 ** 9 + 7
    ans = 0

    for i in range(60+1):
        zero = 0
        one = 0
        m = 1 << i
        for a in A:
            if a & m:
                one += 1
            else:
                zero += 1
        ans += (one * zero) * m
        ans = ans % MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

X, Y = [int(x) for x in input().strip().split()]
p = (X, 2 * X)
n1 = X
n2 = 0
f = True
while p != (X, Y):
    n1 -= 2
    n2 += 1
    p = (n1 + 2 * n2, 2 * n1 + n2)
    if p[1] <= 0:
      	f = False
        break
if f:
    print(combination(n1 + n2, n1) % (10 ** 9 + 7))
else:
    print(0)

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

X, Y = [int(x) for x in input().strip().split()]
p = (X, 2 * X)
n1 = X
n2 = 0
f = True
while p != (X, Y):
    n1 -= 2
    n2 += 1
    p = (n1 + 2 * n2, 2 * n1 + n2)
    if p[1] <= 0:
        f = False
        break

if n1 < 0 or n2 < 0:
    print(0)
else:
    print(combination(n1 + n2, n1) % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline
a, b, x = [int(x) for x in input().strip().split()]
if x >= a ** 2 * b / 2:
    theta = math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3)))
else:
    theta = math.degrees(math.atan(a * (b ** 2) / (2 * x)))
print(theta)s

Fixed submission:
import sys
import math
input = sys.stdin.readline
a, b, x = [int(x) for x in input().strip().split()]
if x >= a ** 2 * b / 2:
    theta = math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3)))
else:
    theta = math.degrees(math.atan(a * (b ** 2) / (2 * x)))
print(theta)
Buggy python submission (verdict: Runtime Error):
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
print(len(set(l)))


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

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
      
l.append(t)
print(len(set(l)))

Buggy python submission (verdict: Runtime Error):
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for  i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
print(len(set(l)))


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

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
      
l.append(t)
print(len(set(l)))

Buggy python submission (verdict: Runtime Error):
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for  i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
  i += 1
print(len(set(l)))


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

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
      
l.append(t)
print(len(set(l)))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
T_A = 0
T_A_all = 0
for i,a in enumerate(A):
    T_A += len([1 for x in A[i+1:] if a > x])
    T_A_all += len([1 for x in A if a > x])
T_B = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            T_B += 1
T_B_all = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            T_B_all += 1
print(T_A,T_B)
print(T_A_all,T_B_all)

a = T_A
z = T_A + T_A_all * (K -1)
print(int((K*(a+z)//2)%((10**9)+7)))


Fixed submission:
M, D = [int(x) for x in input().split()]
ret = 0
for m in range(1, M+1):
  for d10 in range(2, 10):
    for d1 in range(2, 10):
      d = 10 * d10 + d1
      if d > D:
        break
      if d1 * d10 == m:
        ret += 1
    if d10 > D:
      break
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
sn=[''.join(sorted(list(input()))) for _ in range(N)]
sm=set(sn)
res=0
for s in sm:
  cnt=sn.count(s)
  res+=(1+(cnt-1))*(cnt-1)//2
print(res)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
sn=[''.join(sorted(list(input()))) for _ in range(N)]
sm=set(sn)
res=0
for s in sm:
  cnt=sn.count(s)
  res+=(1+(cnt-1))*(cnt-1)//2
print(res)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
sn=[input() for _ in range(N)]
def check(s1,s2):
  a=list(s1)
  b=list(s2)
  a.sort()
  b.sort()
  if a==b:
    return True
  else:
    return False
  
cnt=0
for i in range(len(sn)-1):
  m=1
  if not sn[i]:continue
  for ii in range(i+1,len(sn)):
    if sn[ii] and check(sn[i],sn[ii]):
      cnt+=m
      m+=1
      sn[ii]=None

print(cnt)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Buggy python submission (verdict: Runtime Error):
N=int(input())
sn=[input() for _ in range(N)]
def check(s1,s2):
  a=list(s1)
  b=list(s2)
  a.sort()
  b.sort()
  if a==b:
    return True
  else:
    return False
  
cnt=0
for i in range(len(sn)-1):
  m=1
  for ii in range(i+1,len(sn)):
    if sn[ii] and check(sn[i],sn[ii]):
      cnt+=m
      m+=1
      sn[ii]=None

print(cnt)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Buggy python submission (verdict: Runtime Error):
N=int(input())
sn=[input() for _ in range(N)]
def check(s1,s2):
  for c in s1:
    if s1.count(c)!=s2.count(c):
      return False
  else:
    return True
  
cnt=0
for i in range(len(sn)-1):
  m=1
  for ii in range(i+1,len(sn)):
    if sn[ii] and check(sn[i],sn[ii]):
      cnt+=m
      m+=1
      sn[ii]=None

print(cnt)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
sn=[input() for _ in range(N)]
def check(s1,s2):
  for c in s1:
    if s1.count(c)!=s2.count(c):
      return False
  else:
    return True
  
cnt=0
for i in range(len(sn)-1):
  for ii in range(i+1,len(sn)):
    if sn[i]==sn[ii]:
      cnt+=1
      continue
    if check(sn[i],sn[ii]):
      sn[ii]=sn[i]
      cnt+=1

print(cnt)

Fixed submission:
N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
n=0
sumB=0
q=[]
for m in range(1,M+1):
    maxB=0
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    sumB+=heapq.heappop(q)
    if len(q)==0: break
    
print(-sumB)

Fixed submission:
import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
n=0
sumB=0
q=[]
for m in range(1,M+1):
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    if len(q)!=0:
        sumB+=heapq.heappop(q)

print(-sumB)

Buggy python submission (verdict: Runtime Error):
import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
print(AB)
n=0
sumB=0
q=[]
for m in range(1,M+1):
    maxB=0
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    sumB+=heapq.heappop(q)
    if len(q)==0: break
    
print(-sumB)

Fixed submission:
import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
n=0
sumB=0
q=[]
for m in range(1,M+1):
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    if len(q)!=0:
        sumB+=heapq.heappop(q)

print(-sumB)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,itertools,copy,time
input = sys.stdin.readline
S=int(input().strip())

A=S
B=0


def divide(a):
    if a==1:return [1,1]
    if a==0:return [0,0]
    temp=a
    ans=[a,1]
    c=2
    while True:
        if c==temp:
            break
        elif temp%c==0:
            ans[1]*=c
            temp/=c
            ans[0]=temp
            if ans[0]<=10**9 and ans[1]<=10**9:
                break
            c=2
        else:
            c+=1

    return ans

while True:
    if A <= 10**9:
        print(0,0,A,0,0,1)
        break
    else:
        if A%2==1:
            A+=1
            B+=1
        x1y2=divide(A)
        x2y1=divide(B)
        if max(x1y2) < 10**9 and max(x2y1) < 10**9:
            print(0,0,x1y2[0],x2y1[1],x2y1[0],x1y2[1])
            break
        else:
            A+=1
            B+=1



Fixed submission:
import sys,itertools,copy,math
input = sys.stdin.readline
S=int(input().strip())

y2=math.ceil(S/(10**9))
x2=y2*10**9-S

print(0,0,10**9,1,x2,y2)