Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mov = []
for i in range(5):
    mov.append(int(input()))
mov.reverse()

status = [0 for i in range(6)]
status[0] = n
status.reverse()

# print(mov)
# print(status)

count = 0
while True:
    count += 1
    for i in range(1,len(status)):
        status[i-1] += min(status[i],mov[i-1])
        status[i] -= min(status[i],mov[i-1])
    if status[0]==n:
        print(count)
        exit()
    elif status[-1]==0:
        status.pop(-1)
        mov.pop(-1)


Fixed submission:
import math

n = int(input())
mov = []
for i in range(5):
    mov.append(int(input()))

print(math.ceil(n/min(mov))+4)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mov = []
for i in range(5):
    mov.append(int(input()))
mov.reverse()

status = [0 for i in range(6)]
status[0] = n
status.reverse()

# print(mov)
# print(status)

count = 0
while True:
    count += 1
    for i in range(1,6):
        status[i-1] += min(status[i],mov[i-1])
        status[i] -= min(status[i],mov[i-1])
    if status[0]==n:
        print(count)
        exit()


Fixed submission:
import math

n = int(input())
mov = []
for i in range(5):
    mov.append(int(input()))

print(math.ceil(n/min(mov))+4)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
lst = [[] for _ in range(n)]
ly = [[] for _ in range(m)]
for i in range(m):
    p,y = map(int, input().split())
    ly[i] = (p,y)
    lst[p-1].append(y)
for i in range(n):
    lst[i].sort()

# print(ly)
# print(lst)

for i in ly:
    num = lst[i[0]-1].index(i[1])+1
    print(str(i[0]).zfill(6) + str(num).zfill(6))


Fixed submission:
n,m = map(int, input().split())
lst = [[] for _ in range(n)]

for i in range(m):
    p,y = map(int, input().split())
    lst[p-1].append((y,i))

ans = [None]*m

for i,d in enumerate(lst):
    d.sort()
    for j, (Y,I) in enumerate(d):
        ans[I] = str(i+1).zfill(6) + str(j+1).zfill(6)

for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if all(s[i]=="1" for i in range(min(len(s),k))):
    print(1)
else:
    while s[0]=="1":
        s.pop(0)
    print(s[0])


Fixed submission:
s = input()
k = int(input())

if all(s[i]=="1" for i in range(min(len(s),k))):
    print(1)
else:
    while s[0]=="1":
        s = s[1:]
    print(s[0])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if len(s)>k and all(s[i]=="1" for i in range(k)):
    print(1)
else:
    while s[0]=="1":
        s.pop(0)
    print(s[0])


Fixed submission:
s = input()
k = int(input())

if all(s[i]=="1" for i in range(min(len(s),k))):
    print(1)
else:
    while s[0]=="1":
        s = s[1:]
    print(s[0])
Buggy python submission (verdict: Runtime Error):
from collections import deque
h,w = map(int, input().split())
map = [list(input()) for _ in range(h)]
dis = [[float("inf")]*w for _ in range(h)]
dy = [1,0,-1,0]
dx = [0,1,0,-1]
que = deque([])
que.append((0,0))
dis[0][0]=1
count = 0

for num in range(h*w):
    p = que.popleft()
    if p[0]==h-1 and p[1]==w-1:
        break
    for i in range(4):
        ny = p[0] + dy[i]
        nx = p[1] + dx[i]
        if 0<=ny<h and 0<=nx<w and map[ny][nx]!="#" \
           and dis[ny][nx]==float("inf"):
            que.append((ny,nx))
            dis[ny][nx]=dis[p[0]][p[1]]+1

for i in range(h):
    for j in range(w):
        if map[i][j]=="#":
            count+=1

print(h*w-dis[h-1][w-1]-count if dis[h-1][w-1]!=float("inf") else -1)


Fixed submission:
from collections import deque
h,w = map(int, input().split())
map = [list(input()) for _ in range(h)]
dis = [[float("inf")]*w for _ in range(h)]
dy = [1,0,-1,0]
dx = [0,1,0,-1]
que = deque([])
que.append((0,0))
dis[0][0]=1
count = 0
for i in range(h):
    for j in range(w):
        if map[i][j]=="#":
            count+=1

while que:
    p = que.popleft()
    if p[0]==h-1 and p[1]==w-1:
        break
    for i in range(4):
        ny = p[0] + dy[i]
        nx = p[1] + dx[i]
        if 0<=ny<h and 0<=nx<w and map[ny][nx]!="#" \
           and dis[ny][nx]==float("inf"):
            que.append((ny,nx))
            dis[ny][nx]=dis[p[0]][p[1]]+1

print(h*w-dis[h-1][w-1]-count if dis[h-1][w-1]!=float("inf") else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int, input().split()))
lsta = []
lstb = []

for i in range(m):
    a,b = list(map(int, input().split()))
    if a==1:
        lsta.append(b)
    if b==n:
        lstb.append(a)

for i in lsta:
    if i in lstb:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Fixed submission:
n,m = list(map(int, input().split()))
lsta = [0 for i in range(n+1)]
lstb = [0 for i in range(n+1)]

for i in range(m):
    a,b = list(map(int, input().split()))
    if a==1:
        lsta[b]=1
    if b==n:
        lstb[a]=1

for i in range(n+1):
    if lsta[i]==1 and lstb[i]==1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
    return val

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print(factorial(max(m,n))**2//max(m,n)%mod)
else:
    print(factorial(n)**2*2%mod)


Fixed submission:
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= mod
    return val

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    num = factorial(min(m,n))
    print(num**2*max(m,n)%mod)
else:
    num = factorial(m)
    print(num**2*2%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
    return val

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print(factorial(n)*factorial(m)%mod)
else:
    print(factorial(n)*factorial(m)*2%mod)


Fixed submission:
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= mod
    return val

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    num = factorial(min(m,n))
    print(num**2*max(m,n)%mod)
else:
    num = factorial(m)
    print(num**2*2%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
lst = []

for i in range(n):
    a,b = list(map(int, input().split()))
    lst += [a for i in range(b)]
# print(lst)
lst.sort()
print(lst[k-1])

Fixed submission:
n,k = list(map(int, input().split()))
lst = [None for i in range(n)]

for i in range(n):
    a,b = list(map(int, input().split()))
    lst[i] = (a,b)

# print(lst)
lst.sort(key=lambda x:x[0])
# print(lst)

count = 0
for i in range(n):
    count += lst[i][1]
    if count>=k:
        print(lst[i][0])
        exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in reversed(range(int(n**0.5))):
    if n%i==0:
        print(max(len(str(i)), len(str(n//i))))
        exit()


Fixed submission:
n = int(input())
for i in reversed(range(int(n**0.5)+1)):
    if n%i==0:
        print(max(len(str(i)), len(str(n//i))))
        exit()

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

n = int(input())
for i in reversed(range(math.ceil(n**0.5))):
    if n%i==0:
        print(max(len(str(i)), len(str(n//i))))
        exit()


Fixed submission:
n = int(input())
for i in reversed(range(int(n**0.5)+1)):
    if n%i==0:
        print(max(len(str(i)), len(str(n//i))))
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 10**9 + 7
pow = 1
for i in range(n):
    pow *= i+1
print(pow % a)


Fixed submission:
import math
n = int(input())
print(math.factorial(n)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
import itertools

n,m = map(int, input().split())
path = [[False]*n for _ in range(n)]
for i in range(n):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b]=True
    path[b][a]=True

ans = 0

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break

print(ans)


Fixed submission:
import itertools

n, m = map(int, input().split())
path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True
ans = 0

for i in itertools.permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j + 1]]:
                break

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
mod = 10**9+7

def eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

era = eratosthenes(n)

dict = {}
for i in range(n):
    num = i+1
    while num!=1:
        for j in era:
            while num%j==0:
                num/=j
                if j in dict:
                    dict[j]+=1
                else:
                    dict[j]=1

ans = 1
for i in dict:
    ans = ans*(dict[i]+1)%mod

print(ans)


Fixed submission:
import math

n = int(input())
mod = 10**9+7

def eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

if n==1:
    print(1)
    exit()

era = eratosthenes(n)

dict = {}
for i in range(n):
    num = i+1
    while num!=1:
        for j in era:
            while num%j==0:
                num/=j
                if j in dict:
                    dict[j]+=1
                else:
                    dict[j]=1

ans = 1
for i in dict:
    ans = ans*(dict[i]+1)%mod

print(ans)
Buggy python submission (verdict: Runtime Error):
N = str(input())
if N[2] == 3:
  print("bon")
elif N[2] == 0 or N[2] == 1 or N[2] == 6 or N[2] == 8:
  print("pon")
else:
  print("hon")

Fixed submission:
N = input()
if N[-1] == "3":
  print("bon")
elif N[-1] == "0":
  print("pon")
elif N[-1] == "1":
  print("pon")
elif N[-1] == "6":
  print("pon")
elif N[-1] == "8":
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

for x in range(0,101):
  calc_a = int(x*0.08)
  calc_b = int(x*0.10)
  if calc_a == a and calc_b == b:
    ans = x
    print(ans)
    break
if ans == -1:
  print(ans)

Fixed submission:
import math
import sys

A, B = list(map(int, input().split()))
for i in range(1001):
  priceA = math.floor(i*1.08)
  priceB = math.floor(i*1.10)
  taxA = priceA - i 
  taxB = priceB - i 
  if taxA == A and taxB == B:
    print(i)
    sys.exit()
print("-1")
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
tmp = 0
ans = []

for i in range(X[0],1+X[N-1]):
  for j in range(N):
    tmp = tmp + (X[j]-i)**2
  ans.append(tmp)
  tmp = 0
print(min(ans))

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
ans = []
tmp = 0

for i in range(min(X), 1+max(X)):
  for j in range(N):
    tmp += (X[j]-i)**2 
  ans.append(tmp)
  tmp = 0  
print(min(ans))
Buggy python submission (verdict: Runtime Error):
S = str(input())
N = int(input())
ans = []
tmp = 0

for i in range(0,len(S)):
  tmp = N+ord(S[i])
  if tmp >= 91:
    tmp = tmp - 26
  ans.append(chr(tmp))

print("".join(ans)) 

Fixed submission:
N = int(input())
S = str(input())
ans = []
tmp = 0

for i in range(0,len(S)):
  tmp = N+ord(S[i])
  if tmp >= 91:
    tmp = tmp - 26
  ans.append(chr(tmp))

print("".join(ans))
Buggy python submission (verdict: Runtime Error):
N = input()
D = map(int, raw_input().split())

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  else:
  lop=lop+1
print (cnt)

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

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  lop=lop+1
print (cnt)
Buggy python submission (verdict: Runtime Error):
cnt = []
tmp = 0

b = str(input())
for i in range(0,len(b)):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    tmp=tmp+1
  else:
    cnt.append(tmp)
    tmp=0
print(max(cnt))

Fixed submission:
S = str(input())

cnt = 0
ans = [0]

for i in range(0, len(S)):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    cnt = cnt + 1
    ans.append(cnt)
  else:
    cnt = 0
print(max(ans))
Buggy python submission (verdict: Runtime Error):
r, g, b= list(map(int, input().split())
if (r+g+B)%4 == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
r, g, b= list(map(int, input().split()))

if (100*r+10*g+b)%4 == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
 = int(input())
S = str(input())
cnt = 0

ans = []
for i in range(0,N):
  if S[i] == "I":
    cnt = cnt+1
  elif S[i] == "D":
    cnt = cnt-1
  ans.append(cnt)

if max(ans) <= 0:
  print("0")
else:
  print(max(ans))

Fixed submission:
N = int(input())
S = str(input())
cnt = 0

ans = []
for i in range(0,N):
  if S[i] == "I":
    cnt = cnt+1
  elif S[i] == "D":
    cnt = cnt-1
  ans.append(cnt)

if max(ans) <= 0:
  print("0")
else:
  print(max(ans))
Buggy python submission (verdict: Runtime Error):
import sys

w = str(input())
arr = []

for i in range(0,len(w)):
  arr.append(w[i])
arr = sorted(arr)

for i in range(0,len(w),2):
  if arr[i] != arr[i+1]:
    print("No")
    sys.exit()
print("Yes")

Fixed submission:
import sys

w = str(input())
arr = []

for i in range(0,len(w)):
  arr.append(w[i])
arr = sorted(arr)

if len(arr)%2 == 1:
  print("No")
  sys.exit()

for i in range(0,len(w),2):
  if arr[i] != arr[i+1]:
    print("No")
    sys.exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
N=int(input())
return N%1000

Fixed submission:
N=int(input())
if N%1000==0:
    print(0)
else:
    print((N//1000+1)*1000-N)
Buggy python submission (verdict: Runtime Error):
A=input().split()
S=A[0]
T=A[1]
s=[]
t=[]
for c in S:
    s.append(c)
for c in T:
    t.append(c)

v=1
for i in range(len(s)):
    if not s[i]==t[i]:
        v=0
if v==1:
    print("Yes")
else:
    print("No")

Fixed submission:
A=[input() for i in range(2)]
S=A[0]
T=A[1]
s=[]
t=[]
for c in S:
    s.append(c)
for c in T:
    t.append(c)

v=1
for i in range(len(s)):
    if not s[i]==t[i]:
        v=0
if v==1:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
OK=[]
S,T=input().split()
s=[]
t=[]
for c in S:
    s.append(c)
for c in T:
    t.append(c)

v=1
for i in range(len(s)):
    if s[i]!=t[i]:
        v=0
if v==1:
    print("Yes")
else:
    print("No")

Fixed submission:
A=[input() for i in range(2)]
S=A[0]
T=A[1]
s=[]
t=[]
for c in S:
    s.append(c)
for c in T:
    t.append(c)

v=1
for i in range(len(s)):
    if not s[i]==t[i]:
        v=0
if v==1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):

s,w=map(int,input().split())


if s>w:
    print(safe)
else:
    print(unsafe)

Fixed submission:

s,w=map(int,input().split())


if s>w:
    print("safe")
else:
    print("unsafe")

Buggy python submission (verdict: Runtime Error):

s,w=map(int,input.split())


if s>w:
    print(safe)
else:
    print(unsafe)

Fixed submission:

s,w=map(int,input().split())


if s>w:
    print("safe")
else:
    print("unsafe")

Buggy python submission (verdict: Runtime Error):

A=list(map(int,input.split()))
s=A[0]
w=A[1]

if s>w:
    print(safe)
else:
    print(unsafe)

Fixed submission:

s,w=map(int,input().split())


if s>w:
    print("safe")
else:
    print("unsafe")

Buggy python submission (verdict: Runtime Error):
A=list(map(int,input.split()))
s=A[0]
w=A[1]

if s>w:
    return safe
else:
    return unsafe

Fixed submission:

s,w=map(int,input().split())


if s>w:
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Runtime Error):
S=input().split()
N=S[0]
N=int(N)
del S[0]
M=S[0]
M=int(M)
del S[0]
s=0
for i in range(M):
    s=s+int(S[i])
if s>N:
    print(-1)
else:
    print(N-s)


Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
sum=0
for i in range(m):
  sum+=l[i]
if sum>n:
  print(-1)
else:
  print(n-sum)

Buggy python submission (verdict: Runtime Error):
S=input().split()
N=S[0]
N=int(N)
del S[0]
M=S[0]
M=int(M)
del S[0]
s=0
for i in range(M):
    s=s+int(S[i])
if s>N:
    print(-1)
else:
    print(N-s)


Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
sum=0
for i in range(m):
  sum+=l[i]
if sum>n:
  print(-1)
else:
  print(n-sum)
Buggy python submission (verdict: Runtime Error):
A=input().split()
N=int(A[0])
del A[0]
B=[]
for i in range(N):
    B.append(0)
for i in range(N-1):
    B[int(A[i])-1]+=1
for i in range(N):
    print(B[i])

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(0)
for i in range(n-1):
  a[l[i]-1]+=1
for i in range(n):
  print(a[i])

Buggy python submission (verdict: Runtime Error):
A=input().split()
N=int(A[0])
del A[0]
B=[]
for i in range(N):
    B.append(0)
for i in range(N-1):
    B[int(A[i])-1]+=1
print(B)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(0)
for i in range(n-1):
  a[l[i]-1]+=1
for i in range(n):
  print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
def gcd(a,b,c):
    s=math.gcd(a,b)
    s=math.gcd(s,c)
    return s
t=0
for a in range(K):
    for b in range(K):
        for c in range(K):
            t+=gcd(a+1,b+1,c+1)
print(t)

Fixed submission:
import math
K=int(input())
def gcd(a,b,c):
    s=math.gcd(a,b)
    s=math.gcd(s,c)
    return s
t=0
for a in range(K):
    for b in range(K):
        s=math.gcd(a+1,b+1)
        for c in range(K):
            t+=math.gcd(c+1,s)
print(t)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = list(map(int, input().split(' ')))
print((a * b)//gcd(a, b))

Fixed submission:
from fractions import gcd
a, b = list(map(int, input().split(' ')))
print((a * b)//gcd(a, b))
Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    for idx, val in enumerate(range(maxi)):
        ones[idx] += (num >> idx ) & 1

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

print(ans)

Fixed submission:
x = sum(list(map(int, input().split(' '))))
if x >= 22:
  print('bust')
else:
  print('win')

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    x = bin(num)[2:]
    # print(x)
    for idx, val in enumerate(reversed(x)):
        ones[idx] += int(val)

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

print(ans)

Fixed submission:
x = sum(list(map(int, input().split(' '))))
if x >= 22:
  print('bust')
else:
  print('win')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    x = bin(num)[2:]
    # print(x)
    for idx, val in enumerate(reversed(x)):
        ones[idx] += int(val)

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

print(ans)

Fixed submission:
import sys
lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    for idx, val in enumerate(range(maxi)):
        ones[idx] += (num >> idx ) & 1

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    x = bin(num)[2:]
    # print(x)
    for idx, val in enumerate(reversed(x)):
        ones[idx] += int(val)

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

print(ans)

Fixed submission:
import sys
lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split(' ')))

maxi = 62
mod = int(1e9) + 7
ones = [0 for _ in range(maxi)]
for num in arr:
    for idx, val in enumerate(range(maxi)):
        ones[idx] += (num >> idx ) & 1

ans = 0
for idx, val in enumerate(ones):
    ans += ((pow(2, idx) % mod) * (((n - val)%mod) * (val%mod))) % mod

    ans %= mod

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

n = int(input())
num = list(map(int, input().split(' ')))

def find_max(idx):
    
    prev_gcd = gcd(num[idx[0]], num[idx[1]])
    curr_excluded_num = None
    curr_gcd = None

    for i in range(n):
        if i == idx[0] or i == idx[1]:
            continue
        
        curr_gcd = gcd(prev_gcd, num[i])
        if curr_gcd == prev_gcd:
            continue
        else:
            if curr_excluded_num is None:
                curr_excluded_num = num[i]
            else:
                if curr_gcd > gcd(prev_gcd, curr_excluded_num):
                    prev_gcd = curr_gcd
                else:
                    prev_gcd = gcd(prev_gcd, curr_excluded_num)
                    curr_excluded_num = num[i]

    
    return prev_gcd



if n == 2:
    print(max(num[0], num[1]))
elif n == 3:
    a = gcd(num[0], num[1])
    b = gcd(num[0], num[2])
    c = gcd(num[2], num[1])
    print(max(max(a, b), c))

else:
    ans = find_max((0, 1))
    ans = max(find_max((2, 3)), ans)
    print(ans)




Fixed submission:
from fractions import gcd

n = int(input())
num = list(map(int, input().split(' ')))

def find_max(idx):
    
    prev_gcd = gcd(num[idx[0]], num[idx[1]])
    curr_excluded_num = None

    for i in range(n):
        if i == idx[0] or i == idx[1]:
            continue
        
        curr_gcd = gcd(prev_gcd, num[i])
        if curr_gcd == prev_gcd:
            continue
        else:
            if curr_excluded_num is None:
                curr_excluded_num = num[i]
            else:
                if curr_gcd > gcd(prev_gcd, curr_excluded_num):
                    prev_gcd = curr_gcd
                else:
                    prev_gcd = gcd(prev_gcd, curr_excluded_num)
                    curr_excluded_num = num[i]

    
    return prev_gcd



if n == 2:
    print(max(num[0], num[1]))
elif n == 3:
    a = gcd(num[0], num[1])
    b = gcd(num[0], num[2])
    c = gcd(num[2], num[1])
    print(max(max(a, b), c))

else:
    ans = find_max((0, 1))
    ans = max(find_max((2, 3)), ans)
    print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
arr = sorted(list(map(int, input().split(' '))))
maxi = arr[-1]
gc = maxi
for num in arr[:-1]:
    if gcd(num, maxi) < gc:
        gc = gcd(num, maxi)

print(gc)

Fixed submission:
def gcd(a, b):
    return gcd(b % a, a) if a and b else max(a, b)
    
n = int(input())
arr = sorted(list(map(int, input().split(' '))))
maxi = arr[-1]
gc = maxi
for num in arr[:-1]:
    if gcd(num, maxi) < gc:
        gc = gcd(num, maxi)

print(gc)