akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int MAXN = 100005;

int n,ans;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int d[MAXN];
int fa[MAXN];

bool exist;
bool mark[MAXN];

int getroot(int u)
{
	return u == fa[u] ? u : fa[u] = getroot(fa[u]);
}

int find(int v)
{
	int low = 1,high = n + 1;
	while (low < high)
	{
		int mid = low + high >> 1;
		if (c[mid] >= v)
			high = mid;
		else
			low = mid + 1;
	}
	return low;
}

int main()
{
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		a[n + 1] ^= a[i];
	}
	for (int i = 1;i <= n;i++)
		if (a[i] == a[n + 1])
			exist = 1;
	for (int i = 1;i <= n;i++)
	{
		scanf("%d",&b[i]);
		b[n + 1] ^= b[i];
	}
	bool ok = 1;
	for (int i = 1;i <= n;i++)
		if (a[i] != b[i])
		{
			ok = 0;
			break;
		}
	if (ok)
	{
		printf("0\n");
		return 0;
	}
	memcpy(c,a,sizeof(c));
	memcpy(d,b,sizeof(d));
	sort(c + 1,c + n + 2);
	sort(d + 1,d + n + 2);
	for (int i = 1;i <= n + 1;i++)
		if (c[i] != d[i])
		{
			printf("-1\n");
			return 0;
		}
	for (int i = 1;i <= n + 1;i++)
		fa[i] = i;
	for (int i = 1;i <= n + 1;i++)
		a[i] = find(a[i]);
	for (int i = 1;i <= n + 1;i++)
		b[i] = find(b[i]);
	for (int i = 1;i <= n + 1;i++)
		if (a[i] != b[i])
		{
			fa[getroot(a[i])] = getroot(b[i]);
			mark[getroot(b[i])] = 1;
			ans += (i <= n);
		}
	for (int i = 1;i <= n + 1;i++)
		if (i == fa[i] && mark[i])
			ans++;
	printf("%d\n",ans + (a[n + 1] == b[n + 1] && !exist) - 1);
	return 0;
}

Measured memory_bytes: 3968
<?php
  // 雰囲気的に最小公倍数をアレすればいけそう 雰囲気的に
  // せっかく取得したxを配列にぶちこんで（インデックスとか無視して）ソートするところがミソ
  
  $nx = array_map("intVal", explode(" ", trim(fgets(STDIN))));
  $n = $nx[0];
  $x = $nx[1];
  $arr = array_map("intVal", explode(" ", trim(fgets(STDIN))));
  $arr[] = $x;
  sort($arr);

  $dif = [];
  for($i=0; $i<$n; $i++){
    $dif[] = $arr[$i+1] - $arr[$i];
  }
  
  function gcd($x, $y){
    if($x > $y) return gcd($y, $x);
    if($x == 0) return $y;
    $tmp = $y % $x;
    $y = $x;
    $x = $tmp;
    return gcd($x, $y);
  }

  function lcm($x, $y){
    return intVal(($x * $y) / gcd($x, $y));
  }

  $gcdn = $dif[0];
  for($i=1; $i<$n; $i++){
    $gcdn = gcd($gcdn, $dif[$i]);
  }

  echo $gcdn . PHP_EOL;
?>

Measured memory_bytes: 35292
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

struct data {int x, y, value;};

int main() {
    int h, w, d; cin >> h >> w >> d;
    int M = 300*300;
    int m = M+d-1;
    vector<vector<P>> data(d,vector<P>(m/d));
    REP(i,h+1)REP(j,w+1) {
        int x; cin >> x;
        if (x%d != 0) data[x%d][x/d] = P(i,j);
        else data[x%d][x/d-1] = P(i,j);
    }
    vvint dis(d,vint(m/d+1,0));
    rep(i,d) {
        REP(j,m/d+1) {
            int x = abs(data[i][j].second-data[i][j-1].second);
            int y = abs(data[i][j].first-data[i][j-1].first);
            dis[i][j] = dis[i][j-1] + x + y;
        }
    }
    int q; cin >> q;
    rep(i,q) {
        int l, r; cin >> l >> r;
        if (r%d != 0) cout << dis[r%d][r/d]-dis[l%d][l/d] << endl;
        else cout << dis[r%d][r/d-1]-dis[l%d][l/d-1] << endl;
    }
}

Measured memory_bytes: 10240
from operator import itemgetter
from itertools import combinations
N, M, X = map(int, input().split())
Array = [list(map(int,list(input().split()))) for i in range(N)]

Array.sort(key=itemgetter(0))
C = [i[0] for i in Array]
A = [i[1:] for i in Array]

#print(C,A)

cost = -1
for i in range(N):
    pt = list(combinations(range(N), i+1))
#    print(pt)
    for j in range(len(pt)):
        S = [0 for i in range(M)]
        Sc = 0
#        print("===")
        for k in pt[j]:
            S = [a + b for a, b in zip(A[k], S)]
            Sc += C[k]
#        print("---")
#        print(S)
#        print(Sc)
        
        if X<=min(S) and ((Sc < cost) or cost==-1):
           cost = Sc
print(cost)

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

int main()
{
  while(1){
    int m,f,r;
    cin >> m >> f >> r;
    int tot = m + f;

    if(m == -1 && f == -1 && r == -1)
      {break;}

    if(m == -1 || f == -1)                         {cout << "F"<< endl ;}
    else if(tot >= 80)                             {cout << "A"<< endl;}
    else if(tot >= 65)                             {cout << "B"<< endl;}
    else if(tot >= 50 || r >= 50)          {cout << "C"<< endl;}
    else if(tot >= 30)                             {cout << "D"<< endl;}
    else if(tot < 30)                                {cout << "F"<< endl;}
  }
  return 0;
}



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

struct TimeTable{
	int c;	//本站运行时间
	int s;	//本站首发时间
	int f;	//发车间隔 
};
int main()
{
	int n;
	cin>>n;
	TimeTable a[n+1];
	for(int i=1;i<=n-1;i++)
		cin>>a[i].c>>a[i].s>>a[i].f;
	for(int i=1;i<=n-1;i++){
		int s=i,b=i,tb=0,e=i+1,te; 
		//s始发车站，b当前出发站台,tb当前出发时间，e当前到达站台，te当前到达时间
		while (e<=n){
		 	if (tb<=a[b].s) tb=a[b].s;
		 	else tb=a[b].s+(tb-a[b].s+a[b].f-1)/a[b].f*a[b].f;
			te=tb+a[b].c;
			b++;e++;
			tb=te;
		}
		cout<<te<<endl;
	}
	cout<<0<<endl;
	return 0;
}

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

#define INF (1<<29)

using namespace std;



int main(void){

  int a,b,c,g[10][10],n,sum[10];

  while(cin >> n,n){
    fill(sum,sum+10,0);
    fill(g[0],g[10],INF);

    for(int i=0;i<10;i++)g[i][i]=0;

    for(int i=0;i<n;i++){
      cin >> a >> b >> c;
      g[a][b]=g[b][a]=c;
    }

    for(int k=0;k<10;k++){
      for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
          g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
        }
      }
    }

    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
        if(g[i][j]<INF)sum[i]+=g[i][j];

    int ans1=INF,ans2=0;
    for(int i=0;i<10;i++)
      if(ans1>sum[i] && sum[i]>0)ans1=sum[i],ans2=i;

    cout << ans2 << " " << ans1 << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define F first
#define S second
#define sz(x) (int)x.size() - 1
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 3e5 + 5;

int h[27][N], n;
bool check(int mid) {
    rep(i, mid, n) {
        int a = h[0][i] - h[0][i - mid];
        int c = h[2][i] - h[2][i - mid];
        int g = h[6][i] - h[6][i - mid];
        int t = h['T' - 'A'][i] - h['T' - 'A'][i - mid];
        if(a + c + g + t == mid)
            return true;
    }
    return false;
}
inline void solve() {
      string s;
      cin >> s;
      n = s.size();
      fo(i, n){
          h[s[i-1] - 'A'][i] += 1;
      }
      rep(i,0,25)
        fo(j, n)
          h[i][j] += h[i][j-1];
      int lo = 0, hi = n + 1, mid;
      while(lo <= hi) {
        mid = lo + hi >> 1;
          if(check(mid))
              lo = mid + 1;
          else
              hi = mid - 1;
      }
        cout << lo - 1;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t; while(t--)
                solve();
    return 0;
}


Measured memory_bytes: 28928
N = input()

if len(N) == 1:
    print(N)
if len(N) == 2:
    print(9)
if len(N) == 3:
    print(9 + int(N) - 100 + 1)
if len(N) == 4:
    print(909)
if len(N) == 5:
    print(9 + 900 + int(N) - 10000 + 1)
if len(N) == 6:
    print(90909)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;


int main(){
	int n;
	int q,b,c;
	long long ans = 0;
	long long num[100010] = {0};

	cin >> n;
	for(int i = 1; i <= n; i++){
		long long a;
		cin >> a;
		ans += a;
		num[a]++;
	}	

	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> b >> c;
		ans += (c - b) * num[b];
		num[c] += num[b];
		num[b] = 0;
		cout << ans << endl;	
	}
}


Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x,y) cout<<x<<"-"<<y<<endl;
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
int minn(int a,int b)
{
	if(b < a)
	{
		return b;
	}
	else
	{
		 return a;
	}
	
}
lli poww(lli x,lli y)
{
	if(y==0 || x==1)return 1;
	lli ans=1;
		if(y%2==0)
		{
			lli t=poww(x,(y/2));
			return t*t;
		}
		else
		{
			return x*poww(x,y-1);
			
		}	
}
int main()
{
	FastIO
	int t=1;
	// cin>>t;
	while(t--)
	{
		int a,b,c,k;
		cin>>a>>b>>c>>k;
		int ans=0;
		int rem=k;
		ans=ans+minn(a,k);
		k=k-minn(a,k);
		k=k-minn(b,k);
		ans=ans-minn(c,k);
		cout<<ans;
	}
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int PT[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int QT[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int RT[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let x: usize = sc.read();
    let y: usize = sc.read();
    if y % 2 == 0 && x * 2 <= y && y <= x * 4 {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2084
#include <stdio.h>

int main(){
  int n,m,a;
  scanf("%d%d",&n,&m);
  if(1<n<m){
    while((m%n)!=0){
      a=m%n;
      m=n;
      n=a;
    }
    printf("%d\n",n);
  }
  else if(1<m<n){
    while((n%m)!=0){
      a=n%m;
      n=m;
      m=a;
    }
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 592
n,x = gets.split(" ").map(&:to_i)
while ([n,x] != [0,0]) do
  count = 0
  catch(:stop) do
    n.downto(1) do |n1|
      (n1-1).downto(1) do |n2|
        n3 = x - n1 - n2
        count += 1 if (n3 < n2) && (n3 > 0)
        throw :stop if (n3 > n1)
        break if (n3 > n2)
      end
    end
  end
  puts count
  n,x = gets.split(" ").map(&:to_i)
end

Measured memory_bytes: 8568
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	char s[5];
	cin >> s;
	for (int i = 0;i < 3;i++) {
		if (s[i] == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<pair<ll, ll>>> G;
vl ans;

void dfs(ll v, ll p = -1, ll c = -1) {
    ll color = 1;
    for(auto x : G[v]) {
        ll u = x.first;
        ll e = x.second;
        if(u == p) {
            continue;
        }
        if(color == c) {
            color++;
        }
        ans[e] = color;
        color++;
        dfs(u, v, ans[e]);
    }
}

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

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, i));
        G[b].pb(make_pair(a, i));
    }

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }
    out(K);

    ans.resize(n-1);
    dfs(0);

    rep(i, n-1) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 9728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 310;
// UnionFind
class UnionFind {
public:
  UnionFind(int size_) : parent(size_, -1), __size(size_) {}
  void unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      if (parent[y] < parent[x])
        std::swap(x, y);
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool is_parent(int x) { return find(x) == x; }
  bool is_same(int x, int y) { return find(x) == find(y); }
  int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
  int size(int x) { return -parent[find(x)]; }
  int size() const { return __size; }

private:
  std::vector<int> parent;
  int __size;
};
// UnionFind

int N;
ll A[MAX_N][MAX_N];
ll B[MAX_N][MAX_N];
vector<tuple<ll, pii>> graphs;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
      B[i][j] = A[i][j];
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (B[i][j] != A[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      graphs.emplace_back(mt(A[i][j], mp(i, j)));
    }
  }
  sort(graphs.begin(), graphs.end());
  UnionFind ut(N);
  ll res = 0;
  for (const auto &graph : graphs) {
    ll cost;
    pii pos;
    tie(cost, pos) = graph;
    int a, b;
    a = pos.first;
    b = pos.second;
    bool ok = false;
    if (ut.is_same(a, b)) {
      for (int i = 0; i < N; i++){
        if (i == a or i == b)continue;
        ll tmp = A[a][i] + A[i][b];
        if (tmp == cost){
          ok = true;
          break;
        }
      }
    }

    ut.unite(a, b);
    if (not ok){
      // cerr << res << " " << A[a][b] << endl;
      res += A[a][b];
    }
  }

  cout << res << endl;

  return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    rep(i, M) cin >> X[i];
    sort(all(X));
    vector<int> A(M - 1);
    int ans = 0;
    rep(i, M - 1) {
        A[i] = -abs(X[i] - X[i + 1]);
        ans -= A[i];
    }
    // cout << ans << endl;
    sort(all(A));
    // rep(i, M - 1) cout << A[i] << endl;
    
    rep(i, min(N - 1, M - 1)) ans += A[i];

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


Measured memory_bytes: 1024
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[202020];
int cnt[202020];
vector<int> ans;

int main(){
    cin >> n;
    REP(i, n)cin >> a[i + 1];
    for(int i = n;i >= 1;i--){
        int num = 0;
        for(int j = i;j <= n;j += i)num += cnt[j];
        if(num%2 != a[i]){
            ans.emplace_back(i);
            cnt[i]++;
        }
    }
    cout << (int)ans.size() << endl;
    REP(i, (int)ans.size()){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

ll MOD = 1000000007;


int main(){
  ll H, W, A, B;
  cin >> H >> W >> A >> B;

  map<ll, ll> fact;
  fact[0] = 1;
  rep2(i, 1, H + W - 1){
    fact[i] = (fact[i - 1] * i) % MOD;
  }

  map<ll, ll> factinv;
  ll e = 1000000005;
  ll a = 1;
  ll x = fact[H + W - 2];

  while(e > 0){
    if(e % 2 == 0){
      x = (x*x) % MOD;
      e /= 2;
    } else{
      a = (a*x) % MOD;
      e--;
    }
  }
  
  factinv[H + W - 2] = a;
  
  rep_inv(i, H + W - 3, -1){
    factinv[i] = (factinv[i + 1] * (i + 1)) % MOD;
  }

  ll ans = 0;
  rep2(i, B, W){
    ll c1 = (fact[H - A - 1 + i] * factinv[H - A - 1] % MOD) * factinv[i] % MOD;
    ll c2 = (fact[W + A - i - 2] * factinv[A - 1] % MOD) * factinv[W - 1 - i] % MOD;
    ans = (ans + c1*c2) % MOD;
  }

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

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) if (a[i] == 0) { cout << "0\n"; return 0; }
	ll x = 1;
	rep(i, n) {
		if (x >= INF * 3 / a[i]) {
			cout << "-1\n";
			return 0;
		}
		x *= a[i];
	}
	if (x >= INF - 9) cout << "-1\n";
	else cout << x << '\n';
}

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

int main(){
    int n;
    cin>>n;
    int x[n];
    int max,min;
    long int t=0;
    for(int i =0;i<n;i++){
        cin>>x[i];
    }
    max=x[0];
    min=x[0];
    for(int i=0; i<n;i++){
       if(max<x[i]){
           max=x[i];
       }
       if(min>x[i]){
           min=x[i];
       }
       t=t+x[i];
    }
    cout<<min<<" "<<max<<" "<<t<<endl;
}


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

int n, m;
vector <int> a;
vector <int> b;

struct job{
    int pay, days;
};

vector <pair<int,int>> jobs;

int main(){
    cin >> n >> m;
    a.assign(n, -1);
    b.assign(n, -1);
    priority_queue<int> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        jobs.push_back({a[i], b[i]});
        //q.push({b[i], a[i]});
    }
    sort(jobs.begin(), jobs.end());
    queue <pair<int, int>> cola;
    for (int k = 0; k < jobs.size(); ++k) {
        cola.push(jobs[k]);
    }
    long long ans = 0;
    for (int j = 0; j < m; ++j) {
        while (cola.size()){
            if (cola.front().first <= j+1){
                q.push(cola.front().second);
                cola.pop();
            }else break;
        }
        if (q.size()){
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  rep(i,n) {
    if(a[i] == 0) {
      cout << 0 << "\n";
      return 0;
    }
  }
  
  ll sum = 1;
  ld inf = 1000000000000000000;
  rep(i,n) {
    if((ld)sum * (ld)a[i] > inf) {
      cout << -1 << "\n";
      return 0;
    }
    sum *= a[i];
  }
  cout << sum << "\n";
  
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> void show(vector<T>v){rep(i,v.size()-1){cout<<v.at(i)<<" ";}cout<<v.at(v.size()-1)<<endl;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int N, result;
    cin >> N;
    vector<int> V(N), C(N);
    rep(i, N) cin >> V.at(i);
    rep(i, N) cin >> C.at(i);
    rep(i, N) result += max(0, V.at(i) - C.at(i));
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define int long long

using namespace std;

int n, m;

char S[100010], T[100010];

signed main() {
    scanf("%lld%lld", &n, &m);
    scanf("%s%s", S + 1, T + 1);
    int g = __gcd(n, m);
    int flag = 1;
    for(int i = 0; i < g; i++)
        if(S[n / g * i + 1] != T[m / g * i + 1]) flag = 0;
    if(flag) printf("%lld\n", n * m / g);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 384
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int n;
	int ok=1;
	cin>>n;
	int a;
	rb(i,1,n){
		cin>>a;
		if(!(a&1)){
			if(a%3==0||a%5==0);
			else ok=0;
		}
	}
	if(ok){
		cout<<"APPROVED";	
	}
	else
	cout<<"DENIED";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int hyou[17][17],Table[17][17];

int main(){
	int n,m,a,b,c;
	scanf("%d%d",&n,&m);
	if(n==0&&m==0) return 0;
	memset(hyou,0,sizeof(hyou));
	memset(Table,0,sizeof(Table));
	Table[1][0]=1;
	scanf("%d",&a);
	while(a--){
		scanf("%d%d",&b,&c);
		hyou[b][c]=-1;
	}
	
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(hyou[i][j]==-1){Table[i][j]=0;}
			else{ Table[i][j]=Table[i-1][j]+Table[i][j-1];	}	
		}
	}
	printf("%d\n",Table[n][m]);
	main();
	
	
	return 0;
}

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

multiset<string> s;

int main()
{
	int a, b, c, all = 0;
	scanf("%d %d %d", &a, &b, &c);
	all = a + b + c;
	while(a--) s.insert("a");
	while(b--) s.insert("b");
	while(c--) s.insert("c");
	while(1)
	{
		if(s.size() == 1) break;
		string str = (*s.begin()) + *(--s.end());
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(str);
	}
	cout << *s.begin() << endl;
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ans = 0;
    int N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    int sz = N*(N+1)/2;
    vector<ll> sums;
    vector<bool> nouse(sz, false);
    for(int i = 0; i < N; i++){
        ll acc = 0;
        for(int j = i; j < N; j++){
            acc += A[j];
            sums.push_back(acc);
        }
    }
    ll cnt_bit[45] = {};
    //rep(i, sz) cout << sums[i] << " "; cout << endl;
    rep(i, 45){
        ll val = (1ll << i);
        rep(j, sz) if((sums[j] & val) == val) cnt_bit[i]++;
    }
    for(int i = 44; i >= 0; i--){
        if(cnt_bit[i] >= K){
            ll inc = (1ll << i);
            ans += inc;
            for(int j = 0; j < sz; j++){
                if(!nouse[j]){
                    if((sums[j] & inc) != inc){
                        nouse[j] = true;
                        rep(k, 45){
                            ll eval = (1ll << k);
                            if((sums[j] & eval) == eval){
                                cnt_bit[k]--;
                                //cout << "i = " << i << ", " << sums[j] << endl;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define smallk order_of_key
#define kth find_by_order
*/

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;

const int N = (int)1e5 + 123;
const int M = 1e9 + 7;
const int K = 500;

int n, k;
int a[111];
int main(){

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

    #ifdef LOCAL
        freopen("B.txt", "r", stdin);
    #endif // LOCAL

    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> ans(k + 1, 2);
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= n; ++j){
            if(i < a[j]) continue;
            if(ans[i - a[j]] == 2){
                ans[i] = 1;
            }
        }
    }
    cout << (ans[k] == 2 ? "Second" : "First");
    return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const ll INF=1e18 + 5;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll n,W;cin>>n>>W;
    ll k=1000*n;
    vector<vector<ll> > dp(n,vector<ll>(k+1,INF));
    ll v[n],w[n];
    rep(i,n){
        cin>>w[i]>>v[i];
    }
    dp[0][v[0]]=w[0];
    for(int i=0;i<n;i++){
        dp[i][0]=0;
    }
    repA(i,1,n-1){
        for(int j=0;j<=k;j++){
            if(j-v[i]>=0&&dp[i-1][j-v[i]]!=INF)
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    for(int i=k;i>=0;i--){
        if(dp[n-1][i]<=W){
            cout<<i;return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 79488
#include<bits//stdc++.h>
using namespace std;
int main() {
    int n, a, b;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        v[i].first = a; v[i].second = b;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    char c; cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0; i<N; i++){
		cin >> H[i];
	}
	int count=1;
	for(int i=1; i<N; i++){
		int flag=0;
		for(int j=0; j<i; j++){
			if(H[i]>=H[j])flag++;
		}
		if(flag==i)count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int (i)=(a);(i)<=(b);++(i))
#define mem(n) memset((n),0,sizeof((n)))
#define si(n) scanf("%d",&(n))
#define sl(n) scanf("%lld",&(n))
using namespace std;
typedef long long LL;
const int maxn=200000+5;
const LL mod=1e9+7;
const int inf=0x3f3f3f3f;
typedef pair<LL,LL> pll;
pll val[maxn];
multiset<LL>m1,m2;
int main()
{
    //std::ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    //freopen("test.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
    LL n,x,y;
    sl(n);
    //while(~sl(n))
    {
        //m1.clear();m2.clear();
        //memset(val,0,sizeof(val));
        for(LL i=0;i<n;i++)
        {
            sl(x);sl(y);
            if(x>y) swap(x,y);
            val[i].first=x;val[i].second=y;
            m1.insert(x);
            m2.insert(y);
        }
        sort(val,val+n);
        LL ans=(*m1.rbegin()-*m1.begin())*(*m2.rbegin()-*m2.begin());
        for(LL i=0;i<n;i++)
        {
            m1.erase(m1.find(val[i].first));
            m2.erase(m2.find(val[i].second));
            m1.insert(val[i].second);
            m2.insert(val[i].first);
            ans=min(ans,(*m1.rbegin()-*m1.begin())*(*m2.rbegin()-*m2.begin()));
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 24256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
string s1="AC",s2="WA",s3="TLE",s4="RE";
int a,b,c,d;
int main()
{
    int n;cin>>n;while(n--){string s;cin>>s;if(s==s1) a++;else if(s==s2) b++;else if(s==s3) c++;else d++;}
    cout<<s1<<' '<<'x'<<' '<<a<<endl;
    cout<<s2<<' '<<'x'<<' '<<b<<endl;
    cout<<s3<<' '<<'x'<<' '<<c<<endl;
    cout<<s4<<' '<<'x'<<' '<<d<<endl;
}



Measured memory_bytes: 3628
N = int(input())

c = [[0] * 10 for _ in range(10)]
for i in range(1, N+1):
    i_first = int(str(i)[0])
    i_last = int(str(i)[-1])
    c[i_first][i_last] += 1

cnt = 0
for i in range(10):
    for j in range(10):
        cnt += c[i][j] * c[j][i]
print(cnt)

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

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

    int alice = 0, bob = 0;

    while(!a.empty()) {
        alice += a[a.size() - 1];
        a.pop_back();

        if (!a.empty()) {
            bob += a[a.size() - 1];
            a.pop_back();
        }
    }
    cout << alice - bob << endl;
}

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

int main() {
    int n, ans;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++) cin >> vec.at(i);

    sort(vec.begin(), vec.end());
    ans=vec.at(n-1)-vec.at(0);
    cout << ans << endl;
}

Measured memory_bytes: 256
n=input()
t,a=map(int, input().split(" "))
H=list(map(int, input().split(" ")))
diff=99999999999999999999999999999999999999999999999
for num,i in enumerate(H):
    tmp=abs(t-a-i*0.006)
    if tmp<diff:
        out=num+1
        diff=tmp
print(out)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  cin >> m;
  int l[m],r[m];
  int ans;
  for(int i=0; i<m; i++){
    cin >> l[i];
    cin >> r[i];
  }
  int lower=1,upper=n;
  for(int i=0; i<m; i++){
    lower = max(lower,l[i]);
    upper = min(upper,r[i]);
  }
  ans = (upper - lower + 1);
  if(ans >= 0) cout << ans << endl;
  else cout << 0 <<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<pair<int, ll>, int>;
#define rep(i,n) for(int i=0;i<n;i++)
inline ll in() {ll x;cin>>x;return x;}

const int N = 305;
const int INF = 1001001001;
const ll LINF = 1LL<<60;

vector<vector<ll>> g(N, vector<ll>(N, LINF));
vector<vector<pair<int, ll>>> dist(N, vector<pair<int, ll>>(N, {INF, LINF})); // pair<給油回数、移動後の燃料の残量>

int main() {
  int n = in(), m = in();
  ll l = in();

  rep(i,m) {
    int a = in() - 1, b = in() - 1;
    g[a][b] = g[b][a] = in();
  }

  rep(s,n) { // 現在地の町の番号
    priority_queue<P, vector<P>, greater<P>> q;
    q.push({{0, 0}, s});
    while (!q.empty()) {
      auto p = q.top();
      q.pop();

      pair<int, ll> d = p.first;
      int t = p.second; // 目的地の町の番号
      if (d > dist[s][t]) continue;

      int kaisuu = d.first; // 給油回数
      ll used = d.second; // 燃料の残量
      rep(nv,n) {
        //if (nv == t) continue;
        if (g[t][nv] > l) continue;
        ll nused = used + g[t][nv];
        pair<int, ll> np;
        if (nused > l) np = {kaisuu + 1, g[t][nv]};
        else np = {kaisuu, nused};

        if (dist[s][nv] > np) { // 給油回数と燃料の残量が少なくなっていれば更新してqueueにpushする
          dist[s][nv] = np;
          q.push({np, nv});
        }
      }
    }
  }

  int q = in();
  rep(i, q) {
    int s = in() - 1, t = in() - 1;
    if (dist[s][t].first == INF) cout << -1 << endl;
    else cout << dist[s][t].first << endl;        
  }
  return 0;
}

Measured memory_bytes: 3964
#include <stdio.h>
#include <ctype.h>

int main()
{
    int count = 0,i,j;
    char s[3];

    scanf("%s",s);

    for(i = 0;i < 3;i++)
        s[i] = toupper(s[i]);

    for(i = 0;i < 3;i++)
    {
        if(s[i] == 'R')
        {
            count = 1;
            for(j = i + 1;j < 3;j++)
                if(s[j] == 'R')
                    count++;
                else
                    break;

            i = j;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1712
n = int(input())
m=list(map(int,input().split()))
k=1
s=0
for i in range(n):
    s+=k*m[i]
    k*=(-1)
x=s//2
a=[2*x]
for i in range(n-1):
    a.append(2*(m[i]-a[-1]//2))
print(*a)

    

Measured memory_bytes: 95528
class HashTable:
    def __init__(self, size = 1000003):
        self.size = size
        self.hash_table = [None] * size

    def _gen_key(self, val):
        raw_hash_val = hash(val)
        h1 = raw_hash_val % self.size
        h2 = 1 + (raw_hash_val % (self.size - 1))
        for i in range(self.size):
            candidate_key = (h1 + i * h2) % self.size
            if not self.hash_table[candidate_key] or self.hash_table[candidate_key] == val:
                return candidate_key

    def insert(self, val):
        key = self._gen_key(val)
        self.hash_table[key] = val

    def search(self, val):
        key = self._gen_key(val)
        if self.hash_table[key]:
            return True
        else:
            return False


import sys

n = int(sys.stdin.readline())

simple_dict = HashTable()

ans = ''

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        if simple_dict.search(operation[5:]):
            ans += 'yes'
        else:
            ans += 'no'
        ans += '\n'

print(ans, end = '')

Measured memory_bytes: 36024
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
#include<sstream>
using namespace std;

int main(){
    int n;cin >> n;
    if(n == 1)cout << "Hello World" << endl;
    else{
        int a,b;cin >> a >> b;
        cout << a + b << endl;
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3e3 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, m, a[N], l[N], r[N], vis[N], sum[N], c[N][N], f[N][N], mx[N], len[N]; 
struct node
{
	int l, r;
	bool operator < (const node &p) const
		{
			return l == p.l ? r > p.r : l < p.l; 
		}
} p[N];
char s[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> (), scanf("%s", s + 1);
	for(int i = 1; i <= n; i++) a[i] = s[i] - '0';
	for(int i = 1; i <= m; i++) p[i].l = read <int> (), p[i].r = read <int> ();
	for(int i = 1; i <= m; i++)
		for(int j = p[i].l; j <= p[i].r; j++) vis[j] = 1; 
	sort(p + 1, p + m + 1); int tmp = m; m = 0;
	for(int x = 0, i = 1; i <= tmp; i++)
		if(p[i].r > x) x = p[i].r, p[++m] = p[i]; 
	p[m + 1].l = n * 2; 
	for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + vis[i] * a[i]; 
	for(int i = 1; i <= m; i++) mx[i] = sum[p[i].r]; 
	for(int i = 1; i <= m; i++) l[i] = p[i].l, r[i] = min(p[i + 1].l - 1, p[i].r), len[i] = len[i - 1] + r[i] - l[i] + 1; 
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= i; j++)
			c[i][j] = (!j ? 1 : (c[i - 1][j - 1] + c[i - 1][j]) % mod); 
	f[0][0] = 1; 
	for(int i = 1; i <= m; i++)
		for(int j = 0; j <= mx[i - 1]; j++)
			for(int k = 0; k <= mx[i] - j; k++)
			{
				if((mx[i] - j - k) > p[i].r - r[i] || (p[i].r - r[i] + j + k - mx[i]) > p[i].r - r[i]) continue; 
				f[i][j + k] = (1ll * c[r[i] - l[i] + 1][k] * f[i - 1][j] + f[i][j + k]) % mod;
			}
	printf("%d\n", f[m][sum[n]]); 
	return 0; 
}

Measured memory_bytes: 35880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  long double a, b;
  b += 0.001L;
  cin >> a >> b;
  long double res = a * b;
  ll ans = (ll)res;
  cout << ans << endl;
  return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  ll N, K;
  std::cin >> N >> K;

  std::map<ll, bool> hist;
  hist[N] = true;
  ll ans = N;
  while(true) {
    if(N >= K) {
      N = N % K;
    } else {
      N = K - N;
      ans = std::min(ans, N);
      break;
    }
    if(hist[N]) break;
    ans = std::min(ans, N);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        if (N >= M) {
            System.out.println(0);
            return;
        }

        List<Integer> xList = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            int topX = Integer.parseInt(scanner.next());
            xList.add(topX);
        }
        scanner.close();

        xList.sort(Comparator.naturalOrder());

        List<Integer> diffList = new ArrayList<>();
        for (int i = 0; i < M - 1; i++) {
            int diff = Math.abs(xList.get(i) - xList.get(i + 1));
            diffList.add(diff);
        }

        diffList.sort(Comparator.reverseOrder());

        for (int i = 0; i < N - 1; i++) {
            diffList.set(i, 0);

            if (i == M - 1) {
                break;
            }
        }

        int sum = 0;
        for (int diff : diffList) {
            sum += diff;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 49960
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    int n,ans;
    cin >> n;
    ans=floor(n/1.08);
    while(n>=ans){
        if(floor(ans*1.08)==n){
            cout << ans;
            return 0;
        }
        ans++;
    }
    cout << ":(";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 200200;
int n;
ll a[N];
ll ans;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (int i = 0; i < n; i++) {
		if (a[i] > i) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 1; i < n; i++) {
		if (a[i] > a[i - 1] + 1) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
		if (a[i] != a[i + 1] - 1)
			ans += a[i];
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
program main
 implicit none
 
 character*80 s
 integer*8 B,A,db,da
 db = 0
 da = 0
 read(*,*) s
 read(s(1:2),*) B
 read(s(3:4),*) A
 
 if(B == 0 .or. B > 12) then
  db = 1
 end if
 if(A == 0 .or. A > 12) then
  da = 1
 end if
 
 if(db == 0 .and. da == 0) then
  write(*,*) 'AMBIGUOUS'
 else if(db == 0 .and. da == 1) then
  write(*,*) 'MMYY'
 else if(db == 1 .and. da == 0) then
  write(*,*) 'YYMM'
 else
  write(*,*) 'NA'
 end if
end program main

Measured memory_bytes: 256