Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
sys.setrecursionlimit(100000)

def dfs(i, g, visited):
  visited.add(i)
  for j in g[i]:
    if not (j in visited):
      dfs(j, g, visited)

def main():
  n, m = map(int, input().split())
  p = (list(map(int, input().split())))
  g = [[] for i in range(n + 1)]
  for i in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
  seen = [False for i in range(n + 1)]
  ans = 0
  for i in range(1, n):
    if not seen[i]:
      visited = set()
      dfs(i, g, visited)
      for j in visited:
        seen[j] = True
        if p[j - 1] in visited:
          ans += 1
  print(ans)

if __name__ == "__main__":
  main()

Fixed submission:
import sys
sys.setrecursionlimit(100000)

def dfs(i, g, visited):
  visited.add(i)
  for j in g[i]:
    if not (j in visited):
      dfs(j, g, visited)

def main():
  n, m = map(int, input().split())
  p = (list(map(int, input().split())))
  g = [[] for i in range(n + 1)]
  for i in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
  seen = [False for i in range(n + 1)]
  ans = 0
  for i in range(1, n):
    if not seen[i]:
      visited = set()
      dfs(i, g, visited)
      for j in visited:
        seen[j] = True
        if p[j - 1] in visited:
          ans += 1
  print(ans)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
def dfs(i, g, visited):
  visited.add(i)
  for j in g[i]:
    if not (j in visited):
      dfs(j, g, visited)

def main():
  n, m = map(int, input().split())
  p = (list(map(int, input().split())))
  g = [[] for i in range(n + 1)]
  for i in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
  seen = [False for i in range(n + 1)]
  ans = 0
  for i in range(1, n):
    if not seen[i]:
      visited = set()
      dfs(i, g, visited)
      for j in visited:
        seen[j] = True
        if p[j - 1] in visited:
          ans += 1
  print(ans)

if __name__ == "__main__":
  main()

Fixed submission:
import sys
sys.setrecursionlimit(100000)

def dfs(i, g, visited):
  visited.add(i)
  for j in g[i]:
    if not (j in visited):
      dfs(j, g, visited)

def main():
  n, m = map(int, input().split())
  p = (list(map(int, input().split())))
  g = [[] for i in range(n + 1)]
  for i in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
  seen = [False for i in range(n + 1)]
  ans = 0
  for i in range(1, n):
    if not seen[i]:
      visited = set()
      dfs(i, g, visited)
      for j in visited:
        seen[j] = True
        if p[j - 1] in visited:
          ans += 1
  print(ans)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
m = 1
for i in range(k):
	m *= a[i]
tmp = m
for i in range(k, n):
	m *= a[i]
	m //= a[i - k]
	if m > tmp:
		print('Yes')
	else:
		print('No')
	tmp = m


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
	if a[i] > a[i - k]:
		print('Yes')
	else:
		print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
m = 1
for i in range(k):
	m *= a[i]
tmp = m
for i in range(k, n):
	m *= a[i]
	m //= a[i - k]
	if m > tmp:
		print('Yes')
	else:
		print('No')
	tmp = m


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
	if a[i] > a[i - k]:
		print('Yes')
	else:
		print('No')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
a = float(a)
b = float(b)
for i in range(-7000, 7000):
	if float(i) * 0.08 == a and float(i) * 0.1 == b:
		print(i)
		exit(0)
print(-1)


Fixed submission:
a = input()
print('Yes' if 'A' in a and 'B' in a else 'No')
Buggy python submission (verdict: Runtime Error):
a = input.split()
print(a[1] + a[0])

Fixed submission:
a = input().split()
print(a[1] + a[0])

Buggy python submission (verdict: Runtime Error):
a = input.split()
print(''.join(a))

Fixed submission:
a = input().split()
print(a[1] + a[0])
Buggy python submission (verdict: Runtime Error):
from unittest import TestCase, main
from A import func

class test(TestCase):
  def test_with_valid_params(self):
    test_patterns = [
      ("apple","apples"),
      ("bus","buses"),
      ("box","boxs")
    ]

    for S,result in test_patterns:
      with self.subTest(S=S):
        self.assertEqual(func(S),result)

if __name__ == "__main__":
  main()

Fixed submission:
def func(S):
  if S[-1] == "s":
    return S+"es"
  else:
    return S+"s"


if __name__ == "__main__":
    S = input()
    print(func(S))
Buggy python submission (verdict: Runtime Error):
def func(D):
  comb = 0
  for item in D:
    if item[0]==item[1]:
      comb+=1
    else:
      comb=0
    
    if comb==3:
      return "Yes"  
  return "No"

if __name__ == "__main__":
    N = int(input())
    D = [map(int, input().split()) for _ in range(N)]
    print(func(D))

Fixed submission:
def func(D):
  comb = 0
  for item in D:
    if item[0]==item[1]:
      comb+=1
    else:
      comb=0
    
    if comb==3:
      return "Yes"  
  return "No"

if __name__ == "__main__":
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    print(func(D))
Buggy python submission (verdict: Time Limit Exceeded):
def func(N,A):
  result = 0
  for i in range(0,N-1,1):
    for j in range(i+1,N,1):
      result += (A[i] * A[j])
  return result % (10 ** 9 + 7)

if __name__ == "__main__":
  N = int(input())
  A = list(map(int, input().split()))
  print(func(N,A))

Fixed submission:
MOD = 10 ** 9 + 7

def func(N,A):
  result = 0
  S = sum(A) % MOD
  for x in A:
    S -= x
    S %= MOD
    result += x * S
    result %= MOD
  result %= MOD
  return result

if __name__ == "__main__":
  N = int(input())
  A = list(map(int, input().split()))
  print(func(N,A))
Buggy python submission (verdict: Runtime Error):
def func(A):
  result = 0
  min = 0
  for a in A:
    if a < min:
      result += min - a
    else:
      min = a
  return result

if __name__ == "__main__":
    N = int(input())
    A = list(int,input().split())
    print(func(A))

Fixed submission:
def func(A):
  result = 0
  min = 0
  for a in A:
    if a < min:
      result += min - a
    else:
      min = a
  return result

if __name__ == "__main__":
    N = int(input())
    A = list(map(int,input().split()))
    print(func(A))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()


def main():
    H,W,m=map(int, input().split())
    Hline=[]
    wline=[]
    blist=[]
    for k in range(m):
        h,w=map(int, input().split())
        Hline.append(h)
        wline.append(w)
        blist.append([h,w])
    hc=Counter(Hline).most_common()
    wc=Counter(wline).most_common()
    ans=hc[0][1]+wc[0][1]
    hl=[]
    wl=[]
    for hcc in hc:
        if hcc[1]!= hc[0][1]:
            break
        hl.append(hcc[0])
    for wcc in wc:
        if wcc[1]!= wc[0][1]:
            break
        wl.append(wcc[0])
    for hll in hl:
        for wll in wl:
            if [hll,wll] not in blist:
                print(ans)
                exit()
    print(ans-1)

    
        



if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()


def main():
    H,W,m=map(int, input().split())
    Hline=[]
    wline=[]
    blist=dict()
    for k in range(m):
        h,w=map(int, input().split())
        Hline.append(h)
        wline.append(w)
        blist[h*(W+2)+w]=0
    hc=Counter(Hline).most_common()
    wc=Counter(wline).most_common()
    ans=hc[0][1]+wc[0][1]
    hl=[]
    wl=[]
    for hcc in hc:
        if hcc[1]!= hc[0][1]:
            break
        hl.append(hcc[0])
    for wcc in wc:
        if wcc[1]!= wc[0][1]:
            break
        wl.append(wcc[0])
    for hll in hl:
        for wll in wl:
            if hll*(W+2)+wll not in blist:
                print(ans)
                exit()
    print(ans-1)

    
        



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=input()

xre = x[::-1]

cou = x.count('1')
basepl = int(x, 2) % (cou+1)
basemi = int(x, 2) % (cou-1)

li = [0]*n
pl = 1
mi = 1
for i in range(n):
    if xre[i] == '0':
        li[i] = (basepl + pl)  % (cou+1)
    else:
        li[i] = (basepl + mi)  % (cou-1)
    mi = (mi * 2)% (cou-1)
    pl = (pl * 2)% (cou+1)

def f(n):
    m = n
    k = 1
    while m > 0:
        co = str(bin(m)).count('1')
        m = m % co
        k +=1
    return k

for x in li[::-1]:
    print(f(x))


Fixed submission:
n=int(input())
x=input()

xre = x[::-1]

cou = x.count('1')

if cou == 0:
    for _ in range(n):
        print(1)
    exit()

if cou == 1:
    for i in range(n):
        if i == n-1 and x[i] == '0':
            print(2)
        elif  x[i] == '0' and x[n-1] == '1':
            print(2)
        elif  x[i] == '0' and x[n-1] == '0':
            print(1)
        else:
            print(0)
    exit()

basepl = int(x, 2) % (cou+1)
basemi = int(x, 2) % (cou-1)

li = [0]*n
pl = 1
mi = 1


for i in range(n):
    if xre[i] == '0':
        li[i] = (basepl + pl)  % (cou+1)
    else:
        li[i] = (basemi - mi)  % (cou-1)
    mi = (mi * 2) % (cou-1)
    pl = (pl * 2) % (cou+1)

def f(n):
    m = n
    k = 1
    while m > 0:
        co = str(bin(m)).count('1')
        m = m % co
        k +=1
    return k


for x in li[::-1]:
    print(f(x))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a = list(accumulate(a))
a.insert(0,0)
b = list(accumulate(b))
b.insert(0,0)

for i in range(n+m+1):

    p = [a[s]+b[i-s] for s in range(max(0,i-m),min(i,n)+1)]
    o = min(p)
    if o > k:
        print(i-1)
        break

else:
    print(n+m)

Fixed submission:
from itertools import accumulate
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

aa = list(accumulate(a))
aa.insert(0,0)
bb = list(accumulate(b))
bb.insert(0,0)

ans = 0

for i in range(n+1):
    if aa[i] > k:
        break
    nokori = k-aa[i]
    kazu = bisect.bisect_right(bb, nokori)
    ans = max(ans,i+kazu-1)



print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

su = 0
for i in range(1,n+1):
    m = int(n/i)
    su += int(m*(2*i + (m-1)*i)/2)
    

print(su)

Fixed submission:
n=int(input())

su = 0
for i in range(1,n+1):
    m = int(n/i)
    su += int(m*(2*i + (m-1)*i)/2)
    

print(su)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(max(a))

Fixed submission:
a,b,c,d,e = map(int,input().split())

if a == 0:
    print(1)
if b == 0:
    print(2)
if c == 0:
    print(3)
if d == 0:
    print(4)
if e == 0:
    print(5)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = list(map(int, input().split()))
c = 1

if 0 in a:
    print(0)
    exit()

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)

Fixed submission:
a = int(input())
b = list(map(int, input().split()))
c = 1

if 0 in b:
    print(0)
    exit()

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = list(map(int, input().split()))
c = 1
for n in b:
    c = c*n

if c > 10**18:
    print(-1)
else:
    print(c)

Fixed submission:
a = int(input())
b = list(map(int, input().split()))
c = 1

if 0 in b:
    print(0)
    exit()

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
from math import factorial

def permutations_count(n, r):
    ''' 順列 '''
    return factorial(n) // factorial(n - r)

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))


S = input()

lis = []

for i in range(1,len(S)+1):
    lis.append(int(S[-1*i:]) % 2019)

c = collections.Counter(lis)

su = 0

for k in c:
    if c[k] > 1:
        su += combinations_count(c[k], 2)
        
        
        
su += c[0]

print(su)

Fixed submission:
import collections
from math import factorial

def permutations_count(n, r):
    ''' 順列 '''
    return factorial(n) // factorial(n - r)

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))


S = input()

lis = []
amari = 1
lis.append(int(S[-1]))

for i in range(2,len(S)+1):
    amari = (amari * 10) % 2019
    lis.append((int(S[-1*i]) * amari + lis[i-2]) % 2019)

c = collections.Counter(lis)

su = 0

for k in c:
    if c[k] > 1:
        su += combinations_count(c[k], 2)
        
        
        
su += c[0]

print(su)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
from math import factorial

def permutations_count(n, r):
    ''' 順列 '''
    return factorial(n) // factorial(n - r)

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))


S = input()

lis = []

for i in range(1,len(S)+1):
    lis.append(int(S[-1*i:]) % 2019)

c = collections.Counter(lis)

su = 0

for k in c:
    if c[k] > 1:
        su += combinations_count(c[k], 2)
        
        
        
su += c[0]

print(su)

Fixed submission:
import collections
from math import factorial

def permutations_count(n, r):
    ''' 順列 '''
    return factorial(n) // factorial(n - r)

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))


S = input()

lis = []
amari = 1
lis.append(int(S[-1]))

for i in range(2,len(S)+1):
    amari = (amari * 10) % 2019
    lis.append((int(S[-1*i]) * amari + lis[i-2]) % 2019)

c = collections.Counter(lis)

su = 0

for k in c:
    if c[k] > 1:
        su += combinations_count(c[k], 2)
        
        
        
su += c[0]

print(su)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

su = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i+1,n):
        if s[i] != s[j]:
            for lis in ['R','G','B']:
                if lis != s[i] and lis != s[j]:
                    try:
                        su -= s[2*j-i].count(lis)
                    except:
                        pass

print(su)

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

su = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i+1,n):
        if s[i] != s[j]:
            for lis in ['R','G','B']:
                if lis != s[i] and lis != s[j]:
                    try:
                        su -= s[2*j-i].count(lis)
                    except:
                        pass

print(su)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

su = 0
for i in range(n):
    for j in range(i+1,n):
        if s[i] != s[j]:
            for lis in ['R','G','B']:
                if lis != s[i] and lis != s[j]:
                   su += s[j+1:2*j-i].count(lis) + s[2*j-i+1:].count(lis)

print(su)


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

su = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i+1,n):
        if s[i] != s[j]:
            for lis in ['R','G','B']:
                if lis != s[i] and lis != s[j]:
                    try:
                        su -= s[2*j-i].count(lis)
                    except:
                        pass

print(su)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])

list.sort()
for i in list:
    print(i)

Fixed submission:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

list.sort()
for i in list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[]
for _ in range(n):
    S.append(sys.stdin.readline().rstrip())
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])

list.sort()
for i in list:
    print(i)

Fixed submission:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

list.sort()
for i in list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[]
for _ in range(n):
    S.append(sys.stdin.readline().rstrip())
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])

list.sort()
for i in list:
    print(i)

Fixed submission:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

list.sort()
for i in list:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
S=[]
for _ in range(n):
    S.append(input())
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])
list.sort()

for i in list:
    print(i)

Fixed submission:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

list.sort()
for i in list:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    h,n=map(int, input().split())
    ab=[list(map(int, input().split())) for i in range(n)]
    ans=[0]*(h+1)
    for i in range(1,h+1):
        li = [ans[max(i-j[0],0)]+j[1] for j in ab]
        ans[i]=min(li)
    print(ans[h])

if __name__=='__main__':
    main()

Fixed submission:
from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])

Fixed submission:
from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])

Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int, input().split())
ab=[list(map(int, input().split())) for i in range(n)]

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])

Fixed submission:
from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])
Buggy python submission (verdict: Runtime Error):
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b=map(int,input(),split())
print(lcm(a, b))

Fixed submission:
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b=map(int,input().split())
print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
if sum(map(int,input().split()) > 21:
       print('bust')
else:
       print('win')

Fixed submission:
a= sum(map(int,input().split()))
if a > 21:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
    print(ans%mod)
 
if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
    print(ans)
 
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x: x & 0b1,A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
        A = list(map(lambda x: x >>1,A))
    print(ans)
 
if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
    print(ans)
 
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
    print(ans)
 
if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
    print(ans)
 
if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import numpy as np
n=int(input())
l=list(map(int, input().split()))
l=np.array(l)
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(l[j+1:], l[i]+l[j]) #n未満の個数を数える
print(ans)

Fixed submission:
import bisect
n=int(input())
l=list(map(int, input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(l[j+1:], l[i]+l[j]) #n未満の個数を数える
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
l=list(map(int, input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(l[j+1:], l[i]+l[j]) #n未満の個数を数える
print(ans)
    
  

Fixed submission:
import bisect
n=int(input())
l=list(map(int, input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(l[j+1:], l[i]+l[j]) #n未満の個数を数える
print(ans)