Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print('Yes' if abs(a-b)<=d or abs(a-c)+abs(b-c)<=2d else 'No')

Fixed submission:
a,b,c,d=map(int,input().split())
print('Yes' if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
P=list(map(int,input().split()))
par=[i for i in range(N)]
ans=0

def root(x):
    if x!=par[x]:
        par[x]=root(par[x])
    return par[x]

def connect(x,y):
    if root(x)!=root(y):
        par[root(y)]=root(x)

for i in range(M):
    x,y=map(int,input().split())
    connect(x-1,y-1)

for i in range(N):
    if root(i)==root(P[i]-1):
        ans+=1

print(ans)

Fixed submission:
a,b,c,d=map(int,input().split())
print('Yes' if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')
Buggy python submission (verdict: Runtime Error):
ans=''
for i in range

Fixed submission:
ans=''
for i in range(3):
  s=input()
  ans+=s[i]
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

if N==1 and M==1:
  ans=1
elif N=1 or M=1:
  ans=max(N,M)-2
else:
  ans=(N-2)*(M-2)
  
print(ans)

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

if N==1 and M==1:
  ans=1
elif N==1 or M==1:
  ans=max(N,M)-2
else:
  ans=(N-2)*(M-2)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
dict={}

for i in range(N):
	dict[input()]=1

ans=0
for d in dict:
  ans+=1
  
print('Three' if ans==3 else 'Four')


Fixed submission:
N=int(input())
Colors=list(map(str,input().split()))
dict={}

for c in Colors:
  dict[c]=1

ans=0
for d in dict:
  ans+=1
  
print('Three' if ans==3 else 'Four')
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=set()

for i in range(N):
  s=input()
  if s[0] in [M,A,R,C,H]:
    S.add(s)

L=len(S)

print(L*(L-1)*(L-2)//6)

Fixed submission:
N=int(input())
chars=['M','A','R','C','H']
dict={}
for c in chars:
  dict[c]=0
  
ans=0
  
for i in range(N):
  s=input()
  if (s[0] in chars):
    dict[s[0]]+=1

L=list(dict.values())
    
for i in range(2**5):
  usedchars=[]
  for j in range(5):
    if i>>j&1==1:
      usedchars.append(L[j])
    
  if len(usedchars)==3:
    ans+=usedchars[0]*usedchars[1]*usedchars[2]

print(ans)
Buggy python submission (verdict: Runtime Error):
import queue

q = queue.Queue()
H,W = map(int, input().split())
memo = [[-1]*W for _ in range(H)]
board = [input() for _ in range(H)]
wall=0
direction = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def bfs():
    memo[0][0] = 0
    q.put((0, 0))
    while not q.empty():
        y,x= q.get()
        for (dy, dx) in direction:
            if 0<=y+dy<=H-1 and 0<=x+dx<=W-1 and board[y+dy][x+dx] == '.' and memo[y+dy][x+dx] == -1:
                q.put((y + dy, x + dx))
                memo[y + dy][x + dx] = memo[y][x] + 1
                if (y+dy, x+dx) == (H-1, W-1):
                    return memo[H-1][W-1]

for s in board:
    wall+=s.count('#')

print(H*W-wall-(bfs()+1))

Fixed submission:
import queue

q = queue.Queue()
H,W = map(int, input().split())
memo = [[-1]*W for _ in range(H)]
board = [input() for _ in range(H)]
wall=0
direction = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def bfs():
    memo[0][0] = 0
    q.put((0, 0))
    while not q.empty():
        y,x= q.get()
        for (dy, dx) in direction:
            if 0<=y+dy<=H-1 and 0<=x+dx<=W-1 and board[y+dy][x+dx] == '.' and memo[y+dy][x+dx] == -1:
                q.put((y + dy, x + dx))
                memo[y + dy][x + dx] = memo[y][x] + 1
                if (y+dy, x+dx) == (H-1, W-1):
                    return memo[H-1][W-1]
    return -1


for s in board:
    wall+=s.count('#')

min_dist=bfs()
print(H*W-wall-(min_dist+1) if min_dist>0 else -1)
Buggy python submission (verdict: Runtime Error):
s=list(input())
s[3]=8
print(''.join(s))

Fixed submission:
s=list(input())
s[3]=str(8)
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
n=int(input)
print(48-n)

Fixed submission:
n=int(input())
print(48-n)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
S=input()
flag=False
for i in range(len(S)):
  if i!=A and (S[i]-'0'<0 or 9<S[i]-'0'):
    break
  if i==A and S[i]!='-':
    break
  
  if i==len(S)-1:
    flag=True
    
if flag:
  print('Yes')
else:
  print('No')

Fixed submission:
A,B=map(int,input().split())
S=input()
flag=False
for i in range(len(S)):
  if i!=A and ((ord(S[i])-ord('0'))<0 or 9<(ord(S[i])-ord('0'))):
    break
  if i==A and S[i]!='-':
    break
  
  if i==len(S)-1:
    flag=True
    
if flag:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
l=map(int,input().split())
L=l[0]+l[1]
R=l[2]+l[3]

if R==L:
  print('Balanced')
elif R>L:
  print('Right')
else:
  print('Left')

Fixed submission:
l=list(map(int,input().split()))
L=l[0]+l[1]
R=l[2]+l[3]

if R==L:
  print('Balanced')
elif R>L:
  print('Right')
else:
  print('Left')
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int, input().split())
ans=0

def my_sum(x):
  ret=0
  for j in range(4):
    ret+=x%10
    x=x//10
  return ret 

for i in range(N+1):
  if A<=my_sum(i)<==B:
    ans+=1

print(ans)

Fixed submission:
N,A,B=map(int, input().split())
ans=0

def my_sum(x):
  ret=0
  while x>0:
    ret+=x%10
    x=x//10
  return ret 

for i in range(N+1):
  if A<=my_sum(i)<=B:
    ans+=i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
S=set(L)
ans=0

for s in S:
    tmp=L.count(s)
    if tmp>s:
        ans+=tmp-s
    elif tmp<s:
        ans+=tmp

print(ans)


Fixed submission:
N=int(input())
L=list(map(int,input().split()))
S=set(L)
ans=0
dict={}

for s in S:
    dict[s]=0

for l in L:
    dict[l]+=1

for d in dict.items():
    num=d[0]
    amount=d[1]

    if amount>num:
        ans+=amount-num
    elif amount<num:
        ans+=amount

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))ans=0
flag=0

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1

print(ans)

Fixed submission:
S=input()
ans=0
for s in S:
  if s=='1':
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))ans=0
flag=0

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1


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

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0

while True:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      return
  ans+=1


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

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0

while True:
  for i in range(N):
    if A[i]%2==0:
      A[i]=A//2
    else:
      print(ans)
      return
  ans+=1


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

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0

while True:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A>>1
    else:
      print(ans)
      return
  ans+=1

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

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1
Buggy python submission (verdict: Runtime Error):
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmp=[0]*10
    tmpans=0
    for j in range(0,10):
        bit=i>>j&1
        for n in range(N):
            tmp[n]+=F[n][j]*bit
    for n in range(N):
        tmpans+=P[n][tmp[n]]

    ans=max(ans,tmpans)

print(ans)

Fixed submission:
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmpans=0
    for n in range(N):
        c=0
        for j in range(10):
            if (i>>j&1)&F[n][j]:
                c+=1
        tmpans+=P[n][c]

    ans=max(ans,tmpans)

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10
INF=10**9
ans=-INF


for i in range(1,2**10):
    tmp=[0]*10
    tmpans=0
    for j in range(0,10):
        bit=i>>j&1
        for n in range(N):
            tmp[n]+=F[n][j]*bit
    for n in range(N):
        tmpans+=P[n][tmp[n]]

    ans=max(ans,tmpans)

print(ans)

Fixed submission:
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmpans=0
    for n in range(N):
        c=0
        for j in range(10):
            if (i>>j&1)&F[n][j]:
                c+=1
        tmpans+=P[n][c]

    ans=max(ans,tmpans)

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()

for i in range(1<<3):
  tmp+=S[0]
  for j in range(3):
    if i>>j&1==1:
      tmp+='+'
    else:
      tmp+='-'
  if eval(tmp)==7:
    break
print(tmp+'=7')
    

Fixed submission:
S=input()
for i in range(1<<3):
  tmp=S[0]
  for j in range(3):
    if i>>j&1==1:
      tmp+='+'
    else:
      tmp+='-'
    tmp+=S[j+1]
  if eval(tmp)==7:
    break
print(tmp+'=7')
Buggy python submission (verdict: Runtime Error):
c1=input()
c2=input()
if c1[0]==c2[2] and c1[1]==c2[2] adn c1[2]==c2[0]:
  print('YES')
else:
  print('NO')

Fixed submission:
c1=input()
c2=input()
if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print('Possible')
else:
  print('Impossible')

Fixed submission:
A,B=map(int,input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print('Possible')
else:
  print('Impossible')
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=sorted(list(map(int,input().split()))).reverse()
ans=0
for i in range K:
  ans+=A[i]
  
print(ans)

Fixed submission:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
A.reverse()
ans=0
for i in range(K):
  ans+=A[i]
  
print(ans)
Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())

for i in range(K):
  for j in range(K-i):
    for k in range(K-i-j):
      if i+j+k==S:
        ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())

ans=0

for i in range(K+1):
  if 0<=S-i<=K:
    ans+=S-i+1
  elif K<S-i<=2*K:
    ans+=2*K-(S-i)+1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
result = 0
people = int(input('people:'))
restrict = int(input('Restricted height:'))

for i in range(people):
    p1 = int(input())
    if p1 >= restrict:
        result +=1
print(result)

Fixed submission:
import numpy as np
result = 0
N = list(map(int, input().split())) 
A = list(map(int, input().split())) 

for i in range(N[0]):
    p1 = A[i]
    if p1 >= N[1]:
        result +=1
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
listH =  list(map(int, input().split()))
count_lr = 0
li_lr = []

for i in range(N-1):
    if listH[i] >= listH[i+1]:
        count_lr += 1
        li_lr.append(count_lr)
    else:
        count_lr = 0
        li_lr.append(count_lr)
        
print(max(li_lr))

Fixed submission:
N = int(input())
listH =  list(map(int, input().split()))
val = 0
ans = 0

for i in range(N-1):
    if listH[i] >= listH[i+1]:
        val += 1
    else:
        val = 0
    ans = max(val,ans)
        
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
listH =  list(map(int, input().split()))
count_lr = 0
count_rl = 0
li_lr = []


for i in range(N-1):
    if listH[i] >= listH[i+1]:
        count_lr += 1
        li_lr.append(count_lr)
    else:
        count_lr = 0
        li_lr.append(count_lr)
        
print(max(li_lr))

Fixed submission:
N = int(input())
listH =  list(map(int, input().split()))
val = 0
ans = 0

for i in range(N-1):
    if listH[i] >= listH[i+1]:
        val += 1
    else:
        val = 0
    ans = max(val,ans)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B=int(input().split())
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)

Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d_list=map(int,inout().spllit())
count=0
for i in range(n):
  for j in range(n):
    count+=d_list[i]*d_list[j]
  count-=d_list[i]**2
if n=2:
  print(count)
else:
  print(count/2)

Fixed submission:
n=int(input())
d_list=list(map(int,input().split()))
count=0
for i in range(n):
  for j in range(n):
    if i<j:
        count+=d_list[i]*d_list[j]
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d_list=map(int,inout().spllit())
count=0
for i in range(n):
  for j in range(n):
    count+=d_list[i]*d_list[j]
  count-=d_list[i]**2
print(count)

Fixed submission:
n=int(input())
d_list=list(map(int,input().split()))
count=0
for i in range(n):
  for j in range(n):
    if i<j:
        count+=d_list[i]*d_list[j]
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d_list=map(int,inout().spllit())
count=0
for i in range(n):
  count-=d_list[i]**2
  for j in range(n):
    count+=d_list[i]*d_list[j]
print(count)

Fixed submission:
n=int(input())
d_list=list(map(int,input().split()))
count=0
for i in range(n):
  for j in range(n):
    if i<j:
        count+=d_list[i]*d_list[j]
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d_list=map(int,inout().spllit())
count=0
for i in range(n):
  count-=d_list[i]
  for j in range(n):
    count+=d_list[i]*d_list[j]
print(count)

Fixed submission:
n=int(input())
d_list=list(map(int,input().split()))
count=0
for i in range(n):
  for j in range(n):
    if i<j:
        count+=d_list[i]*d_list[j]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lst=list(map(int,input().split()))
lst.sort(reverse=False)
count=0
for i in range(n-2):
    for j in range(i+1,n-1):              
        for k in range(j+1,n):            
            a=lst[i]
            b=lst[j]
            c=lst[k]
            if b-a<c<a+b:
                    count+=1
            elif c>a+b:
                break
print(count)



Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        x=l[i]+l[j]
        y=bisect.bisect_left(l,x)-j-1        
        ans+=y
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lst=list(map(int,input().split()))
count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):              
            a=lst[i]
            b=lst[j]
            c=lst[k]
            if a<b+c and b<c+a and c<a+b:
                    count+=1
print(count)


Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        x=l[i]+l[j]
        y=bisect.bisect_left(l,x)-j-1        
        ans+=y
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))
count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(k+1,n):              
            a=lst[i]
            b=lst[j]
            c=lst[k]
            if a<b+c and b<c+a and c<a+b:
                    count+=1
print(count)


Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        x=l[i]+l[j]
        y=bisect.bisect_left(l,x)-j-1        
        ans+=y
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lst=list(map(int,input().split()))
count=0
for i in range(n-2):
    for j in range(1,n-1):
        for k in range(2,n):
            if i<j<k:                
                a=lst[i]
                b=lst[j]
                c=lst[k]
                if a<b+c and b<c+a and c<a+b:
                    count+=1
print(count)


Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        x=l[i]+l[j]
        y=bisect.bisect_left(l,x)-j-1        
        ans+=y
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l2=[0]*(n+1)
for i,j in enumerate(l,1):
    l2[j]=i
l2.remove(0)    
print(' '.join(map(str,l2)))    


Fixed submission:
n=int(input())
if n%2==0:
    print(1/2)
else:
    print((1+n)/(2*n))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
s=''
for i in range(1,n+1):
    s+=str(l.index(i)+1)+' '
print(s)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l2=[0]*(n+1)
for i,j in enumerate(l,1):
    l2[j]=i 
print(' '.join(map(str,l2[1:])))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
l=list(map(int,input().split()))
s=''
for i in range(1,n+1):
    s+=str(l.index(i)+1)+' '
print(s)


Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l2=[0]*(n+1)
for i,j in enumerate(l,1):
    l2[j]=i 
print(' '.join(map(str,l2[1:])))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
l=list(map(int,input().split()))
l_2=[]
for i in range(1,n+1):
    l_2.append(l.index(i)+1)
s=''
for j in range(n):
    s+=str(l_2[j])+' '
print(s)


Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l2=[0]*(n+1)
for i,j in enumerate(l,1):
    l2[j]=i 
print(' '.join(map(str,l2[1:])))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lst=list(map(int,input().split()))
for i in range(m):
    x=lst.index(max(lst))
    lst[x]=int(lst[x]/2)
print(sum(lst))

Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))
   
    
    
print(-1*sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort(reverse=True)
for i in range(m):
    x=lst.index(max(lst))
    lst[x]=int(lst[x]/2)
print(sum(lst))    

Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))
   
    
    
print(-1*sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort(reverse=True)
for i in range(m):
    lst.sort(reverse=True)
    lst[0]=int(lst[0]/2)
print(sum(lst))    

Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))
   
    
    
print(-1*sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

s = S
index = 0
ans = 0
while index < len(s)-1:
    c = s[index]
    next_c = s[index+1]
    if c != next_c:
        s = s[:index] + s[index+2:]
        index = 0
        ans += 2
    else:
        index += 1

print(ans)


Fixed submission:
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)

Buggy python submission (verdict: Runtime Error):
S = input()

s = S
index = 0
ans = 0
while index < len(s)-1:
    c = s[index]
    next_c = s[index+1]
    if c != next_c:
        s = s[:index] + s[index+2:]
        index = 0
        ans += 2
    else:
        index += 1
    print(s + ' ans:' + str(ans))

print(ans)


Fixed submission:
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)

Buggy python submission (verdict: Runtime Error):
S = input()

s = S
index = 0
ans = 0
while index < len(s)-1:
    c = s[index]
    next_c = s[index+1]
    if c != next_c:
        s = s[:index] + s[index+2:]
        index = 0
        ans += 2
    else:
        index += 1
    print(s + ' ans:' + str(ans))

print(ans)


Fixed submission:
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)
Buggy python submission (verdict: Runtime Error):
from itertools import count

N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w - WV[i][0] >= 0:  # 品物を追加できるとき
            dp[i+1][w] = max(dp[i+1][w], dp[i][w-WV[i][0]] + WV[i][1])
        # できないとき
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])
print(dp[N][W])


Fixed submission:
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

V = 10**3
dp = [[float('INF')]*(N*(V+1)) for _ in range(N+1)]  # Nとv≦10**3の制約から取りうるvの範囲
dp[0][0] = 0

for i in range(N):
    for v in range((i+1)*(V+1)):
        if v - WV[i][1] >= 0:  # 品物を追加できるとき
            dp[i+1][v] = min(dp[i+1][v], dp[i][v-WV[i][1]] + WV[i][0])
        # できないとき
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

ans = 0
for i in range(N*(V+1)):
    if dp[N][i] <= W:
        ans = i
print(ans)