Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> rest(n);
    for(int i = 0;i < n;i++){
        cin >> rest[i].first.first >> rest[i].first.second;
        rest[i].first.second *= -1;
        rest[i].second = i+1;
    }
 
    sort(rest.begin(),rest.end());
 
    for(int i = 0;i < n;i++){
        cout << rest[i].second << endl;
    }
 
    return 0;
}

Fixed submission:
def main():
    N = int(input())
    A = []
    for i in range(N):
        S, P = input().split()
        A.append((S,int(P),i+1))
 
    sort_A = sorted(A, key=lambda x:(x[0], -x[1])) 
    for i in range(N):
        print(sort_A[i][2])
 
main()

Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> rest(n);
    for(int i = 0;i < n;i++){
        cin >> rest[i].first.first >> rest[i].first.second;
        rest[i].first.second *= -1;
        rest[i].second = i+1;
    }
 
    sort(rest.begin(),rest.end());
 
    for(int i = 0;i < n;i++){
        cout << rest[i].second << endl;
    }
 
    return 0;
}

Fixed submission:
def main():
    N = int(input())
    A = []
    for i in range(N):
        S, P = input().split()
        A.append((S,int(P),i+1))
 
    sort_A = sorted(A, key=lambda x:(x[0], -x[1])) 
    for i in range(N):
        print(sort_A[i][2])
 
main()

Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> rest(n);
    for(int i = 0;i < n;i++){
        cin >> rest[i].first.first >> rest[i].first.second;
        rest[i].first.second *= -1;
        rest[i].second = i+1;
    }
 
    sort(rest.begin(),rest.end());
 
    for(int i = 0;i < n;i++){
        cout << rest[i].second << endl;
    }
 
    return 0;
}

Fixed submission:
def main():
    N = int(input())
    A = []
    for i in range(N):
        S, P = input().split()
        A.append((S,int(P),i+1))
 
    sort_A = sorted(A, key=lambda x:(x[0], -x[1])) 
    for i in range(N):
        print(sort_A[i][2])
 
main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8

N, K = map(int, input().split())
H = [int(hi) for hi in input().split()]
dp = [0]*N

for i in range(1, K+1):
    if i > N-1:
        break
    dp[i] = abs(H[0]-H[i])

for i in range(K+1, N):
    dp[i] = min([dp[i-j]+abs(H[i-j]-H[i]) for j in range(1, K+1)])
    

print(dp[N-1])

Fixed submission:
# coding:utf-8

N, K = map(int, input().split())
H = [int(hi) for hi in input().split()]
dp = [0]*(N+1)


for i in range(1, K+1):
    if i <= N-1:
        dp[i] = abs(H[0]-H[i])

for i in range(K+1, N):
    dp[i] = min([dpk + abs(hk - H[i]) for dpk, hk in zip(dp[i-K:i], H[i-K:i])])


print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)
while True:
    counter = 0
    for i in range(l):
        if i == l-1:
            break
        if s_arr[i] == 'B':
            if s_arr[i+1] == 'W':
                s_arr[i] = 'W'
                s_arr[i+1] = 'B'
                counter += 1
                n += 1
    if counter == 0:
        break
print(n)

Fixed submission:
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)

ans = 0
b_count = 0
for i in range(l, 0, -1):
    if i == l:
        if s_arr[i-1] == 'B':
            b_count += 1
    else:
        if s_arr[i-1]=='B':
            ans += l - i - b_count
            b_count += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)
while True:
    counter = 0
    for i in range(l):
        if i == l-1:
            break
        if (s_arr[i] == 'B')&(s_arr[i+1] == 'W'):
            s_arr[i] = 'W'
            s_arr[i+1] = 'B'
            counter += 1
            n += 1
    if counter == 0:
        break

print(n)

Fixed submission:
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)

ans = 0
b_count = 0
for i in range(l, 0, -1):
    if i == l:
        if s_arr[i-1] == 'B':
            b_count += 1
    else:
        if s_arr[i-1]=='B':
            ans += l - i - b_count
            b_count += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)
while True:
    counter = 0
    for i in range(l):
        if i == l-1:
            break
        if (s_arr[i] == 'B')&(s_arr[i+1]=='W'):
            s_arr[i] = 'W'
            s_arr[i+1] = 'B'
            counter += 1
            n += 1
    if counter == 0:
        break

print(n)

Fixed submission:
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)

ans = 0
b_count = 0
for i in range(l, 0, -1):
    if i == l:
        if s_arr[i-1] == 'B':
            b_count += 1
    else:
        if s_arr[i-1]=='B':
            ans += l - i - b_count
            b_count += 1


print(ans)
Buggy python submission (verdict: Runtime Error):
# coding:utf-8

N, X = map(int, input().split())

def eatBan(c, w):
        return c, w+1
def eatPan(c, w):
    return c+1, w+1
def checkWalk(w, X):
    if w == X:
        return True
    else:
        return False

def createNBurger(w, c, n, X):
    if n == 0:
        c, w = eatPan(c, w)
        return c, w
    else:
        # バン食べる
        c, w = eatBan(c, w)
        if checkWalk(w, X):
            c, w, True
        # N-1 バーガー
        c, w = createNBurger(w, c, n-1, X)
        if checkWalk(w, X):
            c, w, True
        # パティ食べる
        c, w = eatPan(c, w)
        if checkWalk(w, X):
            c, w, True
        # N-1 バーガー
        c, w = createNBurger(w, c, n-1, X)
        if checkWalk(w, X):
            return c, w, True
        # バン食べる
        c, w = eatBan(c, w)
        if checkWalk(w, X):
            c, w, True
        return c, w, False

# Nバーガー作成
c = 0
w = 0
c, w , t= createNBurger(w, c, N, X)

# eat_p = 0
# for i, c in enumerate(burger):
#     if c == "P":
#         eat_p += 1
#     if i == X-1:
#         break
print(c)

Fixed submission:
# coding:utf-8

d = int(input())

c_eve = 25 - d

out = "Christmas"

for i in range(c_eve):
    out += " Eve"

print(out)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8

N = int(input())
an = [int(input()) for i in range(N)]

an.sort()
an.reverse()

print(an)

sum = 0
for i, ai in enumerate(an):
    if i == 0:
        sum += ai/2
    else:
        sum += ai

print(int(sum))

Fixed submission:
# coding:utf-8

d = int(input())

c_eve = 25 - d

out = "Christmas"

for i in range(c_eve):
    out += " Eve"

print(out)
Buggy python submission (verdict: Runtime Error):
# coding:utf-8

# 解答みながらの復習

S = str(input())
T = str(input())

Sdic = [0 for _ in range(26)]
Tdic = [0 for _ in range(26)]

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' \
    'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != 0:
        if Sdic[alphabet.index(si)] == ti:
            pass
        else:
            Able = False
            break
    elif Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != 0:
        if Tdic[alphabet.index(ti)] == si:
            pass
        else:
            Able = False
            break

print("Yes" if Able else "No")



Fixed submission:
# coding:utf-8

# 解答みながらの復習

S = str(input())
T = str(input())

Sdic = [0 for _ in range(26)]
Tdic = [0 for _ in range(26)]

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",\
    "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != ti:
        Able = False
        break
    if Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != si:
        Able = False
        break
        
print("Yes" if Able else "No")

Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8

s = str(input())
t = str(input())

def is_check(index, s, t):
    si = s[index]
    ti = t[index]
    check_arr = s[index+1:]
    for k, sk in enumerate(check_arr):
        if(si == sk):
            if(ti == t[index+1+k]):
                pass
            else:
                return False
        else:
            pass
    return True

for index, si in enumerate(s):
    if(is_check(index, s, t)):
        pass
    else:
        print("No")
        quit()

for index, ti in enumerate(t):
    if(is_check(index, t, s)):
        pass
    else:
        print("No")
        quit()

print("Yes")

Fixed submission:
# coding:utf-8

# 解答みながらの復習

S = str(input())
T = str(input())

Sdic = [0 for _ in range(26)]
Tdic = [0 for _ in range(26)]

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",\
    "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != ti:
        Able = False
        break
    if Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != si:
        Able = False
        break
        
print("Yes" if Able else "No")
Buggy python submission (verdict: Runtime Error):

numTest = int(input())

value = numTest % 10

if value == 2 or value == 4 or value == 5 or value == 7 or value == 9 :
	print('hon')
elif value == 0 or value == 1 or value == 6 or value == 8 :
	print('pon')
elif value == 3 :
	print(bon)

Fixed submission:
numTest = int(input())

value = numTest % 10

if value == 2 or value == 4 or value == 5 or value == 7 or value == 9 :
	print('hon')
elif value == 0 or value == 1 or value == 6 or value == 8 :
	print('pon')
elif value == 3 :
	print('bon')
Buggy python submission (verdict: Runtime Error):
numTest = int(input())

inputLine = input()

print(inputLine[0 : numTest] + '...' if len(inputLine) > numTest else inputLine

Fixed submission:
numTest = int(input())

inputLine = input()

print(inputLine[0 : numTest] + '...' if len(inputLine) > numTest else inputLine)
Buggy python submission (verdict: Time Limit Exceeded):
N,K =map(int,input().split())
A=list(map(int,input().split()))

n=[1]
t=1

while True:
  t=A[t-1]
  if t in n:
    f=n.index(t)
    break
  n.append(t)

k=len(n)-f

if K>=f:
  print(n[f+(K-f)%k])

else:
  print(n[K])
  


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

n=[1]
t=1
ord=[-1]*(N+1)
ord[0]=0

while True:
    t=A[t-1]
    if ord[t] != -1:
        f=n.index(t)
        break
    n.append(t)
    ord[t]=0

k=len(n)-f

if K>=f:
    print(n[f+(K-f)%k])

else:
    print(n[K])
Buggy python submission (verdict: Runtime Error):
n,A,B,C = map(int,input().split())
s = [[*input()] for _ in range(n)]
a = {"A":A, "B":B, "C":C}
ans = ["Yes"]+[0]*n
def dfs(i):
    if i==n:
        print("\n".join(ans))
        exit()
    for p,m in [s[i],s[i][::-1]]:
        if a[m]:
            a[p]+=1; a[m]-=1; ans[i+1]=p
            dfs(i+1)
            #一つ戻る
            a[p]-=1; a[m]+=1
dfs(0)
print("No")

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n,A,B,C = map(int,input().split())
s = [[*input()] for _ in range(n)]
a = {"A":A, "B":B, "C":C}
ans = ["Yes"]+[0]*n
def dfs(i):
    if i==n:
        print("\n".join(ans))
        exit()
    for p,m in [s[i],s[i][::-1]]:
        if a[m]:
            a[p]+=1; a[m]-=1; ans[i+1]=p
            dfs(i+1)
            #一つ戻る
            a[p]-=1; a[m]+=1
dfs(0)
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())

a=min(B,N)
array=[]

for x in range(1,a+1):
  array.append(math.floor(A*x/B)-A*math.floor(x/B))
  
print(max(array))
  

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

a=min(B,N)

if a==B:
  print(math.floor(A*(B-1)/B)-A*math.floor((B-1)/B))
else:
  print(math.floor(A*N/B)-A*math.floor(N/B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
a=[0]*N

for i in range(N):
	a[i]=A.count(i+1)

for i in a:
  print(i)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
a=[0]*N

for i in range(N-1):
	a[A[i]-1]=a[A[i]-1]+1

for i in a:
  print(i)

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

for n in range(len(A)):
  for i in range(N):
    if A[n]==i+1:
      a[i]=a[i]+1

for i in a:
  print(i)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
a=[0]*N

for i in range(N-1):
	a[A[i]-1]=a[A[i]-1]+1

for i in a:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
import math
sum=0


for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += math.gcd(math.gcd(i,j),k)

print(sum)

Fixed submission:
K=int(input())
import math
sum=0


for i in range(1,K+1):
  for j in range(1,K+1):
    c=math.gcd(i,j)
    for k in range(1,K+1):
      sum += math.gcd(c,k)

print(sum)

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

sum=0

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(gcd(i,j),k)

print(sum)

Fixed submission:
K=int(input())
import math
sum=0


for i in range(1,K+1):
  for j in range(1,K+1):
    c=math.gcd(i,j)
    for k in range(1,K+1):
      sum += math.gcd(c,k)

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
K=int(input())
sum=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(i,j,k)

print(sum)

Fixed submission:
K=int(input())
import math
sum=0


for i in range(1,K+1):
  for j in range(1,K+1):
    c=math.gcd(i,j)
    for k in range(1,K+1):
      sum += math.gcd(c,k)

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
R=[]
G=[]
B=[]

for n in range(N):
  if S[n]=="R":
    R.append(n)
  elif S[n]=="G":
    G.append(n)
  else:
    B.append(n)

ans=len(R)*len(G)*len(B)

for r in R:
  for g in G:
    for b in B:
      list=[r,g,b]
      list.sort()
      if list[2]-list[1]==list[1]-list[0]:
        ans -=1

print(ans)
      
    
    

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

ans=S.count("R")*S.count("G")*S.count("B")

#j-i= k-j k=2*j-i

for i in range(N):
  for j in range(i+1,N):
    if 2*j-i<N:
      if S[i]!=S[j] and S[i]!=S[2*j-i] and S[j]!=S[2*j-i]:
        ans -=1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y=map(int,input().split())
list=[]

for i in range(1,N):
  for j in range(i+1,N+1):
    list.append(min(j-i,abs(i-X)+abs(j-Y)+1))


for i in range(N-1):
  print(list.count(i+1))
  

Fixed submission:
N,X,Y=map(int,input().split())
count=[0]*(N-1)

for i in range(1,N):
  for j in range(i+1,N+1):
    count[min(j-i,abs(i-X)+abs(j-Y)+1)-1] += 1


for i in count:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
sum=0
list=[0]*N
list2=[0]*N

for n in range(N):
  list[n]=A.count(n+1)

for n in range(N):
  sum += list[n]*(list[n]-1)//2
  

for n in range(N):
  if list[n]>0:
  	list2[n]=sum-list[n]*(list[n]-1)//2+(list[n]-1)*(list[n]-2)//2
  
for a in A:
  print(list2[a-1])
  
  


    


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sum=0
list=[0]*N
list2=[0]*N

for a in A:
  list[a-1] +=1
  

for n in range(N):
  sum += list[n]*(list[n]-1)//2
  

for n in range(N):
  if list[n]>0:
  	list2[n]=sum-list[n]*(list[n]-1)//2+(list[n]-1)*(list[n]-2)//2
  
for a in A:
  print(list2[a-1])
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
query=[]
reverseflg=False

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S=query[q][2]+S
      else:
        S=S+query[q][2]
    
    else:
      if reverseflg== False:
        S=S+query[q][2]
      else:
        S=query[q][2]+S
        
if reverseflg==False:
  print(S)
else:
  print(S[::-1])

Fixed submission:
from collections import deque
S=list(input())
Q=int(input())
query=[]
reverseflg=False
S=deque(S)

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S.appendleft(query[q][2])
      else:
        S.append(query[q][2])
    
    else:
      if reverseflg== False:
        S.append(query[q][2])
      else:
        S.appendleft(query[q][2])

if reverseflg==True:
  S.reverse()
  
print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
query=[]

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    S = S[::-1]
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      S=query[q][2]+S
    else:
      S=S+query[q][2]

print(S)


Fixed submission:
from collections import deque
S=list(input())
Q=int(input())
query=[]
reverseflg=False
S=deque(S)

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S.appendleft(query[q][2])
      else:
        S.append(query[q][2])
    
    else:
      if reverseflg== False:
        S.append(query[q][2])
      else:
        S.appendleft(query[q][2])

if reverseflg==True:
  S.reverse()
  
print(''.join(S))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]
a_max=0

for n in range(N-(K-1)):
  a = sum(p[n:n+K])
  if a>a_max:
    a_max=a
    

ans=(a_max+K)/2
print(ans)
  

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

a=sum(p[0:K])
array.append(a)

for n in range(N-K):
  a=a-p[n]+p[n+K]
  array.append(a)

ans=(max(array)+K)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

for n in range(N-(K-1)):
  a = sum(p[n:n+K])
  array.append(a)

ans=(max(array)+K)/2
print(ans)
  

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

a=sum(p[0:K])
array.append(a)

for n in range(N-K):
  a=a-p[n]+p[n+K]
  array.append(a)

ans=(max(array)+K)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

for n in range(N-(K-1)):
  sum=0
  for k in range(K):
  	sum += p[n+k]
  array.append(sum)

ans=(max(array)+K)/2
print(ans)
  

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

a=sum(p[0:K])
array.append(a)

for n in range(N-K):
  a=a-p[n]+p[n+K]
  array.append(a)

ans=(max(array)+K)/2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
A=list(map(int,input().split()))

SUM=0

for i in range(N-1):
  for j in range(i+1,N):
    SUM = SUM+(A[i]^A[j])
    SUM %= 10**9+7

print(SUM%(10**9+7))

Fixed submission:
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)

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

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM += b1^b2
  SUM = SUM % (10**9+7)

print(SUM%(10**9+7))

Fixed submission:
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)

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

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM += b1^b2

print(SUM%(10**9+7))

Fixed submission:
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,*a=map(int,open(0).read().split())

dp=[0]*(N+1)
dp[0]=1

for n in range(1,N+1):
	
  if n  in a:
    dp[n]=0
    
  else:
    dp[n]=(dp[n-1]+dp[n-2])%1000000007

print(dp[N])
    

Fixed submission:
N,M,*a=map(int,open(0).read().split())

dp=[1]*(N+1)

for i in a:
  	dp[i]=0

for n in range(2,N+1):
    dp[n]=(dp[n-1]+dp[n-2])%1000000007*dp[n]

print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split()) 
a=[int(input()) for _ in range(M)]

dp=[0]*(N+1)
dp[0]=1

for n in range(1,N+1):
	
  if n  in a:
    dp[n]=0
    
  else:
    dp[n]=(dp[n-1]+dp[n-2])%1000000007

print(dp[N])
    

Fixed submission:
N,M,*a=map(int,open(0).read().split())

dp=[1]*(N+1)

for i in a:
  	dp[i]=0

for n in range(2,N+1):
    dp[n]=(dp[n-1]+dp[n-2])%1000000007*dp[n]

print(dp[N])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
Asorted = sorted(A)


L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

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

print(int((T+0.5)//A*B))

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
A = sorted(A)[:: -1]


L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

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

print(int((T+0.5)//A*B))

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
print(A)

L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

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

print(int((T+0.5)//A*B))

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]
ans=0

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

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

print(int((T+0.5)//A*B))