Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math

def saiki(n,saiki_one_count,do_count):
    do_count += 1
    mod = n % saiki_one_count
    if mod == 0:
        return do_count
    saiki_one_count = bin(mod).count("1")
    return saiki(mod,saiki_one_count,do_count)
def main():
    input = sys.stdin.readline
    N = int(input())
    x = input()
    x_list = list(x)[:-1]
    x_list = [int(value) for value in x_list]
    one_count = x_list.count(1)
    sum_x = 0
    for i in range(len(x_list)):
        if x_list[N -1 - i] == 1:
            sum_x += 2 ** i
    zero_convert = sum_x%(one_count+1)
    one_convert = sum_x%(one_count+1)

    for i in range(len(x_list)):
        current_sum_x = 0
        current_one_count = 0
        if x_list[i] == 0:
            current_one_count = one_count + 1
            current_sum_x = zero_convert + pow(2,N-i-1,current_one_count)
        else:
            current_one_count = one_count - 1
            current_sum_x = one_convert + pow(2,N-i-1,current_one_count)
        do_count = saiki(current_sum_x,current_one_count,0)
        print(do_count)
    return


if __name__ == '__main__':
    main()

Fixed submission:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math

def saiki(n,saiki_one_count,do_count):
    do_count += 1
    mod = n % saiki_one_count
    if mod == 0:
        return do_count
    saiki_one_count = bin(mod).count("1")
    return saiki(mod,saiki_one_count,do_count)
def main():
    input = sys.stdin.readline
    N = int(input())
    x = input()
    x_list = list(x)[:-1]
    x_list = [int(value) for value in x_list]
    one_count = x_list.count(1)
    sum_x = 0
    for i in range(len(x_list)):
        if x_list[N -1 - i] == 1:
            sum_x += 2 ** i

    for i in range(len(x_list)):
        current_sum_x = 0
        current_one_count = 0
        if x_list[i] == 0:
            current_one_count = one_count + 1
            current_sum_x = sum_x + 2 ** (N - 1 - i)
        else:
            current_one_count = one_count - 1
            current_sum_x = sum_x - 2 ** (N - 1 - i)
        do_count = saiki(current_sum_x,current_one_count,0)
        print(do_count)
    return


if __name__ == '__main__':
    main()

Fixed submission:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()