akhauriyash/Code-Regression huggingface dataset:
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    int x, y; cin >> x >> y;
    if(2*x > y || 4*x < y) cout << "No\n";
    else if(y!=1){
        if(y%2 == 0) cout << "Yes\n";
        else cout << "No\n";
    }else cout << "No" << nl;
}

int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
using namespace std;
int a[4],b[4],c,d;
int main(){
	c=0;d=0;
	for(int i=0;i<4;i++){cin>>a[i];c+=a[i];}
	for(int i=0;i<4;i++){cin>>b[i];d+=b[i];}
	cout<<max(c,d)<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll T1, T2;
    cin >> T1 >> T2;
    ll A1, A2;
    cin >> A1 >> A2;
    ll B1, B2;
    cin >> B1 >> B2;
    ll sa1 = T1 * B1 - T1 * A1;
    ll sa2 = T2 * B2 - T2 * A2;
    if (sa1 > 0 && sa1 + sa2 > 0) cout << 0 << endl;
    else if (sa1 < 0 && sa1 + sa2 < 0) cout << 0 << endl;
    else if (sa1 + sa2 == 0) cout << "infinity" << endl;
    else if (sa1 > 0){
        ll real_sa = abs(abs(sa2) - sa1);
        if (sa1 % real_sa == 0) cout << 2 * (sa1 / real_sa) << endl;
        else cout << 2 * (sa1 / real_sa) + 1 << endl;
    }
    else if (sa1 < 0){
        ll real_sa = abs(sa2 + sa1);
        if (sa1 % real_sa == 0) cout << 2 * (abs(sa1) / real_sa) << endl;
        else cout << 2 * (abs(sa1) / real_sa) + 1 << endl;
    }
}

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

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

    int N;
    cin >> N;

    vector<double> v(N);

    for (int n = 0; n < N; n++) {
        cin >> v[n];
    }

    sort(v.begin(), v.end());
    double sum = 0;

    for (int n = 0; n < N - 1; n++) {
        v[n + 1] = (v[n] + v[n + 1]) / (double)2;
    }

    cout << v[N - 1] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

struct combination {
    combination(ll Nmax, ll mod){
        (this -> MOD) = mod;
        (this -> Nmax) = Nmax;
        factorial.resize(Nmax+1, 1);
        inverse_factorial.resize(Nmax+1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r){
        ll ret = (factorial[n]*inverse_factorial[r])%MOD;
        ret = (ret*inverse_factorial[n-r])%MOD;
        return ret;
    }

    private:
        ll MOD, Nmax;
        vector<ll> factorial;
        vector<ll> inverse_factorial;
        ll mod_pow(ll n, ll p, ll mod){
            n %= mod;
            if(p==0) return 1;
            ll res = mod_pow(n*n%mod, p/2, mod);
            if(p%2==1) res = res * n % mod;
            return res;
        }

        void init_factorial(){
            for(ll i=1; i<=Nmax; i++){
                factorial[i] = (factorial[i-1] * i)%MOD;
            }
            inverse_factorial[Nmax] = mod_pow(factorial[Nmax], MOD-2, MOD);
            for(ll i=Nmax-1; i>=1; i--){
                inverse_factorial[i] = (inverse_factorial[i+1]*(i+1))%MOD;
            }
        }
};

int main(){
    ll n, k;  cin >> n >> k;
    ll V = min(n-1, k);
    ll ans = 0;
    ll mod = 1e9 + 7;
    combination comb = combination(n, mod);
    for(ll v = 0; v <= V; v++){
        ll cnt = comb.calc(n, v);
        cnt = cnt * comb.calc(n-1, v);
        cnt %= mod;
        ans = (ans + cnt)%mod;
    }
    cout << ans << endl;
}


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

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  
  rep(i,h) rep(j,w)
  {
    if(s[i][j] == '#') continue;
    char cnt = '0';
    rep(k,8)
    {
      int ni = i + dy[k];
      int nj = j + dx[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w || s[ni][nj] != '#') continue;
      cnt++;
    }
    s[i][j] = cnt;
  }
  
  rep(i,h)
  {
    rep(j,w) cout << s[i][j];
    cout <<"\n";
  }
    
    
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    auto edge = initVec2<int>(n, n);
    rep(i, n){
        rep(j, n){
            char c;
            cin >> c;
            edge[i][j] = c - '0';
        }
    }

    vector<int> col(n);
    rep(i, n){
        if(col[i] != 0){
            continue;
        }
        stack<P> st;
        st.emplace(i, 1);
        while(not st.empty()){
            int v = st.top().first;
            int c = st.top().second;
            st.pop();

            if(col[v] != 0){
                if(col[v] != c){
                    cout << -1 << endl;
                    return 0;
                }
                continue;
            }
            col[v] = c;

            rep(j, n){
                if(not edge[v][j]){
                    continue;
                }
                st.emplace(j, c * -1);
            }
        }
    }

    auto dist = initVec2(n, n, INF);
    rep(i, n) dist[i][i] = 0;
    rep(i, n) rep(j, n) if(edge[i][j]) dist[i][j] = 1;

    rep(k, n){
        rep(i, n){
            rep(j, n){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, n){
        rep(j, n){
            if(dist[i][j] == INF){
                continue;
            }
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int cnt[200000];
int main()
{
  int n,a[200000],mx=-1,t[200000];
  cin>>n;
  for(int i=0;i<n;i++){ 
      cin>>a[i];
      t[i]=a[i];
      cnt[a[i]]++;
      mx=max(mx,a[i]);
  } 
  sort(t,t+n);
  for(int i=0;i<n;i++){ 
    if(a[i]!=mx)cout<<mx<<endl; 
    else { 
        if(cnt[mx]>1)cout<<mx<<endl; 
        else cout<<t[n-2]<<endl; 
    } } 
    // for(int i=0;i<n;i++)cout<<t[i]<<" "; 
      
  

    return 0;
}


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

int main(){

  int N, K, x, A, B;
  int sum = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++){
    cin >> x;
    A = 2 * x;
    B = 2 * (K - x);
    if (A <= B){
      sum += A;
    }
    else{
      sum += B;
    }

  }
  cout << sum << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int ans = K;
    rep(i, N-1) ans *= K-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;


int main()
{ 
ll n;
cin >> n; 
ll t[n]={};
ll tt[n]={};
rep(i,n) {
    cin >> t [i];
    tt [i]=t[i];
}
sort(tt,tt+n);
if(tt[0]*(-1)<tt[n-1]){
    ll pos;
    rep(i,n){
        if(t[i]==tt[n-1])pos=i;
    }
    cout << 2*n-2 << endl;
    cout << pos+1<<' '<< 2<< endl;
    cout << pos+1<<' '<< 2<< endl;
    rep(i,n-2){
        cout << i+2<<' '<< i+3<< endl;
        cout << i+2<<' '<< i+3<< endl;
    }
}
else{
    ll pos;
    rep(i,n){
        if(t[i]==tt[0])pos=i;
    }
    cout << 2*n-2 << endl;
    cout << pos+1<<' '<< n-1<< endl;
    cout << pos+1<<' '<< n-1<< endl;
    rep(i,n-2){
        cout << n-1-i<<' '<< n-2-i<< endl;
        cout << n-1-i<<' '<<n-2-i<< endl;
    }
}


return 0;
} 

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int h,w,v=10,ans=0;
	cin>>h>>w;
	int d[v][v];
	rep(i,v)rep(j,v)cin>>d[i][j];
	rep(k,v)rep(i,v)rep(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	rep(i,h)rep(i,w){
		int t;cin>>t;
		if(t<0)continue;
		ans+=d[t][1];
	}
	dans;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            // if let Some(destv) = dests.remove(&s_num) {
            //     for dest in destv {
            //         q.push_back(dest);
            //     }
            // }
            if let Some(destv) = dests.get_mut(&s_num) {
                for &dest in destv.iter() {
                    q.push_back(dest);
                }
                destv.clear();
            }
        }
        let mut cnt = 0;
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&rem) = rems.iter().next() {
            cnt += rem;
        }
        #[cfg(local)] println!("{}: {:?}", "cnt", cnt);
    }
    println!("{}", ans);
    std::process::exit(0);
}


Measured memory_bytes: 27576
N, L = list(map(int, input().split()))

taste = [L + i for i in range(N)]
taste_abs = list(map(abs, taste))
min_abs_taste = min(taste_abs)
if min_abs_taste != 0 and L < 0:
  min_abs_taste *= -1

print(sum(taste)-min_abs_taste)

Measured memory_bytes: 3060
N,M,Q=map(int,input().split())
qs=[list(map(int,input().split()))for i in range(Q)]
from itertools import combinations_with_replacement
com=combinations_with_replacement(range(1,M+1),N)
ans=0
for A in com:
    tmp=0
    for a,b,c,d in qs:
        if (A[b-1]-A[a-1]==c):
            tmp+=d
    ans=max(ans,tmp)
print(ans)

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int n,l;
    cin>>n>>l;
    int eat = (l<0&&(l+n-1)>0)?0:(l<0?(l+n-1):l);
    int sum = n*(2*l+n-1)/2 - eat;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      string s;
      cin >> s;
      string ans;
      for(int i=0;i<s.size();i++){
            if(s[i]=='0')ans.push_back('0');
            else if(s[i]=='1')ans.push_back('1');
            else if(!ans.empty()) ans.pop_back();
      }
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    f = [0] * (N + 1)
    for x in range(1, 10 ** 2 + 1):
        for y in range(1, 10 ** 2 + 1):
            for z in range(1, 10 ** 2 + 1):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if n <= N:
                    f[n] += 1

    print("\n".join(map(str, f[1:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9708
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, i; cin >> N >> i;
    cout << N-i+1 << endl;
    
    return 0;
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#define rep(i,s,n) for(int i=s;i<n;i++);
#define all(x) (x).begin,(x).end;
typedef long long int ll;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l.at(i);
	sort(l.begin(),l.end());
	int ans=0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			for (int k = j + 1; k < n; k++) {
				if (l[i] + l[j] > l[k]) ans += 1;
				else continue;
			}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    int a[N+1];
    int num=0;
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }
    vector<int> b(N+1,0);
    vector<int> ans;
    
    for(int i=N;i>=1;i--){
        int cnt=0;
        for(int j=i;j<=N;j+=i){
            if(b[j]==1) cnt++;
        }
        int flag=cnt%2;
        if(a[i]!=flag){
            b[i]=1;
            ans.push_back(i);
        }
        
    }
    cout << ans.size() << endl;
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3064
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
String s=sc.nextLine();
String in[]=s.split(",");
	   
int a=Integer.parseInt(in[0]);	   
double b=Double.parseDouble(in[1]);
double c=Double.parseDouble(in[2]);
c*=c;
if(b/c>=25)System.out.println(a);
   }
   }
   }

Measured memory_bytes: 17124
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		map<ll,ll>in;
		vector<ll>name;
		rep(i,n){
			ll a,b,c;
			cin>>a>>b>>c;
			if(!in[a])name.pb(a);
			in[a]+=b*c;
		}
		bool h=false;
		rep(i,name.size()){
			if(in[name[i]]>=1e6){
				h=true;
				cout<<name[i]<<endl;
			}
		}
		if(!h)cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 1288
#include <iostream>

using namespace std;

int main() {
    char a;
    cin >> a;
    if (a == 'A') {
        cout << "T" << endl;
    } else if(a == 'T'){
        cout << "A" << endl;
    } else if(a == 'C'){
        cout << "G" << endl;
    } else if(a == 'G'){
        cout << "C" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
ans=0
result=0
s=[]
for _ in range(n):
    s.append(int(input()))
    
pos=s[0]

for i in range(n):
    if pos==2:
        ans+=1
        result+=1
        break
    else:
        pos=s[pos-1]
        ans+=1

if result==0:
    print(-1)
else:
    print(ans)

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

int main() {
  int N, num, btn, tmp;
  cin >> N;
  vector<int> vec(N);
  num = 0;
  btn = 1;
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  while (btn != 2) {
    tmp = btn;
    btn = vec.at(btn-1);
    vec.at(tmp-1) = 0;
    num++;
    if (btn == 0) {
      num = -1;
      break;
    }
  }
  cout << num << endl;
}


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


void solve(long long X){
    unsigned long long result = 100;
    int i = 0;
    while (result < X) {
        result = result * 1.01;
        i += 1;
    }
    cout << i << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string A,B,C;
    char win;
    cin >> A >> B >> C;
    int maisu_a=A.size(),maisu_b=B.size(),maisu_c=C.size();
    int a_now=0,b_now=0,c_now=0;
    char turn = A[0];
    while(1){
        if(turn == 'a'){
            a_now++;
            if(a_now == maisu_a+1){
                win = 'A';
                break;
            }
            turn = A[a_now-1];
        }
        else if(turn == 'b'){
            b_now++;
            if(b_now == maisu_b+1){
                win = 'B';
                break;
            }
            turn = B[b_now-1];
    }
     else if(turn == 'c'){
            c_now++;
            if(c_now == maisu_c+1){
                win = 'C';
                break;
            }
            turn = C[c_now-1];
    }
}
if(win == 'A') cout << 'A'<<endl;
else if(win == 'B')cout << 'B' <<endl;
else if(win == 'C')cout << 'C' <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int a,b,i,aa;
   
   scanf("%d%d",&a,&b);
   if(a==b){printf("1");return 0;}
   if(1==b){printf("0");return 0;}
   aa=a;
   for(i=1;b>aa;++i){
       aa--;
       aa+=a;
   }
   printf("%d",i);
   return 0;
}


Measured memory_bytes: 1728
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (k, x) = {
        let vec: Vec<i32> = read_vec();
        (vec[0], vec[1])
    };
    let mut vec = Vec::new();
    for i in (x - k + 1)..(x + k) {
        vec.push(format!("{}", i))
    }
    println!("{}", vec.join(" "));
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
n, k, q = list(map(int, input().split(" ")))

points = {}

for i in range(q):
    a = int(input())
    if a not in points:
        points[a] = 0
    points[a] += 1


for i in range(n):
    p = 0
    if (i+1) in points:
        p = points[i+1]
    if k - q+p >= 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9064
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
double t,a,b,d,x,y,v1,v2,ans=1e9;
main(){
	cin>>t>>d>>a>>b>>x>>y;
	r(i,1000)r(j,1000)if(i||j){
		v1=x*i,v2=y*j;
		if(v1+v2>d)continue;
		ans=min(ans,abs(t-(a*v1+b*v2)/(v1+v2)));
	}
	printf("%.9f\n",ans);
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

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

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    string s;
    cin >> s;

    int ans = s.size() - 1;
    set<char> A(ALL(s));
    for (char ch : A) {
        int cnt = 0, res = 0;
        for (char c : s) {
            if (c == ch) {
                res = max(res, cnt);
                cnt = 0;
            } else {
                cnt++;
            }
        }
        res = max(res, cnt);

        ans = min(ans, res);
    }
    cout << ans << endl;

    return 0;
}


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

int main(void){
    int x,a,b;

    cin>>x>>a>>b;

    if(abs(a-x)>abs(b-x))
        cout<<"B"<<endl;
    else
        cout<<"A"<<endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int book[20][20];
int k[20];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int res=INFI;
    int n=read(),m=read(),x=read();
    for(int i=1;i<=n;i++) for(int j=0;j<=m;j++) book[i][j]=read();
    for(int i=0;i<=(1<<n)-1;i++){
        memset(k,0,sizeof(k));
        int ans=0;
        for(int j=1;j<=n;j++){
            if(((1<<(j-1))&i)!=0){
                ans+=book[j][0];
                for(int kk=1;kk<=m;kk++) k[kk]+=book[j][kk];
            }
        }
        bool ok=1;
        for(int i=1;i<=m;i++) if(k[i]<x) ok=0;
        if(ok==1) res=min(res,ans);
    }
    if(res==INFI) cout<<-1<<endl;
    else cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e3 + 5);
const int LOG = (int)(20);

lli H, W, h, w, ar[N][N], tot;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> H >> W >> h >> w;
	if(H % h == 0 && W % w == 0) {
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= H; i++)
		for(int j = 1; j <= W; j++)
			ar[i][j] = -1000;
	if(H % h != 0) {
		for(int i = 1; i <= H; i += h)
			for(int j = 1; j <= W; j++)
				ar[i][j] = 1000 * (h - 1) - 1;
	}
	else if(W % w != 0) {
		for(int i = 1; i <= H; i++)
			for(int j = 1; j <= W; j += w)
				ar[i][j] = 1000 * (w - 1) - 1;
	}
	for(int i = 1; i <= H; i++, cout << endl)
		for(int j = 1; j <= W; j++)
			cout << ar[i][j] << spc;
}

Measured memory_bytes: 5760
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		long A = input.nextLong();
		long B = input.nextLong();
		long X = input.nextLong();
		long L = 0;
		long R = 0; //Smallest and largest numbers in [A,B] that are divisible by x
		long ans = 0;
		if (A%X==0) L=A;
		else {
			L=A/X;
			L++; //Converting to ceil division
			L*=X;
		}
		if (B%X==0) R=B;
		else {
			R=B/X;
			R*=X; //Floor division for accurate upper bound within [A,B] range
		}
		long possible = R-L;
		ans+=possible/X;
		ans++; //Need to include lowerbound of range as well
		System.out.println(ans);
	}	
}

Measured memory_bytes: 23764
#include <iostream>
#define rep(i, n) for(int i=0;i<n;i++)
#define N 9
#define SQRTN 3
#define LIMIT 100
using namespace std;

int limit;
int searchV[4][2] = {{0, 1},{1, 0},{0, -1},{-1, 0}};

struct Board{
  int b[N], h;
  int calcHeust(void){
    h = 0;
    for(int i = 0; i < SQRTN; i++){
      for(int j = 0; j < SQRTN; j++){
        if(b[i*SQRTN + j] == N-1) continue;
        h += abs(b[i*SQRTN + j]/SQRTN-i) + abs(b[i*SQRTN + j]%SQRTN-j);
      }
    }
    return h;
  }
};

void printBoard(Board b){
    rep(i, SQRTN){
     rep(j, SQRTN){
       cout << b.b[i*SQRTN + j];
     }
     cout << endl;
    }
}


Board currentState;

bool dfs(int depth, int prev, int cbX, int cbY){
  currentState.calcHeust();
  if ( currentState.h == 0) return true;
  if ( depth + currentState.h > limit ) return false;
  
  for (int d = 0 ; d < 4 ; d++ ){
    int sx = cbX + searchV[d][0];
    int sy = cbY + searchV[d][1];
    if ( abs(d - prev) == 2 ) continue;
    if ( sx < 0 || sy < 0 || sx >= SQRTN || sy >= SQRTN) continue;

    swap(currentState.b[cbY*SQRTN + cbX], currentState.b[sy*SQRTN + sx]);
    if (dfs(depth+1, d, sx, sy)) return true;
    swap(currentState.b[cbY*SQRTN + cbX], currentState.b[sy*SQRTN + sx]);
  }
  
  return false;
}

int idastar(Board in, int px, int py){
  for (limit=0;limit < LIMIT;limit++){
    currentState = in;
    if (dfs(0, 100, px, py)) return limit;
  }
  return -1;
}

int main(void){
  Board init;
  int p0x, p0y;
  rep(i, N){
    cin >> init.b[i];
    if (init.b[i]==0){
      init.b[i] = N;
      p0y = i/SQRTN;
      p0x = i%SQRTN;
    }
    init.b[i]--;
  }
  cout << idastar(init, p0x, p0y) << endl;;
}



Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

const int N = 103;
int h, w;
char a[N][N];

void input() {
  scanf("%d %d", &h, &w);
  forn(i, 0, h) {
    forn(j, 0, w) {
      scanf(" %c", &a[i][j]);
    }
  }
}

void solve() {
  forn(i, 0, h) {
    bool bad = true;
    forn(j, 0, w) {
      if (a[i][j] == '#')
        bad = false;
    }
    if (bad) {
      forn(j, 0, w) {
        a[i][j] = 'x';
      }
    }
  }
  forn(i, 0, w) {
    bool bad = true;
    forn(j, 0, h) {
      if (a[j][i] == '#')
        bad = false;
    }
    if (bad) {
      forn(j, 0, h) {
        a[j][i] = 'x';
      }
    }
  }

  forn(i, 0, h) {
    bool nl = false;
    forn(j, 0, w) {
      if (a[i][j] != 'x') {
        printf("%c", a[i][j]);
        nl = true;
      }
    }
    if (nl)
      printf("\n");
  }
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
//  freopen("output", "w", stdout);
//  gen();
#endif
  input();
  solve();
  return 0;
}


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

int main() {
  int N, sec, count = 0;
  cin >> N;
  vector<int> vec(N);
  vector<int> flag(N, 0);

  //配列の取得　2の添字の取得
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    vec.at(i)--;
    if (vec.at(i) == 1) {
      sec = i;
    }
  }

  //一番目を押下で光るのは…
  int r = vec.at(0);
  if (r == 1) {
    cout << 1 << endl;
  } else {
    flag.at(r) = 1;
    count++;
    //次に光ってるとこを押して光るのは
    while (true) {
      r = vec.at(r);
      if (r == 1) {
        count++;
        cout << count << endl;
        break;
      } else if (flag.at(r) == 1) {
        cout << -1 << endl;
        break;
      } else {
        flag.at(r) = 1;
        count++;
      }
    }
  }
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,C;
ll s[101010],t[101010],c[101010];
ll imos[101010];

int main(){
	cin>>n>>C;
  rep(i,n){
    cin>>s[i]>>t[i]>>c[i];
    c[i]--;
  }
  rep(i,n){
    imos[s[i]-1]^=(1<<c[i]); imos[t[i]]^=(1<<c[i]);
  }
  rep(i,101010)imos[i+1]^=imos[i];
  ll res=0;
  rep(i,101010)maxch(res,bcnt(imos[i]));
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3328
def main():
    h,w = map(int,input().split())
    if h == 1 or w == 1:
      print(1)
      exit()
    if w%2==0:
        ans = h*w//2
    else:
        if h%2 == 0:
            ans = h*w//2
        else:
            ans = (h-1)*w//2+(w//2+1)
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>


using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = 1000000000 + 7;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}



ll S(ll a) {
	ll ret = a % 10;
	ll n = a;
	n /= 10;
	while (n != 0) {

		ret += n % 10;
		n /= 10;
	}
	return ret;
}



ll pow(ll a, ll b) {


	if (b == 0) return 1;

	if (a % 2 == 1) {
		a * pow(a, b - 1);
	}
	else {
		ll ret = pow(a, b / 2);
		return ret * ret;
	}
}

ll A[100005];

int main() {
	int K, N;
	int pos;
	cin >> N >> K;

	rep(i, N) {

		cin >> A[i];

		if (A[i] == 1) {
			pos = i+1;
		}

	}

	ll ans = inf;
	ll left = 0, right = pos;
	ll val = 1;
	for (int i = 0; i < K; i++) {
		right = min(pos + i, N);
		left = max(right-K+1, 1);


		
			val += (N - right) / (K - 1);
			val += (left - 1) / (K - 1);

			if ((N - right) % (K - 1) != 0)
				val += 1;
			if ((left - 1) % (K - 1) != 0)
				val += 1;
		

		ans = min(ans, val);
		val = 1;
	}
	




	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define all(hoge) (hoge).begin(),(hoge).end()
constexpr ll INF = 1LL << 61;
typedef vector<ll> Array;
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; }

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

	ll n;
	cin >> n;
	vector s(2, vector<string>(n));//元の文字列と反転した文字列
	Array cost(n);
	REP(i, n)cin >> s[0][i] >> cost[i];
	REP(i, n)s[1][i] = s[0][i], reverse(all(s[1][i]));

	//ダイクストラ
	using T = tuple<ll, string, bool>;//コスト、文字列、反転しているかどうか
	map<pair<string, ll>, ll> mp;
	priority_queue<T, vector<T>, greater<T>> que;
	auto push = [&](ll c, string v, ll f) {
		if (mp.count({ v,f }) == 0 || mp[{v, f}] > c)que.push({ c,v,f }), mp[{v, f}] = c;
	};
	ll ans = INF;
	auto pcheck = [&](string& s) {
		REP(i, s.size() / 2)if (s[i] != s[s.size() - 1 - i])return false;
		return true;
	};
	REP(i, n) push(cost[i], s[0][i], 1);
	while (que.size()) {
		auto [c, v, flip] = que.top();
		que.pop();
		if (mp[{v, flip}] < c || ans <= c)continue;
		if (pcheck(v) == true) {
			chmin(ans, c);
			continue;
		}
		REP(i, n) {
			auto check = [&](string a, string b)->string {
				if (a.size() < b.size())swap(a, b);
				REP(i, b.size())if (a[i] != b[i])return "!";
				return a.substr(b.size());
			};
			auto ret = check(v, s[flip][i]);
			if (ret == "!")continue;
			push(c + cost[i], ret, flip ^ (v.size() <= s[flip][i].size()));
		}
	}
	if (ans == INF)cout << -1 << "\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll mod=998244353;

ll dp[303][100100],dp2[303][100100];
// dp[i][j]:Rがjとなる場合の数
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	dp[0][0]=1;
	dp2[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<100000;j++){
			if(dp[i][j]==0)continue;
			(dp[i+1][j]+=dp[i][j]*2)%=mod;
			(dp[i+1][j+a[i]]+=dp[i][j])%=mod;
			(dp2[i+1][j]+=dp2[i][j])%=mod;
			(dp2[i+1][j+a[i]]+=dp2[i][j])%=mod;
		}
	}
	ll cnt=0;
	for(int i=0;i<100000;i++){
		if(i>=(sum+1)/2){
			(cnt+=dp[n][i])%=mod;
		}
	}
	ll cnt1=0;
	if(sum%2==0){
		cnt1=dp2[n][sum/2];
	}
	ll ans=1;
	for(int i=0;i<n;i++){
		ans*=3;
		ans%=mod; // 補集合を引いていきたい
	}
	cout << (ans-3*cnt+3*cnt1+3*mod)%mod << endl;
	return 0;
}


Measured memory_bytes: 471296
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_word::<usize>();
    let mut remain_ingreds = parse_word::<i32>();

    let (ingred, min_ingred) = {
        let mut v = Vec::with_capacity(n);
        let mut min = 1000;

        for _ in 0..n {
            let i = parse_line::<i32>();
            min = cmp::min(min, i);
            v.push(i);
        }

        (v, min)
    };

    remain_ingreds -= ingred.iter().sum::<i32>();

    let donut_cnt = n + (remain_ingreds / min_ingred) as usize;
    println!("{}", donut_cnt);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    ll a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    ll c,k;
    int f=1;
    for(int i=n-1; i>=0; i--)
    {
        if(a[i]==a[i-1]&&f==1)
        {
            c=a[i];
            f=2;
            i-=2;
        }
        if(a[i]==a[i-1]&&f==2)
        {
            k=a[i];
            break;
        }
    }
    if(f==2)
        printf("%lld\n",c*k);
    else
        printf("0\n");
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
ll dp[200000][3];

int main() {
  int n;
  cin >> n;
  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  rep(i, n) {
    rep(j, 3) {
      if (j == 0) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][1] + a[i]);
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][2] + a[i]);
      }
      if (j == 1) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][0] + b[i]);
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][2] + b[i]);
      }
      if (j == 2) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][0] + c[i]);
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][1] + c[i]);
      }
    }
  }
  ll ans = 0;
  rep(k, 3) maxs(ans, dp[n][k]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N,T,A;
    cin>>N>>T>>A;
    
    vector<int> H(N);
    
    int i;
    
    for(i=0;i<N;i++)cin>>H[i];
    
    double min=abs(A-(T-H[0]*0.006));
    int point;
    
    for(i=0;i<N;i++){
        if(min>=abs(A-(T-H[i]*0.006))){
            min=abs(A-(T-H[i]*0.006));
            point=i+1;
        } 
    }
    
    cout<<point<<endl;
    
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef uint64_t ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

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

    int n, k; ll L, R;
    cin >> n >> k >> L >> R;
    vll a(n);
    REP(i, n) cin >> a[i];

    map<int, vll> v1, v2;

    int half = n / 2;
    REP(i, 1 << half) {
        ll s = 0;
        int cnt = 0;
        REP(j, half) {
            if (i >> j & 1) {
                s += a[j];
                cnt++;
            }
        }
        v1[cnt].pb(s);
    }

    int remain = n - half;
    REP(i, 1 << remain) {
        ll s = 0;
        int cnt = 0;
        REP(j, remain) {
            if (i >> j & 1) {
                s += a[half + j];
                cnt++;
            }
        }
        v2[cnt].pb(s);
    }

    for (auto &e: v1) sort(ALL(e.se));
    for (auto &e: v2) sort(ALL(e.se));

    ll ans = 0;
    for(auto &e1: v1) {
        int k1 = e1.fi; auto& vv1 = e1.se;
        int k2 = k - k1;

        if (k2 < 0) continue;

        auto& vv2 = v2[k2];

        for(auto &e: vv1) {
            auto l = lower_bound(ALL(vv2), L - e);
            auto r = lower_bound(ALL(vv2), R - e + 1);
            ans += r - l;
        }
    }

    print(ans);

}



Measured memory_bytes: 23392
import collections
N,K=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
c = collections.Counter(L)
c=c.most_common()
ans=0
if len(c)>K:
  for i in range(len(c)-K):
    ans+=c[len(c)-i-1][1]
  print(ans)
else:
  print(0)

Measured memory_bytes: 44024