Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import PI
r=int(input())
print(2*PI*r)

Fixed submission:
from math import pi
r=int(input())
print(2*pi*r)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
memo = {}
ans = 0

for a in A:
    if not a in memo:
        flag = True
        for div in memo:
            if a % div == 0:
                flag = False
                break
        if flag:
            ans += 1
            memo[a] = 1
    else:
        if memo[a] == 1:
            ans -= 1
            memo[a] += 1
        else:
            continue
print(ans)


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

for i in range(1, 6):
    if x[i-1] == 0:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
memo = {}
ans = 0

for a in A:
    if not a in memo:
        flag = True
        for div in memo:
            if a % div == 0:
                flag = False
                break
        if flag:
            ans += 1
            memo[a] = 1
    else:
        if memo[a] == 1:
            ans -= 1
            memo[a] += 1
        else:
            continue
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
memo = {}
ans = 0

for a in A:
    if not a in memo:
        flag = True
        for div in memo:
            if a % div == 0:
                flag = False
                break
        if flag:
            ans += 1
            memo[a] = 1
    else:
        if memo[a] == 1:
            ans -= 1
            memo[a] += 1
        else:
            continue
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

N = int(input())
A = sorted(list(map(int, input().split())))
memo = {A[0]:None}
ans = 0

gcd_check = A[0]

for a in A[1:]:
    gcd_result = gcd(gcd_check, a)
    if gcd_result == 1:
        ans += 1
        memo[a] = None
        gcd_check *= a
    elif not gcd_result in memo:
        if gcd_result != a:
            ans += 1
            memo[a] = None
            gcd_check *= a
        else:
            memo[a] = None
    else:
        continue

if A[0] != A[1]:
    ans += 1

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
memo = {}
ans = 0

for a in A:
    if not a in memo:
        flag = True
        for div in memo:
            if a % div == 0:
                flag = False
                break
        if flag:
            ans += 1
            memo[a] = 1
    else:
        if memo[a] == 1:
            ans -= 1
            memo[a] += 1
        else:
            continue

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
 
def dcos(x):
    return math.cos(math.radians(x))
 
A, B, H, M = map(int, input().split())
 
one_H = 360 / 12
one_M = 360 / 60
one_H_M = one_H / 60
 
#短針の動きのみ考える。
kakudo_H = one_H * H
#分針の動きを加える。
kakudo_H = kakudo_H + one_H_M*M
 
if kakudo_H > 180:
    kakudo_H = 360 - kakudo_H
 
kakudo_M = one_M * M
if kakudo_M > 180:
    kakudo_M = 360 - kakudo_M
 
kakudo = abs(kakudo_M - kakudo_H)
 
ans = A**2 + B**2 + (-2)*A*B*dcos(kakudo)

assert dcos(kakudo) > 0
 
print(ans**0.5)


Fixed submission:
import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * (360 / (60 * 12))
deg_b = m * (360 / 60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Buggy python submission (verdict: Runtime Error):
import math
 
def dcos(x):
    return math.cos(math.radians(x))
 
A, B, H, M = map(int, input().split())
 
one_H = 360 / 12
one_M = 360 / 60
one_H_M = one_H / 60
 
#短針の動きのみ考える。
kakudo_H = one_H * H
#分針の動きを加える。
kakudo_H = kakudo_H + one_H_M*M
 
if kakudo_H > 180:
    kakudo_H = 360 - kakudo_H
 
kakudo_M = one_M * M
if kakudo_M > 180:
    kakudo_M = 360 - kakudo_M
 
kakudo = abs(kakudo_M - kakudo_H)
 
ans = A**2 + B**2 + (-2)*A*B*dcos(kakudo)

assert kakudo > 0
 
print(ans**0.5)


Fixed submission:
import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * (360 / (60 * 12))
deg_b = m * (360 / 60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

memo =  [[] for _ in range(M+1)]

for _ in range(M):
    Ai, Bi = map(int, input().split())
    memo[Ai].append(Bi)
    memo[Bi].append(Ai)

# print(memo)

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

queue = [1]

while queue:
    room = queue.pop(0)
    for connected_room in memo[room]:
        # print(connected_room)
        if visited[connected_room] == True:
            continue
        ans[connected_room] = room
        visited[connected_room] = True
        queue.append(connected_room)
print("Yes")
for a in ans[2:]:
    print(a)


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

memo =  [[] for _ in range(N+1)]

for _ in range(M):
    Ai, Bi = map(int, input().split())
    memo[Ai].append(Bi)
    memo[Bi].append(Ai)

# print(memo)

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

queue = [1]

while queue:
    room = queue.pop(0)
    for connected_room in memo[room]:
        # print(connected_room)
        if visited[connected_room] == True:
            continue
        ans[connected_room] = room
        visited[connected_room] = True
        queue.append(connected_room)
print("Yes")
for a in ans[2:]:
    print(a)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
memo = [-1] * N
checked_num = {}

teleporter = A[0]
memo[0] = teleporter
repeat_point = -1
flag = False

for i in range(1, N):
    memo[i] = A[teleporter-1]
    teleporter = A[teleporter-1]
    checked_num[memo[i]] = None
    if memo[i] in checked_num and flag == False:
        repeat_point = i
        flag = True

start_point = memo.index(memo[repeat_point])
repeat = repeat_point - start_point
# print(memo, start_point, repeat_point)

if K <= N:
    print(memo[K-1])
else:
    mod = K % repeat
    print(memo[mod-1])


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
memo = [-1] * (N+1)
checked_num = {1:None}
memo[0] = 1

teleporter = A[0]
memo[1] = teleporter
checked_num[memo[1]] = None
repeat_point = -1
flag = False

for i in range(2, N+1):
    # print(i, checked_num)
    memo[i] = A[teleporter-1]
    teleporter = A[teleporter-1]
    if memo[i] in checked_num and flag == False:
        repeat_point = i
        flag = True
    checked_num[memo[i]] = None

# print(memo)

start_point = memo.index(memo[repeat_point])
repeat = repeat_point - start_point
# print(memo, start_point, repeat_point)

if K <= N:
    print(memo[K])
else:
    mod = (K-start_point) % repeat
    # print(memo, start_point, repeat_point, mod)
    print(memo[mod+start_point])
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
ans = [None, None]

for A in range(1, X+1):
    if X % A == 0:
        B = X // A
        for b in range(1, B+1):
            substitute_a = b + A
            left_side = pow(substitute_a, 4)+pow(substitute_a, 3)*b + pow(substitute_a, 2)*pow(b, 2)+substitute_a*pow(b, 3)+pow(b, 4)
            # print("A,B", A, B, "left_side", left_side)
            if left_side == B:
                ans[0], ans[1] = substitute_a, b
                break
            elif left_side > B:
                b = b * (-1)
                substitute_a = b + A
                left_side = pow(substitute_a, 4)+pow(substitute_a, 3)*b + pow(substitute_a, 2)*pow(b, 2)+substitute_a*pow(b, 3)+pow(b, 4)
                if left_side == B:
                    ans[0], ans[1] = substitute_a, b
    if ans[0] != None:
        break

print(ans[0], ans[1])


Fixed submission:
X = int(input())

for A in range(-1000, 1001):
    for B in range(-1000, 1001):
        if A**5 - B**5 == X:
            print(A, B)
            quit()
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A <= W:
    print("unsafe")
else:
    print("safe")

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

if A <= B:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += gcd(gcd(a,b),c)

print(ans)


Fixed submission:
K = int(input())
ans = 0

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

memo1 = []
memo2 = []
memo3 = []

for i in range(1, K+1):
    memo1.append((i,i,i))

for i in range(1, K):
    for j in range(i+1, K+1):
        memo2.append((i,i,j))
        memo2.append((j,j,i))

for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            memo3.append((i,j,k))

for item in memo1:
    ans += gcd(item[2], gcd(item[0], item[1]))
for item in memo2:
    ans += 3 * (gcd(item[2], gcd(item[0], item[1])))
for item in memo3:
    ans += 6 * (gcd(item[2], gcd(item[0], item[1])))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = 0

for i in range(len(S)-2):
    char_1 = S[i]
    for j in range(i+1, len(S)-1):
        char_2 = S[j]
        if char_1 == char_2:
            continue
        one2twodist = j - i
        for k in range(j+1, len(S)):
            char_3 = S[k]
            if char_2 == char_3 or char_1 == char_3 or one2twodist == (k - j):
                continue
            ans += 1

print(ans)


Fixed submission:
N = int(input())
S = list(input())
ans = 0
R, G, B = 0, 0, 0

for char in S:
    if char == "R":
        R += 1
    elif char == "G":
        G += 1
    else:
        B += 1

ans = R*G*B

for i in range(len(S)):
    for j in range(i+1, len(S)):
        if S[i] != S[j]:
            i2j = j - i
            try:
                if not S[j+i2j] in [S[i], S[j]]:
                    ans -= 1
            except:
                break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
memo = {}

for a in A:
    try:
        memo[a] += 1
    except:
        memo[a] = 1

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# print(memo)
for i in range(N):
    ans = 0
    for key in memo.keys():
        if memo[key] < 2:
            continue
        if A[i] == key:
            if memo[key] - 1 < 2:
                continue
            else:
                ans += combinations_count(memo[key]-1, 2)
                # print(ans)
        else:
            ans += combinations_count(memo[key], 2)
    print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
memo = {}

for a in A:
    try:
        memo[a] += 1
    except:
        memo[a] = 1

import math
def combinations_count(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

sum_memo = 0

for key in memo.keys():
    sum_memo += combinations_count(memo[key], 2)

for a in A:
    print(sum_memo-(memo[a]-1))
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
try:
    for i in range(action_mod):
        if one_action[i] == "B":
            ans += 1
except:
    pass

print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

# one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
# for i in range(action_mod):
#     if one_action[i] == "B":
#         ans += 1

print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB
one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

if action_mod <= A:
    ans += action_mod
else:
    ans += A

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#C
from collections import Counter
import itertools

N = int(input())
S = [None] * N
for i in range(N):
    Si = input()
    S[i] = Si

counter = Counter(S)
ret = [letter for letter,count in counter.most_common() if count == counter.most_common()[0][1]]

for i in (sorted(ret)):
    print(i)

Fixed submission:
#C
N = int(input())
memo = {}
max_word = 1
for i in range(N):
    Si = input()
    try:
        memo[Si] += 1
        max_word = max(max_word, memo[Si])
    except:
        memo[Si] = 1
        
keys = [k for k, v in memo.items() if v == max_word]
keys.sort()
for item in keys:
  print(item)
Buggy python submission (verdict: Time Limit Exceeded):
#D
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0

for i in range(0, N-K+1):
    sum_P = sum(P[i:i+K])
    ans = max(ans, sum_P)
#     ans = max(ans, K+0.5*(sum_P-K))
    
print(K+0.5*(ans-K))

Fixed submission:
#D
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = sum(P[0:K])
sum_P = ans

for i in range(1, N-K+1):
    sum_P = sum_P - P[i-1] + P[i+K-1]
    ans = max(ans, sum_P)
#     ans = max(ans, K+0.5*(sum_P-K))
    
print(K+0.5*(ans-K))

Buggy python submission (verdict: Time Limit Exceeded):
#D
import numpy as np

N, K = map(int, input().split())
P = list(map(int, input().split()))
P = np.array(P)
ans = 0

for i in range(0, N-K+1):
    sum_P = np.sum(P[i:i+K])
    ans = max(ans, K+0.5*(sum_P-K))
    
print(ans)

Fixed submission:
#D
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = sum(P[0:K])
sum_P = ans

for i in range(1, N-K+1):
    sum_P = sum_P - P[i-1] + P[i+K-1]
    ans = max(ans, sum_P)
#     ans = max(ans, K+0.5*(sum_P-K))
    
print(K+0.5*(ans-K))

Buggy python submission (verdict: Time Limit Exceeded):
#D
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0

for i in range(0, N-K+1):
    sum_P = sum(P[i:i+K])
    ans = max(ans, K+0.5*(sum_P-K))
    
print(ans)

Fixed submission:
#D
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = sum(P[0:K])
sum_P = ans

for i in range(1, N-K+1):
    sum_P = sum_P - P[i-1] + P[i+K-1]
    ans = max(ans, sum_P)
#     ans = max(ans, K+0.5*(sum_P-K))
    
print(K+0.5*(ans-K))
Buggy python submission (verdict: Time Limit Exceeded):
#E 復習
N = int(input())
K = int(input())

def f(n, K):
    if n <= 10:
        if K == 0:
            return 1
        if K == 1:
            return n
        return 0
    div_n = n//10
    mod_n = n%10
    ans = 0
    if K >= 1:
        ans += f(div_n, K-1) * mod_n
        ans += f(div_n-1, K-1) * (9 - mod_n)
    ans += f(div_n, K)
    return ans

print(f(N, K))

Fixed submission:
#E 復習
N = int(input())
K = int(input())

from functools import lru_cache

@lru_cache(None)
def f(n, K):
    if n <= 10:
        if K == 0:
            return 1
        if K == 1:
            return n
        return 0
    div_n = n//10
    mod_n = n%10
    ans = 0
    if K >= 1:
        ans += f(div_n, K-1) * mod_n
        ans += f(div_n-1, K-1) * (9 - mod_n)
    ans += f(div_n, K)
    return ans

print(f(N, K))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

for _ in range(K):
    H[H.index(max(H))] = 0
    
print(sum(H))

Fixed submission:
#C
import heapq

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = list(map(lambda x: x*(-1), H))
heapq.heapify(H)

if K >= N:
    print(0)
else:
    for _ in range(K):
        heapq.heappop(H)
    print(-sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
 
for i in range(N):
    frag = True
    for j in range(i):
        if P[i] > P[j]:
            frag = False
            break
    if frag == True:
        ans += 1
        
print(ans)

Fixed submission:
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6

for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C
import numpy as np

N = int(input())
P = np.array(list(map(int, input().split())))
ans = 0

for i in range(N):
    min_to_i = np.min(P[:i+1])
    if min_to_i >= P[i]:
        ans += 1
        
print(ans)

Fixed submission:
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6

for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0

for i in range(N):
    min_to_i = min(P[:i+1])
    if min_to_i >= P[i]:
        ans += 1
        
print(ans)

Fixed submission:
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6

for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0

for i in range(N):
    frag = True
    for j in range(i):
        if P[i] > P[j]:
            frag = False
            break
    if frag == True:
        ans += 1
        
print(ans)

Fixed submission:
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6

for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    for Ai in A:
        if Ai >> i & 1:
            x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans % mod)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    B = A >> i & 1
    x = np.count_nonzero(B)
#     for Ai in A:
#         if Ai >> i & 1:
#             x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
INF = 10**9

def calc(N, A):
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            ans += A[i] ^ A[j]

    ans = ans % (INF + 7)
    return ans

print(calc(N, A))

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    B = A >> i & 1
    x = np.count_nonzero(B)
#     for Ai in A:
#         if Ai >> i & 1:
#             x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
INF = 10**9

import numba
@numba.jit
def calc(N, A):
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            ans += A[i] ^ A[j]

    ans = ans % (INF + 7)
    return ans

print(calc(N, A))

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    B = A >> i & 1
    x = np.count_nonzero(B)
#     for Ai in A:
#         if Ai >> i & 1:
#             x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
INF = 10**9
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += A[i] ^ A[j]

ans = ans % (INF + 7)
print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    B = A >> i & 1
    x = np.count_nonzero(B)
#     for Ai in A:
#         if Ai >> i & 1:
#             x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#D
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += A[i] ^ A[j]

ans = ans % (10**9 + 7)
print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10 ** 9 + 7

for i in range(60):
    x, y = 0, 0    
    B = A >> i & 1
    x = np.count_nonzero(B)
#     for Ai in A:
#         if Ai >> i & 1:
#             x += 1
    y = N - x
    ans += (x * y) * (2 ** i)
    
print(ans%mod)