stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;





int main ()

{

    int n;

    cin>>n;

    int a[n+1];

    bool b[n+1]= {false};



    for(int i=1; i<=n; i++)

    {

        cin>>a[i];

    }

    int s;

    int m=0;

    for(int i=n; i>0; i--)

    {

        s=0;

        for(int j=i; j<=n; j+=i)

        {

            if(b[j]==true)

                s++;

        }

        if(s%2!=a[i])

        {

            b[i]=true;

            m++;

        }



    }

    cout<<m<<endl;

    for(int i=1; i<=n; i++)

    {

        if (b[i]==true)



            cout<<i<<" ";

    }

    cout<<endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<math.h>

int main()

{

	int n,an=0;

	scanf("%d",&n);

	int a[n],b[n]={},c[n];

	for(int i=0;i<n;i++)

		scanf("%d",a+i);

	for(int i=n;i>0;i--)

		if(a[i-1]!=b[i-1])

		{

			c[an++]=i;

			for(int j=1;j<sqrt(i);j++)

				if(i%j==0)

				{

					b[j-1]=!b[j-1];

					b[i/j-1]=!b[i/j-1];

				}

			int t=sqrt(i);

			if(t*t==i)

				b[t-1]=!b[t-1];

		}

	printf("%d\n",an);

	for(int i=an-1;i>=0;i--)

		printf("%d ",c[i]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#ifdef NeverBeRed

#include "debug.h"

#else

#define debug(...) 9715

#endif

typedef long long ll;

typedef long double ld;

typedef complex<ll> point;

#define F first

#define S second







int main()

{

	#ifdef TurnRed

		//freopen("a.in", "r", stdin);

		//freopen("a.out", "w", stdout);

	#endif



	ios_base::sync_with_stdio(0), cin.tie(0);



	int n;

	cin >> n;

	vector<int> a(n), b(n+1);

	for (auto &i : a) cin >> i;



	a.insert(a.begin(), 0);

	vector<int> ans;

	for (int i = n; i >= 1; --i)

	{

		int s = 0;

		for (int j = i; j <= n; j += i)

			s ^= b[j];

		if (s != a[i])

		{

			b[i] = 1;

			ans.push_back(i);

		}

	}



	cout << ans.size() << "\n";

	for (auto &i : ans)

		cout << i << " \n"[&i==&ans.back()];



	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<math.h>

int main()

{

	int n,an=0;

	scanf("%d",&n);

	int a[n],b[n]={},c[n];

	for(int i=0;i<n;i++)

		scanf("%d",a+i);

	for(int i=n;i>0;i--)

		if(a[i-1]!=b[i-1])

		{

			c[an++]=i;

			for(int j=1;j<sqrt(i);j++)

				if(i%j==0)

				{

					b[j-1]=!b[j-1];

					b[i/j-1]=!b[i/j-1];

				}

			int t=sqrt(i);

			if(t*t==i)

				b[t-1]=!b[t-1];

		}

	printf("%d\n",an);

	for(int i=an-1;i>=0;i--)

		printf("%d ",c[i]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define F first

#define S second

using namespace std;

typedef long long ll;

typedef pair<ll, ll>pll;

const int N = 2e5 + 5;

ll n, arr[N];

int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;

    for(int i = 1;i <= n;++i)

        cin >> arr[i];

    vector<ll>ans;

    for(int i = n;i >= 0;--i)

    {

        arr[i] %= 2;

        if(arr[i])

        {

            ans.push_back(i);

            for(ll j = 1;j * j <= i;++j)

            {

                if(i % j == 0)

                {

                    arr[j]++;

                    if(j != i / j)

                        arr[i / j]++;

                }

            }

        }

    }

    cout << ans.size() << '\n';

    for(auto &it : ans)

        cout << it << ' ';

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<math.h>

int main()

{

	int n,an=0;

	scanf("%d",&n);

	int a[n],b[n]={},c[n];

	for(int i=0;i<n;i++)

		scanf("%d",a+i);

	for(int i=n;i>0;i--)

		if(a[i-1]!=b[i-1])

		{

			c[an++]=i;

			for(int j=1;j<sqrt(i);j++)

				if(i%j==0)

				{

					b[j-1]=!b[j-1];

					b[i/j-1]=!b[i/j-1];

				}

			int t=sqrt(i);

			if(t*t==i)

				b[t-1]=!b[t-1];

		}

	printf("%d\n",an);

	for(int i=an-1;i>=0;i--)

		printf("%d ",c[i]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	int A[200001];

	rep1(i, N) cin >> A[i];



	vector<int> kotae;

	int B[200001] = {};

	for (int i = N; i > 0; i--) {

		if (A[i] != B[i]) {

			cesp(i);

			cesp(A[i]);

			ce(B[i]);

			kotae.pb(i);

			int rt = sqrt(i);

			rep1(j, rt) {

				if (i % j == 0) {

					B[j] ^= 1;

					if(i != j * j) B[i / j] ^= 1;

				}

			}

		}

	}

	co(kotae.size());

	rep1(i, kotae.size()) {

		cosp(kotae[kotae.size() - i]);

	}



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int dm = 1 << 21;

char dn[dm], * di = dn;

inline void putint(int X) {

	int keta = 0;

	char C[10];

	while (X) {

		*(C + keta) = '0' + X % 10;

		X /= 10;

		keta++;

	}

	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));

	*di++ = '\n';

}

bool b[200001];

int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	char c;

	int N = 0;

	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';



	bool a[200001];

	rep1(i, N) {

		a[i] = getchar_unlocked() - '0';

		getchar_unlocked();

	}



	int kazu = 0;

	for (int i = N; i > 0; i--) {

		bool k = a[i];

		for (int j = i + i; j <= N; j += i) {

			k ^= b[j];

		}

		if (k) {

			kazu++;

			b[i] = true;

		}

	}

	if (kazu == 0) {

		*di++ = '0';

		*di++ = '\n';

	}

	else putint(kazu);

	rep1(i, N) {

		if (b[i]) putint(i);

	}

	fwrite(dn, 1, di - dn, stdout);



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#define MAX 200000

using namespace std;

typedef long long ll;

vector<ll> divisor(ll n) {

  vector<ll> ret;

  for(ll i = 1; i * i <= n; i++) {

    if(n % i == 0) {

      ret.push_back(i);

      if(i * i != n) ret.push_back(n / i);

    }

  }

  return (ret);

}

int main(){

  int n,m=0;

  cin >> n;

  vector<int> a(n);

  ll n_list[MAX+2]={};

  bool add[MAX+2]={};

  bool can=true;

  ll num=0;

  for(int i=0;i<n;i++){

    cin >> a[i];

  }

  for(int i=n;i>0;i--){

    if(n_list[i]%2!=a[i-1]){

      m++;

      add[i]=true;

      vector<ll> div = divisor(i);

      for(int j=0;j<div.size();j++){

        n_list[div[j]]++;

      }

    }

  }

  cout << m <<endl;

  for(int i=1;i<=n;i++){

    if(add[i])cout << i <<" ";

  }

  if(m!=0) cout << endl;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

signed main(){

  ll n,cnt=0,v;

  cin >> n;

  ll a[n],b[n],val[n];

  fill(b,b+n,0);

  fill(val,val+n,0);

  for(int i=0;i<n;i++){

    cin >> a[i];

  }

  for(int i=n-1;i>=0;i--){

    v=0;

    for(int j=i+1;j<=n;j+=i+1){

      v+=b[j-1];

    }

    if(v%2!=a[i]){

      b[i]++;

      cnt++;

    }

  }

  cout << cnt<<endl;

  for(int i=0;i<n;i++){

    if(b[i]==1){

      cout << i+1<<" ";

    }

  }

  if(cnt>0){

    cout << endl;

  }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#define mod 1000000007

#define PI acos(-1)

#include<time.h>

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<map>

#include<queue>

#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;

const ll INF=0x7fffffffffffffff;

const int inf=0x7fffffff;

const int N=2e5+5;

clock_t start,finish;

void time_in(){start=clock();}

void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}

inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}

inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}

inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}

inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();

	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}

inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}

int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};

int st[4][2]={1,0,0,1,-1,0,0,-1};

int t,cas;

int n,m,k;

int main()

{

	int a[N];

	int sum[N];

	int ans[N];

	while(~scanf("%d",&n))

	{

		int cnt=0;

		for(int i=1;i<=n;i++)

		{

			scanf("%d",&a[i]);

			sum[i]=0;

		}

		for(int i=n;i>=1;i--)

		{

			if(sum[i]%2!=a[i])

			{

				ans[cnt++]=i;

				for(int j=1;j*j<=i;j++)

				{

					if(i%j==0)

					{

						sum[j]++;

						if(j*j!=i)sum[i/j]++;

					}

				}

			}

		}

		sort(ans,ans+cnt);

		printf("%d\n",cnt);

		for(int i=0;i<cnt;i++)

		{

			printf("%d",ans[i]);

			printf(i==cnt-1?"\n":" ");

		}

	}

}


// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define int long long



using namespace std;



int n, arr[200001], cnt[200001];



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);



    cin >> n;

    for (int i = 1; i <= n; i++)

        cin >> arr[i];



    vector<int> ans;

    for (int i = n; i >= 1; i--)

        if (cnt[i] % 2 != arr[i])

        {

            ans.push_back(i);

            for (int j = 1; j * j <= i; j++)

                if (j * j == i)

                    cnt[j]++;

                else if (i % j == 0)

                    cnt[j]++, cnt[i / j]++;

                else;

        }

    cout << ans.size() << '\n';

    for (int i : ans)

        cout << i << ' ';

    cout << '\n';



    return 0;

}

// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



const int N = 2e5 + 5;

int arr[N], v[N];



int main() {

    //freopen("in.txt", "rt", stdin);

    int n;

    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) scanf("%d", arr + i);

    for (int i = n; i > 0; --i) {

        int z = 0;

        for (int j = i * 2; j <= n; j += i) {

            z ^= v[j];

        }

        if (z != arr[i]) v[i] = 1;

    }

    vector<int> ans;

    for (int i = 1; i <= n; ++i) {

        if (v[i]) ans.push_back(i);

    }

    printf("%d\n", (int) ans.size());

    for (auto x:ans) printf("%d ", x);

}

// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <vector>

using namespace std;



#define PB push_back



constexpr int kN = int(2E5 + 10);



int a[kN];



int main() {

	int n;

	vector<int> v;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	for (int i = n; i >= 1; i--) for (int j = i << 1; j <= n; j += i) a[i] ^= a[j];

	for (int i = 1; i <= n; i++) if (a[i]) v.PB(i);

	printf("%d\n", int(v.size()));

	if (!v.empty()) printf("%d", v[0]);

	for (int i = 1; i < int(v.size()); i++) printf(" %d", v[i]);

	printf("\n");

}


// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//

//  main.cpp

//  pL L - Preparing Boxes

//

//  Created by Hsiu-Fen Chou on 2019/12/20.

//  Copyright © 2019 Hsiu-Fen Chou. All rights reserved.

//



#include <iostream>

#include <cstring>

#include <vector>

using namespace std;

#define TURBO ios_base::sync_with_stdio(0);cin.tie(0);



int main() {

    TURBO

    int N;

    cin >> N;

    int a[N+1], b[N+1];

    

    for (int i=1; i<=N; i++) cin >> a[i];

    

    memset(b, 0, sizeof(b));

    for (int i=N; i>0; i--){

        int cnt = 0;

        for (int j=2*i; j<=N; j+=i){

            if (b[j] == 1) cnt ^= 1;

        }

        if (cnt ^ a[i]) b[i] = 1;

    }

    vector<int> v;

    for (int i=1; i<=N; i++){

        if (b[i]) v.push_back(i);

    }

    cout << v.size() << '\n';

    for (auto i: v) cout << i << ' ';

    cout << '\n';

    

    return 0;

}


// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define F first

#define S second

bool b[200005]={0};

bool a[200005]={0};

int main()

{

    int n;

    cin>>n;

    for(int i=1;i<=n;i++)

        cin>>a[i];

    for(int i=n;i>0;i--)

    {

        if(b[i]!=a[i])

        {

            b[i]=1;

            for(int j=1;j<=sqrt(i);j++)

            {

                if(i%j==0)

                {

                    a[j]=!a[j];

                    if(j==i/j) continue;

                    a[i/j]=!a[i/j];

                }

            }

        }



    }

    int cnt=0;

    for(int i=1;i<=n;i++)

    {

        if(b[i]) cnt++;

    }

    cout<<cnt<<'\n';

    for(int i=1;i<=n;i++)

    {

        if(b[i]) cout<<i<<' ';

    }

}


// Optimized solution to the same problem (faster):
//l

#include<stdio.h>



int n, a[200005], b[200005]={0}, c[200005], idx=0;



int main()

{

	scanf("%d", &n);

	for(int i=1; i<=n; i++)

	{

		scanf("%d", a+i);

	}

	for(int i=n; i>0; i--)

	{

		int tmp=0;

		for(int j=2; j*i<=n; j++) tmp+=b[i*j], tmp&=1;

		b[i]=tmp^a[i];

		if(b[i]) c[idx++]=i;

	}

	printf("%d\n", idx);

	if(idx)

	{

		printf("%d", c[0]);

		for(int i=1; i<idx; i++) printf(" %d", c[i]);

		puts("");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)

#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)

#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)

#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)



/*

上から順に決めれそう

*/



bool ok=true;

ll n,a[200010],b[200010];

vector<ll> fact[200010],ans;



void factoring(ll n,vector<ll> v[]){

	ll visit[300010]={};

	reg(i,2,n){

		if(visit[i]==0){

			reg(j,1,n){

				if(j*i>n)break;

				visit[i*j]=1;

				v[i*j].push_back(i);//素因数リスト（重複は含まず）

			}

		}

	}

}



void init(){

	cin>>n;

	reg(i,1,n)cin>>a[i];

	// factoring(n,fact);

}



int main(void){

	init();

	ireg(i,1,n){

		if(a[i]==1){

			ans.push_back(i);

			reg(j,1,i){

				if(j*j>i)break;

				if(i%j!=0)continue;

				if(j==i/j){

					a[j]=1-a[j];

				}else{

					a[j]=1-a[j];

					a[i/j]=1-a[i/j];

				}

			}

		}

	}

	ireg(i,1,n)if(a[i]==1)ok=false;

	if(ok){

		cout<<ans.size()<<endl;

		rep(i,ans.size())cout<<ans[i]<<" ";

		cout<<endl;

	}else{

		cout<<-1<<endl;

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)

#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)

#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)

#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)



/*

上から順に決めれる

O(NlogN)版

*/



bool ok=true;

ll n,a[200010];

vector<ll> ans;



void init(){

	cin>>n;

	reg(i,1,n)cin>>a[i];

}



int main(void){

	init();

	ireg(i,1,n){

		for(int j=2;i*j<=n;j++)a[i]^=a[j*i];

		if(a[i]==1){

			ans.push_back(i);

		}

	}

	cout<<ans.size()<<endl;

	rep(i,ans.size())cout<<ans[i]<<" ";

	cout<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main() {

	int n;

	cin >> n;

	int a[n+1]={};

	for(int i=1; i<n+1; i++){

		cin >> a[i];

	}

	int m=0;

	int cnt = 0;

	int b[200010]={};

	for(int i=n; i>0; i--){

		for(int j=i; j<=n; j+=i){

			cnt += b[j];

		}

		cnt%=2;

		if(a[i]!=cnt){

			b[i] = 1;

			m++;

		}

		cnt = 0;

	}

	cout << m << endl;

	for(int i=1; i<n+1; i++){

		if(b[i]) cout << i << endl;

	}

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

int x[200000];

int z[200000];

int len=0;

int main()

{

    int n,i,s=0,mark;

    scanf("%d",&n);

    for(i=1; i<=n; i++)

    {

        scanf("%d",&x[i]);

    }

    for(i=n; i>0; i--)

    {

        s=0;

        mark=i;

        while(mark<=n)

        {

            s+=z[mark];

            mark+=i;

        }

        if(s%2!=x[i])

        {

            z[i]=1;

            len++;

        }

    }

    printf("%d\n",len);

    for(i=1; i<=n; i++)

        if(z[i])

        printf("%d ",i);

    printf("\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)

#define irep(i,a,b) for(ll i=ll(a);i>ll(b);i--)

using ll = long long;

using namespace std;



ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

//sort(a, a + N, greater<ll>())   // descend

//sort(a, a+N)                    //  ascend



/* 

void comb(vector<vector <ll> > &v) {

	ll mod=1000000007;

	rep (i,0,v.size()) {

		v[i][0] = 1;

		v[i][i] = 1;

	}

	rep (k,1,v.size()) {

		rep (j,1,k) {

			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;

		}

	}

}

/*main内でnCn~nC0 生成 **

vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));

comb(v);

*/





int main(){

	ll n;

	cin>>n;

	ll a[220000];

	rep(i,1,n+1)cin>>a[i];

	ll b[220000]={0};

	ll cnt=0;

	ll m=0;

	irep(i,n,0){

		for(ll j=i;j<=n;j+=i)cnt+=b[j];	

		cnt=cnt%2;

		if(a[i]!=cnt){b[i]=1;m++;}

		cnt=0;

	}

	cout<<m<<endl;

	rep(i,1,n+1) if(b[i]==1)cout<<i<<endl;

}










// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)

#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)

#define pb push_back

#define mp make_pair

#define pll pair<ll,ll>

#define endl "\n"

using ll=long long;

using ld=long double;

using namespace std;

ll mod= 1e9+7;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }



ll a[210000];

ll b[210000];

main(){

    ll n,ans=0;

    cin>>n;

    rep(i,1,n+1)cin>>a[i];

    irep(i,n,1){

      ll tmp=0;

      for(ll j=i+i;j<=n;j+=i){

        if(b[j]==1)tmp++;

      }

      if(tmp%2!=a[i]){b[i]=1;ans++;}

    }

    cout<<ans<<endl;

    rep(i,1,n+1){

      if(b[i]==1)cout<<i<<endl;

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < n; i++)

#define rrep(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;

typedef pair<int,int> P;



int main(){

    int n;

    cin >> n;

    int a[n], b[200010] = {}, ans = 0;

    rep(i, n) cin >> a[i];



    for (int j = n; j > 0; j--){

        int tmp = j, cnt = 0;

        while (tmp <= n){

            cnt += b[tmp];

            tmp += j;

        }

        b[j] = (a[j - 1] + cnt) % 2;

        if(b[j] != 0) ans ++;

    }



    cout << ans << endl;



    if (ans == 0) return 0;



    rep(i, n + 1) if (b[i] == 1) cout << i << " ";

    cout << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < n; i++)

#define rrep(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;

#define INF ((1<<30)-1)

#define LINF (1LL<<60)

#define EPS (1e-10)

typedef long long ll;

typedef pair<ll, ll> P;

const int MOD = 1000000007;

const int MOD2 = 998244353;



int a[200010];

int b[200010];



int main(){

    int n;

    cin >> n;

    rep(i, n) cin >> a[i+1];



    for(int i = (n+1)/2; i <= n; i++){

        b[i] = a[i];

    }



    for(int k = n; k >= 1; k--){

        int tmp = 0;

        for(int i = 2 * k; i <= n; i += k){

            tmp += b[i];

        }

        tmp += a[k];

        if (tmp%2 == 0) b[k] = 0;

        else b[k] = 1;

    }



    int cnt = 0;

    rep(i, n) cnt += b[i+1];

    cout << cnt << endl;

    if (cnt == 0) return 0;

    rep(i, n) if (b[i+1] > 0) cout << i+1 << " ";

    cout << endl;



    return 0;

}


// Fastest known solution for this problem: