Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K = int(input())

if K % 2 == 0:
    print(-1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(3, n, 2):
        if i * i > n:
            break
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


arr = factorization(K)
# print(f'{arr=}')

ans = 1
for a in arr:
    b = a[0]
    time = a[1]
    # print(f'{K=}')
    v = ''
    M = set([])
    for i in range(1, 999982):
        v += '7'
        mod = int(v) % b
        if mod == 0:
            # print(f'{K=}, {i=}')
            ans *= i**time
            break
        if mod in M:
            print(f'{K=}, i=-1')
            print(-1)
            exit()
        M.add(mod)

print(ans)


Fixed submission:
K = int(input())

if K == 1 or K == 7:
    print(1)
    exit()

v = 7
M = set([])
for i in range(1, K + 1):
    v = (v * 10 + 7) % K
    if v == 0:
        print(i + 1)
        exit()
    if v not in M:
        M.add(v)
    else:
        print(-1)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

# (x + y) ** 2 = x2 + 2xy + y2
# (y + z) ** 2 = y2 + 2yz + z2
# (z + x) ** 2 = z2 + 2zx + x2
# 右辺 2(x2 + y2 + z2 + xy + yz + zx)
# よって (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 = 2 * n

# x**2 + y**2 + z**2 + xy + yz + zx = n

# x = y = 1, N = 10**4の時のZは大きくて100なので100まで回せばよい
# 4 + 2(z**2 + 2z + 1) = 2 * 10**4
# 2 + z ** 2 + 2z + 1 = 10**4
# z(z + 2) = 10 ** 4 - 3
# 時間がかかりすぎるからx,y,zの値によって+1, +3, +6する 3C3, 3C2, 3C1


def f1(x, y, z):
    return (x + y)**2 + (y + z)**2 + (z + x)**2


# F = [0] * (10**4 + 1)
# F = [0] * (N + 1)
# for i in range(1, 10**4 + 1):
for i in range(1, N + 1):
    f = 0
    # for i in range(83, N + 1):
    right = 2 * i
    # print(f'{i=}')
    for x in range(1, 101):
        if f1(x, 1, 1) > right:
            break
        for y in range(x, 101):
            if f1(x, y, 1) > right:
                break

            for z in range(y, 101):
                # print(f'{i=}, {x=}, {y=}, {z=}')
                left = f1(x, y, z)
                if left > right:
                    break
                if left == right:
                    # print(f'{i=}, {x=}, {y=}, {z=}')
                    if x == y == z:
                        # F[i] += 1
                        f += 1
                    elif x == y or y == z or z == x:
                        # F[i] += 3
                        f += 3
                    else:
                        # F[i] += 6
                        f += 6
    print(f)
# print(f'{F=}')


Fixed submission:
N = int(input())

# (x + y) ** 2 = x2 + 2xy + y2
# (y + z) ** 2 = y2 + 2yz + z2
# (z + x) ** 2 = z2 + 2zx + x2
# 右辺 2(x2 + y2 + z2 + xy + yz + zx)
# よって (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 = 2 * n

# x**2 + y**2 + z**2 + xy + yz + zx = n

# x = y = 1, N = 10**4の時のZは大きくて100なので100まで回せばよい
# 4 + 2(z**2 + 2z + 1) = 2 * 10**4
# 2 + z ** 2 + 2z + 1 = 10**4
# z(z + 2) = 10 ** 4 - 3
# 時間がかかりすぎるからx,y,zの値によって+1, +3, +6する 3C3, 3C2, 3C1


def f1(x, y, z):
    return (x + y)**2 + (y + z)**2 + (z + x)**2


# F = [0] * (10**4 + 1)
# F = [0] * (N + 1)
# for i in range(1, 10**4 + 1):
for i in range(1, N + 1):
    f = 0
    # for i in range(83, N + 1):
    right = 2 * i
    # print(f'{i=}')
    for x in range(1, 101):
        if f1(x, 1, 1) > right:
            break
        for y in range(x, 101):
            if f1(x, y, 1) > right:
                break

            for z in range(y, 101):
                # print(f'{i=}, {x=}, {y=}, {z=}')
                left = f1(x, y, z)
                if left > right:
                    break
                if left == right:
                    # print(f'{i=}, {x=}, {y=}, {z=}')
                    if x == y == z:
                        # F[i] += 1
                        f += 1
                    elif x == y or y == z or z == x:
                        # F[i] += 3
                        f += 3
                    else:
                        # F[i] += 6
                        f += 6
    print(f)
# print(f'{F=}')
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1
print(cnt)


Fixed submission:
a = int(input())
print(a + a**2 + a**3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
alphabets = list('zabcdefghijklmnopqrstuvwxy')

v = []
# 26進数
while True:
    N, mod = divmod(N, 26)
    if mod == 0:
        mod = 26
        N -= 1
    v.append(alphabets[mod])
    if N < 26:
        if N != 0:
            v.append(alphabets[N])
        break
v = v[::-1]
ans = ''.join(v)
print(ans)


Fixed submission:
N = int(input())

# 26進数
v = []
while True:
    N, mod = divmod(N, 26)
    if mod == 0:
        mod = 26
        N -= 1
    v.append(mod)
    if N < 26:
        v.append(N)
        break
v = v[::-1]
# print('v', v)
alphabets = list('0abcdefghijklmnopqrstuvwxyz')
s = []
for i in v:
    if i == 0:
        continue
    s.append(alphabets[i])
# print('s', s)
ans = ''.join(s)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a - 1 for a in A]

log_K = 1
while 1 << log_K < K:
    log_K += 1
# print(f'{log_K=}')
D = [[0] * N for _ in range(log_K)]
for i in range(N):
    D[0][i] = A[i]
for k in range(log_K - 1):
    for i in range(N):
        D[k + 1][i] = D[k][D[k][i]]
# print(f'{D=}')

now = 0
k = 0
while K > 0:
    if K & 1:
        now = D[k][now]
    K = K >> 1
    k += 1
print(now + 1)


Fixed submission:
from collections import deque

N, K = map(int, input().split())
A = list(map(int, input().split()))
T = set([0])  # 0-indexed

c = 0  # 0-indexed
for i in range(N + 1):
    c = A[c] - 1
    # print('c', c)
    if c not in T:
        T.add(c)
    else:
        break
C = deque([c])
T = set([c])  # 0-indexed
for i in range(N + 1):
    c = A[c] - 1
    # print('c', c)
    if c not in T:
        T.add(c)
        C.append(c)
    else:
        break
c2 = 0  # 0-indexed
S = deque([0])
for i in range(N + 1):
    c2 = A[c2] - 1
    if c2 == c:
        break
    else:
        S.append(c2)
# print('C', C)
# print('S', S)
# print('len(C), len(S)', len(C), len(S))

if C[0] == 0:
    mod = K % len(C)
    ans = C[mod]
else:
    if len(S) > K:
        ans = S[K]
    else:
        mod = (K - len(S)) % len(C)
        ans = C[mod]
print(ans + 1)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

# for b in range(65, -64, -1):
for b in range(1000000, -1000000, -1):
    a = (X + b**5)**0.2
    # print('b a', b, a)
    if type(a) == complex:
        if a.imag != 0:
            continue
        print(int(a.real), b)
        exit()
    elif a.is_integer():
        print(int(a), b)
        exit()

for a in range(1000000, -1000000, -1):
    b = (X - a**5)**0.2
    # print('b a', b, a)
    if type(b) == complex:
        if b.imag != 0:
            continue
        print(int(b.real), a)
        exit()
    elif b.is_integer():
        print(int(a), b)
        exit()


Fixed submission:
X = int(input())

for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == X:
            print(a, b)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

INF = 10**18

ans = 0
for i in range(N):
    v = A[0]
    A[0] = INF
    # print('P', P)
    ans += np.count_nonzero(A + v == np.arange(0, len(A)))
    # if i >= 3:
    #     break
    A = A[1:]
print(ans)


Fixed submission:
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

L = defaultdict(int)
R = defaultdict(int)
for i, x in enumerate(A, 1):
    l = i + x
    r = i - x
    L[l] += 1
    R[r] += 1
# print('L', L)
# print('R', R)
ans = 0
for key, l_value in L.items():
    r_value = R[key]
    ans += l_value * r_value
print(ans)
# memo = defaultdict(int)
# answer = 0
# for i, x in enumerate(A, 1):
#     answer += memo[i - x]
#     memo[x + i] += 1

# print('memo', memo)
# print(answer)

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

N = int(input())
A = np.array(list(map(int, input().split())))
P = np.zeros((N), dtype='i')

INF = 10**18

ans = 0
for i in range(N):
    v = A[i]
    A[i] = INF
    P[i:] = np.arange(0, N - i)
    P[:i] = np.arange(1, i + 1)[::-1]
    # print('P', P)
    ans += np.count_nonzero(A + v == P)
    # if i >= 3:
    #     break
print(ans)


Fixed submission:
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

L = defaultdict(int)
R = defaultdict(int)
for i, x in enumerate(A, 1):
    l = i + x
    r = i - x
    L[l] += 1
    R[r] += 1
# print('L', L)
# print('R', R)
ans = 0
for key, l_value in L.items():
    r_value = R[key]
    ans += l_value * r_value
print(ans)
# memo = defaultdict(int)
# answer = 0
# for i, x in enumerate(A, 1):
#     answer += memo[i - x]
#     memo[x + i] += 1

# print('memo', memo)
# print(answer)

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

N = int(input())
A = np.array(list(map(int, input().split())))
B = A.copy()
P = np.zeros((N), dtype='i')

INF = 10**18

ans = 0
for i in range(N):
    B[i] = INF
    P[i:] = np.arange(0, N - i)
    P[:i] = np.arange(1, i + 1)[::-1]
    # print('P', P)
    ans += np.count_nonzero(B + A[i] == P)
    # if i >= 3:
    #     break
print(ans)


Fixed submission:
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

L = defaultdict(int)
R = defaultdict(int)
for i, x in enumerate(A, 1):
    l = i + x
    r = i - x
    L[l] += 1
    R[r] += 1
# print('L', L)
# print('R', R)
ans = 0
for key, l_value in L.items():
    r_value = R[key]
    ans += l_value * r_value
print(ans)
# memo = defaultdict(int)
# answer = 0
# for i, x in enumerate(A, 1):
#     answer += memo[i - x]
#     memo[x + i] += 1

# print('memo', memo)
# print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


K = int(input())

G = [[0] * (K + 1) for _ in range(K + 1)]

for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if G[a][b] == 1:
                ans += 1
                continue
            ans += gcd(G[a][b], c)
print(ans)


Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


K = int(input())

G = [[0] * (K + 1) for _ in range(K + 1)]

for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if G[a][b] == 1:
                ans += 1
                continue
            ans += gcd(G[a][b], c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S = list(input())

if len(S) <= 3:
    print(0)
    exit()

c = Counter(S)
# print('c', c, len(c))
if len(c) != 3:
    print(0)
    exit()

condition1 = 1
for v in c.values():
    condition1 *= v

# print('condition1', condition1)

condition2 = 0
for i in range(N):
    for d in range(N // 2 + 2):
        j = i + d
        k = j + d
        if j >= N or k >= N:
            continue
        # print('i, j, k', i, j, k)
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]):
            condition2 += 1
ans = condition1 - condition2
print(ans)


Fixed submission:
N = int(input())
S = list(input())

if len(S) <= 3:
    print(0)
    exit()

sorted_S = sorted(S)
c = [0, 0, 0]
j = 0
for i in range(len(sorted_S) - 1):
    if sorted_S[i] != sorted_S[i + 1]:
        if j == 0:
            c[j] = i + 1
            j += 1
        else:
            c[j] = (i + 1) - c[j - 1]
            j += 1

# print('c', c, j)
if j != 2:
    print(0)
    exit()
c[2] = N - c[0] - c[1]

condition1 = c[0] * c[1] * c[2]
# print('condition1', condition1)

condition2 = 0
for i in range(N):
    for d in range(N // 2 + 2):
        j = i + d
        k = j + d
        if j >= N or k >= N:
            continue
        # print('i, j, k', i, j, k)
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]):
            condition2 += 1
ans = condition1 - condition2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S = list(input())
c = Counter(S)
# print('c', c)

if len(c) != 3:
    print(0)
    exit()

con1 = 1
for v in c.values():
    con1 *= v

not_con2 = 0
for d in range(3001):
    for i in range(3001):
        j = i + d
        k = j + d
        if N - 1 < k:
            continue
        # print('S', S[i], S[j], S[k], i, j, k)
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            not_con2 += 1

# print('not_con2', not_con2)
ans = con1 - not_con2
print(ans)


Fixed submission:
N = int(input())
S = list(input())

if len(S) <= 3:
    print(0)
    exit()

sorted_S = sorted(S)
c = [0, 0, 0]
j = 0
for i in range(len(sorted_S) - 1):
    if sorted_S[i] != sorted_S[i + 1]:
        if j == 0:
            c[j] = i + 1
            j += 1
        else:
            c[j] = (i + 1) - c[j - 1]
            j += 1

# print('c', c, j)
if j != 2:
    print(0)
    exit()
c[2] = N - c[0] - c[1]

condition1 = c[0] * c[1] * c[2]
# print('condition1', condition1)

condition2 = 0
for i in range(N):
    for d in range(N // 2 + 2):
        j = i + d
        k = j + d
        if j >= N or k >= N:
            continue
        # print('i, j, k', i, j, k)
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]):
            condition2 += 1
ans = condition1 - condition2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N = int(input())

alphabets = list('abcdefghijklmn')[:10]
for i in product(
        alphabets[:1],
        alphabets[:2],
        alphabets[:3],
        alphabets[:4],
        alphabets[:5],
        alphabets[:6],
        alphabets[:7],
        alphabets[:8],
        alphabets[:9],
        alphabets[:10],
):
    print(''.join(i))


Fixed submission:
N = int(input())

alphabets = list('Zabcdefghijklmn')
s = ['a']
ss = []
for i in range(2, N + 1):
    subset = alphabets[1:i + 1]
    for j in range(len(s)):
        for k in subset:
            ss.append(s[j] + k)
            if s[j].find(k) == -1:
                break
    # print('s, ss', s, ss)
    s = ss
    ss = []
print(*s, sep='\n')
# for i in s:
#     print(i)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc154/tasks/abc154_d
import numpy as np
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

v = 0
idx = -1
for i in range(N):
    tmp = p[i:i + K].sum()
    if tmp > v:
        v = tmp
        idx = i

# print('v idx', v, idx)
subset = p[idx:idx + K]
ans = ((subset + 1) / 2).sum()
print(ans)


Fixed submission:
# https://atcoder.jp/contests/abc154/tasks/abc154_d
import numpy as np
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
p = (p + 1) / 2
cumsum = np.cumsum(np.array(p))
tmp = np.pad(cumsum[:-K], [K, 0], 'constant')
print((cumsum - tmp).max())
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))


def f(l):
    left = 0
    right = i + 1
    while left + 1 < right:
        x = (left + right) // 2
        if test(x):
            left = x
        else:
            right = x


ans = 1
for i in range(1, N):
    tmp = sorted(P[:i])
    if tmp[0] >= P[i]:
        ans += 1
print(ans)


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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)

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

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


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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)

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

ans = 0
for i in range(N):
    for j in range(i):
        if P[j] < P[i]:
            break
    else:
        ans += 1
print(ans)


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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
P = np.array(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i):
        if P[j] < P[i]:
            break
    else:
        ans += 1
print(ans)


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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
P = np.array(list(map(int, input().split())))

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


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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = np.array(list(input()))

i = 0
minus = 0
for i in np.arange(K):
    arr = T[np.arange(i, N, K)]
    c = 1
    for j in np.arange(arr.shape[0] - 1):
        if arr[j] == arr[j + 1]:
            c += 1
        else:
            if c >= 2:
                if arr[j] == 'r':
                    score = P
                elif arr[j] == 's':
                    score = R
                else:
                    score = S
                minus += c // 2 * score
            c = 1
    else:
        if c >= 2:
            if arr[j] == 'r':
                score = P
            elif arr[j] == 's':
                score = R
            else:
                score = S
            minus += c // 2 * score

u, counts = np.unique(T, return_counts=True)

max_score = 0
for i, j in zip(u, counts):
    if i == 'r':
        max_score += P * j
    elif i == 's':
        max_score += R * j
    else:
        max_score += S * j
print(max_score - minus)


Fixed submission:
import numpy as np
from collections import Counter

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = np.array(list(input()))

i = 0
minus = 0
for i in np.arange(K):
    arr = T[np.arange(i, N, K)]
    c = 1
    for j in np.arange(arr.shape[0] - 1):
        if arr[j] == arr[j + 1]:
            c += 1
        else:
            if c >= 2:
                if arr[j] == 'r':
                    score = P
                elif arr[j] == 's':
                    score = R
                else:
                    score = S
                minus += c // 2 * score
            c = 1
    else:
        if c >= 2:
            if arr[j] == 'r':
                score = P
            elif arr[j] == 's':
                score = R
            else:
                score = S
            minus += c // 2 * score

counter = Counter(T)


max_score = 0
for i, j in counter.items():
    if i == 'r':
        max_score += P * j
    elif i == 's':
        max_score += R * j
    else:
        max_score += S * j
print(max_score - minus)
Buggy python submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())
if A1 + A2 + A3 >= 22:
  print('bust')
else;
  print('win')


Fixed submission:
a1, a2, a3 = map(int, input().split())
if a1 + a2 + a3 >= 22:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    # s = ''.join(s)
    S.append(s)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(10):
            a = S[i]
            b = S[j]
            if a[k] != b[k]:
                break
        else:
            ans += 1
print(ans)


Fixed submission:
from itertools import combinations
import sys

N = int(input())
A = [[] for _ in range(N + 1)]
B = [[] for _ in range(N + 1)]
C = [[] for _ in range(N + 1)]
num_hint = []
# hint_dict = {}
for i in range(1, N + 1):
    num_i = int(input())
    num_hint.append(num_i)
    for j in range(num_i):
        x, y = map(int, input().split())
        A[i].append((x, y))
        if y == 1:
            B[i].append(x)
        if y == 0:
            C[i].append(x)
        # if hint_dict.get(x) is None:
        #     hint_dict[x] = {0: [], 1: []}
        #     hint_dict[x][y].append(i)
        # else:
        #     hint_dict[x][y].append(i)

for i in range(N + 1, 0, -1):
    for combi in combinations(range(1, N + 1), i):
        remain = set(range(1, N + 1)) - set(combi)
        s = set()
        t = set()
        hint_dict = {}
        for j in combi:
            s |= set(B[j])
            t |= set(C[j])
            for x, y in A[j]:
                if hint_dict.get(x) is None:
                    hint_dict[x] = {0: [], 1: []}
                    hint_dict[x][y].append(i)
                else:
                    hint_dict[x][y].append(i)
        good1 = True
        for value in hint_dict.values():
            if len(value[0]) != 0 and len(value[1]) != 0:
                good1 = False
                break
        good2 = True
        if len(s & remain) != 0:
            good2 = False
        good3 = True
        if len(t & set(combi)) != 0:
            good3 = False
        if good1 and good2 and good3:
            print(i)
            sys.exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(0, N - 1):
    for j in range(i + 1, N):
        # print(bin(A[i] ^ A[j]))
        # ans += int(bin(A[i] ^ A[j]), 0)
        ans += A[i] ^ A[j]
        ans %= mod
print(ans)


Fixed submission:
import sys
import numpy as np

input = sys.stdin.buffer.readline
N = int(input())
A = np.array(list(map(int, input().split())))

MOD = 10**9 + 7

answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x = x * 2 % MOD
    answer += x
answer %= MOD
print(answer)

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

mod = 10**9 + 7

ans = 0
for i in range(0, N - 1):
    for j in range(i + 1, N):
        # print(bin(A[i] ^ A[j]))
        ans += int(bin(A[i] ^ A[j]), 0)
        ans %= mod
print(ans)


Fixed submission:
import sys
import numpy as np

input = sys.stdin.buffer.readline
N = int(input())
A = np.array(list(map(int, input().split())))

MOD = 10**9 + 7

answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x = x * 2 % MOD
    answer += x
answer %= MOD
print(answer)

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

mod = 10**9 + 7

ans = 0
for i in range(0, N - 1):
    for j in range(i + 1, N):
        # print(bin(A[i] ^ A[j]))
        ans += int(bin(A[i] ^ A[j]), 0)
        ans %= mod
print(ans)


Fixed submission:
import sys
import numpy as np

input = sys.stdin.buffer.readline
N = int(input())
A = np.array(list(map(int, input().split())))

MOD = 10**9 + 7

answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x = x * 2 % MOD
    answer += x
answer %= MOD
print(answer)