Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
d=deque(input())
qq=int(input())
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    d.reverse()
  else:
    if q[1]=='1':
      d.appendleft(q[2])
    else:
      d.append(q[2])
print(''.join(list(d)))

Fixed submission:
s=input()
qq=int(input())
re=0
l=''
r=''
f=1
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    re+=1
    if f:
      f=0
    else:
      f=1
  else:
    t=q[2]
    if f:
      if q[1]=='1':
        l+=t
      else:
        r+=t
    else:
      if q[1]=='1':
        r+=t
      else:
        l+=t
if re%2==0:
  print(l[::-1]+s+r)
else:
  print(r[::-1]+s[::-1]+l)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
d=deque(input())
qq=int(input())
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    d.reverse()
  else:
    if q[1]=='1':
      d.appendleft(q[2])
    else:
      d.append(q[2])
print(''.join(list(d)))

Fixed submission:
s=input()
qq=int(input())
re=0
l=''
r=''
f=1
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    re+=1
    if f:
      f=0
    else:
      f=1
  else:
    t=q[2]
    if f:
      if q[1]=='1':
        l+=t
      else:
        r+=t
    else:
      if q[1]=='1':
        r+=t
      else:
        l+=t
if re%2==0:
  print(l[::-1]+s+r)
else:
  print(r[::-1]+s[::-1]+l)
Buggy python submission (verdict: Runtime Error):
n=int(input()
print(n//2+n%2)

Fixed submission:
n=int(input())
print(n//2+n%2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=int(input())
c=0
while n:
  c+=1
  n=n//k
print(c)

Fixed submission:
n,k=map(int,input().split())
c=0
while n:
  c+=1
  n=n//k
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=int(input())
d=len(str(n))
from math import factorial as f
def c(n):
  if n<2:
    return 0
  else:
    return f(n)//(f(n-2)*f(2))
def kk(n):
  dd=len(str(n))
  s=9*(dd-1)
  s+=int(str(n)[0])
  return s
def kkk(n):
  d=len(str(n))
  s=81*(d-1)*(d-2)//2
  s+=9*(d-1)*(int(str(n)[0])-1)
  s+=kk(int(str(n)[1:]))
  return s

if k==1:
  ans=kk(n)
elif k==2:
  ans=kkk(n)
else:
  t=0
  for i in range(2,d-1):
    t+=c(i)
  ans=729*t
  ans+=81*c(d-1)*(int(str(n)[0])-1)
  ans+=kkk(int(str(n)[1:]))
print(ans)

Fixed submission:
n=int(input())
k=int(input())
d=len(str(n))
from math import factorial as f
def c(n):
  if n<2:
    return 0
  else:
    return f(n)//(f(n-2)*f(2))
def kk(n):
  dd=len(str(n))
  s=9*(dd-1)
  s+=int(str(n)[0])
  return s
def kkk(n):
  d=len(str(n))
  s=81*(d-1)*(d-2)//2
  s+=9*(d-1)*(int(str(n)[0])-1)
  s+=kk(int(str(n)[1:]))
  return s

if d==1 and k!=1:
  print(0)
else:
  if k==1:
    ans=kk(n)
  elif k==2:
    ans=kkk(n)
  else:
    t=0
    for i in range(2,d-1):
      t+=c(i)
    ans=729*t
    ans+=81*c(d-1)*(int(str(n)[0])-1)
    ans+=kkk(int(str(n)[1:]))
  print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k]))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[10**9]*(h+max(l)[0])
dp[0]=0
for i in range(1,len(dp)):
  for a,b in l:
    if i-a>=0:
      dp[i]=min(dp[i],dp[i-a]+b)
print(min(dp[h:]))

Fixed submission:
h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[10**9]*(h+max(l)[0])
dp[0]=0
for i in range(1,len(dp)):
  for a,b in l:
    if i-a>=0:
      dp[i]=min(dp[i],dp[i-a]+b)
print(min(dp[h:]))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
def lcm(x, y):
  return (x * y) // gcd(x, y)
def ll(numbers):
  return reduce(lcm, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
l=ll(a)
x=0
m=10**9+7
for i in range(n):
  x+=(l//a[i])%m
  x=x%m
print(x)

Fixed submission:
from fractions import gcd
from functools import reduce
def lcm(x, y):
  return (x * y) // gcd(x, y)
def ll(numbers):
  return reduce(lcm, numbers, 1)
def modinv(a):
    return pow(a,m-2,m)
n=int(input())
a=list(map(int,input().split()))
l=ll(a)
x=0
m=10**9+7
lm=l%m
for i in range(n):
  x+=(lm*modinv(a[i]))%m
  x=x%m
print(x)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=input()
s=0
for i in range(n):
  if a[i][0]==x:
    p=i
    break
for i in range(p+1,n):
  s+=a[i][1]
print(s)

Fixed submission:
n=int(input())
a=[list(input().split()) for _ in range(n)]
x=input()
s=0
for i in range(n):
  if a[i][0]==x:
    p=i
    break
for i in range(p+1,n):
  s+=int(a[i][1])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
  x%=m
print(x%m)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
  x%=m
print(x%m)
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
x=[list(input()) for i in range(h)]
a=[[1]*w]+[[0]*w for i in range(h)]
n=0
for i in range(1,h+1):
  f=False
  if '#' in x[i-1]:
    n+=1
    for j in range(w):
      if x[i-1][j]=='#':
        if f:
          n+=1
        else:
          f=True
      a[i][j]=n
  else:
    for j in range(w):
      a[i][j]=a[i-1][j]
if '#' not in x[0]:
  c=[1]*w
  for j in range(h,0,-1):
    if a[j]==c:
      for k in range(j,0,-1):
        for i in range(w):
          a[k][i]=a[k+1][i]
      break
for i in range(1,h+1):
  print(*a[i]) 

Fixed submission:
h,w,k=map(int,input().split())
x=[list(input()) for i in range(h)]
a=[['*']*w]+[[0]*w for i in range(h)]
n=0
for i in range(1,h+1):
  f=False
  if '#' in x[i-1]:
    n+=1
    for j in range(w):
      if x[i-1][j]=='#':
        if f:
          n+=1
        else:
          f=True
      a[i][j]=n
  else:
    for j in range(w):
      a[i][j]=a[i-1][j]
if '#' not in x[0]:
  c=['*']*w
  for j in range(1,h+1):
    if a[j]!=c:
      for k in range(j-1,0,-1):
        for i in range(w):
          a[k][i]=a[k+1][i]
      break
for i in range(1,h+1):
  print(*a[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=int(n**0.5)
while True:
  if n%s==0:
    print(n//s+s-2)
    break
  s+=1

Fixed submission:
n=int(input())
s=n**0.5
d=[]
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    d.append(i)
    if i!=n//i:
      d.append(n//i)
d.sort()
import bisect as bi
b=bi.bisect_left(d,s)
print(min(n//d[b-1]+d[b-1]-2,n//d[b]+d[b]-2))
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if a*a*b/2==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Fixed submission:
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Fixed submission:
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=sorted(list(map(int, input().split())))
ans=0
count=0
for i in range(n-2):  
  l,r=i+1,i+2
  sums=s[i]+s[l]
  while r<n:
    if s[r]<sums:
      count+=1
      if r==n-1:
        ans+=count
        count=0
        sums=sums-s[l]+s[l+1]
        l+=1
        r=l
      r+=1
    elif l==r:
      r+=1
    else:
      ans+=count
      count=0
      sums=sums-s[l]+s[l+1]
      l+=1
      r=l+1
print(ans)

Fixed submission:
n=int(input())
l=sorted(list(map(int,input().split())))
from bisect import bisect_left as b
a=0
for i in range(n-1):
  for j in range(i+1,n):
    a+=b(l,l[i]+l[j])-j-1
print(a)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a=[0]
i=0
while i<n-1:
  c=0
  while i<n-1:
    if h[i]>=h[i+1]:
      c+=1
      i+=1
    else:
      a.append(c)
      i+=1
      break
a.append(c)
print(max(a))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
a=[0]
i=0
c=0
while i<n-1:
  c=0
  while i<n-1:
    if h[i]>=h[i+1]:
      c+=1
      i+=1
    else:
      a.append(c)
      i+=1
      break
a.append(c)
print(max(a))
Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
k=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  k[a-1].append(b-1)
for i in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x
from collections import deque
d=deque()
d.append(0)
v=[False]*n
v[0]=True
while d:
  g=d.popleft()
  for i in k[g]:
    if v[i]:
      continue
    d.append(i)
    v[i]=True
    s[i]+=s[g]
print(*s)

Fixed submission:
n,q=map(int,input().split())
k=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  k[a-1].append(b-1)
  k[b-1].append(a-1)
s=[0]*n
for i in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x
from collections import deque
d=deque()
d.append(0)
v=[False]*n
v[0]=True
while d:
  g=d.popleft()
  for i in k[g]:
    if v[i]:
      continue
    d.append(i)
    v[i]=True
    s[i]+=s[g]
print(*s)
Buggy python submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(x-k+1,x+K):
  print(i)

Fixed submission:
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d={}
for i in range(n):
  a=str(sorted(input()))
  if a in list(d.keys()):
    d[a]+=1
  else:
    d[a]=1
l=list(d.values())
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)


Fixed submission:
from collections import Counter as co
n=int(input())
a=[str(sorted(input())) for _ in range(n)]
d=co(a)
l=d.values()
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d={}
for i in range(n):
  a=str(sorted(input()))
  if a in list(d.keys()):
    d[a]+=1
  else:
    d[a]=1
l=list(d.values())
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)

Fixed submission:
from collections import Counter as co
n=int(input())
a=[str(sorted(input())) for _ in range(n)]
d=co(a)
l=d.values()
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d={}
for i in range(n):
  a=sorted(input())
  if a in d.keys():
    d[a]+=1
  else:
    d[a]=1
l=list(d.values())
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)
  

Fixed submission:
from collections import Counter as co
n=int(input())
a=[str(sorted(input())) for _ in range(n)]
d=co(a)
l=d.values()
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l.append([a,b])
n=len(l)
l.sort()
p=0
t=l[0][0]
for i in range(n):
  if l[i][0]!=t:
    p+=l[i-1][1]
    t=l[i][0]
print(p)

Fixed submission:
import heapq as h
n,m=map(int, input().split())
a=[list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
hq=[]
x=0;d=0
for i in range(1,m+1):
  while d<n and a[d][0]<=i:
    h.heappush(hq,-a[d][1])
    d+=1
  if len(hq):
    x+=-h.heappop(hq)
print(x)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]<=b[i]:
    c+=a[i]
    d=b[i]-a[i]
    b[i+1]+=d
  else:
    c+=b[i]
if b[n-1]=>a[n-1]:
  c+=a[n-1]
  x=b[n-1]-a[n-1]
  c+=min(a[n],x)
else:
  c+=b[n-1]
print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n):
  c+=min(a[i],b[i])
  d=b[i]-a[i]
  if d>0:
    c+=min(d,a[i+1])
  a[i+1]=min(a[i+1],max(0,a[i+1]-d))
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
d=min(10**9,s)
while True:
  if s%d==0:
    break
  else:
    d-=1
print(0,0,d,0,0,s//d)

Fixed submission:
s=int(input())
t=10**9
if s%t==0:
  print(0,0,1,t,s//t,0)
else:
  print(0,0,1,t,s//t+1,t-(s%t))

Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
d=min(10**9,s)
while True:
  if s%d==0:
    break
  else:
    d-=1
print(0,0,d,0,0,s//d)

Fixed submission:
s=int(input())
t=10**9
if s%t==0:
  print(0,0,1,t,s//t,0)
else:
  print(0,0,1,t,s//t+1,t-(s%t))
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][d]-x[j][d])**2
  if s**(1/2).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

Fixed submission:
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][k]-x[j][k])**2
  if (s**(1/2)).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)
Buggy python submission (verdict: Runtime Error):
import collections as c
s=input()
a=c.Counter(s)
if a.value()==[2,2]:
  print('Yes')
else:
  print('No')

Fixed submission:
import collections as c
s=input()
a=c.Counter(s)
if str(a.values())=='dict_values([2, 2])':
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[n]-d[n-1])

Fixed submission:
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
import math as m
def c(t,r):
    return (m.factorial(t)//(m.factorial(t-r)*m.factorial(r)))%(10**9+7)
for i in range(1,k+1):
  a=c(k-1,i-1)
  b=c(n-k+1,i)
  print((a*b)%(10**9+7))

Fixed submission:
n,k=map(int,input().split())
import math as m
def c(t,r):
    if t>=r:
      return (m.factorial(t)//(m.factorial(t-r)*m.factorial(r)))%(10**9+7)
    else:
      return 0
for i in range(1,k+1):
  a=c(k-1,i-1)
  b=c(n-k+1,i)
  print((a*b)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as c
n,k=map(int,input().split())
for i in range(1,k+1):
  a=len(list(c.combinations(range(k-1),i-1)))%(10**9+7)
  b=len(list(c.combinations(range(n-k+1),i)))%(10**9+7)
  print((a*b)%(10**9+7))

Fixed submission:
n,k=map(int,input().split())
import math as m
def c(t,r):
    if t>=r:
      return (m.factorial(t)//(m.factorial(t-r)*m.factorial(r)))%(10**9+7)
    else:
      return 0
for i in range(1,k+1):
  a=c(k-1,i-1)
  b=c(n-k+1,i)
  print((a*b)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
d=[]
for i in range(n):
  for j in range(n):
    if i!=j:
      d.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter as c
print(n-c(d).most_common()[0][1])

Fixed submission:
n=int(input())
if n==1:
  print(1)
  exit()
l=[list(map(int,input().split())) for _ in range(n)]
d=[]
for i in range(n):
  for j in range(n):
    if i!=j:
      d.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter as c
print(n-c(d).most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[a]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[0]*(n+1)
d[0]=1 
if 1 in a:
  d[1]=0
else:
  d[1]=1
for i in range(2,n+1):
  if i not in a:
    d[i]=(d[i-1]+d[i-2])%mod
print(d[n])

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[0]*(n+1)
d[0]=1 
if a[0]==1:
  d[1]=0
else:
  d[1]=1
for i in range(2,n+1):
  if i not in a:
    d[i]=(d[i-1]+d[i-2])%mod
print(d[n])

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
d=[0]*(n+1)
d[0]=1 
if a[0]==1:
  d[1]=0
else:
  d[1]=1
for i in range(2,n+1):
  if i in a:
    d[i]=0
  else:
    d[i]=d[i-1]+d[i-2]
print(d[n])

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
l = [0] * M
r = [0] * M
for i in range(M):
  l[i], r[i] = map(int, input().split())
a=0
for i in range(1,N+1):
  flag=0
  for j in range(M):
    if i<l[j] or i>r[j]:
      flag=1
  if flag==0:
    a+=1
print(a)   

Fixed submission:
n,m=map(int,input().split())
x=1;y=n
for _ in range(m):
  l,r=map(int,input().split())
  if x<l:
    x=l
  if y>r:
    y=r
print(max(y-x+1,0))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[list(map(int,input().split())) for i in range(m)]
b.sort(key=lambda x:x[1])
p=0
c=[]
for i in b:
  if p>n:
    break
  c+=[i[1]]*i[0]
  p+=i[0]
c=c[:n]
m=sum(a)
x=m
for i in range(n):
  m=m-a[i]+c[i]
  x=max(x,m)
print(x)

Fixed submission:
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[list(map(int,input().split())) for i in range(m)]
b.sort(key=lambda x:x[1])
p=0
c=[]
for i in b[::-1]:
  if p>n:
    break
  c+=[i[1]]*i[0]
  p+=i[0]
n=min(len(c),n)
c=c[:n]
m=sum(a)
x=m
for i in range(n):
  m=m-a[i]+c[i]
  x=max(x,m)
print(x)
Buggy python submission (verdict: Runtime Error):
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,k):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(K,n+1):
  p+=1
print(p/n)

Fixed submission:
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,min(n+1,k)):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(k,n+1):
  p+=1
print(p/n)

Buggy python submission (verdict: Runtime Error):
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,k):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(K,N+1):
  p+=1
print(p/n)

Fixed submission:
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,min(n+1,k)):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(k,n+1):
  p+=1
print(p/n)
Buggy python submission (verdict: Runtime Error):
import fractions
n=int(input())
v=list(map(int,input().split()))
def g(a,b):
  if a==0:return b
  if b==0:return a
  return fractions.gcd(a,b)
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(1,n+1):
  l[i]=g(l[i-1],v[i-1])
for i in range(n)[::-1]:
  r[i]=g(r[i+1],v[i])
x=0
for i in range(n):
  c=g(l[i],r[i+1])
  x=max(c,x)
print(ans)

Fixed submission:
import fractions
n=int(input())
v=list(map(int,input().split()))
def g(a,b):
  if a==0:return b
  if b==0:return a
  return fractions.gcd(a,b)
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(1,n+1):
  l[i]=g(l[i-1],v[i-1])
for i in range(n)[::-1]:
  r[i]=g(r[i+1],v[i])
x=0
for i in range(n):
  c=g(l[i],r[i+1])
  x=max(c,x)
print(x)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
for _ in range(n):
  if a[_]<0:
    b.append(a.pop(_)*(-1))
if 0 in a or len(b)%2==0:
  print(sum(a)+sum(b))
else:
  b.sort()
  print(sum(a)+sum(b)-(b[0]*2))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]<0:
    c+=1
    a[i]=a[i]*-1
if c%2==0 or 0 in a:
  print(sum(a))
else:
  a.sort()
  print(sum(a[1:])-a[0])

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
for _ in range(n):
  if a[_]<0:
    b.append(a.pop(_)*(-1))
if 0 in a or len(b)%2==0:
  print(sum(a)+sum(b))
else:
  b.sort()
  print(sum(a)+sum(b[1:])-b[0])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]<0:
    c+=1
    a[i]=a[i]*-1
if c%2==0 or 0 in a:
  print(sum(a))
else:
  a.sort()
  print(sum(a[1:])-a[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
c=1
if h[0]<=h[1]:
  c=2
for i in range(2,n):
  if h[i]>=max(h[0:i-1]):
    c+=1
print(c)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
c=1
if len(h)>1 and h[0]<=h[1]:
  c=2
for i in range(2,n):
  if h[i]>=max(h[0:i]):
    c+=1
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
c=1
for i in range(1,n):
  if h[i]>=max(h[0:i-1]):
    c+=1
print(c)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
c=1
if len(h)>1 and h[0]<=h[1]:
  c=2
for i in range(2,n):
  if h[i]>=max(h[0:i]):
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0)
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)

Fixed submission:
s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0')
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)
Buggy python submission (verdict: Runtime Error):
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)

Fixed submission:
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
a=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)