akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Extra Start
#define nn '\n'
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(s);
    
    long long int w_num = 0LL, wbase,wcout=0LL;
    rep(i, s.length()) if (s[i] == 'W') w_num++;
    if(w_num==0){ cout << 0 << nn;  return 0; }
    wbase = w_num * (w_num - 1) / 2LL;
    rep(i,s.length()) if(s[i]=='W') wcout += (long long int)i;
    cout << wcout - wbase << nn;
    return 0;
}

Measured memory_bytes: 720
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 2005
using namespace std;

int n,i,j,k,a[maxn],f[maxn],g[maxn],sz[maxn],dep[maxn],ans;
int em,e[maxn*2],nx[maxn*2],ls[maxn];

void insert(int x,int y){
	em++; e[em]=y; nx[em]=ls[x]; ls[x]=em;
	em++; e[em]=x; nx[em]=ls[y]; ls[y]=em;
}

void dfs(int x,int p){
	dep[x]=dep[p]+1,f[x]=g[x]=0,sz[x]=a[x];
	for(int i=ls[x];i;i=nx[i]) if (e[i]!=p){
		dfs(e[i],x),sz[x]+=sz[e[i]];
		f[e[i]]+=sz[e[i]],g[e[i]]+=sz[e[i]];
		if (min(g[x],g[e[i]])>=max(f[x],f[e[i]]))
			f[x]=(g[x]&1)!=(g[e[i]]&1);
		else f[x]=max(f[x],f[e[i]])-min(g[x],g[e[i]]);
		g[x]+=g[e[i]];
	}
}

int main(){
	scanf("%d",&n);
	char ch=getchar(); while (ch<'0'||ch>'9') ch=getchar();
	for(i=1;i<=n;i++) a[i]=ch-'0',ch=getchar();
	for(i=1;i<n;i++) scanf("%d%d",&j,&k),insert(j,k);
	ans=2e9;
	for(int rt=1;rt<=n;rt++){
		dfs(rt,0);
		if (f[rt]==0) {
			int sum=0;
			for(i=1;i<=n;i++) if (a[i]) sum+=dep[i]-1;
			ans=min(ans,sum/2);
		}
	}
	if (ans==2e9) printf("-1"); else printf("%d",ans);
}

Measured memory_bytes: 1904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split();
            long N = long.Parse(str[0]); /* Sの個数 */
            long M = long.Parse(str[1]); /* Cの個数 */
            long ans = 0;

            if (N < M/2)    /* Sが余る？ */
            {
                ans = N;
                M -= N * 2;
                ans += M / 4;
            }
            else            /* Sが足りない */
            {
                ans = M / 2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define mod 1000000007

void solve()
{
    char c;cin>>c;
    char ans=(char)(c+1);
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    solve();
 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
 int n;
    cin >>n;
    vector<int> a(n);
    
   rep(i,n) {
    cin >>a[i];
   }
    
    long long mon = 1000;
    for(int i = 0; i<n-1; i++) {
        if(a[i] < a[i+1]) {
         mon = mon + mon/a[i] * (a[i+1] - a[i]);
        }
     }
    cout << mon;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

int comp(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  int N;
  scanf("%d", &N);
  int i, A[N], c = 0;
  long sum = 0;

  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
    if(A[i] < 0){
      c++;
      A[i] *= -1;
    }
    sum += A[i];
  }

  qsort(A, N, sizeof(int), comp);

  if(c % 2 == 1){
    sum -= 2 * A[0];
  }

  printf("%ld\n", sum);

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int n,m;
	cin >> n >> m;

	
	int c[m];
	for(int i=0; i<m; i++){
		cin >> c[i];
	}
	
	sort(c,c+m);
	
	if(m==1){ cout << n << endl; return 0;}
	else if(m==2){ cout << n/c[1] + n%c[1] << endl; return 0;}
	else{

	int num[n+1]={0};	//x???(0<=x<=n)??????????????????????????????????????°
	
		
	for(int i=0; i<m; i++){num[c[i]]=1;}
	
	queue<int> que;
	for(int i=0; i<m; i++){que.push(c[i]);}
	while(!que.empty()){
		
		for(int i=0; i<m; i++){
			if(c[i]+que.front()<=n && num[c[i]+que.front()]==0){
				num[c[i]+que.front()]=num[que.front()]+1;
				que.push(c[i]+que.front());
			}
		}
		que.pop();
	}
	
	cout << num[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3400
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
void solve()
{
    ll n,m;cin>>n>>m; 
    cout<<min(n%m,m-n%m)<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int num=s.size();
    string first=s.substr(0,(num-1)/2),second=s.substr((num+1)/2);
    if(first==second) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class CWalkOnMultiplicationTable {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        long long int n;
        cin >> n;
        vector<int> vec;
        for (int i = 1; i < pow(n, 0.5) + 1; ++i) {
            if (n % i == 0)vec.push_back(i);
        }
        long long int ans = 1000000000001;
        for (const auto &item: vec) {
            ans = min(ans, item + (n / item) - 2);
        }
        cout << ans << endl;
    }
};


int main() {
    CWalkOnMultiplicationTable solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
X = list(map(int, input().split()))

X_sort = sorted(X)

ans_1 = X_sort[N//2-1]
ans_2 = X_sort[N//2]

if ans_1 == ans_2:
	for _ in range(N):
		print(ans_1)
	sys.exit()

for i in range(N):
	if X[i] < ans_2:
		print(ans_2)
	elif X[i] > ans_1:
		print(ans_1)



Measured memory_bytes: 26772
/*Hatsune Miku 4ever!*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _for(i,a,b) for(int i = (a);i < b;i ++)
#define _rep(i,a,b) for(int i = (a);i > b;i --)
#define INF 0x3f3f3f3f3f3f3f3f
#define lowbit(x) ((x)&(-x))
#define pb push_back
#define MIKU 39
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug() printf("Miku Check OK!\n")
#define bigmiku 3939393939
#define maxn 200039 
#define maxe 1000003
const ll mod = 998244353;
vector<ll> der;
ll inv;
ll fpow(ll a,ll n,ll mod)
{
    ll res = 1;
    while(n)
    {
        if(n & 1)
        {
            res = res % mod * a % mod;
        }
        a = a % mod * a % mod;
        n >>= 1;
    }
    return res; 
}

struct SegTree
{
	struct SegNode
	{
		//l,r代表的是该节点表示的原数组下标 
		int l,r;
		//add为该区间懒惰标记 
		ll add;
		//sum,max和min分别为原数组对应区间的和，最大值以及最小值 
		ll val;
		//x为线段树内部下标 
		#define l(x) tree[x].l
		#define r(x) tree[x].r
		#define val(x) tree[x].val
		#define add(x) tree[x].add
	}tree[maxn<<2];
	void build(int p,int l,int r)
	{
		add(p) = 0;
        //p为线段树内部下标 
		l(p) = l,r(p) = r;
		//到达叶子节点 
		if(l==r)
		{
			val(p) = der[l(p)];
			return ;
		}
		int mid = (l+r)/2;
		//递归构造左右节点 
		build(p*2, l, mid);
		build(p*2+1, mid+1, r);
		//左右节点维护完后开始维护父节点 
		val(p) = ((val(p*2)+val(p*2+1))%mod+mod)%mod;
	}
	//懒惰标记下放 
	void spread(int p)
	{
		if(add(p))
		{
			ll d = add(p);
			val(p*2) = d * inv % mod
					   * ((der[l(p*2)]-der[r(p*2)+1])+mod)%mod;
			val(p*2) %= mod;
			val(p*2+1) = d * inv % mod
					   * ((der[l(p*2+1)]-der[r(p*2+1)+1])+mod)%mod;
			val(p*2+1) %= mod;
			
			add(p*2) = add(p);
			add(p*2+1) = add(p);
			add(p) = 0;
		} 
	}
	void change(int p,int l,int r,ll d)
	{
		//要修改区间完全包住当前节点区间 
		if(l <= l(p) && r >= r(p))
		{
			val(p) = d * inv % mod
					   * ((der[l(p)]-der[r(p)+1])+mod)%mod;
			val(p) %= mod;
			add(p) = d;
			return ;
		} 
		//否则下放当前节点懒惰标记 
		spread(p);
		int mid = (l(p)+r(p))/2;
		/*如果要修改的区间左端点比当前节点代表区间的mid小则说明涉及到了
		左区间*/ 
		if(l <= mid)
			change(p*2, l, r, d);
		//右端同理 
		if(r > mid)
			change(p*2+1, l, r, d);
		val(p) = ((val(p*2)+val(p*2+1))%mod+mod)%mod;
	} 
}T;

int n, q; 

int main()
{
	scanf("%d%d",&n,&q);
	der.pb(1);
	_for(i,1,n+1)
		der.pb((der[i-1]*10)%mod);
	inv = (-9+mod)%mod;
	inv = fpow(inv,mod-2,mod); 
	T.build(1,0,n-1);
	_for(i,1,q+1)
	{
		int L, R, D;
		scanf("%d%d%d",&L,&R,&D);
		L --, R --;
		L = n-1-L;
		R = n-1-R;
		swap(L,R);
		T.change(1,L,R,D);
		printf("%lld\n",T.tree[1].val%mod);
	}
	return 0;
}

Measured memory_bytes: 17220
X,N=map(int,input().split())
p =list(map(int,input().split()))
flag=False

ans=0
minAbs=abs(X-ans)

for i in range(0,102):
    if (i in p)==True:
        continue

    if abs(X-i)<minAbs:
        minAbs=abs(X-i)
        ans=i

print(ans)

Measured memory_bytes: 61856
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n, m; cin >> n >> m;
	priority_queue<ll> q;
	rep(i, n){
		ll tmp; cin >> tmp;
		q.push(tmp);
	}
	for(int i = 0; i < m; ++i){
		ll tmp = q.top();
		q.pop();
		tmp /= 2;
		q.push(tmp);
	}
	ll ans = 0;
	for(int i = 0; i < n; ++i){
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void){

    int a, b, sum, i, ans;
    
    while(scanf("%d %d\n", &a, &b) != EOF) {
        sum = a+b;
        ans=1;
        while(sum>=10) {    //1桁になるまで10で割る
            sum /= 10;
            ans++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n; ll C;
    scanf("%d%lld", &n, &C);
    vector<ll> h(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld", &h[i]);
    }

    vector<ll> dp(n),a(n),b(n);

    const double eps=1e-6;
    vector<pair<double,int> > z;    // xの値, xより少し大きいところの直線のindex
    for(i=0; i<n; i++) {
        if(i>0) {
            ll tmp=0;
            if(!z.empty()) {
                int k=lower_bound(z.begin(), z.end(), make_pair((double)h[i]+eps,-INF))-z.begin();
                if(k>0) {
                    k--;
                    int id=z[k].second;
                    tmp=a[id]*h[i]+b[id];
                }
            }
            dp[i]=tmp+h[i]*h[i]+C;
        }

        // for CHT
        a[i]=-2*h[i];
        b[i]=dp[i]+h[i]*h[i];
        while( 1 ) {
            if(z.empty()) {
                z.push_back(make_pair(-INF,i));
                break;
            }
            else {
                double  x0=z.back().first;
                int id0=z.back().second;

                double tmp=-(double)(b[i]-b[id0])/(a[i]-a[id0]);
                if(tmp<x0) {
                    z.pop_back();
                }
                else {
                    z.push_back(make_pair(tmp,i));
                    break;
                }
            }
        }
    }
    printf("%lld\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 12528
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N,X;
    cin >>N>>X;
    vector<int> L(N+1);
    vector<int> D(N+2);
    D[1] = 0;
    for(int i = 1;i < N+1;i++){
        cin >> L[i];
    }
    int ans = 0;
    for(int i = 2;i < N+2;i++){
        D[i] = D[i-1] + L[i-1];
        if(D[i] <= X)ans++;
        else break;
    }
    cout << ans + 1<< endl;


}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define LD long double
const LL MOD=1e9+7;
#define vL vector<LL>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    LL a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b,min(b+c,a+c));
}

Measured memory_bytes: 256
#include "stdio.h"

long long int GCD(long long int a, long long int b)   //最大公?数
{
	long long int n=1,a1,b1;
	a1 = a; b1 = b;
	while (n != 0)
	{
		n = a1%b1;
		a1 = b1;
		b1 = n;
	}
	return a1;
}
long long int LCM(long long int a, long long int b)    //最小公倍数
{
	long long int n ;
	n = (a*b) / GCD(a, b);
	return n;
}
int main()
{
	long long int a, b;
	while ((scanf("%lld %lld", &a, &b)) != EOF)
	{
		printf("%lld ", GCD(a, b));
		printf("%lld\n", LCM(a, b));
	}
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;

    if(a < b && a < c && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3140
x, y = map(int, input().split())
i1 = x * 12.5
i2 = y * 10
i1 += 0.5
i1 //= 1
z = max(i1, i2)
if z // 12.5 != x or z // 10 != y:
    print(-1)
else:
    print(int(z))


Measured memory_bytes: 2940
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N, D = map(int, input().split())
    cnt = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        if X ** 2 + Y ** 2 <= D ** 2:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
import numpy as np

global mod
mod = 10 ** 9 + 7

def mpow(x, n):  # x^nをmod取りながら返す
    ans = 1
    while n != 0:
        if n & 1:
            ans = ans * x % mod
        x = x * x % mod
        n = n >> 1

    return ans

n, k = map(int, input().split())

ai = n - k + 1
print(ai)

for i in range(2, k +1):
    if n - k + 1 < i:
        print(0)
        continue

    ai = ai * (n - k - i + 2) * (k - i + 1) % mod
    ai = ai * mpow(i*(i-1), mod-2) % mod

    print(ai)



Measured memory_bytes: 12720
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int ck(unsigned long long p){
    int k=0;
    while(p>=10){
        k++;
        p/=10;
    }
    return k;
}
int tk(unsigned long long p){
    int k=0;
    while(p>=10){
        k++;
        p/=10;
    }
    return p;
}
int main(){
    int n;
    cin >> n;
    unsigned long long m=1,a;
    int i;
    bool flg=false;
    bool zeroflg=false;
    for(i=0;i<n;i++){
        cin >> a;
        if((ck(m)+ck(a)>18)||((ck(m)+ck(a)==18)&&(tk(m)*tk(a)>1))){
            flg=true;
        }else{
            m*=a;
        }
        if(m>1000000000000000000){
            flg=true;
        }
        if(a==0){
            zeroflg=true;
        }
    }
    if(zeroflg){
    cout << 0 << endl;
    }else if(flg){
    cout << -1 << endl;
    }else{
    cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x<y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
    
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll h,w,a,b,c,d,m,M;
  cin>>h>>w;
  ll ans=h*w;
  Fr(i,h-1){
    a=w*i;d=(h-i)*w;
    if(d%2) b=(d+min(h-i,w))/2;
    else b=d/2;
    c=d-b;
    ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
  }
  Fr(i,w-1){
    a=h*i;d=(w-i)*h;
    if(d%2) b=(d+min(w-i,h))/2;
    else b=d/2;
    c=d-b;
    ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
    int n; cin>>n;
    int freq[n+1]={};
    
    for(int i=2;i<=n;i++)
    {
        int cur = i;
        for(int j=2;j<=i;j++)
        {
            while(cur%j==0)
            {
                freq[j]++;
                cur/=j;
            }
        }
    }

    int a[6]={};

    for(int i=2;i<=n;i++)
    {
        if(freq[i]>=1) a[0]++;
        if(freq[i]>=2) a[1]++;
        if(freq[i]>=4) a[2]++;
        if(freq[i]>=14) a[3]++;
        if(freq[i]>=24) a[4]++;
        if(freq[i]>=74) a[5]++;
    }

    int ans = 0;

    if((a[2]*(a[2]-1)*(a[1]-2))/2>0) ans+=(a[2]*(a[2]-1)*(a[1]-2))/2;
    if(a[3]*(a[2]-1)>0) ans+=a[3]*(a[2]-1);
    if(a[4]*(a[1]-1)>0) ans+=a[4]*(a[1]-1);
    if(a[5]>0) ans+=1;

    cout<<ans;
   
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N; cin>>N;
  vector<vector<pair<int,int>>> v(N);
  rep(i,N) {
    int A; cin>>A;
    rep(j,A) {
      pair<int,int> pint; cin>>pint.first>>pint.second;
      --pint.first;   // 人i: 0-origin
      v[i].push_back(pint);
    }
  }

  int res = 0;
  for(int bit=0; bit<(1<<N); ++bit) {
    // bitを集合に変換して，正直者リストを生成
    vector<bool> v2(N);
    for(int i=0; i<N; ++i) {
      if(bit & (1<<i)) v2[i] = true;
    }

    bool OK = true;   // 矛盾がないか

    for(int i=0; i<N; ++i) {
      // 人iが正直者でない場合，飛ばす
      if(!v2[i])continue;
      // 証言内容の確認
      for(int j=0; j<(int)v[i].size(); ++j) {
        // 証言相手
        int people = v[i][j].first;
        // 矛盾がある場合
        if (v2[people] != (v[i][j].second == 1)) OK = false;
      }
    }
    // 矛盾があった場合
    if(!OK) continue;

    // 正直者の人数
    int sum = 0;
    for(int i=0; i<N; ++i) {
      if(v2[i])++sum;
    }

    res = max(res, sum);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[][] cake = new long[n][3];
		for (int i = 0; i < n; i++) {
			cake[i][0] = sc.nextLong();
			cake[i][1] = sc.nextLong();
			cake[i][2] = sc.nextLong();
		}

		long answer = 0;
		long[] c = new long[n];
		for (int i = 0; i < 8; i++) {

			for (int j = 0; j < n; j++) {
				long x = 0;
				if ((i & 1) == 1) {
					x += cake[j][0];
				} else {
					x += -cake[j][0];
				}

				if (((i >> 1) & 1) == 1) {
					x += cake[j][1];
				} else {
					x += -cake[j][1];
				}

				if (((i >> 2) & 1) == 1) {
					x += cake[j][2];
				} else {
					x += -cake[j][2];
				}
				c[j] = x;
			}

			Arrays.sort(c);
			long t = 0;
			for (int j = 0; j < m; j++) {
				t += c[n - 1 - j];
			}

			answer = Math.max(answer, t);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 27368
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

cnt = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = n-bisect.bisect_right(C, b)
    cnt += i*j

print(cnt)


Measured memory_bytes: 29140
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
ll n, k;
int main()
{
	cin >> n >> k;
	ll ost = n % k;
	ll najm = min(ost, abs(ost - k));
	cout << najm << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        
    print(R)

Measured memory_bytes: 21628
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    cin >> S;

    bool ans = true;
    REP(h, H) {
        REP(w, W) {
            if (S[h][w] == '#') {
                if (h - 1 >= 0 && S[h - 1][w] == '#')continue;
                if (w - 1 >= 0 && S[h][w - 1] == '#')continue;
                if (h + 1 < H&&S[h + 1][w] == '#')continue;
                if (w + 1 < H&&S[h][w + 1] == '#')continue;
                ans = false;
            }
        }
    }

    YESNO(ans, "Yes", "No");
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> P;	//p, d

int n, m;
P pd[10000];

signed main() {
	int i;
	
	while (cin >> n >> m) {
		if (!n) break;
		for (i = 0; i < n; i++) cin >> pd[i].second >> pd[i].first;
		sort(pd, pd + n, greater<P>());
		
		int ans = 0;
		for (i = 0; i < n; i++) {
			if (m >= pd[i].second) {
				m -= pd[i].second;
			}
			else {
				ans += pd[i].first * (pd[i].second - m);
				m = 0;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3104
// ※※※ 解答不能 ※※※
// hitonanode氏.
// https://atcoder.jp/contests/abc147/submissions/8872500
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)

constexpr int b = 80 * 80 + 3;
constexpr int M = b * 2 + 3;

int main(){
    int H, W;
    scanf("%d %d", &H, &W);
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    rep(i, H) rep(j, W) scanf("%d", &A[i][j]);
    rep(i, H) rep(j, W) scanf("%d", &B[i][j]);
    vector<bitset<M>> dp(W + 1);
    dp[1][b] = 1;
    rep(i, H){
        rep(j, W){
            int d = abs(A[i][j] - B[i][j]);
            dp[j + 1] |= dp[j];
            dp[j + 1] = (dp[j + 1] << d) | (dp[j + 1] >> d);
        }
    }
    printf("%d\n", dp.back()._Find_next(b - 1) - b);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define min(a,b) ((a)<(b))?(a):(b)
int main(void)
{
  int n,a[205],ans[205],cnt=0,min=30;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    while(a[i]%2==0){
      a[i]=a[i]/2;
      cnt++;
    }
    ans[i]=cnt;
    cnt=0;
  }
  for(int i=0;i<n;i++){
    min=min(min,ans[i]);
  }
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        
        switch(str){
            case "Sunny" :
                System.out.println("Cloudy");
                break;
            case "Cloudy" :
                System.out.println("Rainy");
                break;
            case "Rainy" :
                System.out.println("Sunny");
                break;
        }

    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;

int main() {

	ll a, b, c;
	ll ma = 0;
	ll k = 0;
	cin >> a >> b >> c >> k;

	ma = max(a, max(b, c));

	ll sum = a + b + c - ma;        //最大値以外の和

	for (int i = 0; i < k; i++) {
		ma = ma * 2;
	}

	cout << sum + ma << endl;


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
using namespace std;
const int dx[]={1,0,-1,0},dy[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> Pii;
int main(){
    int n,K;
    vector < vector < int > > ship (52);
    scanf("%d%d",&n,&K);
    
    rep(i,K){
        int m;
        scanf("%d",&m);
        rep(j,m){
            int tmp;
            scanf("%d",&tmp);
            ship[i].PB(tmp);
        }
        sort(ship[i].begin(),ship[i].end());
    }

    int r;
    bool feel[52]={false};
    scanf("%d",&r);
    rep(i,r){
        int p,q;
        scanf("%d%d",&p,&q);
        rep(j,ship.size()){
            if(binary_search(ship[j].begin(),ship[j].end(),p) && binary_search(ship[j].begin(),ship[j].end(),q)){
                feel[p] = feel[q] = true;
                break;
            }
        }
    }
    int ans = 0;
    rep(i,51){
        if(feel[i])ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
int main(){
    int r , D, x;
    cin >> r >> D >>x;
    int xi[11];
    xi[0] = x;
    for(int i = 0; i < 10; i++){
        xi[i+1] = r * xi[i] - D;
        cout << xi[i+1] << endl;
    }
}

Measured memory_bytes: 256
//-----

var log = console.log;
if (typeof process != "undefined") {
	var input = "";
	process.stdin.resume();
	process.stdin.setEncoding('utf8');
	process.stdin.on('data', function (chunk) {
		input += chunk;
	});
	process.stdin.on('end', function () {
		var lines = input.split("\n");
		main(lines);
	});
}

//-----

function main(lines) {
	lines.shift();
	lines = lines.map(function (e) {
		var f = e.split(" ");
		var ret = f.map(function (g) {
			return Number(g);
		});
		return ret;
	});
	var datasets = [];
	while (lines.length > 1) {
		//2????????£??????
		var arr = [];
		arr.push(lines.shift());
		arr.push(lines.shift());
		datasets.push(arr);
	}
	datasets.forEach(function (e) {
		var ppow = e[0][1];
		var diff = [];
		e[1].forEach(function (f, i, a) {
			if (i == 0) {
				return;
			} else {
				diff.push(a[i] - a[i - 1]);
			}
		});
		diff.sort(function (a, b) {
			return b - a;
		});
		diff = diff.slice(ppow - 1);
		var sum = 0;
		if (diff.length > 0) {
			sum = diff.reduce(function (p, c) {
				return p + c;
			});
		} else {
			sum = 0;
		}
		log(sum);
	});
}

Measured memory_bytes: 44368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    int ans=N%1000;
    if(ans==0) cout << 0 << endl;
    else cout << 1000-ans << endl;



    



}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int table[26] = { 0 };
    char c;

    while ((c = getchar()) != '\n') {
        table[c-'a'] = 1;
        //cout << table[c-'a'] << endl;
        //cout << (int)(c-'a') << ' ';
    }

    for (char i=0; i<26; i++) {
        if(table[i] == 0) {
            printf("%c\n", i+'a');
            break;
        }
        else if(i == 25) {
            cout << "None" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<pair<int, int>> robot(n, pair<int, int> {});

    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        robot[i] = { x + l, x - l };
    }

    sort(robot.begin(), robot.end());

    int count = 0;
    int last = INT_MIN;

    for (int i = 0; i < n; i++) {
        if (robot[i].second >= last) {
            count++;
            last = robot[i].first;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int A,B;
  cin>> A>> B;

  int ret=0;
  for(int i=A;i<=B;i++)
  {
    string str=to_string(i);
    if(str[0]==str[4]&&str[1]==str[3])ret++;
  }
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int h[n];
  for(int i = 0; i < n; i++) cin >> h[i];

  int ans = 0;
  while(true){
    int s = 0;
    while(s < n){
      if(h[s] == 0){
        ++s;
        continue;
      }
      int mi = h[s];
      int t = s + 1;
      while(t < n && h[t] != 0){
        mi = min(mi, h[t]);
        ++t;
      }
      for(int i = s; i < t; i++) h[i] -= mi;
      ans += mi;
      s = t;
    }
    bool finish = true;
    for(int i = 0; i < n; i++){
      if(h[i] != 0){
        finish = false;
        break;
      }
    }
    if(finish) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
const int MAXN = 65535 + 5;
const double INF = 2e9;
const ll MOD = 1e9 + 7;

//#define DEBUG

int main(){
  FastIO;
  #ifdef DEBUG
    freopen("input.txt", "r", stdin);
  #endif
  string s;
  cin >> s;
  int n = s.size() - 1;
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += (s[i] != s[n]);
    --n;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b;
  cin >> a>>b;
  bool flag=false;
  for(int c=1; c<4; c++){
     if((a*b*c)%2==1)
       flag = true;
  }
  cout << (flag ?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	double num = 0.0;
      	int child = 1;
     	int mom = 1;
     	for(int i = 0; i < a; i++){
          num += 1.0/sc.nextInt();
        }
        System.out.println(1.0/num);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  ll ans=INF;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ll x=i,y=n/i;
      ans=min(ans,x+y);
    }
  }
  cout << ans-2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int H=105;
int val[H][H],a[H*H];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int h,w,n;
  cin>>h>>w>>n;
  rep(i,1,n+1) cin>>a[i];
  int r=1,c=1;
  bool up=true;
  rep(i,1,n+1)
    {
      while(true)
	{
	  if(up)
	    {
	      if((w-c+1)<=a[i])
		{
		  rep(j,c,w+1)
		    val[r][j]=i;
		  a[i]-=(w-c+1);
		  c=w,up=false;
		  r++;
		  if(!a[i]) break;
		}
	      else
		{
		  rep(j,c,c+a[i])
		    val[r][j]=i;
		  c+=a[i];
		  break;
		}
	    }
	  else
	    {
	      if(c<=a[i])
		{
		  repv(j,1,c+1)
		    val[r][j]=i;
		  a[i]-=c;
		  c=1; up=true;
		  r++;
		  if(!a[i]) break;
		}
	      else
		{
		  repv(j,c-a[i]+1,c+1)
		    val[r][j]=i;
		  c-=a[i];
		  break;
		}
	    }
	}
    }
  rep(i,1,h+1)
    rep(j,1,w+1)
    cout<<val[i][j]<<((j==w)?'\n':' ');
  return 0 ;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int tot,n,m,t[110],a[110],b[110],prm[10010],map[110][110],link[110],ans;
bool flag[10010];

void insert(int x)
{
    (x&1?a[++n]:b[++m])=x;
}

bool check(int x)
{
    if (x<=2)
        return 0;
    for (int i=1; prm[i]*prm[i]<=x; ++i)
        if (!(x%prm[i]))
            return 0;
    return 1;
}

bool hungary(int x)
{
    repu(i,1,map[x][0])
        if (!flag[map[x][i]])
        {
            flag[map[x][i]]=1;
            if (!link[map[x][i]] || hungary(link[map[x][i]]))
            {
                link[map[x][i]]=x;
                return 1;
            }
        }
    return 0;
}

int main()
{
    scanf("%d",&tot);
    repu(i,1,tot)
        scanf("%d",&t[i]);
    for (int i=1,j; i<=tot; i=j+1)
    {
        for (j=i; j<tot && t[j+1]==t[j]+1; ++j);
        insert(t[i]),insert(t[j]+1);
    }
    tot=0;
    repu(i,2,1e4)
        if (!flag[i])
        {
            prm[++tot]=i;
            for (int j=i*2; j<=1e4; flag[j]=1,j+=i);
        }
    repu(i,1,n)
        repu(j,1,m)
            if (check(abs(a[i]-b[j])))
                map[i][++map[i][0]]=j;
    repu(i,1,n)
    {
        memset(flag,0,sizeof(bool)*(m+10));
        ans+=hungary(i);
    }
    printf("%d\n",n+m-ans+((n-ans)&1));
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			int[] as = new int[N];
			for(int i = 0; i < N; i++) { as[i] = sc.nextInt(); }
			
			int answer = 0;
			int[] counts = new int[N + 1];
			
			for(int i = N; i >= 1; i--) {
				int already = 0;
				
				for(int j = i * 2; j <= N; j += i) {
					already += counts[j];
					already %= 2;
				}
				
				if(as[i - 1] == already) {
					counts[i] = 0;
				}else {
					answer++;
					counts[i] = 1;
				}
			}
			
			for(int i = 1; i <= N; i++) {
				int calced = 0;

				for(int j = i; j <= N; j += i) {
					calced += counts[j];
					calced %= 2;
				}
				
				if(as[i - 1] != calced) {
					System.out.println(-1);
					return;
				}
			}
			
			System.out.println(answer);
			boolean first = true;
			for(int i = 1; i <= N; i++) {
				if(counts[i] == 0) { continue; }
				
				if(first) {
					System.out.print(i);
					first = false;
				}else {
					System.out.print(" " + i);
				}
			}
			if(answer > 0) { System.out.println(); } 
			
			/*
				System.out.println(Arrays.toString(counts));
			*/
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 51040
n=int(input())
a=[]
for _ in range(n):
    x=int(input())
    a.append(x)
import numpy as np
A=np.array(a)
b=A.argsort()[::-1]
c=b[0]
for i in range(n):
    if i==c:
        print(a[b[1]])
    else:
        print(a[c])

Measured memory_bytes: 24848
class Dice:
    def __init__(self, data):
        self.data = data

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3],self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[1],self.data[0],self.data[4],self.data[5]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4],self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
             self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2],self.data[5],self.data[3],self.data[0]


    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])

print(dice.getTop())

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std; 

struct blah{
	int order; int num;
}a[100005];

bool cmp(blah i, blah j)
{
	return i.order<j.order;
}

int main()
{
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		cin>>a[i].order;
		a[i].num=i;
	}
	sort(a, a+n, cmp);
	for(int i=0; i<n; i++)
	{
		cout<<a[i].num+1 <<" ";
	}
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#define ll long long

const int Inf=1e9+10;
ll jiu[19];

int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9' && ch>='0'){sum=sum*10+ch-'0';ch=getchar();}
	return sum*f;
}

int d;
ll ans;

ll sm[20];

void dfs(int i,int n,ll N,ll revN,ll cif){
	if(i>n){
		if(revN-N==d){
			ans++;
		}
		return;
	}
	ll maxd=revN*sm[n-i+1]+1-N-sm[n-i+1];
	ll mind=revN*sm[n-i+1]+jiu[n-i+1]-(jiu[n-i+1]*sm[i-1]+N);
	if(N && revN-N+maxd<d)return;
	if(N && revN-N+mind>d)return;
	for(int j=9;j>=(i==n)?1:0;j--)
		dfs(i+1,n,N+j*cif,revN*10+j,cif*10);
}

int main(){
	int i,j,k,n,m;
	scanf("%d",&d);
	if(d%9){
		puts("0");
		return 0;
	}
	d/=9;
	ll len=1,ini=0;
	for(i=1;i<=18;i++)
		sm[i]=sm[i-1]*10;
	for(i=1;i<=17;i++){
		ll tmp=1,D=d;
		ini=ini*10+1;
		ll base=ini,lten=len,rten=1;
		for(int j=0;j<=(i>>1);j++){
			tmp*=10-abs(D%(rten*10)/rten)-(!j?1:0);
			D-=base*(D%(rten*10)/rten);
			base-=lten+rten;
			lten/=10;
			rten*=10;
		}
		len*=10;
		if(!D)ans+=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B>C+D)cout<<"Left"<<endl;
  else if(A+B<C+D)cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=200005;
int poz[nmax],st[nmax],dr[nmax];
long long tot,i;
int n,x;
int main()
{
   // freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        poz[x]=i;
    }
    for(i=n;i>=1;i--)
    {
        x=poz[i];
        st[x]=dr[x]=x;
        if(st[x-1]) st[x]=st[x-1];
        if(dr[x+1]) dr[x]=dr[x+1];
        dr[st[x]]=dr[x];
        st[dr[x]]=st[x];
        tot+=1LL*(x-st[x]+1)*(dr[x]-x+1)*i;
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;

int n, ans;
string s, t;
queue<int> q;

int main()
{
    cin >> n >> s >> t;

    if (s == t) // 特判两串相等
    {
        puts("0");
        return 0;
    }

    int up = n - 1, down = n - 1;

    while (down >= 0)
    {
        while (down && t[down - 1] == t[down]) --down; // 找到当前折线在最后一行最左的位置
        while (up >= 0 && (up > down || s[up] != t[down])) --up; // 找到当前折线在第一行最左的位置
        if (up < 0) // 如果第一行没有对应的字符，输出无解
        {
            puts("-1");
            return 0;
        }
        while (!q.empty() && q.front() - q.size() >= down) q.pop(); // 把当前折线不会碰到的部分弹出
        if (up != down) q.push(up); // 如果当前折线真的是“折线”而不是竖直下来不拐弯，就把 S1 的拐点压入队列
        ans = max(ans, (int)q.size() + 1); // 后文会解释为什么这样更新答案
        --down;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 6280
fun main(args: Array<String>) {
    val (w, _, n) =
        readLine()!!.split(" ").map { it.toInt() }
    val rangeMaxY = IntArray(w)//iからwまでの間に居る敵のy座標の最大値
    val maxY = IntArray(w)//i列目の敵のy座標最大値
    repeat(n) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        maxY[x] = Math.max(maxY[x], y)
    }
    for(i in w - 2 downTo 0) {
        rangeMaxY[i] = Math.max(maxY[i+1], rangeMaxY[i+1])
    }

    val min_cost = rangeMaxY.mapIndexed(Int::plus).min()!!
    println(min_cost)
}


Measured memory_bytes: 82212