akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class FIntervalRunning {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        ll t[2],a[2],b[2];cin >> t[0] >> t[1] >> a[0] >> b[0] >> a[1] >> b[1];
        //cout << t[0]*a[0] + t[1]*b[0] << " " << t[0]*a[1] + t[1]*b[1] << endl;
        ll mx = max(t[0]*a[0] + t[1]*b[0] , t[0]*a[1] + t[1]*b[1] );
        ll mn = min(t[0]*a[0] + t[1]*b[0] , t[0]*a[1] + t[1]*b[1] );
        if(mx == mn){
            cout << "infinity" << endl;return;
        }

        if(t[0]*a[0] + t[1]*b[0] < t[0]*a[1] + t[1]*b[1]){
            swap(a[0],a[1]);
            swap(b[0],b[1]);
        }

        if(t[0]*a[0] > t[0]*a[1]){
            cout << 0 << endl;
        }else{
            if((t[0]*a[0] - t[0]*a[1]) % (mx-mn) == 0){
                cout << - 2LL*((t[0]*a[0] - t[0]*a[1]) / (mx-mn)) << endl;
            }else cout << 1LL - 2LL*((t[0]*a[0] - t[0]*a[1]) / (mx-mn)) << endl;

        }

    }
};

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


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;

vector<vector<ll>> dp(1000,vector<ll>(20,0));

vary(int,v,0,0);
int tar;
int DP(int i,int k){
  if(k == tar){
    return 1;
  }
  if(k > tar) return 0;
  int cnt = 0;
  dp[i][k] = 1;
  REP(j,i,18){
    cnt += DP(j,k+v[j]);
  }
  return cnt;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  v.clear();
  REP(i,0,18){
    v.pb(i*i);
  }
  int n;
  while(cin >> n&&n){
    tar = n;
    dp = vector<vector<ll>>(1000,vector<ll>(1000,0));
    cout << DP(1,0) << endl;
  }
  return 0;
}

Measured memory_bytes: 18652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  int count = 0;
  ll sum = 0;
  ll mi = INT_MAX;
  for(int i = 0; i < n; ++i){
    if(A[i] < 0){
     count++;
     sum += -A[i];
    } else {
      sum += A[i];
    }
    mi = min(mi, abs(A[i]));

  }

  if(count % 2 == 0){
    cout << sum << endl;
  } else {
    cout << sum - 2 * mi << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  rep(q, Q) {
    int k;
    cin >> k;
    ll cntD = 0, cntM = 0;
    ll cnt = 0;
    ll ans = 0;
    rep(i, N) {
      if(S[i] == 'D') {
        cntD++;
      } else if(S[i] == 'M') {
        cntM++;
        cnt += cntD;
      } else if(S[i] == 'C') {
        ans += cnt;
      }

      if(i >= k-1) {
        if(S[i-k+1] == 'D') {
          cntD--;
          cnt -= cntM;
        } else if(S[i-k+1] == 'M') {
          cntM--;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    ll ans=0; ll c=0;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            c++;
        }
        else{
            ans+=c*(c+1)/2;
            c=0;
        }
    }
    ans+=c*(c+1)/2;
            c=0;
    
    cout<<ans<<endl;

}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, 0, n){
    cin >> a[i] >> b[i];
  }
  
  ll dp[20020];
  rep(i, 0, 20020)
    dp[i] = 0;
  vector<bool> check(20020, false);
  check[0] = true;
  
  rep(i, 0, 10010){
    if(check[i] == false)
      continue;
    rep(j, 0, n){
      if(check[i+a[j]]){
        llchmin(dp[i+a[j]], dp[i]+b[j]);
      }
      else{
        dp[i+a[j]] = dp[i]+b[j];
        check[i+a[j]] = true;
      }
    }
  }
  
  ll ans;
  ans = -1;
  rep(i, h, 20020){
    if(check[i]){
      if(ans == -1)
        ans = dp[i];
      else
        llchmin(ans, dp[i]);
    }
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3780
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ssum[100001],tsum[100001];
  ssum[0]=tsum[0]=0;
  for(int i=0;i<s.size();i++)
    ssum[i+1]=ssum[i]+(s[i]-'A')+1;
  for(int i=0;i<t.size();i++)
    tsum[i+1]=tsum[i]+(t[i]-'A')+1;
  int n;
  cin>>n;
  int a,b,c,d;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    int sum=ssum[b]-ssum[a-1]-tsum[d]+tsum[c-1];
    if(sum%3==0)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
    }
  return 0;  
  }



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll ans=0;
  string s;
  cin >> s;
  for(ll i=0;i<3;i++) {
    ans+=(ll)(s[i]-'0');
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define MAX 100005
#define NIL -1

int main() {
    int n, k, h, cnt = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> h;
        if(h >= k)
            cnt++;
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let w:Vec<i32> = (0..n).map(|_| read()).collect();

    let sum:i32 = w.iter().sum();
    let mut csum:i32 = 0;
    let mut ans:i32 = sum;
    for i in 0..n {
        let i = i as usize;
        csum += w[i];
        ans = min(ans, ((sum-csum)-csum).abs());
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

class MaxFlow{
private:
    using Edge = struct edge{
        int to, cap, rev;
        edge(const int to, const int cap, const int rev):to(to), cap(cap), rev(rev){}
    };

    struct Graph{
        vector<vector<Edge>> adj_list;

        Graph(const int v_size){this->adj_list.resize(v_size);}

        void add_edge(const int from, const int to, const int cap){
            this->adj_list[from].emplace_back(Edge{to, cap, static_cast<int>(this->adj_list[to].size())});
            this->adj_list[to].emplace_back(Edge{from, 0, static_cast<int>(this->adj_list[from].size()-1)});
        }
    };

    int v_size;
    vector<int> level;
    vector<int> iter;

    void bfs(const int s){
        fill_n(begin(this->level), this->v_size, -1);
        
        queue<int> q;
        this->level[s] = 0;
        q.push(s);

        while(!q.empty()){
            const int v = q.front();
            q.pop();

            for(const auto& e : this->g.adj_list[v]){
                if(e.cap > 0 && this->level[e.to] < 0){
                    this->level[e.to] = this->level[v]+1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(const int v, const int t, const int f){
        if (v == t) return f;

        for(auto&& e : this->g.adj_list[v]){
            if(e.cap > 0 && this->level[v] < this->level[e.to]){
                const int d = this->dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    this->g.adj_list[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }

        return 0;
    }

public:
    Graph g;

    MaxFlow(const int n):v_size(n), g(n){
        this->level.resize(n);
        this->iter.resize(n);
    }

    int operator()(const int s, const int t){
        int flow = 0;
        while(1){
            this->bfs(s);
            if(this->level[t] < 0) return flow;

            fill_n(begin(this->iter), this->v_size, 0);
            
            int f;
            while((f = this->dfs(s, t, INT_MAX)) > 0) flow += f;
        }
    }
};

int main()
{
    int V, E;
    cin >> V >> E;

    MaxFlow mf(V);
    
    int u, v, c;
    for(int i = 0; i < E; ++i){
        cin >> u >> v >> c;
        mf.g.add_edge(u, v, c);
    }

    cout << mf(0, V-1) << endl;
}


Measured memory_bytes: 3184
// atcoder_regular70.cpp : Defines the entry point for the console application.
//

#include<stdlib.h>
#include<stdio.h>
#include<math.h>

int main()
{
	long long int n;
	scanf("%lld",&n);
	int a = (int)sqrt(2 * n);
	if (a*(a + 1) < 2 * n)
		printf("%d\n", a+1);
	else if (a*(a + 1) == 2 * n)
		printf("%d\n", a);
	else
		printf("%d\n",a);
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  long long a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  long long ans = a*x+b*y;
  ans = min(ans, (2LL*c*x) + max(0LL,y-x)*b);
  ans = min(ans, (2LL*c*y) + max(0LL,x-y)*a);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;

    map<int, int> mp;
    for (int i = 1; i <= N; i++) {
        int m = max(0.0, ceil(log2(K) - log2(i)));
        mp[m]++;
    }
    double ans = 0;
    for (auto q : mp) {
        ans += pow(0.5, q.first) * q.second;
    }
    ans /= N;
    cout << fixed << setprecision(9) << ans << '\n';
}


Measured memory_bytes: 4184
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n;
	cin >> n;
	int c[25],v[25];
	rep(i, n) cin >> c[i];
	rep(i,n) cin >> v[i];

	int sum = 0;
	rep(i, n) {
		int var = c[i] - v[i];
		if (var > 0) {
			sum += var;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) 
{
	int a;
	string s;
	
	cin >> a;
	cin >> s;

	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

	return 0;
}

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

vector<int> G[MAX_V];
int match[MAX_V],V;
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}


bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||!used[w]&&dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}

int n,m;
void init(){
  for(int i=0;i<MAX_V;i++) G[i].clear();
  memset(match,-1,sizeof(match));
  V=n+m;
}

int main(){
  while(cin>>m>>n,m||n){
    init();
    int b[m],r[n],i,j;
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++) cin>>r[i];
    for(i=0;i<m;i++){
      for(j=0;j<n;j++){
	if(__gcd(b[i],r[j])!=1) add_edge(i,m+j);
      }
    }
    cout << bipartite_matching() << endl;
  }
  return 0;
}

Measured memory_bytes: 3380
n, y = map(int, input().split())

for a in range(n+1):
  for b in range(n+1-a):
    if 10000*a + 5000*b + 1000*(n-a-b) == y:
      print(a, b, n-a-b)
      exit(0)

print("-1 -1 -1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265358979
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

ll calc(ll a){
    ++a;
    ll ans = 0;
    rep(i,40){
        ll cnt = 0;
        ll loop = (1LL << (i+1));
        cnt = a/loop * loop/2;
        cnt += max(a%loop - loop/2,0LL);
        if(cnt%2 == 1){
            ans += loop/2;
        }
    }
    return ans;
}


int main(){

    ll a,b; cin >> a >> b;
    ll ans = calc(b)^calc(a-1);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val d = IndexedSeq.fill(n)(sc.nextInt())
    (n, d)
  }

  def solve(n:Int, d:IndexedSeq[Int]): Long = {
    val sd = d.sorted
    sd(n/2) - sd(n/2-1)
  }

  def main(args: Array[String]): Unit = {
    val (n, d) = read()
    println(solve(n,d))
  }
}

Measured memory_bytes: 52316
n=int(input())
s=input()
minv = 0
v = 0
minp = 0
i = 0
while i < n:
    if s[i] == 'W':
        v += 1
    else:
        v -= 1
    if v < minv:
        minv = v
        minp = i
    i += 1
ans = (minv - (-minp-1))/2 + ((n-minp-1) - (v - minv))/2
print(str(int(ans)))

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

const ll MAX_N = 2e5;
ll N, M;
Vi E[MAX_N];

int main(){
   cin >> N >> M;
   REP(i, M){
      ll a, b; cin >> a >> b;
      a--; b--;
      E[a].pb(b); E[b].pb(a);
   }
   REP(i, N) SORT(E[i]);
   for (auto &e: E[0]){
      if(binary_search(E[N - 1].begin(), E[N - 1].end(), e)){
         cout << "POSSIBLE" << endl;
         return 0;
      }
   }
   cout << "IMPOSSIBLE" << endl;
   return 0;
}


Measured memory_bytes: 12776
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
map<string,ll>mp;
map<string,bool>vis;
int main()
{
    fast;
    ll n;
    cin>>n;
    string s[n+7];
    for(ll i=0; i<n; i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    ll tot=0;
    for(ll i=0; i<n; i++)
    {
        if(!vis[s[i]])
        {
            ll x=mp[s[i]]-1;
            tot+=(x*(x+1))/2;
            vis[s[i]]=1;
        }
    }
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 27648
import math
N = int(input())
A = list(map(int,input().split()))
A.reverse()
l = 2
r = 2
for i in range(N):
  l = math.ceil(l/A[i])*A[i]
  r = math.floor(r/A[i])*A[i]+A[i]-1
if r >= l:
  print(l,r)
else:
  print(-1)

Measured memory_bytes: 15020
import math

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        gcd_0 = math.gcd(i+1,j+1)
        if gcd_0 == 1:
            ans += gcd_0 * K
        else:
            for k in range(K):
                ans += math.gcd(gcd_0,k+1)

print(ans)

Measured memory_bytes: 9208
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

vv<string> gd;
vv<vll> dis;
ll h,w;

auto modsum= [](ll a, ll b){
	return (a+b)%MOD;
};

ll sol(ll i, ll j){
	if(i==h-1 && j==w-1)
		return 1;
	if(i>=h || j>=w)
		return 0;
	if(dis[i][j] == -1){
		if(gd[i][j] == '#')
			dis[i][j]=0;
		else
			dis[i][j] = modsum(sol(i+1, j), sol(i,j+1));
	}
	return dis[i][j];

}

int main(){
	fastio;
	cin>>h>>w;
	gd = vv<string>(h);
	dis = vv<vll>(h,vll(w,-1));
	for(auto& i: gd){
		cin>>i;
	}
	// sol(0,0);
	// for(ll i=0; i<h; i++){
	// 	for(ll j=0; j<w; j++){
	// 		cout<<dis[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<sol(0,0);

}

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

bool dp[2501][2501], nxt[2501][2501];

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

  vector<int> t(n);
  int sum = 0;
  for(int i=0;i<n;i++){
    cin >> t[i];
    sum += t[i];
  }

  dp[0][0] = 1;
  for(int i=0;i<n;i++){
    memset(nxt, 0, sizeof(nxt));
    for(int j=0;j<=sum-t[i];j++){
      for(int k=0;k<=sum-t[i];k++){
	if(!dp[j][k])continue;
	nxt[j][k] = true;
	nxt[j+t[i]][k] = true;
	nxt[j][k+t[i]] = true;
      }
    }
    swap(dp, nxt);
  }

  int ans = sum;
  for(int j=0;j<=sum;j++){
    for(int k=0;k<=sum;k++){
      if(!dp[j][k])continue;
      int cost = max(j, max(k, sum-j-k));
      ans = min(ans, cost);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 15304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;

  int ans = n / 2;
  ans += n % 2;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

struct para
{
    int a, nr;
};

bool porownanie(para a, para b)
{
    if (a.a < b.a)
        return true;
    if (a.a > b.a)
        return false;
    if (a.nr < b.nr)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<para> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].a;
        a[i].nr = i;
    }
    sort(a.begin(), a.end(), porownanie);
    vector<int> odp(n);
    for (int i = 0; i < n; ++i)
    {
        if (i < n / 2)
            odp[a[i].nr] = a[n / 2].a;
        else
            odp[a[i].nr] = a[n / 2 - 1].a;
    }
    for (int i = 0; i < n; ++i)
        cout << odp[i] << " ";
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#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 all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  cout << 999 - (n + 999) % 1000 << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int total_a, total_b;
	int a, b;
	int n;
	
	while (scanf("%d", &n)){
		if (n == 0){
			break;
		}
		total_a = total_b = 0;
		
		while (n){
			scanf("%d %d", &a, &b);
			if (a > b){
				total_a += a + b;
			}
			else if (a == b){
				total_a += a;
				total_b += a;
			}
			else {
				total_b += a + b;
			}
			n--;
		}
		printf("%d %d\n", total_a, total_b);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void)
{
  int A;
  int B;
  int X;

  scanf("%d %d %d",&A ,&B ,&X);

  if(A <= X && X < A + B){
    puts("YES");
  }
  else{
    puts("NO");
  }

  return 0;

}

Measured memory_bytes: 128
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
n = h + w 
ans = 0
for bit in range(1<<n):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if (bit >> i) & 1 :
                if (bit >> h + j) & 1:
                    if grid[i][j] == '#':
                        cnt += 1
    if cnt == k:
        ans += 1
print(ans)

Measured memory_bytes: 9052
def declare(a,n,number)  
  if a%2==0
    return (number+a)%n
  else
    return (number-a)%n
  end 
end
def check(c,b)
  for i in 0..c.length-1
    if c[i]==b
      return 1
    end
  end
  return 0
end
def lose(a,c,n,current)
  y=declare(a,n,current)
  c.delete_at(y)
  if y==n-1
    return 0
  else
    return y
  end
end

  current=0  
  a=Array.new(200000)
  b=Array.new(1000)
  n,m,q=gets.split(" ").map(&:to_i)
  a=gets.split(" ").map(&:to_i)
  b=gets.split(" ").map(&:to_i)
  c=Array.new(n)
  for i in 0..n-1
    c[i]=i
  end
  for i in 0..m-1
    current=lose(a[i],c,n,current)
    n=n-1
  end
  for i in 0..q-1
    print check(c,b[i]),"\n"
  end

Measured memory_bytes: 23940
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int m[9][9];
int row[9],col[9],dp[18],ds[18];

bool sorv(int x){
    int i, j;
    if(x==9) return true;
    if(row[x]) return sorv(x+1);
    for(j = 1; j < 9; j++){
        if(!col[j] && !dp[x+j] && !ds[x-j+7]){
            row[x] = j;
            col[j] = x;
            dp[j+x] = ds[x-j+7] = 1;
            if(sorv(x+1)) return true;
            row[x] = 0;
            col[j] = 0;
            dp[j+x] = ds[x-j+7] = 0;
        }
    }
    return false;
}

int main(){
    int i, n, j, k;
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d%d",&j,&k);
        j++;k++;	
        //m[j][k] = 1;
        row[j] = k;
        col[k] = j;
        dp[j+k] = ds[j-k+7] = 1;
    }
    for(i = 1; i < 9; i++){
        if(row[i]) continue;
        sorv(i);
        break;
    }
    for(i = 1; i < 9; i++){
        for(j = 1; j < 9; j++){
            if(row[i]==j) cout << 'Q';
            else cout << '.';
        }
        cout << endl;
    }
} 


Measured memory_bytes: 3240
n = int(input())
nl = [input() for _ in [0]*n]
m = int(input())
ml = [input() for _ in [0]*m]
xl = list(set(nl + ml))
x,y,z = 0,0,0
for i in range(len(xl)):
    x = nl.count(xl[i])
    y = ml.count(xl[i])
    z = max(z, (x-y))
print(z)







Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))
h.append(0)

count = 0

while h != [0]*(n+1):
    for i in range(len(h)):
        if h[i] != 0:
            break

    for j in range(i, len(h)+1):
        if h[j] == 0:
            break

    for x in range(i, j):
        h[x] -= 1

    count += 1

print(count)


Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n+1],b[n];
  rep(i,n+1) R a[i];
  rep(i,n) R b[i];
  ll ans=0;
  rep(i,n) {
    ll d=min(b[i],a[i]);
    a[i]-=d;
    b[i]-=d;
    ans+=d;
    d=min(b[i],a[i+1]);
    a[i+1]-=d;
    b[i]-=d;
    ans+=d;
  }
  pr(ans); 
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    const int price = 700;
    int cnt=0;

    if(S[0] == 'o'){
        ++cnt;
    }
    if(S[1] == 'o'){
        ++cnt;
    }
    if(S[2] == 'o'){
        ++cnt;
    }
    cout << price + 100*cnt << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100001];

int main() {
	ll n;
	cin >> n;
	ll l[n];
	ll max = 0;
	ll maxin = 0;
	for (int i = 0; i < n; i++){
		cin >> l[i];
		if (max < l[i]) {
			max = l[i];
			maxin = i;
		}
	}
	ll sum = 0;
	for (int i = 0; i<n;i++) {
	    if (i != maxin)
			sum += l[i];
	}
	if (max >= sum)
		cout << "No" << endl;
	else cout << "Yes" << endl;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::set<int> set;

  int x;

  for (int i = 0; i < 3; i ++) {
    std::cin >> x;

    set.insert(x);
  }

  std::cout << (set.size() == 2 ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind<int> uf(N);
    int l, r, d;
    rep(i,M){
        cin>>l>>r>>d;
        --l, --r;
        if(uf.issame(l, r)){
            int diff=uf.diff(l, r);
            if (diff!=d){
              cout<<"No"<<endl;
              return 0;
            }
        }
        else{
          uf.merge(l, r, d);
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1536
word = input().lower()
text = []
c = 0
while True:
    read = input().split()
    if read[0] == 'END_OF_TEXT':
        break
    else:
        text.append(read)
for i in text:
    for n in i:
        if word == n.lower():
            c += 1
print(c)

Measured memory_bytes: 7440
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    double a,b;cin>>a>>b;
    cout << a/b << ednl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1100;

queue<int> Q;
int A[MAXN];
int N;
vi out;
vpi V;
int cnt[MAXN];

int main(){
    cin>>N;
    // for (int i=1;i<=N;++i)
    for (int i=1;i<=N;++i){
        cin>>A[i];
        V.pb(A[i],i);
    }
    sort(ALL(V));
    for (auto i : V){
        for (int j=1;j<i.s;++j)Q.push(i.s);
    }
    for (auto i : V){
        int l = i.f;
        int in = i.s;
        while (SZ(out) < l-1){
            if (SZ(Q) == 0){
                cout<<"No";
                return 0;
            }
            ++cnt[Q.front()];
            out.pb(Q.front());
            Q.pop();
        }
        if (SZ(out) >= l){
            cout<<"No";
            return 0;
        }
        if (cnt[in] != in-1){
            cout<<"No";
            return 0;
        }
        out.pb(in);
        for (int j=in+1;j<=N;++j)Q.push(in);
    }
    while (SZ(Q)){out.pb(Q.front());Q.pop();}
    assert(SZ(out) == N*N);
    cout<<"Yes\n";
    for (auto i : out)cout<<i<<' ';
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

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

using namespace std;

typedef long long ll;
vector<ll> prime;
vector<ll> is_prime;

void sieve(ll n)
{
  ll p = 0;
  for (ll i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i <= n; i++)
  {
    if (is_prime[i])
    {
      prime[p++] = i;
      for (ll j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
}

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  prime = vector<ll>(n);
  is_prime = vector<ll>(n + 1);
  vector<ll> a(n + 1);
  REP(i, n)
  cin >> a[i + 1];
  if (n == 1)
  {
    if (a[1] == 1)
    {
      cout << 1 << endl;
      cout << 1 << endl;
    }
    else
    {
      cout << 0 << endl;
    }
    return 0;
  }
  //sieve(n);
  vector<ll> hako(n + 1);
  for (ll i = n; i > n / 2; i--)
  {
    hako[i] = a[i];
  }
  for (ll j = 3; j <= n; j++)
  {
    for (ll i = n / (j - 1); i > n / j; i--)
    {
      ll tmp = 0;
      for (ll k = 2; k <= j; k++)
      {
        if (i * k > n)
        {
          break;
        }
        tmp += hako[i * k];
      }
      hako[i] = (a[i] + tmp) % 2;
    }
  }
  ll m = 0;
  for (ll i = 2; i <= n; i++)
  {
    if (hako[i] == 1)
    {
      m++;
    }
    hako[1] += hako[i];
  }
  hako[1] = (hako[1] + a[1]) % 2;
  if (hako[1] == 1)
  {
    m++;
  }
  cout << m << endl;
  REP(i, n)
  {
    if (hako[i + 1] % 2 == 1)
    {
      cout << i + 1 << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 7168
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	for(int i=1;i<s.size();i++){
		if(i+1<s.size()){
			if(s.at(i-1)==s.at(i+1)){
				cout << i << " " << i+2 << endl ;
				return 0 ;
			}
		}
		if(s.at(i)==s.at(i-1)){
			cout << i << " " << i+1 << endl ;
			return 0 ;
		}
	}
	cout << "-1 -1\n" ;
}


Measured memory_bytes: 512
import Data.Char
import Data.Bool

main = do
  [a,b] <- map read . words <$> getLine
  s <- getLine
  let
    (n1,s1) = splitAt a s
    (h,s2) = splitAt 1 s1
    (n2,s3) = splitAt b s2
  let ans = all isDigit n1 && h=="-" && all isDigit n2
  putStrLn $ bool "No" "Yes" ans

Measured memory_bytes: 508
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)


int main(){
    long long int a,c,d=0;
    cin>>a;
  vector<int>b(a);
    rep(i,a)cin>>b[i];
  sort(b.begin(),b.end());
  rep(i,a-2){
    for(int o=i+1;o<a-1;o++){
      for(int j=o+1;j<a;j++){
        if(b[j]<b[i]+b[o])d++;
      }
    }
  }
  cout<<d;
}

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

long long A, B, Q;
vector<long long> zinv;
vector<long long> terav;
long long q[100005];

long long getmin(long long start, vector<long long> ptera, vector<long long>pzin){
	long long ans = -1;
	//first tera
	for(auto te: ptera){
		for(auto zi: pzin){
			long long cost = abs(start - te) + abs(zi - te);
			if(ans == -1){
				ans = cost;
			} else {
				ans = min(ans, cost);
			}
		}
	}

	//first zin
	for(auto zi: pzin){
		for(auto te: ptera){
			long long cost = abs(start - zi) + abs(zi - te);
			if(ans == -1){
				ans = cost;
			} else {
				ans = min(ans, cost);
			}
		}
	}
	return ans;
}

int main(){
	cin >> A >> B >> Q;
	for(long long i = 0; i < A; i++){
		long long tmp;
		cin >> tmp;
		zinv.push_back(tmp);
	}
	for(long long i = 0; i < B; i++){
		long long tmp;
		cin >> tmp;
		terav.push_back(tmp);
	}
	for(long long i = 0; i < Q; i++){
		cin >> q[i];
	}
	sort(zinv.begin(), zinv.end());
	sort(terav.begin(), terav.end());

	for(long long i = 0; i < Q; i++){
		auto zit = lower_bound(zinv.begin(), zinv.end(), q[i]);
		auto te = lower_bound(terav.begin(), terav.end(), q[i]);

		vector<long long> possible_zin;
		vector<long long> possible_tera;

		if(zit == zinv.begin()){
			possible_zin.push_back(*zit);
		}else if(zit == zinv.end()){
			zit--;
			possible_zin.push_back(*zit);
		}else{
			possible_zin.push_back(*zit);
			zit--;
			possible_zin.push_back(*zit);
		}

		if(te == terav.begin()){
			possible_tera.push_back(*te);
		}else if(te == terav.end()){
			te--;
			possible_tera.push_back(*te);
		}else{
			possible_tera.push_back(*te);
			te--;
			possible_tera.push_back(*te);
		}

		//cout << "Q : " << q[i] << endl;
		//cout << "possible zin" << endl;
		//for(auto tmp: possible_zin){
		//	cout << tmp << endl;
		//}
		//cout << "possible tera" << endl;
		//for(auto tmp: possible_tera){
		//	cout << tmp << endl;
		//}

		cout << getmin(q[i], possible_tera, possible_zin) << endl;
	}
}



Measured memory_bytes: 3828
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  #startline-------------------------------------------
    state = ["AC", "WA", "TLE", "RE"]
    n = int(input())
    s = [input() for i in range(n)]
    for i in range(4):
        print(state[i]+" "+"x"+" "+str(s.count(state[i])))
    
if __name__ == "__main__":
    main() #endline===============================================

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    std::cout << std::fixed;
    std::cout << std::setprecision(8);

    ll n,k;
    ll mx=0,tmp=0;
    cin>>n>>k;
    vector<ll> p(n);
    for (int i = 0; i < n; i++)
    {
        cin>>p[i];
        p[i]++;
    }

    for (int i = 0; i < k; i++)
    {
        tmp+=p[i];
    }
    mx=tmp;
    
    for (int i = k; i < n; i++)
    {
        tmp=tmp+p[i]-p[i-k];
        mx=max(mx,tmp);
    }
    
    cout<<(double)mx/2.0<<endl;
    
    return 0;
}

Measured memory_bytes: 1792