akhauriyash/Code-Regression huggingface dataset:
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

ll n, h, w;
P p[100000];
set<P> st,ext;
ll cs[10];

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

	REP(i, n){
		int x,y;
		cin >> y >> x;
		x--;y--;
		p[i] = MP(x, y);
		ext.insert(p[i]);
	}

	ll sum = 0;
	REP(i, n){
		FOR(dx, -2, 1)FOR(dy, -2, 1){
			int nx = p[i].first + dx, ny = p[i].second + dy;
			P t = MP(nx, ny);
			if(nx < 0) continue;
			if(ny < 0) continue;
			if(nx >= w - 2) continue;
			if(ny >= h - 2) continue;
			if(EXIST(st, t))continue;
			st.insert(t);

			int c = 0;
			REP(px, 3)REP(py, 3){
				int sx = nx + px, sy = ny + py;
				if(EXIST(ext, MP(sx, sy)))c++;
			}
			cs[c]++;
			sum++;
		}
	}

	cs[0] = (ll)(w-2) * (h-2) - sum;

	REP(i, 10){
		cout << cs[i] << endl;
	}
}


Measured memory_bytes: 47872
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> gates(M + 10);
  vector<int> cards(N + 10);

  for(int i = 0;i < M;++i)
  {
    cin >> gates[i].first >> gates[i].second;
  }
  for(int l = 0;l < N;++l)
  {
    cards[l] = l + 1;
  }

  int ans = 0;
  pair<int,int> anspair = {0,1000000};
  
  for(int j = 0;j < M;++j)
  {
    anspair.first = max(anspair.first, gates[j].first);
    anspair.second = min(anspair.second, gates[j].second);
  }

  for(int k = 0;k < N;++k)
  {
    if(anspair.first <= cards[k] && cards[k] <= anspair.second)ans++;
  }
  
  cout << ans << endl;

  return 0;
}


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

int findSomeofDigits ( int n ){
  int sum = 0;
  while ( n > 0 ){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main (){
  int N,A,B;
  cin >> N >> A >> B;
  
  int total = 0;
  for ( int i = 1; i <= N; i++){
    int sum = findSomeofDigits(i);
    if ( sum >= A && sum <= B ){
      total += i;
    }
  }
  
  cout << total << endl;
  
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;

  int ret = 0;
  REP(i, s.size()) {
    if(ret == 0 && s[i] == 'C') ret = 1;
    if(ret == 1 && s[i] == 'F') ret = 2;
  }
  if(ret == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, k): (usize, usize) = parse!(it, 2);
    let p: Vec<usize> = parse!(it, n);
    let mut ids = std::collections::HashSet::new();
    let mut ret = n - k + 1;
    let mut count = 1;
    for i in 1..n {
        if p[i - 1] < p[i] {
            count += 1;
        } else {
            count = 1;
        }
        if count >= k {
            ids.insert(i);
        }
    }
    if ids.len() > 0 {
        ret -= ids.len() - 1;
    }
    let mut minq = std::collections::VecDeque::new();
    let mut maxq = std::collections::VecDeque::new();
    let pushmin = |x, i, minq: &mut std::collections::VecDeque<_>| {
        while minq.len() > 0 && minq[minq.len() - 1] > (x, i) {
            minq.pop_back().unwrap();
        }
        minq.push_back((x, i));
        if i > k && minq[0].1 < i - k {
            minq.pop_front().unwrap();
        }
        minq[0].1
    };
    let pushmax = |x, i, maxq: &mut std::collections::VecDeque<_>| {
        while maxq.len() > 0 && maxq[maxq.len() - 1] < (x, i) {
            maxq.pop_back().unwrap();
        }
        maxq.push_back((x, i));
        if i > k && maxq[0].1 < i - k {
            maxq.pop_front().unwrap();
        }
        maxq[0].1
    };
    for i in 0..k {
        pushmin(p[i], i, &mut minq);
        pushmax(p[i], i, &mut maxq);
    }

    for l in 0..(n - k) {
        let r = l + k;
        let mini = pushmin(p[r], r, &mut minq);
        let maxi = pushmax(p[r], r, &mut maxq);
        if ids.contains(&r) {
            continue;
        }
        if mini == l && maxi == r {
            ret -= 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edges{
    ll u,v,w;
    void print(){
        cout<<u<<" "<<v<<" "<<w<<"\n";
    }
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<edges> a;
    ll l;cin>>l;
    ll n=20;
    for(ll i=2;i<=n-1;i++){
        a.push_back({i-1,i,0});
        a.push_back({i-1,i,(1ll<<(i-2))});
    }
    ll w=0;
    for(ll i=n-1;i>=1;i--){
        ll cur = (1ll<<(i-1));
        while(l>=cur){
            a.push_back({i,n,w});
            l-=cur;
            w+=cur;
        }
    }
    cout<<n<<" "<<a.size()<<"\n";
    for(auto &ele:a)ele.print();
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int> > v;
  while(N--){
    int a,b;
    cin>>a>>b;
    v.emplace_back(b,a);
  }
  sort(begin(v),end(v));
  priority_queue<int> in;
  priority_queue<int,vector<int>,greater<int> > out;
  long long s=0;
  for(int i=100000;i>=0;i--){
    while(!v.empty()&&v.back().first==i){
      out.push(v.back().second);
      v.pop_back();
    }
    while(!in.empty()&&!out.empty()&&in.top()>out.top()){
      s+=-in.top()+out.top();
      out.push(in.top());
      in.push(out.top());
      out.pop();
      in.pop();
    }
    while(!out.empty()){
      if(i*1LL*(in.size()+1)<s+out.top())break;
      s+=out.top();
      in.push(out.top());
      out.pop();
    }
  }
  cout<<in.size()<<endl;
}

  

Measured memory_bytes: 7824
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define dump(x) cout << #x << " = " << (x) << endl

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

    int s;
    cin >> s;

    int now = s;
    vector<int> v;
    v.pb(s);

    bool flag = true;

    while (flag) {
        int newnum;
        if (now % 2 == 0) {
            newnum = now / 2;
        } else {
            newnum = now * 3 + 1;
        }

        auto it = find(v.begin(), v.end(), newnum);
        if (it != v.end()) {
            flag = false;
        }
        v.pb(newnum);
        now = newnum;
    }

    cout << v.size() << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
struct Node{
    int x,y,id;
}p[max_n];
struct edge{
    int u,v,w;
    bool operator <(edge e){
        return w<e.w;
    }
}edge[max_n];
int tot;
int par[max_n];
int findpar(int x){
    return x==par[x]?x:par[x]=findpar(par[x]);
}
int n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    sort(p+1,p+n+1,[&](Node p1,Node p2){return p1.x<p2.x;});
    for(int i=1;i+1<=n;i++){
        edge[++tot]={p[i].id,p[i+1].id,p[i+1].x-p[i].x};
    }
    sort(p+1,p+n+1,[&](Node p1,Node p2){return p1.y<p2.y;});
    for(int i=1;i+1<=n;i++){
        edge[++tot]={p[i].id,p[i+1].id,p[i+1].y-p[i].y};
    }
    for(int i=1;i<=n;i++)par[i]=i;
    sort(edge+1,edge+tot+1);
    int ans=0;
    for(int i=1;i<=tot;i++){
        int u=edge[i].u,v=edge[i].v,w=edge[i].w;
        u=findpar(u),v=findpar(v);
        if(u!=v){
            ans+=w;
            par[u]=v;
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 4224
n, m = map(int, input().split())
hs = list(map(int, input().split()))

ans = [1] * n

for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if hs[a] < hs[b]:
    ans[a] = 0
  elif hs[a] == hs[b]:
    ans[a] = 0
    ans[b] = 0
  else:
    ans[b] = 0

print(sum(ans))


Measured memory_bytes: 20112
#include <iostream>
#include <string>
#include <stack>
#include<algorithm>
#include <vector>

using namespace std;

typedef struct _Areas
{
    int left;
    int area;
} Areas;


int main(){
    string input;
    stack<int> s1;
    stack<Areas> s2;
    int sum = 0;
    cin >> input;

    for (int i = 0; i < input.length(); i++)
    {
        if(input[i] == '\\'){
            s1.push(i);
        } else if(input[i] == '/' && !s1.empty())
        {
            int j = s1.top(); s1.pop();
            int area = i - j;
            sum += area;
            int tmp_sum = area;

            while (!s2.empty() && s2.top().left > j){
                tmp_sum += s2.top().area;
                s2.pop();
            } 
            Areas areas = {j, tmp_sum};
            s2.push(areas);
        }
    }

    vector<int> answer;
    while(s2.size() > 0){
        answer.push_back(s2.top().area); 
        s2.pop();
    }
    reverse(answer.begin(), answer.end());

    cout << sum << endl;
    cout << answer.size();
    for(int i = 0; i < answer.size(); i++){
        cout << " " << answer[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define readl(_s) getline(cin, (_s));
#define boost() cin.tie(0); cin.sync_with_stdio(0)

const int MN = 10000005;

int n, a[MN];

int32_t main() {
    boost();

    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) a[j]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += i * a[i];
    printf("%lld\n", ans);

    return 0;
}

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

int main(){
 
  vector<int> haiku(3);
  int seven = 0, five = 0;
  
 for(int i = 0; i < 3; i++)
 {
   cin >> haiku.at(i);   
   if(haiku.at(i) == 7)
   {
     seven++;
   }else if(haiku.at(i) == 5){
     five++; 
   }
     
     }
 
  if(seven == 1 && five == 2){
  cout << "YES" << endl;
  }else{
   cout << "NO" << endl; 
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	
*/
int a, b, c, d;
int solve()
{
	const int lower = max(a, c);
	const int upper = min(b, d);
	return max(0, upper - lower);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	cin >> a >> b >> c >> d;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 892
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector <int> v(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        if (i % 2)
        {
            sum += v[i];
        }
        else
        {
            sum -= v[i];
        }
    }
    sum = abs(sum);
    cout << sum << " ";
    for (int i = 1; i < n; i++)
    {
        cout << v[i-1] * 2 - sum << " ";
        sum = v[i-1] * 2 - sum;
    }

    return 0;
}

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

int main() {
  long long n,min = 1000000000001;
  cin >> n;
  for(int i = 1;i <= sqrt(n);i++){
    long long b;
    if(n%i == 0){
      b = n/i;
      if(i+b <= min){
        min = i+b;
      }
    }
  }
  cout << min-2 << endl;
}


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

using namespace std;

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

int main() {
	bool num[30];
	memset(num, 0, sizeof(num));
	REP(i,28) {
		int tmp;
		cin >> tmp;
		num[tmp-1] = true;
	}

	REP(i,30) if (!num[i]) cout << i + 1 << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const ll Mod = 1e9 + 7;
const ll Nax = 110;
ll N;

///For Easy Code
#define rep(i,v)    for(ll i=0;i<v.size();++i)
typedef vector < ll > Row;
typedef vector < Row > Matrix;

///Zero Matrix
Matrix Zero(ll n,ll m)
{
    return Matrix( n , Row(m,0) );
}

///Identity Matrix
Matrix Identity(ll n)
{
    Matrix Res = Zero(n,n);
    rep(i,Res)  Res[i][i] = 1;
    return Res;
}

///Matrix Multiplication
Matrix Muliply(const Matrix &a,const Matrix &b)
{
    Matrix Res=Zero( a.size() , b[0].size() );

    rep(i,a) rep(k,a[0])    if(a[i][k])
        rep(j,b[0])
            Res[i][j] = ( Res[i][j] + a[i][k]*b[k][j] )%Mod;

    return Res;
}

///Matrix Power
Matrix Power(const Matrix &a,ll k)
{
    if(k==0)    return Identity( a.size() );
    if(k&1)     return Muliply( a , Power(a,k-1) );
    return Power( Muliply(a,a) , k>>1LL );
}

ll Calc(ll k,Matrix Transition)
{
    Matrix Initial = Zero(N,N);

    for(ll i=0;i<N;i++) Initial[0][i] = 1;

    Matrix Transition_k = Power(Transition,k);

    Matrix Res = Muliply( Initial , Transition_k );

    ll Ans = 0;

    for(ll i=0;i<N;i++) Ans = ( Ans + Res[0][i] )%Mod;

    return Ans;
}

int main()
{
    ll k;   cin>>N>>k;

    Matrix a = Zero(N,N);

    for(ll i=0;i<N;i++)
        for(int j=0;j<N;j++)
            scanf("%I64d",&a[i][j]);

    cout<<Calc(k,a);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	
	if (N == 3 || N == 5 || N == 7) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=55,mod=1e9+7;
int fac[maxn],ifac[maxn],f[maxn][maxn],g[maxn][maxn<<1];
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
int main(){
	int n=read();
	fac[0]=1;
	REP(i,1,n) fac[i]=(ll)i*fac[i-1]%mod;
	ifac[n]=ksm(fac[n],mod-2);
	DREP(i,n,1) ifac[i-1]=(ll)i*ifac[i]%mod;
	f[1][0]=f[1][1]=n;
	REP(i,1,n){
		REP(l,0,0) REP(j,-i,l) if(g[i][j+n] && (j+l)%2==0) add(f[i+l][abs(j+l)/2],(ll)g[i][j+n]*ifac[n-i-l]%mod*ifac[l]%mod);
		REP(j,0,i) if(f[i][j]) REP(k,0,n-i) add(g[i+k][j-k+n],(ll)f[i][j]*fac[n-i]%mod*ifac[k]%mod);
		REP(l,1,n-i) REP(j,-i,l) if(g[i][j+n] && (j+l)%2==0) add(f[i+l][abs(j+l)/2],(ll)g[i][j+n]*ifac[n-i-l]%mod*ifac[l]%mod);
	}
	/*
	REP(i,1,n-1) REP(j,0,i) if(f[i][j]) REP(k,0,n-i) REP(l,0,n-i-k)
		if(k+l && !((k+l+j)&1) && k+l>=j)
			add(f[i+k+l][abs(l-k+j)/2],(ll)f[i][j]*C[n-i][k+l]%mod*C[k+l][k]%mod);
	*/
	printf("%d\n",f[n][0]);
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n;
vector<vector<pair<int, ll>>> p;
vector<int> col;

void dfs(int i, int c) {
  if (col[i] >= 0) {
    return;
  }
  col[i] = c;
  for (auto &v : p[i]) {
    dfs(v.first, (c + v.second) % 2);
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n;
  p.resize(n);
  col.resize(n);
  for (int i = 0; i < n; i++) col[i] = -1;
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    p[u].emplace_back(v, w);
    p[v].emplace_back(u, w);
  }
  dfs(0, 0);
  for (int i = 0; i < n; i++) cout << col[i] << endl;
  return 0;
}


Measured memory_bytes: 8960
/*input
57 38
60 84
*/
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

fn main() {
    let mut v: Vec<u64>;
    let mut input: String;
    loop {
        input = format!("");
        match std::io::stdin().read_line(&mut input) {
            Ok(0) => {
                break;
            }
            Ok(_) => {
                v = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().expect(""))
                    .collect();
                println!("{}", gcd(v[0], v[1]));
            }
            Err(_) => {}
        };
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; int a;
  string ans;
  ans="No";
  scanf ("%d", &n);
  a=(int)log10(double(n))+1;
  for (int i=1;i<a+1; i++){
    int k,k1;
    k1=(int)pow(10,(double)i);
  k=n%(k1);
  if ((k*10/k1)==9){
    ans="Yes";
    break;
  }
  }
    
  cout<<ans;    

return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
  char a[51];
  char b[51];
  int i = 0;
  scanf("%s", a);
  scanf("%s", b);
  while (1) {
    if (a[i] == '\0') break;
    printf("%c", a[i]);
    if (b[i] == '\0') break;
    printf("%c", b[i++]);
  }
  return 0;
}

Measured memory_bytes: 128
loop {
  h, w = gets.chomp.split(' ').map { |i| i.to_i }
  if h == 0 and w == 0 then break
  else
    (1..h).each {
      (1..w).each {
        print '#'
      }
      print "\n"
    }
    print "\n"
  end
}

Measured memory_bytes: 6104
#include<iostream>

//??°??¢(0??§???????????????1??§??????)
int place[21][21]={};

//??????????????°??¨??????????????°
int N,M;

//???????????????
int mass;
char dir[10];

int main() {
	while (true) {
		//?????????
		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 21; j++) {
				place[i][j] = 0;
			}
		}
		//????????\???
		std::cin>>N;
		if(N==0)break;
		for (int i = 0; i < N; i++) {
			int x,y;
			std::cin>>x>>y;
			place[y][x]=1;
		}
		//????????????(?????????(10,10))
		int rX=10;
		int rY=10;
		std::cin >> M;
		for (int i = 0; i < M; i++) {
			std::cin >> dir >> mass;
			//???????????????
			int dirX,dirY;
			switch (dir[0]) {
			case 'N': dirX=0; dirY=1 ; break;
			case 'S': dirX=0; dirY=-1; break;
			case 'E': dirX=1; dirY=0 ; break;
			case 'W': dirX=-1;dirY=0 ; break;
			}
			for (int i = 0; i < mass; i++) {
				rX+=dirX;
				rY+=dirY;
				place[rY][rX]=0;
			}
		}
		//place??¨??????0??????ok
		bool flag=true;
		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 21; j++) {
				if(place[i][j]!=0)flag=false;
			}
		}
		if (flag)std::cout << "Yes" << std::endl;
		else     std::cout << "No"  << std::endl;
	}


	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>

int main (){
    int yyyy,mm,dd;
  	char temp,temp2;
  
  scanf("%d %c %d %c %d",&yyyy,&temp,&mm,&temp2,&dd);
  
  if(mm <= 4){
    printf("Heisei");
  }else{
    printf("TBD");
  }
 
    return 0;
  
}



Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextLong()
    println(problem166d(x))
}

fun problem166d(x: Long): String {
    for (i in 0..10000) {
        for (j in -1000..1000) {
            if (Math.pow(i.toDouble(), 5.toDouble()).toLong() - Math.pow(j.toDouble(), 5.toDouble()).toLong() == x) {
                return "$i $j"
            }
        }
    }
    return ""
}

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

using namespace std;

class UnionFind {
	vector<int> data;
	public:
	int independentSet;
	UnionFind(int size) : data(size, -1), independentSet(size) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			independentSet--;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

class Solution {
public:
	void solve() {
		int n, m, k;
		cin >> n >> m >> k;
		vector<pair<int, int>> ab(m), cd(k);
		for(int i=0; i < m; i++)cin >> ab[i].first >> ab[i].second;
		for(int i=0; i<k; i++)cin >> cd[i].first >> cd[i].second;
		UnionFind uf(n+1);
		for(int i=0; i < m; i++)uf.unionSet(ab[i].first, ab[i].second);
		vector<int> ans(n+1, 0);
		for(int i=0; i < n; i++)ans[i+1] = uf.size(i+1);
		for(int i=0; i < m; i++)ans[ab[i].first]--, ans[ab[i].second]--;
		for(int i=0; i < k; i++)if(uf.findSet(cd[i].first, cd[i].second))ans[cd[i].first]--, ans[cd[i].second]--;
		for(int i=0; i<n; i++)cout << ans[i+1]-1 << " ";
		cout << "\n";
		
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main() {
	int n,y,res,a,b,c;
	cin>>n>>y;
	for(int i=0;i<=2000;i++){
		for(int j=0;j<=2000;j++){
			if(i+j<=n){
			if(10000*i+5000*j+1000*(n-i-j)==y){
				res++;
				a=i;
				b=j;
				c=n-i-j;
			}
			}
		}
	}
	if(res!=0){
		cout<<a<<" "<<b<<" "<<c<<endl;
	
	}
	else{
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

vector<ll> c;
vector<ll> ab;

ll cnt(ll n) {
    ll ret = 0;
    auto r = lower_bound(all(ab),n-c[0]);
    ret += ab.end()-r;
    rep2(i,1,c.size()) {
        ll l = c[i];
        while(true) {
            if(r == ab.begin()) break;
            if(*(r-1) >= n-l) r--;
            else break;
        }
        ret += ab.end()-r;
    }
    return ret;
}

ll solve(ll k,ll l = 0,ll r = 30000000001) {
    if(r-l == 1) return l;
    ll mid = (l+r)/2;
    ll n = cnt(mid);
    if(n >= k) return solve(k,mid,r);
    else return solve(k,l,mid);
}

int main() {
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y);
    vector<ll> oc(z),oab;
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> oc[i];
    rep(i,x) rep(j,y) oab.pb(a[i]+b[j]);
    sort(all(oab));
    for(int i = max(0,int(oab.size()-k)); i < oab.size(); i++) ab.pb(oab[i]);
    sort(all(oc));
    for(int i = max(0,int(oc.size()-k)); i < oc.size(); i++) c.pb(oc[i]);
    rep2(i,1,k+1) cout << solve(i) << endl;
}

Measured memory_bytes: 10480
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#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;
using ll = long long;
using ld = long double;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
int main(){
    string S;
    cin >> S;
    S == "ABC" ? cout << "ARC" << endl : cout << "ABC" << endl;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
}


Measured memory_bytes: 21972
//Code By PMD
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define whatis(a) cout << #a " is " << (a) << endl;
using namespace std;

typedef long long i64;
const int N = 100005;
const i64 mod = 1e9+7;
const i64 inf = 1e18+7;

void solve() {
	int a , b ;
	cin >> a >> b;
	cout << max(a + b , max (a - b, a * b));
}
main(){
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}
//Code By PMD




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, X; cin >> N >> X;
    vector<int> m(N);
    for(int i = 0; i < N; i++)
    {
        cin >> m.at(i);
    }
    int sum = 0;
    for(int i = 0; i < N; i++)
    {
        sum += m.at(i);
    }
    int min = m.at(0);
    for(int i = 1; i < N; i++)
    {
        if(min > m.at(i))
        {
            min = m.at(i);
        }
    }
    cout << N + (X - sum)/min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[60][60], f[120], g[101000], h[10100], counto = 0, ans = 0, x[100] = {}, y, z;
int64_t ab[10000] = {}, abc = 0, abcd = 0;
pair<int, int>manji[101] = {};
char rikka, toka[150][150] = {};
vector<int> train,code;
vector<char>aka,ao;
string saya, homu, kyok, mami[108], mado[100];
bool gg;
bool exist[1000];
int main() {
	cin >> a>>b>>c;
	for (int i = 1; a >= b+c*2; i++) {
		a = a - b;
		a = a - c;
		counto++;
	}
	cout << counto << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    digits = [-1 for _ in range(n)]
    for i in range(m):
        s, c = rli()
        s -= 1
        if digits[s] != -1 and digits[s] != c:
            print(-1)
            return
        digits[s] = c
    if n == 1:
        if digits[0] == -1:
            print(0)
        else:
            print(digits[0])
        return
    if digits[0] == 0:
        print(-1)
        return
    elif digits[0] == -1:
        digits[0] = 1
    for i in range(n):
        if digits[i] == -1:
            digits[i] = 0
    print("".join(map(str, digits)))
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    cout << "ABC" << N << endl;

    return 0;
}


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

int main(){
  int n, count=0;
  string S;
  cin >> n >> S;

  for(int i=0;i<n;i++){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        i++;
        if(S[i+1]=='C'){
          i++;
          count++;
        }
      }
    }
  }
 
  cout << count << endl;
  return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>

int main()
{
    long long n{}, k{};
    std::cin >> n >> k;

    auto result = 1;
    while (n >= k) {
        n /= k;
        result++;
    }
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;

map<ll, ll> mp;

ll calc(ll hp) {
    if (hp == 1) return 1;
    return 1 + 2 * calc(hp / 2);
}

int main() {
    ll H;
    cin >> H;
    cout << calc(H) << endl;

    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int k = 0;
	string c = "CODEFESTIVAL2016";
	for(int i = 0;i < 16;i++)
	{
		if(s.at(i) != c.at(i))
		{
			k++;
		}
	}
	cout << k << endl;
	return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main (){
    int N,a,b,SUM = 999999;
    cin >> N;
    for(a=1;a<=(N+1)/2;a++){
        b = N-a;
        if(findSumOfDigits(a)+findSumOfDigits(b) <= SUM ){
            SUM = findSumOfDigits(a)+findSumOfDigits(b);
        }
    }
    cout << SUM << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  long long ret = 0;
  int now = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int l = 0, r = 0; l < n; l++) {
    if (r < l) r = l;
    for (; r <= n; r++) {
      if (r == n || now & a[r]) break;
      now ^= a[r];
      ret += (r + 1) - l;
    }
    now ^= a[l];
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1024
// Problem : D - Anything Goes to Zero
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
 int g0(int N)
 {
 	// bug(N);
 	int ans=0;
 	while(__builtin_popcount(N)!=0)
 	{
 		ans++;
 		N%=__builtin_popcount(N);
 	}
 	
 	return ans;
 }
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	string str;
	cin>>str;
	int c=0;
	F0R(x,N)
	{
		if(str[x]=='1')c++;
	}
	// bug(c);
	vi b,d;
	b.pb(1%(c-1==0?1:c-1));
	d.pb(1%(c+1));
	F0R(x,N-1)
	{
		b.pb((b.back()*2)%(c-1==0?1:c-1));
		d.pb((d.back()*2)%(c+1));
		// bug(b.back());
		// bug(d.back());
		// cout<<nl;
	}
	int vb=0,vd=0;
	reverse(all(str));
	F0R(x,N)
	{
		if(str[x]=='1')
		{
			vb=(vb+b[x])%(c-1==0?1:c-1);
			vd=(vd+d[x])%(c+1);
		}
	}
	// bug(vb);
	// bug(vd);
	vi res;
	F0R(x,N)
	{
		int val; 
		if(str[x]=='1')
		{
			if(c==1)
			{
				res.pb(0);
				continue;
			}
			val=(vb-b[x]+c-1)%(c-1==0?1:c-1);
		}
		else
		{
			// bug(d[x]);
			val=(vd+d[x])%(c+1);
		}
		// cout<<g0(val)<<nl;
		res.pb(1+g0(val));
	}
	F0Rd(x,N)
		cout<<res[x]<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

int main() {
    int a, b;
    cin >> a >> b;
    int plug = 1, cnt = 0;
    while (1)
    {
        if (b <= plug) break;
        plug--;
        plug += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int c[201], temp[201];
int n, m, k;

void riffle(){
	for (int i = 0; i < 2*n; i += 2){
		temp[i] = c[i/2];
	}
	for (int i = 0; i < 2*n; i += 2){
		temp[i+1] = c[n+i/2];
	}
	for (int i = 0; i < 2*n; i++){
		c[i] = temp[i];
	}
}

void cut(){
	for (int i = 0; i < 2*n-k; i++){
		temp[i] = c[k+i];
	}
	for (int i = 0; i < 2*n; i++){
		temp[2*n-k+i] = c[i];
	}
	for (int i = 0; i < 2*n; i++){
		c[i] = temp[i];
	}
}

int main(){
	for (int i = 0; i < 201; i++){
		c[i] = i+1;
	}
	scanf("%d%d", &n, &m);
	while (m--){
		scanf("%d", &k);
		if (k == 0)
			riffle();
		else 
			cut();
	}
	for (int i = 0; i < 2*n; i++){
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 3184
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[200002];


int _left[200002], _right[200002];
void init() {
	{
		long long sum = 0;
		int c = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i] == 0)c += 2;
			else if (a[i] % 2)c++;
			sum += a[i];
			if (c > sum) {
				c = sum;
			}
			_left[i] = c;

		}
		for (int i = 1; i <= n; i++) {
			_left[i] = min(_left[i], _left[i - 1] + (a[i] % 2 == 0));
		}
	}
	{
		long long sum = 0;
		int c = 0;
		for (int i = n; i >= 1; i--) {
			if (a[i] == 0)c += 2;
			else if (a[i] % 2)c++;
			sum += a[i];
			if (c > sum) {
				c = sum;
			}
			_right[i] = c;
		}
		for (int i = n; i >= 1; i--) {
			_right[i] = min(_right[i], _right[i + 1] + (a[i] % 2 == 0));
		}
	}
}


int f() {
	int ret = 2 * n;

	for (int i = 1; i <= n; i++) {
		ret = min(ret, _left[i - 1] + _right[i]);
	}

	return ret;
}


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

	cin >> n;
	rep(i, n)cin >> a[i + 1];


	init();
	cout << f() << endl;


	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
string s[200010];
int main() {
	int n,ans=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9892
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


#define MAX_V 300005

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>


int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V*3, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main(){
  int m;
  cin >> V >> m;
  rep(i, m){
    int u, v;
    cin >> u >> v;
    u--; v--;
    edge e = {v+V, 1};
    edge e2 = {v+V*2, 1};
    edge e3 = {v, 1};
    G[u].push_back(e);
    G[u+V].push_back(e2);
    G[u+2*V].push_back(e3);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;
  dijkstra(s);
  if(d[t]==INF){
    cout << "-1" << endl;
  } else {
    cout << d[t]/3 << endl;
  }
  return 0;
}


Measured memory_bytes: 21176
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(A>=B){
            for(long i=1; i<=Math.pow(10, 10)/A; i++){
                if(A*i%A==0 && A*i%B==0){
                    System.out.println(A*i);
                    break;
                }
            }
        }
        else if (A<B){
            for(long i=1; i<=Math.pow(10,10)/B; i++){
                if(B*i%A==0 && B*i%B==0){
                    System.out.println(B*i);
                    break;
                }
            }
        }
    }
}

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

int main(void){
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> a;
	int prev = s[0];
	a.push_back(0);
	for(int i = 1; i < n; ++i){
		if(prev!=s[i]) a.push_back(i);
		prev = s[i];
	}
	a.push_back(n);
	int ans = 0;
	for(int i = 0; i < a.size(); ++i){
		int m = 2*k+1;
		if(s[a[i]] == '0'){
			m--;
		}
		ans = max(ans, ((m+i<a.size())?a[m+i]:n) - a[i]);
		// cout << a[m+i] - a[i] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    int a,b;
    cin>>a>>b;
    if(a+b==3){
        cout<<3;
    }
    else if(a+b==4){
        cout<<2;
    }
    else{
        cout<<1;
    }

    return 0;
             
    
}

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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n, m, k, res = 0;
	cin >> n >> m >> k;

	vector<int> a(n + 1), b(m + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int j = 1; j <= m; ++j) {
		cin >> b[j];
		b[j] += b[j - 1];
	}

	// for (int x : a)
	// 	cout << x << ' ';
	// cout << '\n';

	// for (int x : b)
	// 	cout << x << ' ';
	// cout << '\n';

	for (int i = 0; i <= n; ++i) {
		if (a[i] > k)
			continue;

		int target = k - a[i];
		int idx = lower_bound(b.begin(), b.end(), target) - b.begin();

		if (idx > m || b[idx] != target)
			--idx;

		// cout << a[i] << ' ' << target << ' ' << b[idx] << '\n';

		res = max(res, i + idx);
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long a;
	string s;
	cin>>a>>s;
	long long cur=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='.') continue;
		cur=cur*10+(s[i]-'0');
	}
	long long fans=(a*cur)/100;
	cout<<fans;
}


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

int main(){
	int n;
  	cin >> n;
  	vector<int> x(n), y(n);
  	rep(i, n) cin >> x[i] >> y[i];
  
  	auto dist = [&](int i, int j){
    	double dx = x[i] - x[j];
      	double dy = y[i] - y[j];
      	return sqrt(dx * dx + dy * dy);
    };
  
  	vector<int> p(n);
  	rep(i, n) p[i] = i;
  	double len = 0;
  	int cnt = 0;
  	do{
    	rep(i, n- 1){
        	len += dist(p[i], p[i+1]);
        }
      	cnt++;
    }while(next_permutation(p.begin(), p.end()));
  
  	double ans = len / cnt;
  	printf("%.10f\n", ans);
}

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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define ll long long int
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};



int main(){
    double n,d;
    cin>>n>>d;
    
    d = d*2+1;
    
    cout<<(int)ceil(n/d);
    return 0;
}


Measured memory_bytes: 256