akhauriyash/Code-Regression huggingface dataset:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    h=I()
    def nextPowerOf2(n): 
        p = 1
        if (n and not(n & (n - 1))):
            return n
        while (p < n) :
            p <<= 1
        return p
    if h==1:
        print(1)
    else:
        p = nextPowerOf2(h)
        if h==p:
            print(nextPowerOf2(h+1)-1)
        else:
            print(p-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4208
#include <stdio.h>

int expr(const char **);
int term(const char **);
int factor(const char **);
int number(const char **);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  scanf("%d", &n);
  char s[101];
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}

Measured memory_bytes: 1736
from math import gcd
K = int(input())

ans = 0
for a in range(1, K + 1):
    ans += a
    for b in range(a + 1, K + 1):
        ans += gcd(a, b) * 6
        for c in range(b + 1, K + 1):
            ans += gcd(a, gcd(b, c)) * 6
print(ans)


Measured memory_bytes: 9188
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,d+2):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	res = max(res,space)
	if res < 3:
		flag = 0

print("Yes" if flag else "No")


Measured memory_bytes: 3516
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    vvi edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    if (n == 1) {
        cout << k << "\n";
        return 0;
    }
    vi dp(n + 1, -1);
    int start = 0;
    for (int i = 0; i < n; ++i) {
        if (edges[i].size() == 1) {
            start = i;
            break;
        }
    }
    dp[start] = k;
    dp[edges[start].front()] = k - 1;
    deque<int> que;
    que.push_back(edges[start].front());
    while (que.size() != 0) {
        int q = que.front();
        que.pop_front();
        int used = 2;
        for (auto &e : edges[q]) {
            if (dp[e] != -1)
                continue;
            dp[e] = max(0, k - used);
            used++;
            que.push_back(e);
        }
    }
    ll ret = 1;
    for (int i = 0; i < n; ++i) {
        ret = (ret * dp[i]) % MOD;
    }
    cout << ret << "\n";
    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> v(26,51);
    for(int ix=0;ix<n;ix++){
        string s; cin >> s;
        vector<int> tmp(26,0);
        for(int ix2=0;ix2<s.size();ix2++){
            tmp.at(s.at(ix2)-'a')++;
        }
        for(int ix2=0;ix2<26;ix2++) v.at(ix2) = min(tmp.at(ix2),v.at(ix2));
    }
    string ans = "";
    for(int ix=0;ix<26;ix++){
        //if(v.at(ix) == 0) break;
        for(int ix2 = 0;ix2 < v.at(ix); ix2++) ans += ('a'+ix);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n;
int a[2][MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int k=0; k<2; k++)
		for (int i=0; i<n; i++) 
			scanf("%d", &a[k][i]);
	return 1;
}

void init() {
}

long solve() {
	for (int k=0; k<2; k++) {
		for (int i=0; i<n-1; i++) 
			a[k][i+1] += a[k][i];
	}
	int r = 0;
	for (int i=0; i<n; i++) {
		r = max(r, a[0][i] + a[1][n-1]-(i? a[1][i-1]: 0));
	}
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
#include <stdio.h>
int main(){

    int n, x, i, j, k, count;
    while(1){
        count = 0;
        scanf("%d %d",&n, &x);
        if(n == 0 && x == 0) break;

        for(i = 1; i <= n; i++){
            for(j = i +1; j <= n; j++){
                for(k = j + 1; k <= n; k++){
                    if(x == i + j + k){
                        count++;
                        break;
                    }
                }
            }
        }

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

    }

    return 0;
}


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






int main() {
  vector<int> as;
  vector<int> bs;
  vector<int> cs;
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int x; cin >>x;
    as.push_back(x);
  }
  for(int i = 0; i < n; i++) {
    int x; cin >>x;
    bs.push_back(x);
  }
  for(int i = 1; i < n; i++) {
    int x; cin >>x;
    cs.push_back(x);
  }
  int res = 0; int onceki = -1;
  for(int i = 0; i < n; i++) {
    res += bs[i];
  }
  for(int i = 1; i < n;i++) {
    if(as[i] - as[i-1] == 1) {
      res += cs[as[i-1]-1];
    }
  }
  cout << res << endl;

}


Measured memory_bytes: 256
"""
オイラー間数値の問題
1,2,…,N1,2,…,N  のうち、NN と互いに素であるものの個数を求めよ。

答え
素因数分解したときに現れる素数をp1，p2，p3...とした時
N(1 ー 1/p1)(1 - 1/p2)(1 - 1/p3)
2の倍数を除去，3の倍数を除去，といった感じ
O(√N)
"""
import copy


p = N = int(input())
prime_numbers = []
d = 2
ans = 1 * N

while d*d <= p:
    if N % d == 0:
        ans *= 1 - 1/d
        while N % d == 0: N //= d
    d += 1

if N > 1:
    ans *= 1 - 1/N

print(int(ans))


Measured memory_bytes: 6340
// class point	の練習（クラスの高度な実装）
#include <iostream>
using namespace std;



int main() {
	int a, b, c;
	int cnt = 0;

	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c % i == 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3136
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
 
ll inv[1000001], f[1000001], fi[1000001];

ll C(int N, int K) {
	return f[N] * fi[K] % MOD * fi[N - K] % MOD;
}

ll H(int N, int K) {
	if (K == 0) return !N;
	return H(N + K - 1, K - 1);
}

int main() {
	inv[1] = 1;
	for (int i = 2; i <= 1000000; i++)
		inv[i] = -MOD / i * inv[MOD % i] % MOD;
	f[0] = fi[0] = 1;
	for (int i = 1; i <= 1000000; i++) {
		f[i] = f[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * inv[i] % MOD;
	}
	vector<ll> p3(1000001);
	p3[0] = 1;
	for (int i = 1; i <= 1000000; i++)
		p3[i] = p3[i - 1] * 3 % MOD;
	vector<ll> p2(1000001);
	p2[0] = 1;
	for (int i = 1; i <= 1000000; i++)
		p2[i] = p2[i - 1] * 2 % MOD;
	int N, M, L;
	cin >> N >> M >> L;
	N++;
	if (M > L) swap(M, L);
	ll ans = 0;
	ll hoge = 0;
	for (int k = 0; k <= M + L; k++) {
		ll unko = 0;
		unko = (unko + p2[k]) % MOD;
		hoge = hoge * 2 % MOD;
		if (k > M) hoge = (hoge + C(M + k - M - 1, k - M - 1)) % MOD;
		if (k > L) hoge = (hoge + C(L + k - L - 1, k - L - 1)) % MOD;
		unko = (unko - hoge) % MOD;
		ans = (ans + unko * p3[M + L - k] % MOD * C(N - 2 + k, k)) % MOD;
	}
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

/*繰り返し二乗法(mod付き)*/
template<typename T,typename U>
U mod_pow(long long n,T k,U p){//n^k(mod p). O(log K).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return (U)res;
}

int main(){
	int n;
	cin>>n;
	
	llong ans=mod_pow(10LL,n,MOD);
	ans=ans-2*mod_pow(9,n,MOD)+mod_pow(8,n,MOD);
	while(ans<0) ans+=MOD;
	ans%=MOD;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

struct Node  T[MAX];
int n,D[MAX];

void pre(int u){
  if(u==NIL) return;
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}

void in(int k){
  if(k==NIL) return;
  in(T[k].l);
  printf(" %d",k);
  in(T[k].r);
}

void post(int h){
  if(h==NIL) return;
  post(T[h].l);
  post(T[h].r);
  printf(" %d",h);
}

int main(){

  int n,i,j,num,node,nodenum,c,left,right,r,root;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].p = NIL;

  for(i = 0;i<n;i++){
    scanf("%d %d %d",&node,&left,&right);
    T[node].l = left;
    T[node].r = right;
    if(left!=NIL) T[left].p = node;
    if(right!=NIL) T[right].p = node;

    }

  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;

printf("Preorder\n");
pre(root);
printf("\n");
printf("Inorder\n");
in(root);
printf("\n");
printf("Postorder\n");
post(root);
printf("\n");

return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll H,W;
    cin >> H >> W;
    ll h , w;
    cin >> h >> w;
    cout << (H-h)*(W-w) << endl;


	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, parent, lchild, sibling):
        self.parent = parent
        self.lchild = lchild
        self.sibling = sibling
        self.depth = None

    def __repr__(self):
        return "{" + str(self.parent) + " " + str(self.lchild) + " " + str(self.sibling) + "}"

class NodeList:
    def __init__(self,size):
        self.nlist = [Node(None,None,None) for i in range(size)]

    def add(self, id, sibs):
        #print(self)
        self.nlist[id].lchild = sibs[0]
        #print(self)
        for i in range(len(sibs)-1):
            self.nlist[sibs[i]].parent = id
            self.nlist[sibs[i]].sibling = sibs[i+1]
            #print(self)
        self.nlist[sibs[-1]].parent = id

    def calcDepth(self, idx):
        cnt = -1
        while  idx != None:
            #print("depth",self.nlist[idx])
            idx = self.nlist[idx].parent
            cnt += 1
        return cnt

    def getChilds(self, lchild):
        res = []
        while lchild != None:
            #print("childs",self.nlist[lchild])
            res.append(lchild)
            lchild = self.nlist[lchild].sibling
        return res

    def calcStatus(self, node):
        if node.parent == None:
            return "root"
        if node.lchild == None:
            return "leaf"
        return "internal node"

    def print(self):
        for idx, node in enumerate(self.nlist):
            parent = node.parent
            if parent == None:
                parent = -1
            depth = self.calcDepth(idx)
            childs = self.getChilds(node.lchild)
            status = self.calcStatus(node)
            print("node "+str(idx)+": parent = "+str(parent)+", depth = "+str(depth)+", "+str(status)+", "+str(childs))


    def __repr__(self):
        return str(self.nlist)

            


N = int(input())
NL = NodeList(N)

for i in range(N):
    D = list(map(int, input().split()))
    if len(D) is not 2:
        NL.add(D[0], D[2:])
NL.print()
    







Measured memory_bytes: 33664
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n,k = ip()
x = ip()
x.sort()
print(sum(x[:k]))

Measured memory_bytes: 62496
while True:
    line = input().split()
    a = int(line[0])
    op = line[1]
    b = int(line[2])
    if op == '?':
        break
    else:
        if op == '+':
            print(a+b)
        if op == '-':
            print(a-b)
        if op == '*':
            print(a*b)
        if op == '/':
            print(a//b)


Measured memory_bytes: 5596
#include <iostream>
using namespace std;

int main(){
	int n;
	int a[100];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n - 1; i >= 0; i--){
		cout << a[i];
		if(i != 0) cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))
#define sz(x) (ll)x.size()

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

const ll inf = (ll)1e18 + 5;
const ll mod = 1e9+7;

ll dp[2005][2005];

// returns the sum 
ll get(ll a, ll b, VLL & A, VLL & B) {
	if (a == -1 || b == -1) return 1;
	if (dp[a][b] != -1) return dp[a][b];

	ll ans = get(a-1, b, A, B) + get(a, b-1, A, B)- get(a-1, b-1, A, B);
	if (A[a] == B[b]) {
		ans += get(a-1,b-1,A,B);
	}
	ans %= mod;
	if (ans < 0) ans += mod;
	ans %= mod;
	
	dp[a][b] = ans;
	return ans;
}

void solve() {
	mst(dp, -1);

	ll n, m;
	in(n,m);
	VLL A(n), B(m);
	in(A, B);

	cout << get(sz(A)-1, sz(B)-1, A, B) << endl;
}

signed main() {
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}

Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
        int n;
        vector<pair<ll, pair<ll, ll>>> v;
        cin >> n;
        for(int i = 0; i < n; i++) {
                int a, b, c;
                cin  >> a>> b>> c;
                v.push_back({a, {b, c}});
        }
        sort(v.begin(), v.end());
        ll x = 0, y = 0, t = 0;
        for (int i = 0; i < n; i++) {
                ll dst = abs(x - v[i].second.first)+abs(y - v[i].second.second);
                ll rem = (v[i].first - (dst + t));
                if (rem < 0 ||  (rem % (dst + t))%2 == 1) {
                        cout << "No";
                        return 0;
                } else {
                        x = v[i].second.first;
                        y = v[i].second.second;
                        t = v[i].first;
                }
        }
        cout << "Yes";
        return 0;
}


Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
  int n,x;
  cin>>n;
  int A[1000001];
  memset(A,0,sizeof(A));
  int m = 1000001;
  bool prime[1000001]; 
  memset(prime, true, sizeof(prime)); 
  for (int p=2; p*p<=m; p++) 
  { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=m; i += p) 
                prime[i] = false; 
        } 
  } 
  
  vector<int> v;
  for(int i = 2;i <= m;i++)
  {
    if(prime[i] == 1)
      v.push_back(i);
  }
  
  for(int i = 0;i < n;i++)
  {
    cin>>x;
    for(int j = 0;j < (int)v.size() - 1;j++)
    {
      if(prime[x])
      {
        A[x]++;
        break;
      }
      if(x%v[j] == 0)
      {
        A[v[j]]++;
      }
      while(x%v[j] == 0)
        x /= v[j];
    } 
  }
  int f = 0;
  int h = 0;
  for(int i = 0;i < (int)v.size() - 1;i++)
  {
      if(A[v[i]] > 1)
      {
        f = 1;
      }
      if(A[v[i]] == n)
      {
        h = 1;
      }
   }
  if(f == 0)
  {
    cout<<"pairwise coprime"<<"\n";
    return 0;
  }
  if(h == 0)
  {
    cout<<"setwise coprime"<<"\n";
    return 0;
  }
  else
  {
    cout<<"not coprime"<<"\n";
    return 0;
  } 
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define DEBUG(x) cout << #x << ": " << (x) << endl

// bitset 素数　prime エラトステネスのふるい　累積和

int main() {
    int MAX = 101010;
    vi is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vi a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vi s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    // クエリ処理
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}



Measured memory_bytes: 1792
import java.util.*;
public class Main {
    
    static int[] a = null;
    
    static void solve(){
        Scanner sc = new Scanner(System.in);
        int NOC = sc.nextInt();
        int n = NOC*2; 
        a = new int[n];
        int i = 0; int sum = 0;
        while(n-->0) a[i++] = sc.nextInt();
        Arrays.sort(a);
        for(i=0; i<a.length; i+=2) sum+=a[i];
        System.out.println(sum);
        sc.close();
    }
    
    public static void main(String args[]) {
        solve();
    }
}

Measured memory_bytes: 35932
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> L(N);
    REP(i, 0, N) cin >> L[i];

    ll ans = 0;
    sort(ALL(L));
    REP(i, 0, N) {
        REP(j, i + 1, N) {
            int to = (int)(lower_bound(ALL(L), L[i] + L[j]) - L.begin());
            ans += max(to - (j + 1), 0);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int N = (1 << n);
  vector<int> mp(n);
  int dst(0), crr(n - 1);
  for (int i = 0; i < n; i++) {
    if ((a ^ b) & (1 << i)) {
      mp[dst] = i;
      dst++;
    } else {
      mp[crr] = i;
      crr--;
    }
  }
  if (!(dst & 1)) {
    cout << "NO" << '\n';
    return 0;
  } else {
    cout << "YES" << '\n';
  }
  vector<int> burg(N);
  for (int d = 0; d < n; d++) {
    int D = (1 << d);
    for (int j = D; j < N; j+= D) {
      burg[j] = n - d - 1;
    }
  }
  vector<int> rt(N);
  rt[0] = a;
  for (int i = 1; i <= N - 1; i++) {
    for (int j = 3; j <= dst && N - (1 << (n + 2 - j)) <= i; j += 2) {
      if (burg[i] == j - 2){
        burg[i] = j - 1;
      } else if (burg[i] == j - 1) {
        burg[i] = j - 2;
      }
    }
    rt[i] = rt[i - 1] ^ (1 << mp[burg[i]]);
  }
  for (int i = 0; i < N; i++) {
    cout << rt[i];
    if (i < N - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}

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

int main() {
    int ans = 0;
    rep(i,5) {
        int x;
        cin >> x;
        if (x == 0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a,b,c; cin>>a>>b>>c;
	if(a+b>=c) cout<<c+b<<endl;
	else cout<<a+2*b+1<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int memo[11][350];
int N, S;
bool used[11];

int const MAX = 330;

void dfs(int cnt, int sum) {
  if(sum > MAX) return;
  if(cnt > 10) return;
  
  for(int i=0; i<10; i++) {
    if(used[i]) continue;
    used[i] = 1;
    int next = i*cnt;
    memo[cnt][sum+next] ++;
    dfs(cnt + 1, sum + next);
    used[i] = 0;
  }
}

int main() {
  
  fill(used, used+10, 0);
  dfs(1, 0);
  while(cin >> N >> S) {
    if(S>MAX) cout << 0 << endl;
    else cout << memo[N][S] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;

		for (int i = 1; i <= n; i += 2) {
			int cnt = 0;
			for (int j = 1; j <= i; j++) {
				if (i % j == 0)
					cnt++;
			}
			if (cnt == 8) {
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define MAX 1000001
#define M 1000000007
#define ll long long
#define ld long double
using namespace std;

int main() {
	int n;
	cin >> n;
	int x = 0, y = 0, elapsed = 0;
	for (int i=0;i<n;i++) {
		int t, a, b;
		cin >> t >> a >> b;
		int d = abs(x-a) + abs(y-b);
		t-=elapsed;
		elapsed+=t;
		if (d>t || (t-d)%2==1) {
			cout << "No\n";
			return 0;
		}
		x = a;
		y = b;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 46 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 03:33:58
**/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, K; cin >> N >> K;
    ll answer = K;
    for (auto i = 0; i < N - 1; ++i) {
        answer *= K - 1;
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll x, y;
    cin >> x >> y;
    if(x % y == 0) fail();
    cout << x << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18


N, M, Q = map(int, input().split()) 
ABCD = [list(map(int, input().split())) for _ in  range(Q)]
#print(ABCD)

lst = []

def dfs(i, n, tmp):
    if n == N:
        lst.append(tmp)
        return 0
    for j in range(i, M + 1):
        dfs(j, n + 1, tmp + [j])

dfs(1, 0, [])
#print(lst)

ans = 0
for l in lst:
    tmp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if l[b - 1] - l[a - 1] == c:
            tmp += d
    ans = max(tmp, ans)
    
print(ans)

Measured memory_bytes: 93700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int a = iin(), b = iin();
    printf("%d %d %lf\n", a / b, a % b, (double)a / (double)b);
    return 0;
}



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

int main(void) {
	int n,k;
	scanf("%d%d",&n,&k);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	/*for(int i=k-1;i<n;i++){
		for(int p=i;p>i-k;p--){
			hyouten[i] *= a[p];
		}
	}*/

	/*for(int i=k;i<n;i++){
		//printf("hyouten[%d]:%d:",i,hyouten[i-1]);
		if(hyouten[i-1]<hyouten[i]){
			printf("Yes\n");
		}
		else printf("No\n");
	}*/

	for(int i=k;i<n;i++){
		if(a[i-k]<a[i])printf("Yes\n");
		else printf("No\n");
	}
}


Measured memory_bytes: 2424
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let m = sc.read();
    let a: Vec<Vec<i64>> = (0..n).map(|_| (0..m).map(|_| sc.read()).collect()).collect();
    let b: Vec<i64> = (0..m).map(|_| sc.read()).collect();
    for i in 0..n {
        println!("{}", (0..m).fold(0, |acc, j| acc + a[i][j] * b[j]));
    }
}



Measured memory_bytes: 5048
#include<iostream>

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  char map[8][8];
  int start_pos[8];
  int end_pos[8];
  int i,j;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin>>map[i][j];
      //cout<<map[i][j];
    }
    start_pos[i]=0;
    end_pos[i]=W-1;
  }
  
  int start,end;
  start=0;
  end=0;
  for(i=0;i<H;i++){
    start=0;
    end=0;
    for(j=0;j<W;j++){
      if(start==0 && map[i][j]=='#'){
	start=1;
	start_pos[i]=j;
      }else  if(start==1 && end==0 && map[i][j]!='#'){
	end=1;
	end_pos[i]=j-1;
      }else if(end==1 && map[i][j]=='#'){
	cout<<"Impossible"<<endl;
		return 0;
      }
    }
  }   
    for(i=0;i<H-1;i++){
      //cout<<"start:"<<start_pos[i]<<endl;
      //cout<<"end:"<<end_pos[i]<<endl;
      if(end_pos[i]!=start_pos[i+1]){
	cout<<"Impossible"<<endl;
	return 0;
      }
    }
      cout<<"Possible"<<endl;
    return 0;
    
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll power(ll a,ll b)
{
    ll r = 1;
    while(b>0)
    {
        if(b%2 == 1)
        {
             r = r*a;
        }
        a = a*a;
    }
    return r;
}

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);

    ll n,k;
    cin>>n>>k;

    ld ans = 0;

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

        ld d = 1.0L/n;
        ll st = i;
        while(st<k)
        {
            st = st*2;
            d = d/2.0L;
        }
        ans += d;
    }

    cout<<fixed<<setprecision(15)<<ans<<endl;
    
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*200000
b=[]
for i in A:a[i-1]+=1
for i in a:
    if i:b.append(i)
b.sort()
ans=0
for i in range(len(b)-K):ans+=b[i]
print(ans)

Measured memory_bytes: 32012
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    int N; cin >> N;
    vector<ll> H(N);
    vector<int> A(N-1);
    rep(i,N) cin >> H[i];
    int c = 0;
    int ans = 0;
    rep(i,N-1){
        if(H[i] >= H[i+1]) A[i] = 1;
        else A[i] = 0;
    }
    rep(i,N-1){
        c = (c+A[i])*A[i];
        ans = max(ans,c);
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 1408
#include <cstdio>

using namespace std;

int main() 
{
    int n;
    scanf("%d", &n);
    int a[n];

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

    int first = a[0];
    int firstcount = 1;
    int second = -1;
    int secondcount = 0;
    int third = -1;
    int thirdcount = 0;

    for (int i = 1; i < n; ++i) {
        if ((second == -1) && (a[i] != first)) {
            second = a[i];
            secondcount++;
            continue;
        }

        if ((third == -1) && (a[i] != first) && (a[i] != second)) {
            third = a[i];
            thirdcount++;
            continue;
        }

        if (a[i] == first) {
            firstcount++;
        } else if (a[i] == second) {
            secondcount++;
        } else if (a[i] == third) {
            thirdcount++;
        } else {
            printf("No\n");
            return 0;
        }
    }

    if (second == -1) {
        if (first == 0)
            printf("Yes\n");
        else
            printf("No\n");
    } else if (third == -1) {
        if (first == 0) {
            if (firstcount * 2 == secondcount) {
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        } else if (second == 0) {
            if (secondcount * 2 == firstcount) {
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        } else {
            printf("No\n");
        }
    } else {
        if (((first ^ second) == third) && (firstcount == secondcount) && (firstcount == thirdcount))
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 512
import random
import sys

class maps(object):
    def __init__(self):
        self.readinputs()

    # recieve |V| and |E|
    def readinputs(self):
        self.V, self.E = map(int, input().split())
        self.es = [[] for i in range(self.V)]
        self.Mes = [[0]*self.V for i in range(self.V)]

        for _ in range(self.E):
            # recieve edges
            a, b, c = map(int, input().split())
            a, b = a-1, b-1
            self.es[a].append((b,c))
            self.es[b].append((a,c))
            self.Mes[a][b] = c
            self.Mes[b][a] = c

        self.F = list(map(int, input().split()))
        self.T = int(input())

        self.info = [[] for i in range(self.T)]

    def random_walk(self):
        where = [('v', 0)] # ('e',from,to,dist)

        self.path = [0]*self.T
        for t in range(self.T):

            # recieve info
            Nnew = int(input())
            for _ in range(Nnew):
                new_id, dst = map(int, input().split())
                self.info[t].append((new_id, dst))
            Nput = int(input())
            for _ in range(Nput):
                put_id = int(input())

            now_where = where[-1]
            if now_where[0] == 'v':
                to, dist = random.choice(self.es[now_where[1]])
                # to, dist = self.es[now_where[1]][n]
                self.path[t] = to
                if dist == 1:
                    where.append(('v', to))
                else:
                    where.append(('e', now_where[1], to, 1))
            elif now_where[0] == 'e':
                now_where = where[-1]
                # num = random.randint(0,1)

                if True:
                    self.path[t] = now_where[2]
                    if now_where[3] + 1 < self.Mes[now_where[1]][now_where[2]]:
                        where.append(('e', now_where[1], now_where[2], now_where[3] + 1))
                    elif now_where[3] + 1 == self.Mes[now_where[1]][now_where[2]]:
                        where.append(('v', now_where[2]))
                    else:
                        # ココの分岐に来ることはありえない。
                        pass

                else:
                    self.path[t] = now_where[1]
                    if now_where[3] - 1 > 0:
                        where.append(('e', now_where[1], now_where[2], now_where[3] - 1))
                    elif now_where[3] - 1 == 0:
                        where.append(('v', now_where[1]))
                    else:
                        # ココの分岐に来ることはありえない。
                        pass
            else:
                # ココの分岐に来ることはありえない。
                pass

            print(self.path[t] + 1, flush=True) # interactive output

            vardict = input()
            if vardict == 'NG':
                sys.exit()

            Nachieve = int(input())
            for _ in range(Nachieve):
                achive_id = int(input())

if __name__ == "__main__":
    M = maps()
    M.random_walk()

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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static double[] exp = new double[100001];

	public static void main(String[] args) {
		precalc();
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			System.out.println(solve());
		}
	}

	static double solve() {
		return exp[N];
	}

	static void precalc() {
		int pos = 0;
		double[][] prob = new double[2][101];
		double[][] v = new double[2][101];
		prob[pos][0] = 1;
		double[] success = new double[101];
		success[0] = 1;
		for (int i = 1; i < success.length; ++i) {
			success[i] = success[i - 1] / 2;
		}
		for (int i = 0; i <= 100000; ++i) {
			double sum = 0;
			Arrays.fill(prob[1 - pos], 0);
			Arrays.fill(v[1 - pos], 0);
			for (int j = 0; j < 100; ++j) {
				sum += v[pos][j];
				prob[1 - pos][j + 1] += prob[pos][j] * success[j];
				prob[1 - pos][0] += prob[pos][j] * (1 - success[j]);
				v[1 - pos][j + 1] += (v[pos][j] + prob[pos][j]) * success[j];
				v[1 - pos][0] += v[pos][j] * (1 - success[j]);
			}
			exp[i] = sum;
			pos = 1 - pos;
		}
	}

}

Measured memory_bytes: 13000
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k,m;
        int [][][] cnt = new int[4][3][10];
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        m = Integer.parseInt(in.readLine());
        for(i=0;i<m;i++){
            str = in.readLine().split(" ");
            for(j=0;j<4;j++){
                n[j] = Integer.parseInt(str[j]);
            }
            cnt[n[0]-1][n[1]-1][n[2]-1] += n[3];
        }
        for(i=0;i<4;i++){
            for(j=0;j<3;j++){
                for(k=0;k<10;k++){
                    System.out.print(" "+cnt[i][j][k]);
                }
                System.out.println();
            }
            if(i<3) System.out.println("####################");
        }
        System.out.flush();
    }
}

Measured memory_bytes: 24664
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
     int n;
     cin >> n;
     vi v(n),arr(n+1,0);
     vi ans;
     for(int i=0;i<n;i++)cin >> v[i];
     for(int i=n;i>=1;i--){
       int count=0;
        for(int j=i;j<=n;j+=i){
          count+= arr[j];
        }
        if(count%2 != v[i-1]){
           arr[i]++;
           ans.pb(i);
        }
     }  
      cout << ans.size() << '\n';
      for(int x:ans){
        cout << x <<' ';
      }
  }  

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

Measured memory_bytes: 5444
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll n;
    cin >> n;
    if(n%2==0) {
        cout << n << endl;
    }
    else {
        cout << 2*n << endl;
    }
}

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

int main() {

    char s;
    cin >> s;
    if(isupper(s)){
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {

	int a, b;
	cin >> a >> b;
	if (a + b == 15)
		cout << "+";
	else if (a*b == 15)
		cout << "*";
	else
		cout << "x";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
  long key;
  struct node *left;
  struct node *right;
  struct node *p;
}Node;

void print_tree(Node *x,int order) {
  if (order == 0) {
    printf(" %ld", x->key);    
  }
  if(x->left != NULL) print_tree(x->left,order);
  if (order == 1) {
    printf(" %ld", x->key);    
  }
  if(x->right != NULL) print_tree(x->right,order);
  if (order == 2) {
    printf(" %ld", x->key);    
  }
}

Node *insert(Node *root, long key) {
  Node *z = (Node*)malloc(sizeof(Node));
  z->key = key;
  z->p = NULL;
  z->left = NULL;
  z->right = NULL;
  Node *x,*y;
  y = NULL;
  x = root;
  while(x != NULL) {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  if(y  == NULL) return z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
  return root;
}

int main()
{
  long i,N,key;
  char command[7];
  Node *root = NULL;
  scanf("%ld",&N);
  for (i = 0; i < N; i++) {
    scanf("%s",command);
    if(strcmp(command,"insert") == 0) {
      scanf("%ld",&key);
      root = insert(root,key);
    }
    if(strcmp(command,"print") == 0) {
      print_tree(root,1);
      printf("\n");
      print_tree(root,0);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> cnt(5, 0);
	string s = "MARCH";
	for(int i = 0; i < n; i++)
	{
		string t;
		cin >> t;
		for(int j = 0; j < 5; j++)
		{
			if(t[0] == s[j])
				cnt[j]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < 5; i++)
	{
		for(int j = i + 1; j < 5; j++)
		{
			for(int k = j + 1; k < 5; k++)
			{
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
	int n;
    cin >> n;
    vector<int> d(n), p(n), a(n), b(n);
    rep(i, 0, n){
        cin >> d[i];
        p[d[i] - 1] = i;
    }
    a[0] = 1;
    rep(i, 1, n){
        a[i] = a[i - 1] + 1;
        if(p[i - 1] < p[i]){
            a[i] += p[i] - p[i - 1];
        }
    }
    b[n - 1] = 1;
    repb(i, n - 2, 0){
        b[i] = b[i + 1] + 1;
        if(p[i] > p[i + 1]){
            b[i] += p[i] - p[i + 1];
        }
    }
    rep(i, 0, n){
        if(i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    rep(i, 0, n){
        if(i != 0) cout << " ";
        cout << b[i];
    }
    cout << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    string a, b;
    cin >> a >> b;
    int c = stoi(a+b);
    if((int)sqrt(c)*(int)sqrt(c) == c){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
    int n, m;
    long long ans = 0;
    cin >> n >> m;

    if(n >= 2) ans += combination(n, 2);
    if(m >= 2) ans += combination(m, 2);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256