Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')
pl=a%(p+1)
if popcount(a)!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if popcount(a)!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))


Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')
pl=a%(p+1)
if popcount(a)!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if popcount(a)!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))


Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')
pl=a%(p+1)
if popcount(x)!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if popcount(a)!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))


Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')
pl=a%(p+1)
if popcount!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if popcount(a)!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")

pl=a%(popcount(a)+1)
if popcount!=1:
  mi=a%(popcount(a)-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,popcount(a)+1)
    b%=popcount(a)+1
  else:
    if popcount(a)-1!=0:
      b=mi
      b-=pow(2,N-i-1,popcount(a)-1)
      b%=popcount(a)-1
    else:
      print(0)
      continue
  print(f(b))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return str(bin(x)).count("1")

pl=a%(popcount(a)+1)
if popcount!=1:
  mi=a%(popcount(a)-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,popcount(a)+1)
    b%=popcount(a)+1
  else:
    if popcount(a)-1!=0:
      b=mi
      b-=pow(2,N-i-1,popcount(a)-1)
      b%=popcount(a)-1
    else:
      print(0)
      continue
  print(f(b))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return str(bin(x)).count("1")

pl=a%(popcount(a)+1)
if popcount!=1:
  mi=a%(popcount(a)-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,popcount(a)+1)
    b%=popcount(a)+1
  else:
    if popcount(a)-1!=0:
      b=mi
      b-=pow(2,N-i-1,popcount(a)-1)
      b%=popcount(a)-1
    else:
      print(0)
  print(f(b))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(input())
m=0
onecount=0
for i in range(N):
  d=N-1-i
  if X[i]=='1':
    m+=2**d
    onecount+=1

def f(x):
  result={}
  result[0]=0
  result[1]=1
  if x in result:
    return result[x]
  else:
    a=str(bin(x))
    b=a.count('1')
    d=x%b
    result[a]=f(d)+1
    return f(d)+1
  
for i in range(N):
  d=N-1-i
  if X[i]=='0':
    D=m+2**d
  else:
    D=m-2**d
  print(f(D))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(input())
m=0
onecount=0
for i in range(N):
  d=N-1-i
  if X[i]=='1':
    m+=2**d
    onecount+=1

def f(x):
  result={}
  result[0]=0
  result[1]=1
  if x in result:
    return result[x]
  else:
    a=str(bin(x))
    b=a.count('1')
    d=x%b
    result[a]=f(d)+1
    return f(d)+1
  
for i in range(N):
  d=N-1-i
  if X[i]=='0':
    D=m+2**d
  else:
    D=m-2**d
  print(f(D))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(input())
m=0
onecount=0
for i in range(N):
  d=N-1-i
  if X[i]=='1':
    m+=2**d
    onecount+=1

def f(x):
  result={}
  result[0]=0
  result[1]=1
  if x in result:
    return result[x]
  else:
    a=str(bin(x))
    b=a.count('1')
    d=x%b
    return f(d)+1
  
for i in range(N):
  d=N-1-i
  if X[i]=='0':
    D=m+2**d
  else:
    D=m-2**d
  print(f(D))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(input())
m=0
onecount=0
for i in range(N):
  d=N-1-i
  if X[i]=='1':
    m+=2**d
    onecount+=1

def f(x):
  result={}
  result[0]=0
  result[1]=1
  if x in result:
    return result[x]
  else:
    a=str(bin(x))
    b=a.count('1')
    d=x%b
    return f(d)+1
  
for i in range(N):
  d=N-1-i
  if X[i]=='0':
    D=m+2**d
  else:
    D=m-2**d
  print(f(D))

Fixed submission:
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))