akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int get_keta(unsigned t) {
  int ans {};
  for (ans = 0;t > 9;t/=10, ++ans);
  return (ans+1);
}
unsigned get_permu(const int& start, const int& end, const int& ketasuu, const int& N) {
  if (ketasuu == 1) {
    if (start != end) return 0;
    return (N<start)?0:1;
  }
  unsigned tmp_num {1};
  for (auto i = 1;i < ketasuu;++i) {
    tmp_num *= 10;
  }
  int N_cp = N - start*tmp_num - end;
  if (N_cp < 0) {
    return 0;
  } else if (N_cp > tmp_num) {
    tmp_num = 1;
    for (auto i = 0;i < ketasuu - 2;++i) {
      tmp_num *= 10;
    }
    return tmp_num;
  } else {
    return 1+(N_cp/10);
  }
}
int main(int argc, char** argv) {
  unsigned N;
  std::cin >> N;
  std::vector<std::vector<unsigned>> dp(10, std::vector<unsigned>(10, 0));
  int ketasuu = get_keta(N);
  for (auto i = 1;i <= ketasuu;++i) {
    for (auto j = 1;j <= 9;++j) {
      for (auto k = 1;k <= 9;++k) {
        dp[j][k] += get_permu(j, k, i, N);
      }
    }
  }
  unsigned long sum {};
  for (auto i = 1;i <= 9;++i) {
    for (auto j = 1;j <= 9;++j) {
      sum += dp[i][j]*dp[j][i];
    }
  }
  std::cout << sum << '\n';
}


Measured memory_bytes: 256
h,w,d=gets.chomp.split.map(&:to_i)
a=h.times.map{gets.chomp.split.map(&:to_i)}
c=[]
h.times{|i|
  w.times{|j|
    c[a[i][j]-1]=[i,j]}}
b=[0]*d
(h*w-d).times{|k|
  b[k+d]=b[k]+(c[k][0]-c[k+d][0]).abs+(c[k][1]-c[k+d][1]).abs
}
q=gets.to_i
q.times{
l,r=gets.chomp.split.map(&:to_i)
p b[r-1]-b[l-1]
}

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

int main(){
  int N, K;
  cin>>N>>K;
  
  vector<bool> have(N, false);

  for(int i=0;i<K;i++){
    int sunuke=0;
    cin>>sunuke;
    for(int s=0;s<sunuke;s++){
      int tmp;
      cin>>tmp;
      have.at(tmp-1)=true;
    }
  }
  int ans=0;
  for(auto h: have){
    if(!h){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(){
	int i=0,j=0;
	char str1[21],str2[21];
    scanf("%s",str1);
	while (str1[i]) {
		i++;
	}
	str2[i]='\0';
	i--;
	while (str1[j]) {
		str2[i]=str1[j];
		i--;
		j++;
	}
	printf("%s\n",str2);
	return 0;
}

Measured memory_bytes: 0
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int n, m;
  cin >> n >> m;

  int sum = 0;
  vector<int> a(n);
  rep(i,n) cin >> a[i], sum += a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  rep(i,m) {
    if (a[i]*4*m < sum) { cout << "No" << endl; return 0; }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  std::string S;
  std::cin >> S;

  ll N = S.size();

  // □□□　パネルに A□□　埋めるイメージ
  // i文字目まで調べた時に, パネルが何枚埋められたか
  // dp[10][2] であれば, 10 文字目まで調べて, AB□ 埋められた状態の通り数
  std::vector< std::vector<ll> > dp(N+10, std::vector<ll>(4, 0LL));

  // 0 文字選択して, 0枚パネルが埋められた(何も埋められてない)通り数は 1
  dp[0][0] = 1;

  for (ll i = 0; i < N; i++) {
    // パネルを埋めない場合
    for (ll j = 0; j < 4; j++) {
      if (S[i] != '?') {
	dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
      } else {
	dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 3) % MOD;
      }
    }

    // パネルを埋める場合
    if (S[i] == 'A' || S[i] == '?') dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % MOD;
    if (S[i] == 'B' || S[i] == '?') dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % MOD;
    if (S[i] == 'C' || S[i] == '?') dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % MOD;
  }

  print(dp[N][3]);
  return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;
    s = "0" + s;
    vector<pi> count(N + 1, {0, 0});
    vector<set<int>> graph(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    for (int i = 1; i <= N; i++) {
        for (auto temp : graph[i]) {
            if (s[i] == 'A') count[temp].first++;
            else count[temp].second++;
        }
    }
    queue<int> explore;
    set<int> wrong;
    auto judge = [&](int idx) {
        return (count[idx].first == 0 || count[idx].second == 0);
    };
    for (int i = 1; i <= N; i++) if (judge(i)) explore.push(i);
    while (!explore.empty()) {
        int now = explore.front();
        explore.pop();
        wrong.insert(now);
        for (int temp : graph[now]) {
            if (s[now] == 'A') count[temp].first--;
            else count[temp].second--;
        }
        set<int> step = graph[now];
        for (int temp : graph[now]) if (judge(temp)) explore.push(temp);
        for (int temp : step) {
            graph[temp].erase(now);
            graph[now].erase(temp);
        }
    }
    cout << (wrong.size() == N ? "No" : "Yes") << endl;
}

Measured memory_bytes: 29128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				int n = sc.nextInt();
				if(n == 0)	break;
				int[][] cor = {{0, 2}, {1, 2}, {2, 2}, {0, 1}, {1, 1}, {2, 1}, {0, 0}, {1, 0}, {2, 0}};
				double[][][] dp = new double[3][3][n+1];
				int[][] dis = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
				double e = 1.0 / 4.0;
				//dp[x][y][バッテリー] バッテリーの時のx.yにいる確率
				//dp[x][y][ba] = dp[x-1][y][ba+1]*1/4+...
				String dummy = sc.nextLine();
				String str = sc.nextLine();
				String[] s = str.split(" ");
				int sx = cor[s[0].charAt(0) - 'A'][0];
				int sy = cor[s[0].charAt(0) - 'A'][1];
				int tx = cor[s[1].charAt(0) - 'A'][0];
				int ty = cor[s[1].charAt(0) - 'A'][1];
				int bx = cor[s[2].charAt(0) - 'A'][0];
				int by = cor[s[2].charAt(0) - 'A'][1];
				
				for(int x=0; x<3; x++) {
					for(int y=0; y<3; y++) {
						for(int i=0; i<n+1; i++) {
							dp[x][y][i] = 0.0;
						}
					}
				}
				dp[sx][sy][n] = 1.0;
				
				for(int i=n; i>0; i--) {
					for(int x=0; x<3; x++) {
						for(int y=0; y<3; y++) {
							for(int next=0; next<4; next++) {
								int nx = x + dis[next][0];
								int ny = y + dis[next][1];
								if(nx == x && ny == y) {
									continue;
								}
								else if(nx==bx && ny==by) {
									dp[x][y][i-1] += dp[x][y][i]*e;
								}
								else if((nx<0 || nx>2) || (ny<0 || ny>2)) {
									dp[x][y][i-1] += dp[x][y][i]*e;
								}
								else {
									dp[nx][ny][i-1] += dp[x][y][i]*e;
								}
							}
						}
					}
				}
				System.out.printf("%.8f\n", dp[tx][ty][0]);
			}
		}
	}

}




Measured memory_bytes: 27292
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

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

    int n;
    cin >> n;

    vector< int> in(n);
    for (int &e : in) cin >> e;

    int best = 0, cnt = 0;
    for (int i = 0; i < n; i ++) {
        if (i + 1 < n && in[i] >= in[i + 1]) {
            cnt ++;
        }
        else 
            cnt = 0;
        best = max(best, cnt);
    }
    cout << best << endl;
}

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

using weight = int;

struct edge {
    int to;
    weight cost;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

// when g has neg cycle, second -> false
std::pair<std::vector<weight>, bool> spfa(graph const& g, int s) {
    constexpr weight inf = std::numeric_limits<weight>::max() / 2;
    const int n = g.size();
    std::vector<weight> d(n, inf);
    std::vector<int> in_q(n), count(n);
    std::queue<int> que;
    d[s] = 0;
    que.emplace(s);
    in_q[s] = true;
    ++count[s];
    bool neg_cycle = false;
    [&]() {
        while(!que.empty()) {
            int v = que.front();
            que.pop();
            in_q[v] = false;
            for(auto& e : g[v]) {
                if(d[v] != inf && d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    if(!in_q[e.to]) {
                        que.emplace(e.to);
                        in_q[e.to] = true;
                        ++count[e.to];
                        if(count[e.to] >= n) {
                            neg_cycle = true;
                            return;
                        }
                    }
                }
            }
        }
    }();

    return std::make_pair(d, !neg_cycle);
}

using namespace std;

int main() {
    int n;
    cin >> n;
    graph g(n);
    for(int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for(int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            g[u].push_back(edge{v, c});
        }
    }

    auto ans = spfa(g, 0).first;
    for(int i = 0; i < n; ++i) {
        cout << i << ' ' << ans[i] << endl;
    }
}



Measured memory_bytes: 7540
// Devarshi

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync

int x,y;
cin>>x>>y;
cout<<x+y/2;

return 0;
}


Measured memory_bytes: 256
/**
 * When Can We Meet?
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int q = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | q) == 0) break;

			int[] meets = new int[101];
			int[] dates = new int[n + 1];
			for (int i = 0; i < n; i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				int m = parseInt(st.nextToken());
				for (int j = 0; j < m; j++) {
					int date = parseInt(st.nextToken());
					int meet = ++meets[date];
					if (dates[meet] == 0) {
						dates[meet] = date;
					} else {
						dates[meet] = Math.min(dates[meet], date);
					}
				}
			}
			int ans = 0;
			for (int i = n; i >= q; i--) {
				if (dates[i] != 0) {
					ans = dates[i];
					break;
				}
			}
			System.out.println(ans);
		} //end while
	} //end main
}

Measured memory_bytes: 28540
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

inline int calc(const vi& v, const vi& perm) {
    int ret = 0;
    for (int el : v) ret = ret*10+perm[el];
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (cin >> N) {
        if (N==0) break;
        vector<char> vs;
        vector<string> ss(N);
        for (int i = 0; i < N; i++) {
            cin >> ss[i];
            for (char c : ss[i]) vs.push_back(c);
        }
        sort(vs.begin(), vs.end());
        vs.erase(unique(vs.begin(), vs.end()), vs.end());
        vector<vi> nums;
        for (int i = 0; i < N; i++) {
            vi v;
            for (char c : ss[i]) {
                v.push_back(lower_bound(vs.begin(), vs.end(), c)-vs.begin());
            }
            nums.push_back(v);
        }
        vector<int> perm(10);
        for (int i = 0; i < 10; i++) perm[i] = i;
        int ans = 0;

        do {
            bool muri = false;
            for (int i = 0; i < N; i++) if (nums[i].size() > 1 && perm[nums[i][0]] == 0) {
                muri = true;
                break;
            }
            if (muri) continue;
            int target = calc(nums[N-1], perm), sum = 0;
            for (int i = 0; i < N-1; i++) {
                if (sum > target) break;
                sum += calc(nums[i], perm);
            }
            if (sum==target) ans++;
        } while (next_permutation(perm.begin(), perm.end()));

        int cnt = 10-vs.size();
        int div = 1;
        for (int i = 1; i <= cnt; i++) div *= i;
        cout << ans/div << endl;
    }
    return 0;
}

Measured memory_bytes: 3032
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, A, B, INF = 10000000000000;
	vector<long long> P, DP;
	cin >> N >> A >> B;
	P.resize(N);
	DP.assign(N + 1, INF);
	DP[0] = 0;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N; j++) {
			if (DP[j] >= INF || j == P[i]) continue;
			if (j < P[i]) {
				DP[P[i]] = min(DP[P[i]], DP[j]);
				DP[j] += A;
			}
			else {
				DP[j] += B;
			}
		}
	}
	long long ANS = INF;
	for (int i = 0; i <= N; i++) {
		ANS = min(ANS, DP[i]);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    String[] a = N.split("");

    String msg = "No";
    if (a[0].equals(a[2])) {
      msg = "Yes";
    }

    System.out.println(msg);

  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v1,v2;
char s[5],res[666];
inline char Q1(int l,int r) {
    printf("? ");
    for (int i=l;i<=r;++i)
        printf("%d%c",i,i==r?'\n':' ');
    fflush(stdout);
    char s[5];scanf("%s",s);
    return s[0];
}
inline char Q2(vector<int> &vec) {
    printf("? ");
    for (int i=0;i<(int)vec.size();++i)
        printf("%d%c",vec[i],i+1==(int)vec.size()?'\n':' ');
    fflush(stdout);
    char s[5];scanf("%s",s);
    return s[0];
}
int main()
{
    scanf("%d",&n);
    char a=Q1(1,n);
    char b=(a=='R')?'B':'R';
    int left=1,right=n+1;
    while (left+1<right) {
        int mid=(left+right)>>1;
        int c=Q1(mid,mid+n-1);
        if (a==c) left=mid;
        else right=mid;
    }
    res[left]=a;
    res[left+n]=b;
    for (int i=1;i<=n+n;++i) {
        if (i>=right&&i<=left+n-1) v1.push_back(i);
        if (i+1<right||i>left+n) v2.push_back(i);
    }
    for (int i=1;i<=n+n;++i) if (!res[i]) {
        if (i>=right&&i<=left+n-1) {
            v2.push_back(i);
            res[i]=Q2(v2);
            v2.pop_back();
        } else {
            v1.push_back(i);
            res[i]=Q2(v1);
            v1.pop_back();
        }
    }
    printf("! ");
    puts(res+1);
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 724
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int a,b;
	cin>>a>>b;
	int out=0;
	for(ll i=1;i*i<=b;i++)if(b%i==0){
		int t=b/i;
		if(t>=a)cmax(out,i);
		t=i;
		if(t>=a)cmax(out,b/i);
	}
	cout<<out<<endl;
	/*
	int n;
	cin>>n;
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	rep(i,101)rep(j,101){
		vi t(n);
		rep(k,n)if(in[k][2]){
			int w=abs(i-in[k][0])+abs(j-in[k][1])+in[k][2];
			t[k]=w;
		}
		sort(all(t));
		if(t[0]!=t[n-1])continue;
		cout<<i<<" "<<j<<" "<<t[0]<<endl;
		
	}
	
	*/
}

/*
int n,m;
vvi nex[2],dp(2);
vi in;
void f(int a){
	int N=-1,t=m;
	while(t){
		vi dp(n,-1);
		int w=0;
		rep(i,n)if(dp[i]==-1){
			int l=i,r=i+1;
			while(r<n&&in[r]-in[r-1]<=t)r++;
			loop(j,l,r)dp[j]=r;
		}
		nex[a].pb(dp);
		t/=2;
		N++;
	}
	dp[a]=vi(1<<N,-1);
	dp[a][0]=0;
	rep(i,1<<N)if(dp[a][i]-n)rep(j,N)if((i&1<<j)==0)cmax(dp[a][i|1<<j],nex[a][j+1][dp[a][i]]);
}
int main(){
	cin>>n>>m;
	in=vi(n);
	rep(i,n)cin>>in[i];
	
	f(0);
	rep(i,n)in[i]*=-1;
	sort(all(in));
	f(1);
	
	rep(i,n){
		int l=n-nex[1][0][i]-1,r=nex[0][0][i];
		bool h=false;
		
	}
	
}
*/








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
	ll n;
	cin>>n;
	ll v[n],w[n];
	VI cntr(n,0),cntc(n,0);
	for(i=0;i<n;i++){
		ll r,c;
		cin>>r>>c;
		r--; c--;
		v[r]=c;
		w[c]=r;

		cntr[r]++;
		cntc[c]++;
	}

	for(i=0;i<n;i++){
		if(cntr[i]==0||cntc[i]==0){
			cout<<-1<<endl;
			return 0;
		}
	}

	ll ans=0;
	for(i=0;i<n;i++){
		if(v[i]!=i){
			ll p=w[i];
			ll s=v[i];
			v[p]=s;
			w[s]=p;
			v[i]=i;
			w[i]=i;
			ans++;
		}
	}
	cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 5976
#include <iostream>
using namespace std;
int main()
{
    string a;
    string b;
    string c;
    string d;
    
    cin>>a;
    b=a.substr(0,5);
    c=a.substr(6,7);
    d=a.substr(14,5);
    cout<<b<<" "<<c<<" "<<d<<"\n";
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 200005
#define v_n 5005
#define LL long long
#define e_n 5000005
#define MOD 1000000007
#define eps 0.000000001
#define Blen 20 
using namespace std;
vector<int> hh;
int main(void)
{
	int i,j,k;
	FAST_IO;
//	Relocate;
    int n;
    cin>>n;
    hh.push_back(0);
    up(i,1,n)
    {
    	hh.push_back(i);
    }
    
    if(n%2)
    {
      int tt=hh[n];
       down(i,n-1,(n+1)/2)
       {
    	 hh[i+1]=hh[i];
       }
       hh[(n+1)/2]=tt;
    }
    
    vector<pair<int,int> > ans;
    up(i,1,n)
    {
    	up(j,i+1,n)
    	{
    		if(j!=n+1-i)
    		{
    			ans.push_back(make_pair(hh[i],hh[j])); 
    		}
    	}
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
    {
    
    	cout<<ans[i].first<<" "<<ans[i].second<<endl;;
    }
	return 0;
} 

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
        
        int N = input.nextInt();
        int a[] = new int[N];
        int tf=0;
        int x1 =0;
        int x2 =0;
        for(int i = 0; i<a.length; i++){
            a[i] = input.nextInt();
        tf += a[i];
        }
        double v = (double)tf/N;
        int tf1 = (int)Math.ceil(v);
        int tf2 = (int)Math.floor(v);
        //System.out.println(v);
        //System.out.println(tf1);
        //System.out.println(tf2);
        for(int i = 0; i<a.length; i++){
            x1+=Math.pow((a[i]-tf1), 2);
             x2+=Math.pow((a[i]-tf2), 2);
        }
         System.out.println((x1<x2)?x1:x2);
             
    }
}

Measured memory_bytes: 27124
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


template<typename T>
class segment_tree{
	int n;
	T fval;
	function<T(T,T)> operation;
	vector<T> dat;
	
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l){
			return fval;
		}
		
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
			return operation(vl, vr);
		}
	}
	
public:
	
	segment_tree(){
		
	}
	
	segment_tree(int n_, T val, function<T(T,T)> fun){
		init(n_, val, fun);
	}
	
	~segment_tree(){
		
	}
	
	void init(int n_, T val, function<T(T,T)> fun){
		fval = val;
		
		operation = fun;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = operation(dat[k*2 + 1],dat[k*2 + 2]);
		}
	}
	
	T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}
	
};


signed main(){
	cout<<fixed<<setprecision(10);
	
	const int MAX = 350000;
	int N, K;
	int ans = 0;
	segment_tree<int> seg;
	vector<int> A;
	
	cin>>N>>K;
	
	A.resize(N);
	
	seg.init(MAX,0, [](int first, int second){ return max(first,second);});
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int i = 0; i < N; i++){
		int a = max(A[i] - K, 0ll);
		int b = min(A[i] + K, MAX-10);
		
		int con = seg.query(a, b+1);
		
		ans = max(ans, con+1);
		
		seg.update(A[i], con+1);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 13764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll inf=1000000000;
 
int main() {
    int h,n;
    cin>>h>>n;
    ll dp[1010][10010];
    ll a[n];
    ll b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    
    }
    for(int i=0;i<1010;i++){
        for(int j=0;j<10010;j++){
            dp[i][j]=inf;
        }
    
    }
  	dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=h;j++){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i][(j+a[i])<=h?(j+a[i]):h]=min(dp[i][j]+b[i],dp[i][(j+a[i])<=h?(j+a[i]):h]);
        }
    }    
    cout<<dp[n-1][h]<<endl;
}

Measured memory_bytes: 82604
N, M = map(int, input().split())

path_num = [0 for i in range(N)] 
for i in range(M):
    k, l = map(int, input().split())
    path_num[k - 1] += 1
    path_num[l - 1] += 1

for num in path_num:
    print(num)

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;

int c1, c2, c3;

int main() {
  while (1) {
    if (scanf("%d%d%d", &c1, &c2, &c3) != 3) return 0;

    int cnt = 0;
    for (int i=1; i<=10; i++) {
      if (i == c1) continue;
      if (i == c2) continue;
      if (i == c3) continue;
      if (c1+c2+i <= 20) cnt++;
    }

    if (cnt >= 4) puts("YES");
    else puts("NO");
  }
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
int a , b , c;
int main()
{
    cin >> a >> b >> c;
    if ((a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7) || (a == 7 && b == 5 && c == 5))
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
  vector<int> S, T;

  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int s;
    scanf("%d", &s);
    S.push_back(s);
  }



  int q;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    int t;
    scanf("%d", &t);
    T.push_back(t);
  }
  
//  printf("%d\n", (int)S.size());

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

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

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

  int i = 0;
  int j = 0;
  int ans = 0;
  while(i < S.size() && j < T.size()){
    if(S[i] == T[j]){
      ans++;
      i++;
      j++;
    }else if(S[i] > T[j]){
      j++;
    }else{
      i++;
    }
  }
  cout << ans << endl;
}



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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

ll n;
vector<int> ans;

ll maxBit(ll x) {
	for (ll i = 50; i >= 0; i--)
		if (x & (1LL << i))
			return i;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n; n++;
	ll d = maxBit(n);
	for (ll i = d - 1; i >= 0; i--)
		if ((n & (1LL << i)) == 0) {
			ans.push_back(ans.size() + 1);
		}
		else {
			ans.push_back(ans.size() + 1);
			ans.push_back(1);
			for (int j = 0; j < ans.size() - 1; j++)
				ans[j]++;
		}
	int tmp = ans.size();
	for (int i = 1; i <= tmp; i++)
		ans.push_back(i);
	cout << ans.size() << endl;
	for (int i : ans)
		cout << i << ' ';
	cout << endl;
}



Measured memory_bytes: 256
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int n;
    cin >> n;
    vector<int> count;
    vector<int> appear_min(26, INF);
    string S;
    rep(i, n) {
        cin >> S;
        count = vector<int>(26, 0);
        rep(j, S.length()) count[S[j] - 'a']++;
        rep(j, 26) appear_min[j] = min(appear_min[j], count[j]);
    }
    string ans = "";
    rep(i, 26) rep(j, appear_min[i]) ans += (char) (i + 'a');
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String b = sc.nextLine();

        if(b.equals("A")){
            System.out.println('T');
        }
        if(b.equals("T")){
            System.out.println('A');
        }
        if(b.equals("C")){
            System.out.println('G');
        }
        if(b.equals("G")){
            System.out.println('C');
        }
    }

}


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

int main(){
	
	int n,m; cin>>n>>m;
	vector<pair<ll,ll>> cb(m+n,{0,1});
	for(int i=0; i<n; i++){
		cin >> cb.at(i+m).first;
	}
	for(int i=0; i<m; i++){
		cin >> cb.at(i).second >> cb.at(i).first;
	}
	sort(cb.rbegin(),cb.rend());
	int i{},used{};
	ll sum{};
	while(1){
		if(used+cb.at(i).second>=n){
			sum += cb.at(i).first*(n-used);
			break;
		}
		else{
			sum += cb.at(i).second*cb.at(i).first;
			used+=cb.at(i).second;
			i++;
			
		}
		
	}
	cout << sum << endl;
	
}

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

typedef struct {
	int pNum;
	double pTime;
} Record;

void sort(Record *data, int n)
{
	int i, j;
	Record temp;

	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (data[j].pTime > data[j + 1].pTime){
				temp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = temp;
			}
		}
	}
}


int main(void)
{
	Record in[3][8];
	Record chance[6];
	int i, j;

	for (i = 0; i < 3;i++){
		for (j = 0; j < 8; j++){
			scanf("%d%lf", &in[i][j].pNum, &in[i][j].pTime);
		}
		sort(in[i], 8);
		printf("%d %.2lf\n%d %.2lf\n", in[i][0].pNum, in[i][0].pTime, in[i][1].pNum, in[i][1].pTime);
		chance[i * 2] = in[i][2];
		chance[i * 2 + 1] = in[i][3];
	}

	sort(chance, 6);

	printf("%d %.2lf\n%d %.2lf\n", chance[0].pNum, chance[0].pTime, chance[1].pNum, chance[1].pTime);
	return (0);
}

Measured memory_bytes: 0
from collections import deque
INF = 10**10
h, w = map(int, input().split())
s = [[s for s in input()] for _ in range(h)]
sx, sy = 0, 0
gx, gy = w-1, h-1

d = [[INF for _ in range(w)] for _ in range(h)]
d[0][0] = 0
que = deque([])
que.append([sx, sy])

x_ = [1, 0, -1, 0]
y_ = [0, 1, 0, -1]

while que:
    x, y = que.popleft()
    if x == gx and y == gy: break
    for dx, dy in zip(x_, y_):
        cx, cy = x + dx, y + dy
        if cx != -1 and cy != -1 and cx != w and cy != h and s[cy][cx] != "#" and d[cy][cx] == INF:
            que.append([cx, cy])
            d[cy][cx] = d[y][x] + 1
if d[h-1][w-1] == INF:
    print(-1)
    exit()
cnt = 0
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == "#":
            cnt += 1
print(h*w - d[h-1][w-1] - 1 - cnt)

Measured memory_bytes: 3436
S=int(input())

if S<10**18:
    X1,Y1=0,0

    mod=10**9

    X2=mod
    Y3=S//mod + 1

    Y2=1
    X3=mod-S%mod
else:
    X1,Y1,X2,Y3=0,0,0,0
    Y2=10**9
    X3=10**9

print(X1,Y1,X2,Y2,X3,Y3)


Measured memory_bytes: 38256
#include <stdio.h>
int main(){
	int n,i;
	long  sum=0;
	long  max=-1000000,min=1000000;
	long  a[10001];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %ld",&a[i]);
		sum=sum+a[i];
		if(max<a[i]){
			max=a[i];
		}
		if(min>a[i]){
			min=a[i];
		}
	}
	
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll a(N);
    for(int i=0;i<N;i++) cin>>a[i];
    
    vector<bool> ans(N,false);
    
    for(int i=N;i>=1;i--){
        bool sum=0;
        for(int j=2;i*j<=N;j++){
            if(ans[i*j-1]){
                if(sum==0)sum=1;
                else sum=0;
            }
        }
        if(sum==a[i-1]){
            ans[i-1]=false;
        }else{
            ans[i-1]=true;
        }
    }
    
    ll sum=0;
    for(int i=0;i<N;i++)if(ans[i])sum++;
    cout<<sum<<endl;
    for(int i=0;i<N;i++)if(ans[i])cout<<i+1<<" ";
    
    return 0;
}


Measured memory_bytes: 2560
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


#define int long long

using namespace std;


const int MAX = 510000;

ll mod_inverse(int a,int M){
	int x=M-2;
	ll temp=a;
	ll ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed compare_int(const void *a, const void *b)
{
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	int x,y,z;
	static int a[200010];
	static int b[200010];
	static int v[100010];
	static int p[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	vector<int> vtemp;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;
	
	//データの読み込み


	scanf("%lld %lld",&n,&m);
	//scanf_s("%lld %lld",&n,&m);


	//scanf("%s",&s);
	//scanf_s("%s",&s,20);


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



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();
//	COMinit();

	n=n%m;

	printf("%lld",min(n,m-n));

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLong();
            var A = ReadArrayLong();
            long snu = A.Sum();
            var arai = 0L;
            var ans = long.MaxValue;
            for (long i = 0; i < N - 1; i++)
            {
                snu -= A[i];
                arai += A[i];
                ans = Math.Min(ans, Math.Abs(snu - arai));
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n,i,j,k;
  cin >> n;

  vl a(n + 1);

  forn(1,n + 1,i){
    cin >> a[i];
    a[i] %= 2;
  }
  ll ans = 0;
  bool ok = 1;
  vl res;

  ll take[n + 1];
  memset(take, 0, sizeof take);

  for(i = n; i >= 1; i--){
    if(a[i]){
      ll cnt = 0;
      for(j = i; j <= n; j += i){
        cnt += take[j];
      }
      if(cnt % 2){
        continue;
      }else{
        take[i] = 1;
      }
    }else{
      ll cnt = 0;
      for(j = i; j <= n; j += i){
        cnt += take[j];
      }
      if(cnt % 2){
        take[i] = 1;
      }else{
        continue;
      }
    }
  }

  for(i = 1; i <= n; i++){
    if(take[i]){
      res.pb(i);
    }
  }

  cout << sz(res) << '\n';
  prv(res);

  ktj();
}


Measured memory_bytes: 5108
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=2e5+10;

char s[N],ans[N];
bool vis[26];
int dat[N];

void solve(){
    scanf("%s",s);

    int len=strlen(s);
    int tot=0,cnt=0;
    dat[0]=len;
    for(int i=len-1;i>=0;i--){
        if(!vis[s[i]-'a']){
            cnt++;
            vis[s[i]-'a']=1;
            if(cnt==26){
                mem(vis,0);
                cnt=0,tot++;
                dat[tot]=i;
            }
        }
    }

    int anscnt=0;
    for(int i=0;i<26;i++){
        if(!vis[i]) {ans[anscnt++]=i+'a';break;}
    }
    if(tot){
        for(int i=tot;i>=1;i--){
            for(int j=dat[i];j<dat[i-1];j++){
                if(s[j]==ans[anscnt-1]){
                    mem(vis,0);
                    for(int k=j+1;k<dat[i-1];k++) vis[s[k]-'a']=1;
                    for(int i=0;i<26;i++){
                        if(!vis[i]) {ans[anscnt++]=i+'a';break;}
                    }
                }
            }
        }
    }
    ans[anscnt]=0;
    printf("%s",ans);
}

int main(){
    solve();
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define maxn 200005
int m,n,x,y,ans,f[maxn],ni[maxn];
int f1(int a,int b){
	return (a += b) >= mod ? a - mod : a;
}
int f2(int a,int b){
	return (a -= b) < 0 ? a + mod : a;
}
int f3(int a,int b){
	return a * b % mod;
}
int f4(int a,int k){
	if(k == 0) return 1;
	if(k == 1) return a;
	int s = f4(a,k / 2) % mod;
	if(k % 2) return (s * s % mod) * a % mod;
	else return s * s % mod;
}
int C(int a,int b){
	return f3(f3(f[b],ni[a]),ni[b - a]);
}
int p(int xa,int ya,int xb,int yb){
	int n = xb - xa,m = yb - ya;
	return C(m ,n + m);
}
signed main(){
//	freopen("date.in","r",stdin);
//	freopen("date.out","w",stdout);
	scanf("%lld%lld%lld%lld",&n,&m,&x,&y); 
	f[0] = 1,ni[0] = 1;
	for(int i = 1; i <= maxn - 5; i++){
		f[i] = f3(f[i - 1],i) % mod;
		ni[i] = f4(f[i],mod - 2) % mod;
	}
	for(int i = 1; i <= n - x; i++){
		ans = f1(ans,f3(p(1,1,i,y) % mod,p(i,y + 1,n,m) % mod)) % mod;
	}
	printf("%lld",ans);
//	for(int i = 1; i <= 5; i++) printf("%lld\n",f[i])
//	printf("%lld",f4(3,4));
//	printf("%lld",p(1,1,4,4));
//	printf("%lld",f1(9,9));
	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      cnt++;
    }
    else {
      ans += cnt;
    }
  }
  cout << ans;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int n;
    int k;
    int i,j;
    int temp;
    scanf("%d %d",&n,&k);
    int p[n];
    for(i=0;i<n;++i){
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;++i){
        for(j=n-1;j>i;--j){
            if(p[i]>p[j]){
                temp=p[i];
                p[i]=p[j];
                p[j]=temp;
            }
        }
    }
    int sum=0;
    for(i=0;i<k;++i){
        sum+=p[i];
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s[0]=='9' || s[1] =='9')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define maxn 100010
int a[maxn];
int main()
{
	int n; scanf("%d", &n);
	int num = 0, ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", a + i);
		if (a[i] == a[i - 1]) ++num;
		else ans += num / 2, num = 1;
	}
	ans += num / 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;cin>>n>>k;int a[n];long long cnt=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
    if(a[i]>a[j])
    {cnt+=(((long long)k*(k+1)/2)%1000000007);cnt=cnt%1000000007;}
    for(int i=0;i<n;i++)
        for(int j=i-1;j>=0;j--)
        if(a[i]>a[j])
    {cnt+=(((long long)k*(k-1)/2)%1000000007);cnt=cnt%1000000007;}
    cout<<cnt;
    return 0;
}


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

print(str(A).replace('[', '').replace(']', '').replace(',', ''))

for i in range(1, N):
  key = A[i]
  j = i - 1
  while j >= 0 and A[j] > key:
    A[j+1] = A[j]
    j -= 1
  A[j+1] = key
  print(str(A).replace('[', '').replace(']', '').replace(',', ''))



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

int main(){
  vector<vector<int>> c(3,vector<int>(3));
  rep(i,3) rep(j,3) cin >> c.at(i).at(j);
  
  int a,b;
  bool ok = true;
  rep(i,3){
    if( i == 0 ){
      a = c.at(i).at(1) - c.at(i).at(0);
      b = c.at(i).at(2) - c.at(i).at(1);
      continue;
    }
    if( c.at(i).at(1) - c.at(i).at(0) != a ) ok = false;
    if( c.at(i).at(2) - c.at(i).at(1) != b ) ok = false;
  }
  
  cout << ( ok ? "Yes" : "No" ) << endl;
      
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli par[100001];
lli siz[100001];
//vector<lli>k[200000];       //if memory limit exceed try to exclude it
lli find(lli a) {
	if (a == par[a])return a;
	return find(par[a]);
}
void unite(lli a,lli b) {
	a = find(a);
	b = find(b);
	if (siz[b] > siz[a])swap(a, b);
	par[b] = a;
	siz[a]+=siz[b];
}

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
	lli n,m;
	cin>>n>>m;
	lli a[m][3];
	for(lli i=0;i<m;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	loop(i,1,n+1) {
		par[i] = i;
		siz[i]=1;
		//k[i].push_back(i);
	}
	for(lli i=0;i<m;i++){
		unite(a[i][0],a[i][1]);
	}
	lli te[n+1];
	for(lli i=1;i<=n;i++)te[i]=0;
	//for(lli i=1;i<=n;i++)cout<<par[i];
	for(lli i=1;i<=n;i++)te[find(i)]++;
	lli ans=0;
	for(lli i=1;i<=n;i++)if(te[i]!=0)ans++;
	cout<<ans;

	/*
	for(lli i=m-1;i>=0;i--){
		ans.pb(ans1);
		if(find(a[i][0])==find(a[i][1])){continue;
		}
		ans1=ans1-(k[find(a[i][0])].size()*k[find(a[i][1])].size());
		//cout<<k[find(a[i][0])].size()<<" "<<k[find(a[i][1])].size()<<endl;
		unite(a[i][0],a[i][1]);
		
	}
	reverse(ans.begin(),ans.end());
	for(lli i=0;i<ans.size();i++)cout<<ans[i]<<endl;
	/*loop(i,0,n-1) {
		lli a, b; cin >> a >> b;
		unite(a, b);
	}*/
	//lli t=k[find(1)].size();
	//for (lli i=0;i<t;i++)cout <<k[find(1)][i]<< " ";
    return 0;
}


Measured memory_bytes: 6272