Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])


Fixed submission:
import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

if (N==1):
    print(1)
    quit()

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
import decimal

N, K = map(int, input().split())
n = decimal.Decimal(N)
result = decimal.Decimal(0.00000000000)

def check(i, K):
    count = 0
    while (K > i):
        i *= 2
        count += 1
    return count

for i in range(1,N+1):
    count = check(i, K)
    dec = decimal.Decimal(1.00000000000)
    for j in range(count):
        dec /= decimal.Decimal(2.00000000000)
    result += dec

print(result/n)

Fixed submission:
N, K = map(int, input().split())
result = 0

def check(i, K):
    count = 0
    while (K > i):
        i *= 2
        count += 1
    return count

for i in range(1,N+1):
    count = check(i, K)
    dec = 1
    for j in range(count):
        dec /= 2.0
    result += dec

print(round(result/N, 12))
Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
p = LF()

dp = [[0.0]*(N+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

print(sum(dp[N][N//2+1:]))

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
p = LF()

dp = [[0.0]*(N+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

print(sum(dp[N][N//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
import threading
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

threading.stack_size(128*1024*1024)

N, K = LI()
A = LI()

dp = [-1]*(K+1)
for a in A:
    dp[a] = 1
for i in range(A[0]):
    dp[i] = 0

def rec(x):
    if (x<0):
        return 1
    if (dp[x]!=-1):
        return dp[x]
    res = 1
    for a in A:
        res &= rec(x-a)
    dp[x] = 1^res
    return dp[x]

print("First" if rec(K) else "Second")


Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
import threading
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, K = LI()
A = LI()

dp = [False]*(K+1)
for a in A:
    dp[a] = True

for i in range(K+1):
    for a in A:
        if (i<a):
            break
        if (not dp[i-a]):
            dp[i] = True
            break

print("First" if dp[K] else "Second")
Buggy python submission (verdict: Runtime Error):
gcd = lambda x, y: x if (y==0) else gcd(y, x%y)
lcm = lambda x, y: int(x*y/gcd(x, y))

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

gcd_all = 0
lcm_all = 1

for ai in A :
    gcd_all = gcd(gcd_all, ai)
    lcm_all = lcm(lcm_all, ai)

m = lcm_all - 1
print(sum(list(map(lambda ai: m%ai, A))))


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

print(sum(list(map(lambda ai: ai-1, A))))

Buggy python submission (verdict: Runtime Error):
gcd = lambda x, y: x if (y==0) else gcd(y, x%y)
lcm = lambda x, y: int(x*y/gcd(x, y))

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

gcd_all = 0
lcm_all = 1

for ai in A :
    gcd_all = gcd(gcd_all, ai)
    lcm_all = lcm(lcm_all, ai)

m = lcm_all - 1
print(sum(list(map(lambda ai: m%ai, A))))


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

print(sum(list(map(lambda ai: ai-1, A))))
Buggy python submission (verdict: Runtime Error):
import math
X = int(input())
max_num = 1

for i in range(2, int(math.sqrt(X))+1) :
    for j in range(2, int(math.log2(X))+1) :
        if (i**j <= X):
            max_num = max(max_num, i**j)
        else:
            break
print(max_num)

Fixed submission:
import math
X = int(input())
max_num = 1

for i in range(2, int(math.sqrt(X))+1) :
    for j in range(2, int(math.log2(X))+1) :
        if (i**j <= X):
            max_num = max(max_num, i**j)
        else:
            break
print(max_num)
Buggy python submission (verdict: Runtime Error):
S=int(input())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if S<3:
    ans=0
n=S//3
ans=0
for i in range(1,n+1):
    ans+=cmb(S-2*

Fixed submission:
S=int(input())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if S<3:
    ans=0
n=S//3
ans=0
for i in range(1,n+1):
    ans+=cmb(S-2*i-1,i-1,mod)
    ans%=mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
B=[0 for _ in range(N)]
C=A
for i in range(1,N):
    M=max(C[:i])
    if M>A[i]:
        B[i]=M-A[i]
        C[i]=M
print(sum(B))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=0
M=A[0]
for i in range(1,N):
    if A[i]>M:
        M=A[i]
    else:
        ans+=M-A[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
B=[0 for _ in range(10001)]
C=A
for i in range(1,N):
    M=max(C[:i])
    if M>A[i]:
        B[i]=M-A[i]
        C[i]=M
print(sum(B))


Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=0
M=A[0]
for i in range(1,N):
    if A[i]>M:
        M=A[i]
    else:
        ans+=M-A[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)#新しいリストを作成
    #print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        #print(pair)
print(ans)

Fixed submission:
X,K,D=map(int, input().split())
n=(K*D-X)//(2*D)
#print(n)
if n<0:
    ans=abs(X-K*D)
elif n>=K:
    ans=abs(X+K*D)
else:
    ans1=abs(X+(2*n-K)*D)
    ans2=abs(X+(2*(n+1)-K)*D)
    ans=min(ans1,ans2)
    #print(n,ans1,ans2)
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)#新しいリストを作成
    print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        print(pair)
print(ans)

Fixed submission:
X,K,D=map(int, input().split())
n=(K*D-X)//(2*D)
#print(n)
if n<0:
    ans=abs(X-K*D)
elif n>=K:
    ans=abs(X+K*D)
else:
    ans1=abs(X+(2*n-K)*D)
    ans2=abs(X+(2*(n+1)-K)*D)
    ans=min(ans1,ans2)
    #print(n,ans1,ans2)
print(ans)
Buggy python submission (verdict: Runtime Error):
def count1(n):
    nx=bin(n)
    return nx.count('1')

N=int(input())
X=input()
for i in range(N):
    Ni2=X
    if X[i]=='0':
        Ni2=X[:i]+'1'+X[(i+1):] #文字列は変更できない
    else:
        Ni2=X[:i]+'0'+X[(i+1):]
    Ni=int(Ni2,2)
    ans=0
    #print(Ni)
    while Ni!=0:
        Ni=Ni%count1(Ni)
        ans+=1
    print(ans)


Fixed submission:
L,R,d=map(int, input().split())
ans=R//d-(L-1)//d
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
    ans = max(ans, i + j)
print(ans)


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
a.append(a[i] + A[i])
for i in range(M):
b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
    ans = max(ans, i + j)
print(ans)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
sum=0
for j in range(1,N+1):
    sum+=int(((N//j)*(N//j+1)/2)*j)
print(sum)


Fixed submission:
N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
def sieve_of_eratosthenes(n): #エラトステネスのふるい
    candidate = list(range(2, n+1)) #候補
    prime = []
    limit = n**0.5 + 1 #+1がないと平方数を素数にしてしまう

    while True:
        p = candidate[0]
        if limit <= p:
            prime.extend(candidate) #この時点での残っているのは素数
            break
        prime.append(p) #pを素数リストに登録

        candidate = [i for i in candidate if i % p != 0]

        # i = 0
        # while True:
            # if i >= len(candidate): #iはcandidateの長さ分
                # break
            # elif candidate[i] % p == 0: #余りがゼロなら
                # candidate.pop(i) #素数ではないのでpop(取り除く)する
            # i += 1

    return prime

def factorization(n,plist):
    arr = []
    temp = n
    for i in plist: #range(2, int(-(-n**0.5//1))+1):
        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

#print(factorization(24)) #[[2, 3], [3, 1]]

N=int(input())
if N==1:
    print(1)
else:
    plist=sieve_of_eratosthenes(10000)
    sum=0
    for i in range(2,N+1):
        temp=1
        arr=factorization(i,plist)
        for j in range(len(arr)):
            temp*=arr[j][1]+1
        temp*=i
        sum+=temp
        #print(temp)
    print(1+sum)

Fixed submission:
N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1

    return num

N=int(input())
if N==1:
    print(1)
else:
    sum=0
    for i in range(2,N+1):
        sum+=i*num_divisors_trial_division(i)
        #print(temp)
    print(1+sum)

Fixed submission:
N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)
Buggy python submission (verdict: Runtime Error):
=input()
T=S.replace('?', 'D')
print(T)

Fixed submission:
S=input()
T=S.replace('?', 'D')
print(T)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")

Fixed submission:
l = list(map(int, input().split()))
a=l[0]
b=l[1]
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
N=input()
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)


Fixed submission:
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = math.gcd(g, A[i])
print(g)


Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = gcd(g, A[i])
print(g)

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

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = math.gcd(g, A[i])
print(g)


Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = gcd(g, A[i])
print(g)
Buggy python submission (verdict: Runtime Error):
x=int(input())
y=int(input())
if x%y != 0:
    print(x)
else:
    print(-1)

Fixed submission:
import math
import sys

x,y = map(int, input().split())
if x%y != 0:
    print(x)
else:
    print(-1)

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

x=int(input())
y=int(input())
if x%y != 0:
    print(x)
else:
    print(-1)

Fixed submission:
import math
import sys

x,y = map(int, input().split())
if x%y != 0:
    print(x)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
puts (c-a-b > 0 and 4*a*b < (c-a-b)**2 ) ? "Yes" : "No"

Fixed submission:
a,b,c = map(int, input().split())
print("Yes" if (c-a-b > 0 and 4*a*b < (c-a-b)**2) else "No")
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

li = []

for i in range(N):
    x, l = map(int, input().split())
    li.append([x-l,x+l])

li.sort(key=lambda x:x[1])
li.sort(key=lambda x:x[0])

ans = 0
t = 0 - 10**9 + 99
for i in range(N):
    if t <= li[i][0]:
        ans += 1
        t = li[i][1]

print(ans)


Fixed submission:
import math

H = int(input())
W = int(input())
N = int(input())

k = max([H,W])
ans = math.ceil(N/k)

print(ans)
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,n):
        ans += ( a[i] ^ a[j] ) % mod

print(ans% mod)

Fixed submission:
n,*a=map(int,open(0).read().split())
c=0
for i in range(61):
  i=2**i
  t=sum(i&b and 1 for b in a)
  c=(c+t*(n-t)*i)%(10**9+7)
print(c)

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

ans = 0
for i in range(0,n-1):
    for j in range(i,n):
        ans += a[i] ^ a[j] 

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

Fixed submission:
n,*a=map(int,open(0).read().split())
c=0
for i in range(61):
  i=2**i
  t=sum(i&b and 1 for b in a)
  c=(c+t*(n-t)*i)%(10**9+7)
print(c)
Buggy python submission (verdict: Runtime Error):
# import math
import bisect
import numpy as np
mod = 10**9 + 7

# http://cav-inet.hateblo.jp/entry/2017/02/18/165141
def binary_search(list,target): 

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = (left + right)//2
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return False
	else:
		return True

n = int(input())
a = list(map(int,input().split()))
c = np.cumsum(a)
s = c[n-1]

if binary_search(c, c[n-1]/2):
    print(0)
    exit()

i = bisect.bisect_left(c, c[n-1]/2)
ans = min(2*c[i]-s, s - c[i-1]-1)
print(ans)


Fixed submission:
def award(x):
    return max(0, 4*(10**5) - x*(10**5))

x,y = map(int,input().split())

ans  = award(x)
ans += award(y)

if x == 1 and y == 1:
    ans += 4*(10**5)

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

N = int( input() )
tree = list( map( int, input().split() ) )

c = Counter(tree)
if tree[0] != 0 or c[0] != 1:
    print(0)
else:
    ans = 1
    a = c[0]
    for i in range( 1,N):
        t = c[i]
        # print(i,a,t,a**t)
        ans *= ( a**t )
        a = t
    print(ans%998244353)

Fixed submission:
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )

c = Counter(tree)
if tree[0] != 0 or c[0] != 1:
    print(0)
else:
    ans = 1
    a = c[0]
    for i in range( 1,len(c)):
        t = c[i]
        if t == 0:
            print(0)
            exit()
        else:
            ans *= ( a**t )
            a = t
    print(ans%998244353)
Buggy python submission (verdict: Runtime Error):
# https://juppy.hatenablog.com/entry/2019/04/05/%E8%9F%BB%E6%9C%AC_Python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC_2_heapq_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3
import heapq

n,m,*a = map(int, open(0).read().split())

# a = [1,7,3,5,4]

# #heapify
# #配列a = [1,7,3,5,4]をheapにする
hq = heapq._heapify_max(a)
# print(a) #[7, 5, 3, 1, 4]

# #heappop
# #最大値の取り出し
# print(_heappop_max(a)) #7
# print(a) #[5, 4, 3, 1]

# #heappush
# #要素(2)の挿入
# _heappush_max(a,2)
# print(a) #[5, 4, 3, 1, 2]

# #最大値の取り出し
# print(_heappop_max(a)) #5
s = sum(a)
d = 0
for i in range(m):
  t = heapq._heappop_max(a)
  d += t-t//2
  heapq._heapreplace_max(a, t//2)
  # print(a)

print(s-d)

Fixed submission:
# https://juppy.hatenablog.com/entry/2019/04/05/%E8%9F%BB%E6%9C%AC_Python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC_2_heapq_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3
import heapq
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

n,m,*a = map(int, open(0).read().split())


# a = [1,7,3,5,4]

# #heapify
# #配列a = [1,7,3,5,4]をheapにする
heapq._heapify_max(a)
# print(a) #[7, 5, 3, 1, 4]

# #heappop
# #最大値の取り出し
# print(_heappop_max(a)) #7
# print(a) #[5, 4, 3, 1]

# #heappush
# #要素(2)の挿入
# _heappush_max(a,2)
# print(a) #[5, 4, 3, 1, 2]

# #最大値の取り出し
# print(_heappop_max(a)) #5
s = sum(a)
d = 0
for i in range(m):
  t = _heappop_max(a)
  d += t-t//2
  _heappush_max(a, t//2)
  # print(a)

print(s-d)