Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

H,W,K = map(int,input().split())

A = []
for i in range(H):

    a = list(map(int,list(input())))
    A.append(a)

#print (A)
ans = float("inf")

for i in range(2**(H-1)):

    wtk = [0]
    cut = 0

    for j in range(H-1):

        if i & 2**j > 0:
            wtk.append(wtk[-1]+1)
            cut += 1
        else:
            wtk.append(wtk[-1])

    now = [0] * (H)

    for y in range(W):

        flag = True
        nnow = now.copy()
        save = [0] * (H)

        for x in range(H):

            nnow[wtk[x]] += A[x][y]
            save[wtk[x]] += A[x][y]

        if max(save) > K:
            cut = float("inf")
            break
        if max(nnow) > K:
            cut += 1
            nnow = save

        now = nnow

    ans = min(ans,cut)
            
print (ans)


Fixed submission:

H,W,K = map(int,input().split())

A = []
for i in range(H):

    a = list(map(int,list(input())))
    A.append(a)

#print (A)
ans = float("inf")

for i in range(2**(H-1)):

    wtk = [0]
    cut = 0

    for j in range(H-1):

        if i & 2**j > 0:
            wtk.append(wtk[-1]+1)
            cut += 1
        else:
            wtk.append(wtk[-1])

    now = [0] * (H)

    for y in range(W):

        flag = True
        nnow = []
        for ll in now:
            nnow.append(ll)
        save = [0] * (H)

        for x in range(H):

            nnow[wtk[x]] += A[x][y]
            save[wtk[x]] += A[x][y]

        if max(save) > K:
            cut = float("inf")
            break
        if max(nnow) > K:
            cut += 1
            nnow = save

        now = nnow

    ans = min(ans,cut)
            
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

dp = [[0,0,0]] #bitをset代わりとして用いる [bitset,最後に置いた数字,転倒数]の構成

for loop in range(N): #N枚のカードを置いていく

    ndp = [] #次のループのdp配列
    for ing in dp: #dpの中の各場合について次の場合を調べる

        bit = ing[0]
        lastnum = ing[1]
        revnum = ing[2]

        for i in range(N): #各カードが後ろにおけるかを判定

            if bit & (2**i) > 0: #既に使われてたら飛ばす
                continue

            revnum_add = 0
            for j in range(N): #転倒数がいくつ増えるかの計算
                if j > i and bit&(2**j) > 0:
                    revnum_add += 1

            if i % 2 == loop % 2: #置く位置と初期位置の偶奇が等しければ表
                if A[i] >= lastnum: #置けるなら置く
                    ndp.append([ bit|(2**i) , A[i] ,revnum+revnum_add])

            else:
                if B[i] >= lastnum:
                    ndp.append([ bit|(2**i) , B[i] ,revnum+revnum_add])


    dp = ndp


ans = float("inf") #答えは最小の転倒数
for ing in dp:
    ans = min(ans,ing[2])

if ans == float("inf"):
    ans = -1
print (ans)


Fixed submission:

N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = float("inf")

for ii in range(2 ** N):

    s = format(ii,'b').zfill(N)
    on = 0
    
    for j in s:
        if j == "1":
            on += 1

    if on != (N+1)//2:
        continue

    q = []
    q2 = []

    for i in range(N):
        if s[i] == "1":
            if i % 2 == 0:
                q.append([A[i],i])
            else:
                q.append([B[i],i])
        else:
            if i % 2 != 0:
                q2.append([A[i],i])
            else:
                q2.append([B[i],i])           

    q.sort()
    q2.sort()
    q2.append([float("inf"),0])
    #print (q,q2)

    flag = True
    nmax = 0

    for i in range((N+1)//2):


        if nmax > q[i][0]:
            flag = False
        nmax = q[i][0]

        if nmax > q2[i][0]:
            flag = False
        nmax = q2[i][0]

    if flag:
        r = []
        for i in range((N+1)//2):
            r.append(q[i][1])
            r.append(q2[i][1])

        #print (r)

        now = 0
        z = [i for i in range(N)]
        for i in range(N):
            for j in range(len(z)):
                if z[j] == r[i]:
                    now += j
                    del z[j]
                    break
            #print (z,now)
        ans = min(now,ans)

if ans == float("inf"):
    ans = -1
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


N = int(input())

x = list(map(int,input().split()))

mod = 10 ** 9 + 7


ans = 0
t = [1]
u = [1]

for i in range(N):

    i += 1
    t.append(t[-1] * i % mod)

for i in range(N-1):
    u.append(u[-1] * (N-1-i))
    
#print (t)
#print (u)
u.reverse()


now = 0
for i in range(N-1):

    now += u[i+1] * t[i]
    now %= mod
    ans += now * (x[i+1] - x[i])
    ans %= mod
    #print (i,ans/6)

print (ans)



Fixed submission:

N = int(input())

x = list(map(int,input().split()))

mod = 10 ** 9 + 7


ans = 0
t = [1]
u = [1]

for i in range(N):

    i += 1
    t.append(t[-1] * i % mod)

for i in range(N-1):
    u.append(u[-1] * (N-1-i) % mod)
    
#print (t)
#print (u)
u.reverse()


now = 0
for i in range(N-1):

    now += u[i+1] * t[i]
    now %= mod
    ans += now * (x[i+1] - x[i])
    ans %= mod
    #print (i,ans/6)

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

if N % 3 == 0:

    cr = ["abb","a.c","ddc"]

    ans = [ ["."] * N for i in range(N) ]

    for i in range(N):

        for j in range(N):

            ans[i][j] = cr[i % 3][j % 3]

    for i in range(N):
        print ("".join(ans[i]))

elif N % 4 == 0:

    cr = ["abee","abff","ccgh","ddgh"]

    ans = [ ["."] * N for i in range(N) ]

    for i in range(N):

        for j in range(N):

            ans[i][j] = cr[i % 4][j % 4]

    for i in range(N):
        print ("".join(ans[i]))

else:
    print (-1)

    if N == 5:
        a = []
        a[1] += 1

Fixed submission:

N = int(input())


if N == 3:

    ans = [".aa","b..","b.."]

    for i in ans:
        print (i)

elif N >= 4:

    four = ["abcc","abdd","hhfg","eefg"]
    five = ["ahhgg","ai..f","bi..f","b.jje","ccdde"]
    six = ["add.ff","a.ce..","bbce..",".ffadd","e..a.c","e..bbc"]
    seven = [".iijjkk","fadd...","fa.c...","gbbc...","g...add","h...a.c","h...bbc"]

    ans = [ ["."] * N for i in range(N) ]

    now = 0
    while N-now > 7:

        for i in range(4):
            for j in range(4):

                ans[i+now][j+now] = four[i][j]

        now += 4

    if N - now == 4:
        for i in range(4):
            for j in range(4):

                ans[i+now][j+now] = four[i][j]

    elif N - now == 5:
        for i in range(5):
            for j in range(5):

                ans[i+now][j+now] = five[i][j]

    elif N - now == 6:
        for i in range(6):
            for j in range(6):

                ans[i+now][j+now] = six[i][j]

    else:
        for i in range(7):
            for j in range(7):

                ans[i+now][j+now] = seven[i][j]

    for i in range(N):
        print ("".join(ans[i]))

else:
    print (-1)
Buggy python submission (verdict: Runtime Error):

N,K = map(int,input().split())

H = list(map(int,input().split()))


dp = [[None] * (N-K+1) for i in range(N) ]

for i in range(N):

    nh = H[i]

    dp[i][1] = nh

    for j in range(i):
        for k in range(N-K):

            if dp[j][k] != None:

                if dp[i][k+1] == None:
                    
                    dp[i][k+1] = dp[j][k] + max(0, H[i]-H[j])

                else:

                    dp[i][k+1] = min(dp[i][k+1] , dp[j][k] + max(0, H[i]-H[j]))

ans = float("inf")
for i in range(N):

    if dp[i][-1] != None:
        ans = min(ans,dp[i][-1])

print (ans)


Fixed submission:
import sys


N,K = map(int,input().split())

if N == K:
    print (0)
    sys.exit()

H = list(map(int,input().split()))


dp = [[None] * (N-K+1) for i in range(N) ]

for i in range(N):

    nh = H[i]

    dp[i][1] = nh

    for j in range(i):
        for k in range(N-K):

            if dp[j][k] != None:

                if dp[i][k+1] == None:
                    
                    dp[i][k+1] = dp[j][k] + max(0, H[i]-H[j])

                else:

                    dp[i][k+1] = min(dp[i][k+1] , dp[j][k] + max(0, H[i]-H[j]))

ans = float("inf")
for i in range(N):

    if dp[i][-1] != None:
        ans = min(ans,dp[i][-1])

print (ans)

Buggy python submission (verdict: Runtime Error):

N,K = map(int,input().split())

H = list(map(int,input().split()))


dp = [[None] * (N-K+1) for i in range(N) ]

for i in range(N):

    nh = H[i]

    dp[i][1] = nh

    for j in range(i):
        for k in range(N-K):

            if dp[j][k] != None:

                if dp[i][k+1] == None:
                    
                    dp[i][k+1] = dp[j][k] + max(0, H[i]-H[j])

                else:

                    dp[i][k+1] = min(dp[i][k+1] , dp[j][k] + max(0, H[i]-H[j]))

ans = float("inf")
for i in range(N):

    if dp[i][-1] != None:
        ans = min(ans,dp[i][-1])

print (ans)


Fixed submission:
import sys


N,K = map(int,input().split())

if N == K:
    print (0)
    sys.exit()

H = list(map(int,input().split()))


dp = [[None] * (N-K+1) for i in range(N) ]

for i in range(N):

    nh = H[i]

    dp[i][1] = nh

    for j in range(i):
        for k in range(N-K):

            if dp[j][k] != None:

                if dp[i][k+1] == None:
                    
                    dp[i][k+1] = dp[j][k] + max(0, H[i]-H[j])

                else:

                    dp[i][k+1] = min(dp[i][k+1] , dp[j][k] + max(0, H[i]-H[j]))

ans = float("inf")
for i in range(N):

    if dp[i][-1] != None:
        ans = min(ans,dp[i][-1])

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

N = int(input())

lis = [0] * (10 ** 1 + 10)

D = list(map(int,input().split()))
maxi = 0

for i in D:
    maxi = max(maxi,i)
    lis[i] += 1

ans = 1
for i in range(maxi + 1):

    if i == 0 and lis[i] != 1:
        ans = 0
        print (0)
        sys.exit()
    elif i != 0:
        #print (ans,lis[i-1],lis[i])
        ans = ans * ( lis[i-1] ** lis[i] ) 
        ans %= 998244353

#print (lis)
print (ans % 998244353)


Fixed submission:
import sys

N = int(input())

lis = [0] * (10 ** 5 + 10)

D = list(map(int,input().split()))
maxi = 0

if D[0] != 0:
    print (0)
    sys.exit()

for i in D:
    maxi = max(maxi,i)
    lis[i] += 1

ans = 1
for i in range(maxi + 1):

    if i == 0 and lis[i] != 1:
        ans = 0
        print (0)
        sys.exit()
    elif i != 0:
        #print (ans,lis[i-1],lis[i])
        ans = ans * ( lis[i-1] ** lis[i] ) 
        ans %= 998244353

#print (lis)
print (ans % 998244353)
Buggy python submission (verdict: Runtime Error):

N = int(input())

A = list(map(int,input().split()))

dic = {}

for a in A:

    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1

B = []
for i in dic:
    B.append(dic[i])

B.sort()

B_sub = B.copy()

for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 

aind = N + 1
nind = len(B) - 1

#print (B,B_sub)

for i in range(N):

    i += 1

    while True:

        while nind > 0 and B[nind] > aind - 1:

            nind -= 1

        if ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break

        aind -= 1


Fixed submission:

N = int(input())

A = list(map(int,input().split()))

dic = {}

for a in A:

    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1

B = []
for i in dic:
    B.append(dic[i])

B.sort()

B_sub = B.copy()

for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 

aind = N + 1
nind = len(B) - 1

#print (B,B_sub)

for i in range(N):

    i += 1

    while True:

        while nind > 0 and B[nind] > aind - 1:

          nind -= 1

        if i > len(B):
            print (0)
            break

        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break

        aind -= 1
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = input()

nowlen = N // 2
flag = False
while True:

    if nowlen == 0:
        break

    dic = {}

    for i in range(N - nowlen + 1):

        if S[i:i+nowlen] not in dic:
            dic[S[i:i+nowlen]] = i

        elif i - dic[S[i:i+nowlen]] >= nowlen:
            flag = True
            break

    if flag:
        break

    
    nowlen -= 1



print (nowlen)
        


Fixed submission:

N = int(input())

S = input()
CS = S

ans = 0

for i in range(N):

    now = 0
    for j in range(N):

        if S[j] == CS[j]:
            now += 1
        else:
            ans = max(ans, min(i,now) )
            now = 0

    ans = max( ans , min(i,now) )

    CS = " "+CS

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):


N = int(input())

S = input()

now = 0

ans = 1

for i in range(2*N):

    #print (S[i],ans,now)

    if i == 0 and S[i] == "W":
        ans = 0
        break

    if i == 0 and S[i] == "B":
        now += 1
        continue

    if S[i] == "W":

        if now % 2 != 0:

            now += 1

        else:

            ans *= now
            now -= 1

    if S[i] == "B":

        if now % 2 != 0:

            ans *= now

            now -= 1

        else:

            now += 1


    if now < 0:
        ans = 0
        break

    #print (S[i],ans,now)

if now != 0:
    ans = 0

fac = 1
for i in range(N):

    i += 1
    fac = (fac * i) % (10 ** 9 + 7)

print ((fac * ans) % (10 ** 9 + 7) )

Fixed submission:


N = int(input())

S = input()

now = 0

ans = 1

for i in range(2*N):

    #print (S[i],ans,now)

    if i == 0 and S[i] == "W":
        ans = 0
        break

    if i == 0 and S[i] == "B":
        now += 1
        continue

    if S[i] == "W":

        if now % 2 != 0:

            now += 1

        else:

            ans = (ans * now) % (10 ** 9 + 7)
            now -= 1

    if S[i] == "B":

        if now % 2 != 0:

            ans = (ans * now) % (10 ** 9 + 7)

            now -= 1

        else:

            now += 1


    if now < 0:
        ans = 0
        break

    #print (S[i],ans,now)

if now != 0:
    ans = 0

fac = 1
for i in range(N):

    i += 1
    fac = (fac * i) % (10 ** 9 + 7)

print ((fac * ans) % (10 ** 9 + 7) )

Buggy python submission (verdict: Time Limit Exceeded):
import math


N = int(input())

S = input()

now = 0

ans = 1

for i in range(2*N):

    #print (S[i],ans,now)

    if i == 0 and S[i] == "W":
        ans = 0
        break

    if i == 0 and S[i] == "B":
        now += 1
        continue

    if S[i] == "W":

        if now % 2 != 0:

            now += 1

        else:

            ans *= now
            now -= 1

    if S[i] == "B":

        if now % 2 != 0:

            ans *= now

            now -= 1

        else:

            now += 1


    if now < 0:
        ans = 0
        break

    #print (S[i],ans,now)

if now != 0:
    ans = 0

print ((math.factorial(N) * ans) % (10 ** 9 + 7) )


Fixed submission:


N = int(input())

S = input()

now = 0

ans = 1

for i in range(2*N):

    #print (S[i],ans,now)

    if i == 0 and S[i] == "W":
        ans = 0
        break

    if i == 0 and S[i] == "B":
        now += 1
        continue

    if S[i] == "W":

        if now % 2 != 0:

            now += 1

        else:

            ans = (ans * now) % (10 ** 9 + 7)
            now -= 1

    if S[i] == "B":

        if now % 2 != 0:

            ans = (ans * now) % (10 ** 9 + 7)

            now -= 1

        else:

            now += 1


    if now < 0:
        ans = 0
        break

    #print (S[i],ans,now)

if now != 0:
    ans = 0

fac = 1
for i in range(N):

    i += 1
    fac = (fac * i) % (10 ** 9 + 7)

print ((fac * ans) % (10 ** 9 + 7) )
Buggy python submission (verdict: Time Limit Exceeded):

N,Q = map(int,input().split())

ab = []

link = {} 

for i in range(N-1):

    a,b = map(int,input().split())

    if a-1 not in link : link[a-1] = []
    if b-1 not in link : link[b-1] = []


    link[a-1].append(b-1)
    link[b-1].append(a-1)



plus = [0] * N

for i in range(Q):

    p,x = map(int,input().split())

    plus[p-1] += x


Q = []

ans = [0] * N
end = set([])
p = [-1] * N
p[0] = 0

nowq = 0
Q.append(0)

end = end | set([0])


while nowq < N:

    nowpo = Q[nowq]
    #print (nowpo)
    ans[ nowpo ] = ans[p[ nowpo ]] + plus[nowpo]

    for i in link[nowpo]:

        if i not in end:

            Q.append(i)
            p[i] = nowpo
            #print (i,nowpo)


            end = end | set([i])


    nowq += 1

#print (Q,p,link)

for i in ans:
    print (i)


Fixed submission:

N,Q = map(int,input().split())

ab = []

link = {} 

for i in range(N-1):

    a,b = map(int,input().split())

    if a-1 not in link : link[a-1] = []
    if b-1 not in link : link[b-1] = []


    link[a-1].append(b-1)
    link[b-1].append(a-1)



plus = [0] * N

for i in range(Q):

    p,x = map(int,input().split())

    plus[p-1] += x


Q = []

ans = [0] * N
end = [0] * N
p = [-1] * N
p[0] = 0

nowq = 0
Q.append(0)

end[0] = 1


while nowq < N:

    nowpo = Q[nowq]
    #print (nowpo)
    ans[ nowpo ] = ans[p[ nowpo ]] + plus[nowpo]

    for i in link[nowpo]:

        if end[i] == 0:

            Q.append(i)
            p[i] = nowpo
            #print (i,nowpo)


            end[i] = 1


    nowq += 1

#print (Q,p,link)

for i in ans:
    print (i)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N,M = map(int,input().split())

AB = []

for i in range(N):

    A,B = map(int,input().split())

    AB.append([A,B])

AB.sort()


day = 1
i = 0
maxi = []
ans = 0

while day <= M:

    if i < N and AB[i][0] == day:

        ind = bisect.bisect_left(maxi,AB[i][1])
        maxi.insert(ind,AB[i][1])
        i += 1
        
    else:

        day += 1
        if len(maxi) > 0:
            ans += maxi.pop(-1)

print (ans)

    


Fixed submission:
import heapq

N,M = map(int,input().split())

AB = []

for i in range(N):

    A,B = map(int,input().split())

    AB.append([A,B])

AB.sort()


day = 1
i = 0
lis = []
ans = 0

while day <= M:

    if i < N and AB[i][0] == day:

        heapq.heappush(lis,-1 * AB[i][1])
        i += 1

    else:

        day += 1

        if len(lis) > 0:
            ans -= heapq.heappop(lis)

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):

p = int(input())

a = list(map(int,input().split()))

lis = [0] * (p+1)

for i in range(p):

    if i == 0:
        lis[1] = 1
        lis[0] = 0

    else:
        
        nlis = [0] * (p+1)

        for j in range(p+1):
            nlis[j] += lis[j] * (-1 * i)
            if j != 0:
                nlis[j] += lis[j-1]

        lis = nlis

#print (lis) = (x-0)*(x-1)*…*(x-p+1)の各項の係数
#ラグランジュ補完を実際に計算していく
#参考　https://mathtrain.jp/hokan

ans = [0] * p

for i in range(p):

    #fi(x)を計算 (x-i)でlisを割る
    if a[i] == 0:
        continue

    nlis = [0] * p

    for j in range(p-1,-1,-1):

        if j == p-1:
            nlis[j] = lis[j+1]
        else:
            nlis[j] = (lis[j+1] - nlis[j+1] * (-1 * i))

    for j in range(p):
        ans[j] += nlis[j]

for i in range(p):
    ans[i] = (p - ans[i]) % p
print (" ".join(map(str,ans)))


Fixed submission:

p = int(input())

a = list(map(int,input().split()))

lis = [0] * (p+1)

for i in range(p):

    if i == 0:
        lis[1] = 1
        lis[0] = 0

    else:
        
        nlis = [0] * (p+1)

        for j in range(p+1):
            nlis[j] += lis[j] * (-1 * i)
            if j != 0:
                nlis[j] += lis[j-1]
            nlis[j] %= p

        lis = nlis

#print (lis) = (x-0)*(x-1)*…*(x-p+1)の各項の係数
#ラグランジュ補完を実際に計算していく
#参考　https://mathtrain.jp/hokan

ans = [0] * p

for i in range(p):

    #fi(x)を計算 (x-i)でlisを割る
    if a[i] == 0:
        continue

    nlis = [0] * p

    for j in range(p-1,-1,-1):

        if j == p-1:
            nlis[j] = lis[j+1]
        else:
            nlis[j] = (lis[j+1] - nlis[j+1] * (-1 * i)) % p

    for j in range(p):
        ans[j] += nlis[j]

for i in range(p):
    ans[i] = (p - ans[i]) % p
print (" ".join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):

N = int(input())

a = list(map(int,input().split()))

"""
for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False
        print (i+1,"はみたさない")
        break

    else:
        pass
        print (summ,a[i],"でおｋ")

if flag :
    

    #print (lis)

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans[:-1])

else:
    print (-1)

"""

lis = [-1] * N



for i in range(N):

    i = N-i
    cnt = 2
    summ = 0
    flag = True

    while i * cnt <= N:

        summ += lis[i * cnt -1]
        cnt += 1

    #print (a[i-1],summ)

    if a[i-1] == 0 and summ % 2 == 0:
        lis[i-1] = 0
        #print ("a")

    elif a[i-1] == 0 and summ % 2 == 1:
        llis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 0:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 1:
        lis[i-1] = 0

    if not flag:
        break

if flag:

    #print (lis)

    print (sum(lis))

    ans = ""

    for i in range(len(lis)):
        if lis[i] == 1:
            ans += str(i+1) + " "

    print (ans)

else:
    print (-1)


    


Fixed submission:

N = int(input())

a = list(map(int,input().split()))

"""
for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False
        print (i+1,"はみたさない")
        break

    else:
        pass
        print (summ,a[i],"でおｋ")

if flag :
    

    #print (lis)

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans[:-1])

else:
    print (-1)

"""

lis = [-1] * N



for i in range(N):

    i = N-i
    cnt = 2
    summ = 0
    flag = True

    while i * cnt <= N:

        summ += lis[i * cnt -1]
        cnt += 1

    #print (a[i-1],summ)

    if a[i-1] == 0 and summ % 2 == 0:
        lis[i-1] = 0
        #print ("a")

    elif a[i-1] == 0 and summ % 2 == 1:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 0:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 1:
        lis[i-1] = 0

    if not flag:
        break

if flag:

    #print (lis)

    print (sum(lis))

    ans = ""

    for i in range(len(lis)):
        if lis[i] == 1:
            ans += str(i+1) + " "

    print (ans)

else:
    print (-1)