Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03000 (python)

Fixed submission:
n,x=[int(x) for x in input().rstrip().split()]
l=[int(x) for x in input().rstrip().rsplit()]
 
cnt=1
now=0
for i in l:
  now+=i
  if now<=x:
    cnt+=1    
  else:
    break  
print(cnt)

Buggy submission (verdict: Runtime Error):
n,x=[int(x) for x in input().rstrip().split()]
l=[int(x) for x in input().rstrip().rsplit()]

cnt=0
now=0
i=0
while(now<=x):
  cnt+=1
  now+=l[i]
  i+=1
print(cnt)
Problem p03069 (python)

Fixed submission:
import sys

n=int(input())
c=input()
black=c.count("#")
white=c.count(".")

if black==n:
  print(0)
  sys.exit()

b=0
w=0
now=0
ans=float('inf')

for i in range(n):
  if c[i]=="#":
    b+=1
  w=(i+1)-b

  now=b+(white-w)
  ans=min(ans,now)
  
print(min(ans,white))

Buggy submission (verdict: Runtime Error):
n=int(input())
c=input()
b=c.count("#")
w=c.count(".")

cnt=0
for i in range(w):
  if c[i]=="#":
    cnt+=1
  bb=b-cnt
  ww=w-cnt

ans=min(ww+cnt,b,w)
print(ans)
Problem p04011 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a):
    if 0<b:
        ans+=c
    else:
        ans+=d
    b=b-1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
kai,av=[int(x) for x in input().rstrip().split()]
l=[int(x) for x in input().rstrip().split()]
ll=[i for i in range(1,kai+1)]
result=[]
count=0
 
 
for i in ll:
    for j in itertools.combinations(l,r=i):
        if av==(sum(j)/i):
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
//string S[100];

int main(){
	int N,K,X,Y;cin>>N>>K>>X>>Y;
	int ans;

	for(int i=1;i<N+1;i++){
		if(K<i){
			ans+=Y;

		}else{
			ans+=X;
		}
	}
	cout<<ans<<endl;
}
Problem p04044 (python)

Fixed submission:
a = input().rstrip().split()
N=int(a[0])
L=int(a[1])
l=[]

for i in range(N):
    b=input()
    l.append(b)

l.sort()

ans=""
for i in range(N):
    ans+=l[i]
print(ans)

Buggy submission (verdict: Runtime Error):
a = input().rstrip().split()
N=int(a[0])
L=int(a[1])
l=[]

for i in range(N):
    b=input()
    l.append()

l.sort()

ans=""
for i in range(N):
    ans+=l[i]
print(ans)
Problem p02945 (python)

Fixed submission:
import numpy as np

A,B = map(int,input().split())
ans = [A+B,A-B,A*B]
ans = np.sort(ans)
print (ans[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
s = []
for i in range (N):
    word = input()
    word_lst = []
    for j in range (len(word)):
        word_lst.append(word[j])
    word_lst = np.sort(word_lst)
    words = ""
    for j in range (len(word_lst)):
        words += word_lst[j]
    s.append(words)
#print (s)

count = 0
for i in range (N):
    for j in range (i+1,N):
        #print (i,j)
        #print (s[i],s[j])
        if s[i] == s[j]:
            count += 1
print (count)
Problem p02609 (python)

Fixed submission:
import sys
N = int(input())

X = input()

o = 0
cnt = 0
for i in X:
    o *= 2
    if i == "1":
        o += 1
        cnt += 1

if cnt == 0:
    for i in range(N):
        print (1)
    sys.exit()
elif cnt == 1:
    orev = [o % (cnt+1) , None]
else:
    orev = [o % (cnt+1) , o % (cnt-1)]

for i in range(N):

    nb = int(X[i])

    if nb == 0:
        mod = cnt+1
        now = (orev[0] + pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)

    else:
        if cnt == 1:
            print (0)
            continue
        
        mod = cnt-1
        now = (orev[1] - pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

X = input()

o = 0
cnt = 0
for i in X:
    o *= 2
    if i == "1":
        o += 1
        cnt += 1

orev = [o % (cnt+1) , o % (cnt-1)]

for i in range(N):

    nb = int(X[i])

    if nb == 0:
        mod = cnt+1
        now = (orev[0] + pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)

    else:
        mod = cnt-1
        now = (orev[1] - pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)
Problem p02692 (python)

Fixed submission:

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

import sys
sys.setrecursionlimit(500000)

s = []

for i in range(N):

    S = input()
    s.append(S)

def dfs(dep,A,B,C):

    if dep == N:
        return []

    if s[dep] == "AB":

        if A == B == 0:
            return None
        if A >= B:
            cat = dfs(dep+1,A-1,B+1,C)
            if cat != None:
                cat.append("B")
                return cat
        if A <= B:
            cat = dfs(dep+1,A+1,B-1,C)
            if cat != None:
                cat.append("A")
                return cat

    elif s[dep] == "BC":
        
        if B == C == 0:
            return None
        if B >= C:
            cat = dfs(dep+1,A,B-1,C+1)
            if cat != None:
                cat.append("C")
                return cat
        if B <= C:
            cat = dfs(dep+1,A,B+1,C-1)
            if cat != None:
                cat.append("B")
                return cat

    else:

        if A == C == 0:
            return None
        if A >= C:
            cat = dfs(dep+1,A-1,B,C+1)
            if cat != None:
                cat.append("C")
                return cat
        if A <= C:
            cat = dfs(dep+1,A+1,B,C-1)
            if cat != None:
                cat.append("A")
                return cat

    return None

       
rev = dfs(0,A,B,C)

if rev == None:
    print ("No")
else:
    print ("Yes")
    for i in range(N-1,-1,-1):
        print (rev[i])

Buggy submission (verdict: Runtime Error):

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

import sys

s = []

for i in range(N):

    S = input()
    s.append(S)

def dfs(dep,A,B,C):

    if dep == N:
        return []

    if s[dep] == "AB":

        if A == B == 0:
            return None
        elif A > B:
            cat = dfs(dep+1,A-1,B+1,C)
            if cat != None:
                cat.append("B")
                return cat
        else:
            cat = dfs(dep+1,A+1,B-1,C)
            if cat != None:
                cat.append("A")
                return cat

    elif s[dep] == "BC":
        
        if B == C == 0:
            return None
        elif B > C:
            cat = dfs(dep+1,A,B-1,C+1)
            if cat != None:
                cat.append("C")
                return cat
        else:
            cat = dfs(dep+1,A,B+1,C-1)
            if cat != None:
                cat.append("B")
                return cat

    else:

        if A == C == 0:
            return None
        elif A > C:
            cat = dfs(dep+1,A-1,B,C+1)
            if cat != None:
                cat.append("C")
                return cat
        else:
            cat = dfs(dep+1,A+1,B+1,C-1)
            if cat != None:
                cat.append("A")
                return cat

    return None

       
rev = dfs(0,A,B,C)

if rev == None:
    print ("No")
else:
    print ("Yes")
    for i in range(N-1,-1,-1):
        print (rev[i])
Problem p02698 (python)

Fixed submission:

import bisect
import sys
sys.setrecursionlimit(500000)

def LIS(lis):

    seq = []

    for c in lis:
        ind = bisect.bisect_left(seq,c)

        if ind == len(seq):
            seq.append(c)
        else:
            seq[ind] = c

    return len(seq)


N = int(input())

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

lis = [ [] for i in range(N) ]

for i in range(N-1):

    u,v = map(int,input().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)

ans = [None] * N

def dfs(v,p,ln):

    ind = bisect.bisect_left(ln,a[v])

    if ind == len(ln):
        mt = None
        ln.append(a[v])
    else:
        mt = ln[ind]
        ln[ind] = a[v]

    ans[v] = len(ln)

    for nex in lis[v]:

        if nex != p:
            dfs(nex,v,ln)

    if mt == None:
        del ln[-1]
    else:
        ln[ind] = mt

    return

dfs(0,0,[])

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

Buggy submission (verdict: Runtime Error):

import bisect

def LIS(lis):

    seq = []

    for c in lis:
        ind = bisect.bisect_left(seq,c)

        if ind == len(seq):
            seq.append(c)
        else:
            seq[ind] = c

    return len(seq)


N = int(input())

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

lis = [ [] for i in range(N) ]

for i in range(N-1):

    u,v = map(int,input().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)

ans = [None] * N

def dfs(v,p,ln):

    ind = bisect.bisect_left(ln,a[v])

    if ind == len(ln):
        mt = None
        ln.append(a[v])
    else:
        mt = ln[ind]
        ln[ind] = a[v]

    ans[v] = len(ln)

    for nex in lis[v]:

        if nex != p:
            dfs(nex,v,ln)

    if mt == None:
        del ln[-1]
    else:
        ln[ind] = mt

    return

dfs(0,0,[])

for i in range(N):
    print (ans[i])
Problem p02727 (python)

Fixed submission:

X,Y,A,B,C = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort()

p.reverse()
q.reverse()
r.reverse()

qi = 0
ri = 0

lis = [0]

for i in range(B+C):

    if (qi == Y or qi == B) and ri==C:
        lis.append(float("-inf"))
    elif qi == Y or qi == B:
        lis.append(lis[-1] + r[ri])
        ri += 1
    elif ri == C:
        lis.append(lis[-1] + q[qi])
        qi += 1
    elif q[qi] > r[ri]:
        lis.append(lis[-1] + q[qi])
        qi += 1
    else:
        lis.append(lis[-1] + r[ri])
        ri += 1

#print (lis)
ans = 0

n = 0
for i in range(X+1):

    if i != 0:
        n += p[i-1]

    if len(lis) > X+Y-i:
        ans = max(ans , n + lis[X+Y-i])

print (ans)

Buggy submission (verdict: Runtime Error):

X,Y,A,B,C = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort()

p.reverse()
q.reverse()
r.reverse()

qi = 0
ri = 0

lis = [0]

for i in range(B+C):

    if (qi == Y or qi == B) and ri==C:
        lis.append(float("-inf"))
    elif qi == Y or qi == B:
        lis.append(lis[-1] + r[ri])
        ri += 1
    elif ri == C:
        lis.append(lis[-1] + q[qi])
        qi += 1
    elif q[qi] > r[ri]:
        lis.append(lis[-1] + q[qi])
        qi += 1
    else:
        lis.append(lis[-1] + r[ri])

ans = 0

n = 0
for i in range(X+1):

    if i != 0:
        n += p[i-1]

    ans = max(ans , n + lis[X+Y-i])

print (ans)
Problem p02825 (python)

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 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
Problem p02858 (python)

Fixed submission:



import fractions


mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def modpower(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def powerX(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 
    else            : return power(x, y//2)**2 * x

def power(x,y):
    return x ** y


def div(a, b):
    return mul(a, modpower(b, mod-2))

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

htgcd = fractions.gcd(H,T)
wtgcd = fractions.gcd(W,T)
n = htgcd * wtgcd

p = pow( 2, ( H // htgcd) ,mod ) +pow( 2, (W // wtgcd) , mod) - 3
p += pow(2,fractions.gcd( H // htgcd , W // wtgcd),mod)

#print (p,n)

ans = pow( p , n , mod )

print (ans)

Buggy submission (verdict: Runtime Error):



import fractions


mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def modpower(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def powerX(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 
    else            : return power(x, y//2)**2 * x

def power(x,y):
    return x ** y


def div(a, b):
    return mul(a, modpower(b, mod-2))

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

htgcd = fractions.gcd(H,T)
wtgcd = fractions.gcd(W,T)
n = htgcd * wtgcd

p = ( 2 ** ( H // htgcd)) + 2 ** (W // wtgcd)) - 3)
p += 2 ** fractions.gcd( H // htgcd , W // wtgcd))

#print (p,n)

ans = modpower(p , n)

print (ans)
Problem p02866 (python)

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 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)
Problem p02890 (python)

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 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
Problem p02949 (python)

Fixed submission:

"""

https://atcoder.jp/contests/abc137/tasks/abc137_e

辺の重みからPを引いておく
→あとはベルマンフォード？

正の閉路探索→むずくね？
閉路があったとしても、増えなきゃあっていい…

→まずゴールにたどり着ける頂点を列挙
→たどり着けない点は無意味なのでremove

→あとはベルマンフォード
"""

import sys
sys.setrecursionlimit(200000)

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

lis = [ [] for i in range(N) ]
rev = [ [] for i in range(N) ]
exist = [False] * N

for i in range(M):

    A,B,C = map(int,input().split())
    A -= 1
    B -= 1

    lis[A].append([B , C - P])
    rev[B].append(A)

def dfs(v):

    exist[v] = True
    for nex in rev[v]:
        if not exist[nex]:
            dfs(nex)

dfs(N-1)

dis = [float("-inf")] * N
dis[0] = 0

for i in range(N+1):

    flag = False

    for v in range(N):
        for uc in lis[v]:

            if exist[uc[0]] and dis[uc[0]] < dis[v] + uc[1]:
                #print (uc[0] , dis[v] + uc[1])
                dis[uc[0]] = dis[v] + uc[1]
                flag = True

if flag:
    print (-1)
else:
    print (max( 0 , dis[N-1] ))

Buggy submission (verdict: Runtime Error):

"""

https://atcoder.jp/contests/abc137/tasks/abc137_e

辺の重みからPを引いておく
→あとはベルマンフォード？

正の閉路探索→むずくね？
閉路があったとしても、増えなきゃあっていい…

→まずゴールにたどり着ける頂点を列挙
→たどり着けない点は無意味なのでremove

→あとはベルマンフォード
"""

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

lis = [ [] for i in range(N) ]
rev = [ [] for i in range(N) ]
exist = [False] * N

for i in range(M):

    A,B,C = map(int,input().split())
    A -= 1
    B -= 1

    lis[A].append([B , C - P])
    rev[B].append(A)

def dfs(v):

    exist[v] = True
    for nex in rev[v]:
        if not exist[nex]:
            dfs(nex)

dfs(N-1)

dis = [float("-inf")] * N
dis[0] = 0

for i in range(N+1):

    flag = False

    for v in range(N):
        for uc in lis[v]:

            if exist[uc[0]] and dis[uc[0]] < dis[v] + uc[1]:
                #print (uc[0] , dis[v] + uc[1])
                dis[uc[0]] = dis[v] + uc[1]
                flag = True

if flag:
    print (-1)
else:
    print (max( 0 , dis[N-1] ))
Problem p02960 (python)

Fixed submission:

S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1
keta = 1

for i in range(len(S)):

    nlis = [0] * 13



    for j in range(10):

        for k in range(13):

            if s[i]== "?" or j == int(s[i]):
                nlis[ (k + (j * keta)) % 13] += lis[k]

    keta *= 10
    keta = keta % 13
    for j in range(13):
        lis[j] = nlis[j] % (10**9 + 7)

#print (lis)
print (lis[5] % (10**9 + 7))

Buggy submission (verdict: Runtime Error):

S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1

for i in range(len(S)):

    nlis = [0] * 13

    if s[i] == "?":

        for j in range(10):

            for k in range(13):

                nlis[ (k + (j * (10**i))) % 13] += lis[k]

    else:

        now = int(s[i])

        for k in range(13):

            nlis[ (k + (now * (10 ** i))) % 13 ] += lis[k]

    #print (nlis)
    lis = nlis.copy()

#print (lis)
print (lis[5] % (10**9 + 7))
Problem p02972 (python)

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)

Buggy 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)