Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(input())
m=0
for i in range(1,n-1):
  if l[i]=="R":
    if l[i+1]=="R":
      m+=1
  if l[i]=="L":
    if l[i-1]=="L":
      m+=1
if l[0]=="R" and l[0]==l[1]:
  m+=1
if l[-1]=="L" and l[-2]==l[-1]:
  m+=1
print(min(m+k*2,n-1))

Fixed submission:
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=1
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if c//2<=k:
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R":
      if l[i+1]=="R":
        m+=1
    if l[i]=="L":
      if l[i-1]=="L":
        m+=1
  if l[0]=="R" and l[0]==l[1]:
    m+=1
  if l[-1]=="L" and l[-2]==l[-1]:
    m+=1
  print(m+k*2)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=0
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if (c%2==0 and c//2<=k):
  print(n-1)
if (c%2==1 and c//2<k):
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R" and l[i-1]=="R":
      m+=1   
    elif l[i]=="R" and l[i-1]=="L":
      pass
    elif l[i]=="L" and l[i-1]=="R":
      pass
    else:
      m+=1
  if l[-1]==l[-2] and l[-2]=="R":
    m+=1
  elif l[-1]==l[-2] and l[-2]=="L":
    m+=1
  print(m+k*2)

Fixed submission:
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=1
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if c//2<=k:
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R":
      if l[i+1]=="R":
        m+=1
    if l[i]=="L":
      if l[i-1]=="L":
        m+=1
  if l[0]=="R" and l[0]==l[1]:
    m+=1
  if l[-1]=="L" and l[-2]==l[-1]:
    m+=1
  print(m+k*2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
sum=0
l=map(int,input().split())
for i in range(n):
  num=l[i]
  sum+=1/num
print(1/sum)


Fixed submission:
n=int(input())
sum=0
l=list(map(int,input().split()))
for i in range(n):
  num=l[i]
  sum+=1/num
print(1/sum)

Buggy python submission (verdict: Runtime Error):
n=int(input())
sum=0
for i in range(n):
  num=int(input())
  sum+=1/num
print(1/sum)

Fixed submission:
n=int(input())
sum=0
l=list(map(int,input().split()))
for i in range(n):
  num=l[i]
  sum+=1/num
print(1/sum)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b=True
for i in range(1,n):
  if l[-i]>=l[-i-1]:
    pass
  elif l[-i]=l[-1-i]+1:
    l[-1-i]=l[-1-i]-1
  else:
    b=False
    break
if b:
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
b=True
for i in range(1,n):
  if l[n-i]>=l[n-i-1]:
    pass
  elif l[n-i]==l[n-1-i]-1:
    p=l[n-1-i]
    l[n-1-i]=p-1
  else:
    b=False
    break
if b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
in n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)


Fixed submission:
n,d=map(int,input().split())
if n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m-n=>2018:
  print(0)
else:
  l=[]
  for i in range(n,m+1):
    l.append(i%2019)
  l=sorted(l)
  print(l[0]*l[1])

Fixed submission:
n,m=map(int,input().split())
if m-n>=2018:
  print(0)
else:
  l=[]
  for i in range(n,m+1):
    l.append(i%2019)
  t=10000
  for i in range(len(l)-1):
    for j in range(i+1,len(l)):
      if t>(l[i]*l[j])%2019:
        t=(l[i]*l[j])%2019
  print(t)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())))
if l[0]>=0:
  c=l[0]
  l1=[]
  for i in range(1,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  score=l[-1]-c
  print(score)
  for i in l1:
    print(i[0],i[1])
  print(l[-1],c)
elif l[-1]<0:
  c=l[-1]
  l1=[]
  for i in range(0,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  print(c)
  for i in l1:
    print(i[0],i[1])
else:
  l1=[]
  l2=[]
  l3=[]
  for i in l:
    if i<=0:
      l1.append(i)
    else:
      l2.append(i)
  c=l1[0]
  for i in range(len(l2)-1):
    l3.append([c,l2[i]])
    c-=l2[i]
  s1=l2[len(l2)-1]
  for i in range(1,len(l1)):
    l3.append([s1,l1[i]])
    s1-=l1[i]
  score=s1-c
  print(score)
  for i in l3:
    print(i[0],i[1])
  print(s1,c)

Fixed submission:
n=int(input())
l=sorted(list(map(int,input().split())))
if l[0]>=0:
  c=l[0]
  l1=[]
  for i in range(1,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  score=l[-1]-c
  print(score)
  for i in l1:
    print(i[0],i[1])
  print(l[-1],c)
elif l[-1]<0:
  c=l[-1]
  l1=[]
  for i in range(0,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  print(c)
  for i in l1:
    print(i[0],i[1])
else:
  l1=[]
  l2=[]
  l3=[]
  for i in l:
    if i<0:
      l1.append(i)
    else:
      l2.append(i)
  c=l1[0]
  for i in range(len(l2)-1):
    l3.append([c,l2[i]])
    c-=l2[i]
  s1=l2[len(l2)-1]
  for i in range(1,len(l1)):
    l3.append([s1,l1[i]])
    s1-=l1[i]
  score=s1-c
  print(score)
  for i in l3:
    print(i[0],i[1])
  print(s1,c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())))
if l[0]>=0:
  c=l[0]
  l1=[]
  for i in range(1,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  score=l[-1]-c
  print(score)
  for i in l1:
    print(i[0],i[1])
  print(l[-1],c)
else:
  l1=[]
  l2=[]
  l3=[]
  for i in l:
    if i<=0:
      l1.append(i)
    else:
      l2.append(i)
  c=l1[0]
  for i in range(len(l2)-1):
    l3.append([c,l2[i]])
    c-=l2[i]
  s1=l2[len(l2)-1]
  for i in range(1,len(l1)):
    l3.append([s1,l1[i]])
    s1-=l1[i]
  score=s1-c
  print(score)
  for i in l3:
    print(i[0],i[1])
  print(s1,c)

Fixed submission:
n=int(input())
l=sorted(list(map(int,input().split())))
if l[0]>=0:
  c=l[0]
  l1=[]
  for i in range(1,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  score=l[-1]-c
  print(score)
  for i in l1:
    print(i[0],i[1])
  print(l[-1],c)
elif l[-1]<0:
  c=l[-1]
  l1=[]
  for i in range(0,n-1):
    l1.append([c,l[i]])
    c-=l[i]
  print(c)
  for i in l1:
    print(i[0],i[1])
else:
  l1=[]
  l2=[]
  l3=[]
  for i in l:
    if i<0:
      l1.append(i)
    else:
      l2.append(i)
  c=l1[0]
  for i in range(len(l2)-1):
    l3.append([c,l2[i]])
    c-=l2[i]
  s1=l2[len(l2)-1]
  for i in range(1,len(l1)):
    l3.append([s1,l1[i]])
    s1-=l1[i]
  score=s1-c
  print(score)
  for i in l3:
    print(i[0],i[1])
  print(s1,c)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
q=deque()
l=[]
for i in range(h):
  l.append(list(input()))
lb=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if l[i][j]=="#":
      q.append([i,j])
move=[[1,0],[-1,0],[0,1],[0,-1]]
count=0
b=True
q2=deque()
while b:
  while q:
    q1=q.popleft()
    x1=q1[0]
    y1=q1[1]
    for i in range(4):
      dx=move[i][0]
      dy=move[i][1]
      x=x1+dx
      y=y1+dy
      if x<0 or x>h-1 or y<0 or y>w-1:
        pass
      elif l[x][y]=="#":
        pass
      else:
        l[x][y]="#"
        q2.append([x,y])
  if len(q2)!=0:
    q=q2
    q2=deque()
    count+=1
  else:
    b=False
print(count)

Fixed submission:
from collections import deque
h,w=map(int,input().split())
q=deque()
l=[]
for i in range(h):
  l.append(list(input()))
lb=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if l[i][j]=="#":
      q.append([i,j])
move=[[1,0],[-1,0],[0,1],[0,-1]]
count=0
b=True
q2=deque()
while b:
  while q:
    q1=q.popleft()
    x1=q1[0]
    y1=q1[1]
    for i in range(4):
      dx=move[i][0]
      dy=move[i][1]
      x=x1+dx
      y=y1+dy
      if x<0 or x>h-1 or y<0 or y>w-1:
        pass
      elif l[x][y]=="#":
        pass
      else:
        l[x][y]="#"
        q2.append([x,y])
  if len(q2)!=0:
    q=q2
    q2=deque()
    count+=1
  else:
    b=False
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
import functools
import fractions
l1=[]
for i in range(n):
  a=l[0]
  del l[0]
  s = functools.reduce(fractions.gcd, l)
  l1.append(s)
  l.append(a)
print(max(l1))


Fixed submission:
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
l=list(map(int,input().split()))
l1=[]
l1.append(l[0])
for i in range(1,n):
  l1.append(gcd(l1[-1],l[i]))
l2=[]
l2.append(l[-1])
for i in range(n-2,-1,-1):
  l2.append(gcd(l2[-1],l[i]))
l3=[]
for i in range(2,n):
  l3.append(gcd(l1[i-2],l2[n-i-1]))
l3.append(l2[n-2])
l3.append(l1[n-2])
print(max(l3))

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
def gcd(n,m):
  l0=[]
  if n==0:
    return m
  elif m==0;
  return n
  else:
    for i in range(1,n//2):
      if n%i==0:
        l0.append(i)
    l0.append(n)
    g=1
    for i in l0:
      if m%i==0:
        g=i
    return(g)
l1=[]
for i in range(n):
  ll1=gcd(0,l[0])
  ll2=gcd(0,l[n-1])
  if i==0:
    ll1=gcd(0,l[1])
    for j in range(1,n-1):
      ll1=gcd(ll1,l[j])
    l1.append(ll1)
  elif i==n-1:
    ll2=gcd(0,l[0])
    for j in range(n-1):
      ll2=gcd(ll2,l[j])
    l1.append(ll2)
  else:
      for j in range(i):
        ll1=gcd(ll1,l[j])
      for j in range(n-1,i:-1):
        ll2=gcd(ll2,l[j])
      l1.append(gcd(ll2,ll1))
print(max(l1))


Fixed submission:
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
l=list(map(int,input().split()))
l1=[]
l1.append(l[0])
for i in range(1,n):
  l1.append(gcd(l1[-1],l[i]))
l2=[]
l2.append(l[-1])
for i in range(n-2,-1,-1):
  l2.append(gcd(l2[-1],l[i]))
l3=[]
for i in range(2,n):
  l3.append(gcd(l1[i-2],l2[n-i-1]))
l3.append(l2[n-2])
l3.append(l1[n-2])
print(max(l3))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
import functools
import fractions
l1=[]
for i in range(n):
  a=l[0]
  del l[0]
  s = functools.reduce(fractions.gcd, l)
  l1.append(s)
  l.append(a)
print(max(l1))

Fixed submission:
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
l=list(map(int,input().split()))
l1=[]
l1.append(l[0])
for i in range(1,n):
  l1.append(gcd(l1[-1],l[i]))
l2=[]
l2.append(l[-1])
for i in range(n-2,-1,-1):
  l2.append(gcd(l2[-1],l[i]))
l3=[]
for i in range(2,n):
  l3.append(gcd(l1[i-2],l2[n-i-1]))
l3.append(l2[n-2])
l3.append(l1[n-2])
print(max(l3))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
s=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]=0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
    


Fixed submission:
n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
s=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]==0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]=0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
    


Fixed submission:
n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
s=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]==0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
Buggy python submission (verdict: Runtime Error):
l=list(map(int,input().split()))
if max[l]!=l[2] and min(l)!=l[2]:
  print("Yes")
else:
  print("No")

Fixed submission:
l=list(map(int,input().split()))
if max(l)!=l[2] and min(l)!=l[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,s=map(int,input().split())
l=list(input())
for i in range(s):
  p,q=map(int,input().split())
  c=0
  for o in range(p,q):
    if l[o-1]=="A" and l[o]=="C":
      c+=1
  print(c)
    


Fixed submission:
n,m=map(int,input().split())
l=list(input())
list=[0]
c=0
for i in range(len(l)-1):
  if l[i]=="A" and l[i+1]=="C":
    c+=1
    list.append(c)
  else:
    list.append(c)
for i in range(m):
  n,m=map(int,input().split())
  print(list[m-1]-list[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
a,s=map(int,input().split())
l=list(input())
for i in range(s):
  p,q=map(int,input().split())
  c=0
  for o in range(p,q):
    if l[o-1]=="A" and l[o]=="C":
      c+=1
  print(c)
    

Fixed submission:
n,m=map(int,input().split())
l=list(input())
list=[0]
c=0
for i in range(len(l)-1):
  if l[i]=="A" and l[i+1]=="C":
    c+=1
    list.append(c)
  else:
    list.append(c)
for i in range(m):
  n,m=map(int,input().split())
  print(list[m-1]-list[n-1])
Buggy python submission (verdict: Runtime Error):
a,s,d=map(int,input().split())
list=list(map(int,input().split()))
c=0
for i in range(a):
  l=list(map(int,input().split()))
  sum=d
  for k in range(s):
    sum+=list[k]*l[k]
  if sum>0:
    c+=1
print(c)
  

Fixed submission:
a,s,d=map(int,input().split())
lis=list(map(int,input().split()))
c=0
for i in range(a):
  l=list(map(int,input().split()))    
  sum=d
  for k in range(s):
    sum+=lis[k]*l[k]
  if sum>0:
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,s=map(int,input().split())
  l.append([a,s])
l=sorted(l)
p=0
c=0
for i in l:
  if c+l[i][1]>m:
    p+=l[i][0]*(m-c)
    break
  else:
    p+=l[i][0]*l[i][1]
    c+=l[i][1]
print(p)

Fixed submission:
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,s=map(int,input().split())
  l.append([a,s])
l=sorted(l)
p=0
c=0
for i in range(len(l)):
  if c+l[i][1]>m:
    p+=l[i][0]*(m-c)
    break
  else:
    p+=l[i][0]*l[i][1]
    c+=l[i][1]
print(p)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
lm1=[0 for i in range(len(lm))]
ln1=[0 for i in range(len(ln))]
if lm[0]!=lm[1]:
  lm1[0]=1
if ln[0]!=ln[1]:
  ln1[0]=1
for i in range(1,len(lm)):
  if lm[i]==1 and lm[0]==0:
    lm1[i]=1
for i in range(1,len(ln)):
  if ln[i]==1 and ln[0]==0:
    ln1[i]=1
lmn=[0 for i in range(len(lm))]
for i in range(len(lm)):
  if lm1[i]==ln1[i]:
    pass
  else:
    lmn[i]=1
s=1
ss=0
for i in lmn:
  ss+=s*i
  s*=2
print(ss)


Fixed submission:
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
if n!=0:
  lm1=[0 for i in range(len(lm))]
  ln1=[0 for i in range(len(ln))]
  if lm[0]!=lm[1]:
    lm1[0]=1
  if ln[0]!=ln[1]:
    ln1[0]=1
  for i in range(1,len(lm)):
    if lm[i]==1 and lm[0]==0:
      lm1[i]=1
  for i in range(1,len(ln)):
    if ln[i]==1 and ln[0]==0:
      ln1[i]=1
  lmn=[0 for i in range(len(lm))]
  for i in range(len(lm)):
    if lm1[i]==ln1[i]:
      pass
    else:
      lmn[i]=1
  s=1
  ss=0
  for i in lmn:
    ss+=s*i
    s*=2
  print(ss)
else:
  print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lm=[]
m1=m
while m1!=0:
  lm.append(m1%2)
  m1=m1//2
ln=[]
n1=n-1
while n1!=0:
  ln.append(n1%2)
  n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
lm1=[0 for i in range(len(lm))]
ln1=[0 for i in range(len(ln))]
if lm[0]!=lm[1]:
  lm1[0]=1
if ln[0]!=ln[1]:
  ln1[0]=1
for i in range(1,len(lm)):
  if lm[i]==1 and lm[0]==0:
    lm1[i]=1
for i in range(1,len(ln)):
  if ln[i]==1 and ln[0]==0:
    ln1[i]=1
lmn=[0 for i in range(len(lm))]
for i in range(len(lm)):
  if lm1[i]==ln1[i]:
    pass
  else:
    lmn[i]=1
s=1
ss=0
for i in lmn:
  ss+=s*i
  s*=2
print(ss)

Fixed submission:
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
if n!=0:
  lm1=[0 for i in range(len(lm))]
  ln1=[0 for i in range(len(ln))]
  if lm[0]!=lm[1]:
    lm1[0]=1
  if ln[0]!=ln[1]:
    ln1[0]=1
  for i in range(1,len(lm)):
    if lm[i]==1 and lm[0]==0:
      lm1[i]=1
  for i in range(1,len(ln)):
    if ln[i]==1 and ln[0]==0:
      ln1[i]=1
  lmn=[0 for i in range(len(lm))]
  for i in range(len(lm)):
    if lm1[i]==ln1[i]:
      pass
    else:
      lmn[i]=1
  s=1
  ss=0
  for i in lmn:
    ss+=s*i
    s*=2
  print(ss)
else:
  print(m)
Buggy python submission (verdict: Runtime Error):
a,s,d=map(int,input().split())
l=[]
for i in range(1,min(a,s)+1):
  if a%i==0 and s%i==0:
    l.append(i)
print(l[-2])

Fixed submission:
a,s,d=map(int,input().split())
l=[]
for i in range(1,min(a,s)+1):
  if a%i==0 and s%i==0:
    l.append(i)
print(l[-d])
Buggy python submission (verdict: Time Limit Exceeded):
l=list(input())
c=0
while "1" in l and "0" in l:
  for i in range(1,len(l)):
    if (l[i-1]=="0" and l[i]=="1") or (l[i-1]=="1" and l[i]=="0"):
      del l[i-1]
      del l[i-1]
      c+=2
      break
print(c)
      

Fixed submission:
s=list(input())
c1=0
c2=0
for i in range(len(s)):
  if s[i]=="1":
    c1+=1               
  else:
    c2+=1
print(2*min(c1,c2))
Buggy python submission (verdict: Runtime Error):
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
list2=[]
s=0
for i in range(4):
  list=[0,0,0,0]
  list[i]+=l[0]
  if i!=3:
    s+=10
  for j in range(4):
    list[j]+=l[1]
    if j!=3:
      s+=10
      for o in range(4):
        list[o]+=l[2]
        if o!=3:
          s+=10
          for p in range(4):
            list[p]+=l[3]
            if p!=3:
              s+=10
              for u in range(4):
                list[u]+=l[4]
                if u!=3:
                  s+=10                 
                  for t in range(4):
                    list[t]+=l[5]
                    if t!=3:
                      s+=10
                      for r in range(4):
                        list[r]+=l[6]
                        if r!=3:
                          s+=10
                          for q in range(4):
                            list[q]+=l[7]
                            if q!=3:
                              s+=10
                            if list[0]==0 or list[1]==0 or list[2]==0:
                              pass
                            else:
                              list2.append(abs(a-list[0])+abs(b-list[1])+abs(c-list[2]))
print(min(list2))
                        
                      

  

  
  


           

Fixed submission:
n,x,y,z=map(int,input().split())
l=[]
cmin=1000000000
for i in range(n):
  l.append(int(input()))
for i in range(4**n):
  l1=[]
  for j in range(n):
    if i>=4:
      l1.append(i%4)
      i=(i//4)
    elif i!=0:
      l1.append(i)
      i=0
    else:
      l1.append(i)
  c1=0
  c2=0
  c3=0
  d1=0
  d2=0
  d3=0
  l1=l1[::-1]
  for j in range(n):
    if l1[j]==0:
      pass
    elif l1[j]==1:
      c1+=l[j]
      d1+=1
    elif l1[j]==2:
      c2+=l[j]
      d2+=1
    else:
      c3+=l[j]
      d3+=1
  if c1*c2*c3!=0:
    c=abs(c1-x)+abs(c2-y)+abs(c3-z)+(d1+d2+d3-3)*10
    if c<=cmin:
      cmin=c
print(cmin)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
l=[a]
b=True
i=1
while b==True:
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a in l:
    b==False
    print(i+1)
    exit
  else:
    l.append(a)
    i+=1
   
  
    

Fixed submission:
a=int(input())
l=[a]
b=True
i=1
while b==True:
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a in l:
    b=False
    print(i+1)
    exit
  else:
    l.append(a)
    i+=1
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(n):
  for j in range(i,n):
    if 0 in l[i:j+1]:
      pass
    else:
      l[i:j+1]-=1
      c+=1
print(c)

Fixed submission:
import numpy as np
n=int(input())
l=np.array(list(map(int,input().split())))
c=0
for i in range(n):
  for j in range(n-i):
    if 0 in l[i:n-j]:
      pass
    else:
      c+=min(l[i:n-j])
      l[i:n-j]=l[i:n-j]-np.array([min(l[i:n-j])]*(n-j-i))
print(c)
Buggy python submission (verdict: Runtime Error):
l=sorted(list(map(int,input(.split()))))
if l==[1,9,7,4]:
  print("YES")
else:
  print("NO")
         

Fixed submission:
l=sorted(list(map(int,input().split())))
if l==[1,4,7,9]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
def dp1(n1):
  if dp[n1]!=-1:
    return dp[n1]
  else:
    ans=min(dp1(n1-1)+abs(l[n1-1]-l[n1]),dp1(n1-2)+abs(l[n1-2]-l[n1]))
    dp[n1]=ans
    return ans
print(dp1(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
def dp1(n1):
  if dp[n1]!=-1:
    return dp[n1]
  else:
    ans=min(dp1(n1-1)+abs(l[n1-1]-l[n1]),dp1(n1-2)+abs(l[n1-2]-l[n1]))
    dp[n1]=ans
    return ans
print(dp1(n-1))

Buggy python submission (verdict: Runtime Error):
n=int(input())
dp=[0 for i in range(n)]
l=list(map(int,input().split()))
def dp1(n1):
  if n1==n-1:
    ans=min(dp[n-2]+abs(l[n-2]-l[n-1]),dp[n-3]+abs(l[n-3]-l[n-1]))            
    dp[n-1]=ans
    return ans
  else:
    ans=min(dp[n1-2]+abs(l[n1-2]-l[n1-1]),dp[n1-3]+abs(l[n1-3]-l[n1-1]))
    dp[n1]=ans
    return ans
dp1(0)
print(dp[n-1])

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
def dp1(n1):
  if dp[n1]!=-1:
    return dp[n1]
  else:
    ans=min(dp1(n1-1)+abs(l[n1-1]-l[n1]),dp1(n1-2)+abs(l[n1-2]-l[n1]))
    dp[n1]=ans
    return ans
print(dp1(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=tuple(map(int,input().split()))
dp=[-1]*(n+1)
dp[1]=0
for i in range(2,min(n,k)+1):
  dp[i]=abs(l[i-1]-l[0])
if k>=n:
  print(dp[n])
else:
  dp[k+1]=abs(l[0]-l[k])
  for i in range(k+2,n+1):
    min=10**10
    for j in range(i-k,i):
      if min>dp[j]+abs(l[j-1]-l[i-1]):
        min=dp[j]+abs(l[j-1]-l[i-1])
    dp[i]=min
  print(dp[n])


Fixed submission:
n,k=map(int,input().split())
l=tuple(map(int,input().split()))
dp=[-1]*(n+1)
dp[1]=0
for i in range(2,min(n,k)+1):
  dp[i]=abs(l[i-1]-l[0])
if k>=n:
  print(dp[n])
else:
  dp[k+1]=abs(l[0]-l[k])
  for i in range(k+2,n+1):
    min=10**10
    for j in range(i-k,i):
      if min>dp[j]+abs(l[j-1]-l[i-1]):
        min=dp[j]+abs(l[j-1]-l[i-1])
    dp[i]=min
  print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)
n1,k=map(int,input().split())
l=list(map(int,input().split()))
inf=10**9
dp=[-1 for i in range(n1)]
dp[0]=0
def dp1(n):
  if n==0:
    return 0
  elif dp[n]!=-1:
    return dp[n]
  elif 1<=n and n<=k-1:
    num=n
    min=inf
    for i in range(num):
      num1=dp1(i)
      high=abs(l[i]-l[n])
      if min>num1+high:
        min=num1+high
    dp[n]=min
    return min
  else:
    min=inf
    for i in range(1,1+k):
      num1=dp1(n-i)
      high=abs(l[n-i]-l[n])
      if min>num1+high:
        min=num1+high
    dp[n]=min
    return min
print(dp1(n1-1))
      

Fixed submission:
n,k=map(int,input().split())
l=tuple(map(int,input().split()))
dp=[-1]*(n+1)
dp[1]=0
for i in range(2,min(n,k)+1):
  dp[i]=abs(l[i-1]-l[0])
if k>=n:
  print(dp[n])
else:
  dp[k+1]=abs(l[0]-l[k])
  for i in range(k+2,n+1):
    min=10**10
    for j in range(i-k,i):
      if min>dp[j]+abs(l[j-1]-l[i-1]):
        min=dp[j]+abs(l[j-1]-l[i-1])
    dp[i]=min
  print(dp[n])