Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,*a=map(open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)

Fixed submission:
n,*a=map(int,open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
s=1
if any(a==0):
  print(0)
  exit()
for i in a:
  s*=i
  if s>1e18:
    print(-1)
    exit()
print(s)

Fixed submission:
n,*a=map(int,open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)
Buggy python submission (verdict: Runtime Error):
from math import floor
a,b=input().split()
a=int(a)
b=list(b)
b=int(b[0]+b[2:])
print(floor(a*b/100))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b[0]+b[2:])
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=b[0]+b[2:]
print(int(a*b/100))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b[0]+b[2:])
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int(a*b))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b[0]+b[2:])
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
  a[nxt]=i
  nxt=A[nxt]-1
  i+=1
  if a[nxt]!=0:
    g=i-a[nxt]
    t=a[nxt]-1
    break
if t>=k:
  print(a.index(k+1)+1)
else:
  k-=t
  u=k%g
  print(a.index(t+u+1)+1)

Fixed submission:
s=input()
t=input()
if s==t[:-1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
x=int(input())
t=int(x**0.2)
for i in [t-1,t,t+1,t+2,t+3]:
  if  i**5+1==x:
    print(i,-1,sep=' ')
  elif i**5-1==x:
    print(i,1,sep=' ')

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
ans=0
for i in range(n):
  f=1
  for j in l[i]:
    if h[i]<=h[j]:
      f=0
  if f:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
ans=0
for i in range(1,n+max(a)):
  ans+=L[i]*R[i]
print(ans)

Fixed submission:
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(int(x**0.2)+100,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()

Buggy python submission (verdict: Runtime Error):
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(x**0.2+10*2,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()

Fixed submission:
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(int(x**0.2)+100,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
ans=0
for i in range(1,n+max(a)):
  ans+=L[i]*R[i]
print(ans)

Fixed submission:
from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
def count(A):
  ret=0
  for i in A.values():
    ret+=i*(i-1)//2
  return ret
print(count(L+R)-count(L)-count(R))

Buggy python submission (verdict: Time Limit Exceeded):
n,*A=map(int,open(0).read().split())
ans=0
for i in range(1,n):
  for j in range(n):
    if j+i<n:
      if A[j]+A[j+i]==i:
        ans+=1
    else:
      break
print(ans)

Fixed submission:
from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
def count(A):
  ret=0
  for i in A.values():
    ret+=i*(i-1)//2
  return ret
print(count(L+R)-count(L)-count(R))
Buggy python submission (verdict: Runtime Error):
n,m,s=map(int,input().split())
a=[]
q=[[0]]
while q:
  x=q.pop()
  if len(x)<=n:
    if x[-1]==0:
      for j in range(1,m+1):
        c=x+[j]
        q.append(c)
    else:
      for j in range(x[-1],m+1):
        c=x+[j]
        q.append(c)
  else:
    a.append(x)
li=[tuple(map(int,input().split())) for _ in  range(s)]

ans=0
for A in a:
  s=0
  for i,j,k,l in li:
    if A[j]-A[i]==k:
      s+=l
  ans=max(ans,s)
print(ans)
  

Fixed submission:
k=int(input())
a,b=map(int,input().split())
if b//k*k>=a:
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
x=min(b-1,x)
print(a*x//b)

Fixed submission:
a,b,n=map(int,input().split())
x=min(b-1,n)
print(a*x//b)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
s=n//b
ans=0
for i in range(0,s+1):
  x=min(b*i+b-1,n)
  ans=max((a*x)//b-a*i,ans)
print(ans)

Fixed submission:
a,b,n=map(int,input().split())
x=min(b-1,n)
print(a*x//b)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=0
p=[0]*2019
for i,c in enumerate(s[::-1]):
  t+=int(c)*10**i
  t%=2019
  p[t]+=1
print(p[0]+sum((i*(i-1)//2) for i in p[1:]))

Fixed submission:
s=input()
res=0
t=1
p=[0]*2019
for i in map(int,s[::-1]):
  res+=i*t
  res%=2019
  p[res]+=1
  t*=10
  t%=2019
print(p[0]+sum((i*(i-1)//2) for i in p))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
if len(s)<5:
  print(0)
  exit()
ans=0
for i in range(len(s)-4):
  for j in range(i+4,len(s)+1):
    if int(s[i:j])%2019==0:
      ans+=1
print(ans)

Fixed submission:
s=input()
res=0
t=1
p=[0]*2019
for i in map(int,s[::-1]):
  res+=i*t
  res%=2019
  p[res]+=1
  t*=10
  t%=2019
print(p[0]+sum((i*(i-1)//2) for i in p))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
if len(s)<5:
  print(0)
  exit()
ans=0
for i in range(len(s)):
  j=i+4
  while j<len(s):
    if int(s[i:j+1])%2019==0:
      ans+=1
    j+=1
print(ans)

Fixed submission:
s=input()
res=0
t=1
p=[0]*2019
for i in map(int,s[::-1]):
  res+=i*t
  res%=2019
  p[res]+=1
  t*=10
  t%=2019
print(p[0]+sum((i*(i-1)//2) for i in p))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
if len(s)<5:
  print(0)
  exit()
ans=0
for i in range(len(s)):
  j=i+4
  while j<len(s):
    if int(s[i:j+1])%2019==0:
      ans+=1
    j+=1
print(ans)

Fixed submission:
s=input()
res=0
t=1
p=[0]*2019
for i in map(int,s[::-1]):
  res+=i*t
  res%=2019
  p[res]+=1
  t*=10
  t%=2019
print(p[0]+sum((i*(i-1)//2) for i in p))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
mod=10**9+7
ans=0
for i in range(k,n+2):
  ans+=((2*n-i+1)*i//2-i*(i-1)//2+1)%mod
print(ans)

Fixed submission:
import math
r=int(input())
print(2*r*math.pi)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>a:
    print(-1)
else:
    print(a-s)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>n:
    print(-1)
else:
    print(n-s)
Buggy python submission (verdict: Runtime Error):
n=str(input())
s=0
for i in range(1,n+1):
    if i%3!=0 or i%3!=0:
        s+=i
print(s)

Fixed submission:
n=int(input())
s=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        s+=i
print(s)

Buggy python submission (verdict: Runtime Error):
n=str(input())
s=0
for i in range(1,n+1):
    if i%3!=0 or i%3!=5:
        s+=i
print(s)

Fixed submission:
n=int(input())
s=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        s+=i
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
s=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            s=s+math.gcd(math.gcd(a,b),c)
print(s)

Fixed submission:
import math
k=int(input())
s=[]
ans=0
for a in range(1,k):
  for b in range(a+1,k+1):
    s.append(math.gcd(a,b))
for c in range(1,k+1):
  for i in range(len(s)):
    ans+=math.gcd(s[i],c)*2
  for j in range(1,k+1):
    ans+=math.gcd(c,j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=sum(a)/(4*m)
ans=0
for i in range(n):
    if a[n]>=c:
        ans+=1
if ans>=m:
    print('Yes')
else:
    print('No')

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=sum(a)/(4*m)
ans=0
for i in range(n):
    if a[i]>=c:
        ans+=1
if ans>=m:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
s=[]
for i in range(1,n):
  for j in range(i+1,n+1):
    s.append(min(j-i,abs(x-j)+1+abs(y-i),abs(x-i)+1+abs(y-j)))
for l in range(1,n):
  print(s.count(l))

Fixed submission:
n,x,y=map(int,input().split())
res=[0]*n
for i in range(1,n):
  for j in range(i+1,n+1):
    s=(min(j-i,abs(x-j)+1+abs(y-i),abs(x-i)+1+abs(y-j)))
    res[s]+=1
for k in range(1,n):
  print(res[k])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    m=c.count(d[i])
    if m>1:
      b=b+m*(m-1)/2
  return b
for k in range(n):
  print(int(ans(a,k)))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
res=0
for i in s.values():
    res+=i*(i-1)//2
ans=0
for j in range(n):
    if s[a[j]]==1:
        print(res)
    else:
        ans=res-s[a[j]]+1
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    m=c.count(d[i])
    if m>1:
      b=b+m*(m-1)/2
  return b
for k in range(n):
  print(int(ans(a,k)))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
res=0
for i in s.values():
    res+=i*(i-1)//2
ans=0
for j in range(n):
    if s[a[j]]==1:
        print(res)
    else:
        ans=res-s[a[j]]+1
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    if c.count(d[i])>1:
      b=b+(c.count(d[i])*(c.count(d[i])-1))/2
  return b
for k in range(n):
  print(int(ans(a,k)))


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
res=0
for i in s.values():
    res+=i*(i-1)//2
ans=0
for j in range(n):
    if s[a[j]]==1:
        print(res)
    else:
        ans=res-s[a[j]]+1
        print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    if c.count(d[i])>1:
      b=b+(c.count(d[i])*(c.count(d[i])-1))/2
      return b
for k in range(n):
  print(int(ans(a,k)))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
res=0
for i in s.values():
    res+=i*(i-1)//2
ans=0
for j in range(n):
    if s[a[j]]==1:
        print(res)
    else:
        ans=res-s[a[j]]+1
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
H,W,K=map(int,input().split())
S=[list(input()) for _ in range(H)]
ans=10**18
for i in range(1<<(H-1)):
    x=bin(i).count('1')
    cho=[0]*(x+1)
    f=1
    cnt=x
    for w in range(W):
        j=0
        nx=[0]*(x+1)
        for h in range(H):
          cho[j]+=int(S[h][w])
          nx[j]+=int(S[h][w])
          if cho[j]>K:
            if nx[j]>K:
              f=0
              break
            else:
              cho=copy.copy(nx)
              cnt+=1
          if (i>>h)&1:
            j+=1
        if f==0:
          break
    if f:
      ans=min(ans,cnt)
print(ans)

Fixed submission:
import copy
H,W,K=map(int,input().split())
S=[list(input()) for _ in range(H)]
ans=10**18
for i in range(1<<(H-1)):
    x=bin(i).count('1')
    cho=[0]*(x+1)
    f=1
    cnt=x
    for w in range(W):
        j=0
        nx=[0]*(x+1)
        for h in range(H):
          cho[j]+=int(S[h][w])
          nx[j]+=int(S[h][w])
          if cho[j]>K:
            if nx[j]>K:
              f=0
              break
            else:
              cho=copy.copy(nx)
              cnt+=1
          if (i>>h)&1:
            j+=1
        if f==0:
          break
    if f:
      ans=min(ans,cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
q=int(input())
rev=False
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    rev=not rev
  elif c[1]=='1' and rev:
    S.appendleft(c[2])
  elif c[1]=='2' and not rev:
    S.appendleft(c[2])
  else:
    S.append(c[2])
if rev:
  S.reverse()
ans=''.join(S)
print(ans)

Fixed submission:
a=input()
if len(set(a))==1:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
q=int(input())
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    S.reverse()
  elif c[1]=='1':
    S.appendleft(c[2])
  elif c[1]=='2':
    S.append(c[2])
ans=''.join(S)
print(ans)


Fixed submission:
a=input()
if len(set(a))==1:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
q=int(input())
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    S.reverse()
  elif c[0]=='2':
    if c[1]=='1':
      S.appendleft(c[2])
    elif c[1]=='2':
      S.append(c[2])
ans=''.join(S)
print(ans)

Fixed submission:
a=input()
if len(set(a))==1:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
      
import sys
input = sys.stdin.readline
from operator import or_

input()
seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0)
ans = []
for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1"))
print(*ans)

Fixed submission:
n=int(input())
print(n//2+n%2)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,m,k=map(int,input().split())
link=[[] for _ in range(n)]
block=[[]  for _ in range(n)]
ans=[]
s=[]
for i in range(m):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)
for i in range(k):
  a,b=map(int,input().split())
  block[a-1].append(b-1)
  block[b-1].append(a-1)
for i in range(n):#スタートの選び方
    visited=set()
    q=deque([i])
    while len(q)>0:
        x=q.pop()
        visited.add(x)
        for j in link[x]:
            if j in visited:
              continue
            elif j in q:
              continue
            else:q.append(j)
    ans.append(len(visited))
    s.append(visited)

Fixed submission:
n=int(input())
print(n//2+n%2)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=0
ans=[]
for _ in range(n):
  ans.append('a')
for i in range(m):
  s,c=map(int,input().split())
  if ans[s-1]!='a' and ans[s-1]!=str(c):
    a=-1
  ans[s-1]=str(c)
if ans[0]=='a' and n!=1:
  ans[0]='1'

if ans[0]=='0' and n!=1:
  a=-1
if ans[0]=='a' and n==1:
  ans[0]='0'
for j in range(n):
  if ans[j]=='a':
    ans[j]='0'
if a==-1:
  print(a)
else:
  print(''.join(ans))

Fixed submission:
n=int(input())
print(n//2+n%2)
Buggy python submission (verdict: Time Limit Exceeded):
class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
import sys
input=sys.stdin.readline
input()
def lam(x,y):
  return x|y
seg = SegmentTree([set(x) for x in input()[:-1]],lam, set())
ans = []
for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, set(y))
  else:
    ans.append(len(seg.find(int(x) - 1, int(y))))
print(*ans)

Fixed submission:
class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
      
import sys
input = sys.stdin.readline
from operator import or_

input()
seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0)
ans = []
for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1"))
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
ans=0
for i in range(n):
    s.append((p[i]+1)/2)
for l in range(n-k+1):
    ans=max(ans,sum(s[l:l+k]))
print(ans)

Fixed submission:
import numpy as np
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[]
for i in p:
  l.append(i+1)
t=np.cumsum(np.array(l),dtype=int)
ans=t[k-1]
for j in range(n-k):
  ans=max(ans,t[j+k]-t[j])
print(ans/2)
Buggy python submission (verdict: Runtime Error):
from heapq import heappop,heapify
n,k=map(int,input().split())
q=[-int(i) for i in input().split()]
if k==0:
  print(sum(q))
  exit()
heapify(q)
for i in range(k):
  x=heappop(q)
print(-sum(q))

Fixed submission:
n,k=map(int,input().split())
q=[int(i) for i in input().split()]
q.sort(reverse=True)
print(sum(q[k:]))

Buggy python submission (verdict: Runtime Error):
from heapq import heappop,heapify
n,k=map(int,input().split())
q=[-int(i) for i in input().split()]
heapify(q)
for i in range(k):
  x=heappop(q)
print(-sum(q))

Fixed submission:
n,k=map(int,input().split())
q=[int(i) for i in input().split()]
q.sort(reverse=True)
print(sum(q[k:]))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
l=[]
s=0
for i in range(n):
    a,b=map(int,input().split())
    s=max(s,a)
    l.append((a,b))
dp=[10**10]*(h+s)
dp[0]=0
for i in range(h):
    for s,t in l:
        dp[i+s]=min(dp[i]+t,dp[i+s])
print(min(dp[h:]))

Fixed submission:
H,N=map(int,input().split())
magic=[list(map(int,input().split())) for _ in range(N)]
maxA=max(a for a,b in magic)
DP=[0]*(H+maxA)
for i in range(1,H+maxA):
    DP[i]=min(DP[i-a]+b for a,b in magic)
print(DP[H])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())
def lcm(a,b):
  return a*b//gcd(a,b)
s=A[0]
for i in A:
  s=lcm(s,i)
A=np.array(A,dtype=int)
B=s//A
ans=0
for i in B:
  ans=(ans+i)%MOD
print(ans)

Fixed submission:
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
mod=10**9+7
def lcm(a,b):
  s=fractions.gcd(a,b)
  return a*b//s

n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in a:
  l=lcm(l,i)
ans=0
for j in a:
  ans=(ans+l//j)%mod
print(ans)

Fixed submission:
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
import numpy as np
mod=10**9+7
def lcm(a,b):
  s=fractions.gcd(a,b)
  return a*b//s

n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in a:
  l=lcm(l,i)
ans=0
a=np.array(a)
ans=int(sum(l/a%mod)%mod)
print(ans)

Fixed submission:
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
mod=10**9+7
def lcm(a,b):
  s=fractions.gcd(a,b)
  return a*b//s

n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in a:
  l=lcm(l,i)
ans=0
for j in a:
  ans=(ans+l//j)%mod
print(ans)

Fixed submission:
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
import numpy as np
mod=10**9+7
def lcm(a,b):
  s=fractions.gcd(a,b)
  return a*b//s

n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in a:
    l=lcm(l,i)
a=np.array(a)
print(int(sum(l/a%mod)%mod))

Fixed submission:
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())
ans = 0
mod = 10 **9 + 7
for k in range(61):
	m = 1 << k
	c = 0
	for x in a:
		if m & x:
			c += 1
	ans +=c * (n - c) * m
	ans %= mod
print(ans)

Fixed submission:
n, *a = map(int, open(0).read().split())
ans = 0
mod = 10 **9 + 7
for k in range(61):
	m = 1 << k
	c = 0
	for x in a:
		if m & x:
			c += 1
	ans +=c * (n - c) * m
	ans %= mod
print(ans)