akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }

};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main(){
  int x,y;
  cin>>x>>y;

  //条件外の計算
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  if(2*x<y || 2*y<x){
    cout<<0<<endl;
    return 0;
  }



//  cout<<x<<" "<<y<<endl;
  int a = 0;
  int b = 0;//aにはxを2引いた回数,bにはｙを2引いた回数
  mint count =(x+y)/3;
//  cout <<count<<endl;
  while(count!=0){

    if(x>y ||x==y){
//      cout<<"a"<<endl;
      a+=1;
      x-=2;
      y-=1;
    }
    else{
//      cout<<"b"<<endl;
      b+=1;
      x-=1;
      y-=2;
    }

    count-=1;
  }
  mint sum_a=1;
  mint sum_b=1;
  mint sum_ab=1;
  for(int i=1;i<=a;++i){
    sum_a*=i;
  }
  for(int i=1;i<=b;++i){
    sum_b*=i;
  }
  for(int i=1;i<=(a+b);++i){
    sum_ab*=i;
  }

  mint ans=sum_ab/(sum_a*sum_b);

//  cout<<a<<" "<<b<<endl;
//  cout<<x<<" "<<y<<endl;
  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int W,N,x[50000],sum[50001];
bool dp[50001];
int imos[50002];
bool can(int x){
	rep(i,N+1) dp[i]=false;
	dp[0]=true;
	imos[1]=1;
	for(int i=1;i<=N;i++){
		int lb=1,ub=i+1;
		while(ub-lb>1){
			int m=(ub+lb)/2;
			if(W-(sum[i]-sum[i-m])>=m-1) lb=m;
			else ub=m;
		}
		int r=lb;
		lb=1,ub=i+1;
		while(ub-lb>1){
			int m=(lb+ub)/2;
			if(W-(sum[i]-sum[i-m])<=(long long)(m-1)*x) ub=m;
			else lb=m;
		}
		int l=ub;
		if(imos[i-l+1]-imos[i-r]>0) dp[i]=true;
		imos[i+1]=imos[i]+(dp[i]?1:0);
	}
	for(int i=N;i>=0;i--){
		if(sum[N]-sum[i]+(N-1-i)>W) break;
		if(dp[i]) return true;
	}
	return false;
}
int main(){
	while(true){
		scanf("%d%d",&W,&N);
		if(W==0) return 0;
		rep(i,N) scanf("%d",x+i);
		rep1(i,N) sum[i]=sum[i-1]+x[i-1];
		int ub=W/2+1,lb=0;
		while(ub-lb>1){
			int m=(ub+lb)/2;
			if(can(m)) ub=m;
			else lb=m;
		}
		cout<<ub<<endl;
	}
}

Measured memory_bytes: 1828
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    if n > ((i+1)*2-1):
        b.append(n-((i+1)*2-1))
    else:
        b.append(((i+1)*2-1)-n)

a.sort()
b.sort()
if a==b:
    print((2**(n//2))%(10**9+7))
else:
    print(0)

Measured memory_bytes: 54892
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n;
    ll ans=0;

    cin >> n;

    vector<ll> a(n);
    ll sum_all = 0;

    for(auto&& x : a){
        cin >> x;
        sum_all=(sum_all+x)%MOD;
    }

    for(ll i=0; i<n; i++){
        sum_all -= a[i];
        if(sum_all<0)sum_all+=MOD;

        ll mul = (a[i]*sum_all)%MOD;
        ans = (ans+mul)%MOD;
    }
    
    cout << ans << endl;
 
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;

  ll A = 1, B = 1;
  for(int i = 0; i < N; i++){
    if(i == 0){
      cin >> A >> B;
    } else { 
      ll tmp1, tmp2; cin >> tmp1 >> tmp2;
      ll n; 
      if(A % tmp1 == 0){
        n = A / tmp1;
      } else { 
        n = A / tmp1 + 1;
      }

      if(B%tmp2 == 0){
        n = max(n, B / tmp2);
      } else { 
        n = max(n, B / tmp2 + 1);
      }

      A = n * tmp1;
      B = n * tmp2;
    }
  }
  cout << A + B << endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        sc.close();

        for (int i = 0; i < s.length(); i += 2) {
            System.out.print(s.charAt(i));

        }
    }
}

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

int H, W;
vector<vector<char>> S;

typedef pair<int,int> P;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

bool is_wall(P& p) {
  int i = p.first;
  int j = p.second;
  if ( i < 0 || i >= H || j < 0 || j >= W ) {
    return false;
  }
  return S.at(i).at(j) == '#';
}

int bfs(P& s) {
  queue<P> q;
  vector<vector<int>> d(H, vector<int>(W, INF));
  q.push(s);
  d.at(s.first).at(s.second) = 0;
  
  while ( q.size() ) {
    P p = q.front(); q.pop();
    rep(i,4) {
      int ni = p.first + dx.at(i);
      int nj = p.second + dy.at(i);
      if ( 0 <= nj && nj < W && 0 <= ni && ni < H && S.at(ni).at(nj) != '#'
          && d.at(ni).at(nj) == INF ) {
        q.push(make_pair(ni,nj));
        d.at(ni).at(nj) = d.at(p.first).at(p.second) + 1;
      }
    }
  }
  int ret = 0;
  int dd;
  rep(i,H) {
    rep(j,W) {
      dd = d.at(i).at(j);
      if ( ret < dd && dd < INF ) {
        ret = dd;
      }
    }
  }
  return ret;
}

P coord(int k) {
  int j = k % W;
  int i = (k-j)/W;
  return make_pair(i, j);
}

int main() {
  //input
  cin >> H >> W;
  S.resize(H, vector<char>(W));
  rep(i,H) {
    rep(j,W) {
      cin >> S.at(i).at(j);
    }
  }
  //calc
  int answer = 0;
  int V = H * W;
  for(int i = 0; i < V; i++) {
    P ip = coord(i);
    if ( is_wall(ip) ) {
      continue;
    }
    int dist = bfs(ip);
//    cout << "(" << ip.first << "," << ip.second << ") -> " << dist << endl;
    if ( answer < dist && dist < INF ) {
      answer = dist;
    }
  }
  //output
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#define FORi(N) for(int i = 0; i < N; ++i)
#define FORj(N) for(int j = 0; j < N; ++j)
#define FORk(N) for(int k = 0; k < N; ++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
int main() {
    ll n;
    cin >> n;
    vector<ll> p(n);
    FORi(n) {
        cin >> p[i]; 
    }
    ll num = 0;
    FORi(n-2){
        if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
            num++;
        }
        else if(p[i+2]>p[i+1]&&p[i+1]>p[i]){
            num++;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 888
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
$T = trim(fgets(STDIN));
//list($H,$W) =  explode(" ",trim(fgets(STDIN)));

$res=0;
for($i=0;$i<strlen($S);$i++) {
  if ($S[$i]==$T[$i]) $res++;
}
printf("%d\n",$res);


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int c[N][N],f[N][N],n,Mod,ans;
#define mul(x,y) (1ll*(x)*(y)%Mod)
inline int add(int x, int y)
{	return (x+y>=Mod?x+y-Mod:x+y);
}
inline int po(int x, int y, int M=Mod)
{
	int r=1;
	for(;y;y>>=1,x=1ll*x*x%M) if(y&1) r=1ll*r*x%M;
	return r;
}
int main()
{
	scanf("%d%d",&n,&Mod);
	for(int i=0;i<=n;++i) f[i][0]=c[i][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=i;++j)
		{
			c[i][j]=add(c[i-1][j],c[i-1][j-1]);
			f[i][j]=add(f[i-1][j-1],mul(f[i-1][j],j+1));
		}
	for(int i=0;i<=n;++i)
	{
		int tmp=mul(c[n][i],po(2,po(2,n-i,Mod-1))),res=0,bs=po(2,n-i);
		if(i&1) tmp=Mod-tmp;
		for(int j=0,k=1;j<=i;++j,k=mul(k,bs))
			res=add(res,mul(f[i][j],k));
		ans=add(ans,mul(tmp,res));
	}
	printf("%d\n",ans);
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 n,k;
vector<bool> checked(100000,false);
vector<int32> child(100000,0);
vector<vector<int32>> adjacent(100000);
int64 ans = 1;

void dfs(int32 x, int32 d){
    REP(i,adjacent[x].size()){
        if(!checked[adjacent[x][i]]){
            checked[adjacent[x][i]] = true;
            child[x]++;
            dfs(adjacent[x][i],d+1);
        }
    }
    REP(i,child[x]){
        if(d == 0){
            ans = ans * (k - 1 - i) % MOD;
        }else{
            ans = ans * (k - 2 - i) % MOD;
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    REP(i,n-1){
        int32 a,b;
        cin >> a >> b;
        a--;b--;
        adjacent[a].pb(b);
        adjacent[b].pb(a);
    }
    ans = k;
    checked[0] = true;
    dfs(0,0);
    // REP(i,n)cout << child[i] << endl;
    ANS(ans);
    return 0;
}

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

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

using namespace std;

int main(){
  int n;cin>>n;
  int c;cin>>c;
  int result=0;
  int t;

  rep(i,n-1){
    cin>>t;
    if(t==c){
      result++;
      c=-1;
    }else{
      c=t;
    }
  }

  cout<<result;

  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B; cin >> A >> B;
    int ans = B;
    if(A <= 5) ans = 0;
    else if(A <= 12) ans = B / 2;
    cout << ans << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
aa = 0
aaa = 0
bb = 0
bbb = 0
x = True
for i in range(1, 1100):
    if a == int(i*0.08) and x:
        aa=i
        x = False
        continue
    if a ==int(i*0.08)-1:
        aaa = i-1
        break
x = True
for i in range(1, 1100):
    if b == int(i*0.1) and x:
        bb=i
        x = False
        continue
    if b ==int(i*0.1)-1:
        bbb = i-1
        break
#print(aa, aaa, bb, bbb)
if bb>=aa and bb <= aaa:
    print(bb)
elif aa >=bb and aa<= bbb:
    print(aa)
else:
    print(-1)

Measured memory_bytes: 3064
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
 
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>
 
using namespace std;


#define ll long long
#define ld double
#define null NULL
#define prev prev228
#define index index228
#define left left228
#define right right228
#define hash hash228
#define forn0(i, n) for (int i = 0; i < (int)n; ++i)
#define forn(i, n) for (int i = 1; i <= (int)n; ++i)




template<typename T> inline void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> inline void uax(T &a, T b) {
    if (b > a) a = b;
}

const int maxn = 200 * 1000 + 3;


int a[maxn], b[maxn], c[maxn];



signed main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    int res = 0;
    for (int bit = 0; bit <= 28; ++bit) {
        bool on = 0;
        for (int i = 1; i <= n; ++i) {
            c[i] = b[i] % (1 << bit);
        }
        sort(c + 1, c + n + 1);
        int h0 = 0, h1 = 0;
        for (int i = 1; i <= n; ++i) {
            if ((b[i] >> bit) & 1) {
                ++h1;
            } else {
                ++h0;
            }
        }
        for (int i = 1; i <= n; ++i) {
            if ((a[i] >> bit) & 1) {
                if (h0 & 1) {
                    on ^= 1;
                }
            } else {
                if (h1 & 1) {
                    on ^= 1;
                }
            }
        }
        for (int i = 1; i <= n; ++i) {
            int rest = a[i] % (1 << bit);
            int l = 0, r = n;
            while (r - l > 1) {
                int m = (l + r) >> 1;
                if (c[m] + rest >= (1 << bit)) {
                    r = m;
                } else {
                    l = m;
                }
            }
            if (c[r] + rest >= (1 << bit) && ((n - r + 1) & 1)) {
                on ^= 1;
            }
        }
        res += (1 << bit) * on;
    }
    cout << res << '\n';
    return 0;
}








Measured memory_bytes: 2560
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    if n==1:
        print(abs(l[0]-x))
    else:
        l.append(x)
        l.sort()
        S=[]
        for i in range(n):
            S.append(l[i+1]-l[i])
        from functools import reduce
        from fractions import gcd
        print(reduce(gcd,S))
resolve()

Measured memory_bytes: 79612
X, Y = map(int,input().split())
crain = (4 * X - Y) / 2
turtle = (Y- 2*X) /2
if crain.is_integer() and crain >= 0 and turtle.is_integer() and turtle >= 0 :
    crain = int(crain)
    print('Yes')
else:
    print('No')

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

int N;
int t[114514], x[114514], y[114514];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	t[0] = 0; x[0] = 0; y[0] = 0;
	for (i = 1; i <= N; i++) {
		if (scanf("%d%d%d", &t[i], &x[i], &y[i]) != 3) return 1;
	}
	for (i = 1; i <= N; i++) {
		int zikan = t[i] - t[i - 1];
		int kyori = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (zikan < kyori || (zikan - kyori) % 2 != 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1280
#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)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

int n;
LL k;
vector<int> p,q;
vector<int> mods[6];

vector<int> compose(const vector<int> &v1,const vector<int> &v2){
  vector<int> v;
  REP(i,v1.size())v.push_back(v1[v2[i]]);
  return v;
}

vector<int> inverse(const vector<int> &v){
  vector<int> retv(v.size());
  REP(i,v.size())retv[v[i]]=i;
  return retv;
}

int main(){
  cin>>n>>k;
  int tmp;
  REP(i,n){
    cin>>tmp;tmp--;
    p.push_back(tmp);
  }
  REP(i,n){
    cin>>tmp;tmp--;
    q.push_back(tmp);
  }
  mods[0]=p;mods[1]=q;
  REP(i,4){
    mods[2+i]=compose(mods[1+i],inverse(mods[i]));
  }
  LL iter = (k-1)/6;
  vector<int> pow,b;
  REP(i,n)pow.push_back(i);
  b=compose(q,compose(inverse(p),compose(inverse(q),p)));
  while(iter>0){
    if(iter%2){
      pow = compose(pow,b);
    }
    b=compose(b,b);
    iter/=2;
  }
  vector<int> v = compose(compose(pow,mods[(k-1)%6]),inverse(pow));
  REP(i,n){
    if(i==0)cout<<v[i]+1;
    else cout<<" "<<v[i]+1;
  }
  cout<<endl;
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 3e5+23;
const int sqN = 550;

int a[N], h[N];
int d[sqN];

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int L = max(a[i]-k, 0), R = min(a[i]+k, N);
    int l = (L+sqN-1)/sqN, r = R/sqN;
    int cur = 0;
    if (l < r-1) {
      for (int j = l; j < r; ++j) cur = max(cur, d[j]);
      for (int j = L; j < l*sqN; ++j) cur = max(cur, h[j]);
      for (int j = R; j >= r*sqN; --j) cur = max(cur, h[j]);
    } else {
      for (int j = L; j <= R; ++j) cur = max(cur, h[j]);
    }
    h[a[i]] = 1+cur;
    d[a[i]/sqN] = max(d[i]/sqN, h[a[i]]);
    ans = max(ans, h[a[i]]);
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> card(100);
  int alice=0,bob=0;

  for(int i=0;i<n;i++){
    cin >> card[i];
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());

  for (int i=0;i<card.size();i++){
    if (i%2==0) alice+=card[i];
    else bob+=card[i];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [u64; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1
fn main() {
    input! { a: usize, b: usize, c: usize }
    if a ==b && b==c { println!("{}","Yes");} else { println!("{}","No");}
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll v[n],c[n];
  ll ans = 0;
  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];
  rep(i,n) if(v[i]>c[i]) ans+=v[i]-c[i];
  pri(ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 1e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

inline void NIE() { puts("-1"); exit(0); }

int n;
int a[maxN];

int main() {

	n = ri();
	rep (i, 1, n) a[i] = ri();
	
	LL L = 2, R = 2;
	per (i, n, 1) {
		LL p = a[i];
		if (L % p) L += p - L % p;
		if (R % p) R -= R % p;
		if (L > R) NIE();
		R += p - 1;
	}
	printf("%lld %lld\n", L, R);
	
	return 0;
}


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

using namespace std;

int main()
{
    int n, k;
    
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &k);
        
        if(n == 0 && k == 0) { break; }
        
        vector<int> a(n);
    
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }
        
        int sum = 0;
        
        for(int i = 0; i < k; i++)
        {
            sum += a[i];
        }
        
        int ret = sum;
        
        for(int i = k; i < n; i++)
        {
            sum += (a[i] - a[i - k]);
            
            ret = max(ret, sum);
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

Measured memory_bytes: 3344
#include <iostream>

using namespace std;

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	
	if((a+w >= b && a <= b) || (a <= b+w && a+w >= b+w))
	{
		cout << 0 << endl;
	}
	else
	{
		cout << ((a - (b+w)) > 0 ? a - (b+w) : b - (a+w)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll mod2=1e9+9 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   int m=1<<n;
   map<string,ll> mp[n+1];
   ll ans=0;
   rep(i,m){
       int cnt=0;
       string ret="";
       string res="";
       rep(j,n){
           if(i&(1<<j)){cnt++;ret+=s[j];}
           else res+=s[j];
       }
       reverse(res.begin(),res.end());
       ret+=res;
       mp[cnt][ret]++;
   }
   rep(i,m){
       int cnt=0;
       string ret="";
       string res="";
       rep(j,n){
           if(i&(1<<j)){cnt++;ret+=s[n+j];}
           else res+=s[n+j];
       }
       reverse(ret.begin(),ret.end());
       ret+=res;
       ans+=mp[cnt][ret];
   }
   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    ll n, m = LINF;
    cin >> n;
    for(int i = 0; i < 5; i++){
        ll a;
        cin >> a;
        chmin(m,a);
    }
    cout << (n-1)/m + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, a, b; cin >> n >> m >> a >> b;
    vector<int> D(n);
    for(int i = 0; i < n; i++) cin >> D[i];
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        if(D[i] >= a) v.push_back(D[i]);
        else break;
    }
    int num = n - v.size();
    if(num >= m) cout << v.size() << endl;
    else
    {
        int ans = 0;
        int pos = v.size() - 1;
        while(v.size())
        {
            if(v[pos] <= b)
            {
                v.pop_back();
                pos--;
            }
            else
            {
                ans = v.size();
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}




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

using namespace std;

int main()
{
    string s;
    cin >> s;
    long n = s.size();

    string s1, s2;
    s1 = s.substr(0, (n - 1) / 2);
    s2 = s.substr(((n+3) / 2) - 1);
    reverse(s2.begin(), s2.end());
    if (!(s1.compare(s2) == 0))
    {
        cout << "No" << endl;
        return 0;
    }

    string s3, s4;
    long n1 = s1.size();
    s3 = s1.substr(0, int(ceil(((n1 - 1) / 2.0))));
    s4 = s1.substr(((n1+3) / 2) - 1, n1);
    reverse(s4.begin(), s4.end());
    if (!(s3.compare(s4) == 0))
    {
        cout << "No" << endl;
        return 0;
    }

    long n2 = s2.size();
    s3 = s2.substr(0, int(ceil(((n2 - 1) / 2.0))));
    s4 = s2.substr(((n2+3) / 2) - 1, n2);
    reverse(s4.begin(), s4.end());
    if (!(s3.compare(s4) == 0))
    {
        cout << "No" << endl;
        return 0;
    }

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


Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    ans = a[0]+sum(b)
    sub = ans
    for i in range(1, n):
        sub += a[i]
        sub -= b[i-1]
        if ans < sub:
            ans = sub
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
  long long int x,y;
  cin>>x>>y;
  if((x<=1 && y<=1) || abs(x-y)<=1){
    cout<<"Brown"<<endl;
  }
  else{
    cout<<"Alice"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool prime[10002];
int main() {
	for(int i = 2; i * i <= 10000; i++) {
		if(prime[i]) continue;
		for(int j = i * i; j < 10000; j+=i) {
			prime[j] = true;
		}
	}
	int n;
	while(cin >> n,n) {
		for(int i = n; i >= 3; i--) {
			if(!prime[i] && !prime[i-2]) {
				printf("%d %d\n", i - 2, i);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1144
/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

struct P {
  double c[3];
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<double>> colors(n, vector<double>(3));
  REP(i, n){
    REP(j, 3){
      cin >> colors[i][j];
    }
  }

  double ret = 0;
  REP(i, 1 << n){
    if (__builtin_popcount(i) != m) continue;
    double v = 0;
    REP(a, n - 1){
      FOR(b, a, n){
        if (BIT(i, a) && BIT(i, b)) {
          REP(j, 3){
            v += SQ(colors[a][j] - colors[b][j]);
          }
        }
      }
    }
    // LOG("%d\n", i);
    // LOG("..%lf\n", v);
    ret = max(ret, v);
  }
  // cout << ret << endl;
  printf("%.10lf\n", ret);
}

Measured memory_bytes: 3264
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    char S; cin >> S;
    cout << char(S + 1);
    return 0;
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
a,b,c = inp
lol=(a-c)*2/a.to_f
lol = 1.0 if(c == 0)
p lol*(b-1)/a
#n = inp[0]
=begin
t = []
n.times do
  t.push(inp)
end  
=end


=begin
=end

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

vector<long long> enum_divisors(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i);
        if (i != n / i) res.emplace_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int n, m; cin >> n >> m;
    long long ma = 1;
    for (auto d: enum_divisors(m)) if (d * n <= m) ma = max(ma, d);
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#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
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll fun(ll h)
{
	if(h == 1)
		return 1;
	ll ret = fun(h/2);
	return 2 * ret + 1;
}

int main()
{
	FAST;
	ll h, i, j;
	cin >> h;
	ll ans = fun(h);
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = (1<<18);
struct Intervalle
{
	int maximum , ajout;
};

struct Event
{
	int moment , debut , fin , valeur;
	bool operator < (const Event & autre) const
	{
		return moment < autre.moment;
	}
};

int taille;
Intervalle arbre[MAXN * 2];
void update(int noeud)
{
	arbre[noeud].maximum += arbre[noeud].ajout;
	if (noeud < MAXN)
	{
		arbre[noeud * 2].ajout += arbre[noeud].ajout;
		arbre[noeud * 2 + 1].ajout += arbre[noeud].ajout;
	}
	arbre[noeud].ajout = 0;
}

void merge(int noeud)
{
	arbre[noeud].maximum = max(arbre[noeud * 2].maximum , arbre[noeud * 2  + 1].maximum);
}

void ajouter(int noeud , int debut , int fin , int debutCible , int finCible , int ajout)
{
	//cout<<debut<<" "<<fin<<" "<<noeud<<" "<<debutCible<<" "<<finCible<<endl;
	update(noeud);
	if (debutCible <= debut && fin <= finCible)
	{
		arbre[noeud].ajout += ajout;
		update(noeud);
	}
	else if (!(fin < debutCible || debut > finCible))
	{
		ajouter(noeud * 2 , debut , (debut + fin) / 2 , debutCible , finCible , ajout);
		ajouter(noeud * 2 + 1 , (debut + fin) / 2 + 1 , fin , debutCible , finCible , ajout);
		merge(noeud);
	}
}

int recupeMax(int noeud , int debut , int fin , int debutCible , int finCible)
{
	update(noeud);
	if (debutCible <= debut && fin <= finCible)
	{
		return arbre[noeud].maximum;
	}
	else if (!(fin < debutCible || debut > finCible))
	{
		int g = recupeMax(noeud * 2 , debut , (debut + fin) / 2 , debutCible , finCible);
		int d = recupeMax(noeud * 2 + 1 , (debut + fin) / 2 + 1 , fin , debutCible , finCible);
		merge(noeud);
		return max(g , d);
	}
	else
	{
		return -1e18;
	}
}

int dp[MAXN];

int32_t main()
{
	int nbSegments;
	cin >> taille >> nbSegments;
	Event events[nbSegments * 2];
	for (int i = 0 ; i < nbSegments ; i++)
	{
		int debut , fin , v;
		cin >> debut >> fin >> v;
		events[i * 2] = {debut , debut , fin , -v};
		events[i * 2 + 1] = {fin + 1 , debut , fin , v};
	}
	int nbEvents = nbSegments * 2;
	sort(events , events + nbEvents);
	int totalActu = 0;
	int in = 0;
	int leMax = 0;
	for (int i = 1 ; i <= taille ; i++)
	{
		while (in < nbEvents && events[in].moment == i)
		{
			totalActu -= events[in].valeur;
			ajouter(1 , 0 , MAXN - 1 , events[in].debut , events[in].fin , events[in].valeur);
			in++;
		}
		dp[i] = recupeMax(1 , 0 , MAXN - 1 ,  0 , i - 1) + totalActu;
		ajouter(1 , 0 , MAXN - 1 , i , i , dp[i]);
		leMax = max(leMax , dp[i]);
	}
	cout<<leMax<<endl;

}

Measured memory_bytes: 22528
#include <iostream>
#include <vector>
#define MAX 200000
using namespace std;

int main(void){
  int N;
  cin >> N;
  int num[MAX]={};
  vector<int> v;
  for(int i=0;i<N-1;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp-1);
  }
  for(int i=0;i<N-1;i++){
    int ai = v[i];
    num[ai] = num[ai] + 1;
  }
  for(int i=0;i<N;i++){
    cout << num[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5016
#include <iostream>
#include <string>
using namespace std; 
string s,t;
int main()
{
    cin>>s>>t;
   int ans=0;
   for(int i=0;i<s.length();i++)
   if(s[i]!=t[i])
   ans++;
   
   cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3560
#include<iostream>

using namespace std;

long long gcd(long long,long long);
long long lcm(long long,long long);

int main(void){
	int n;
	 long long t[101],ans=0;
	
	cin>>n;
	
	for(int lop=0;lop<101;lop++){
		t[lop]=0;
	}
	
	cin>>ans;
	for(int lop=0;lop<n-1;lop++){
		cin>>t[lop];
		ans=lcm(ans,t[lop]);
	}
	cout<<ans<<endl;
	
	return 0;
}

long long gcd(long long a,long long b){
	long long c;
	if(a<b){
		c=a;
		a=b;
		b=c;
	}
	c=a%b;
	
	if(c==0){
		return b;
	}else{
		return gcd(b,c);
	}
	
}

long long lcm(long long a,long long b){
	long long c;
	
	c=gcd(a,b);
	return a/c*b;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const ll INF = 1e15;


int main(){

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());

    ll ans = 0;
    if(n % 2 == 0){
        //偶数
        //出現回数が2,1.....-1,2の形
        for(int i = 0;i < n/2-1;i++){
            ans += 2*a[i];
        }
        ans += a[n/2-1];
        ans -= a[n/2];
        for(int i = n/2+1;i < n;i++){
            ans -= 2*a[i];
        }

    }else{
        //奇数
        //出現回数が2,...2,1,1,-2,.....-2のケース
        ll cnt1 = 0;
        for(int i = 0;i < n/2-1;i++){
            cnt1 += 2*a[i];
        }
        cnt1 += a[n/2-1] + a[n/2];
        for(int i = n/2+1;i < n;i++){
            cnt1 -= 2*a[i];
        }

        //出現回数が2,...,2,-1,-1,-2,.....-2のケース
        ll cnt2 = 0;
        for(int i = 0;i < n/2;i++){
            cnt2 += 2*a[i];
        }
        cnt2 -= (a[n/2] + a[n/2+1]);
        for(int i = n/2+2;i < n;i++){
            cnt2 -= 2*a[i];
        }
        ans = max(cnt1,cnt2);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#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 < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main()
{
    int n, m, sum = 0;
    cin >> n >> m;

    vector<int> A(n);
    rep(i,n){
        cin >> A.at(i);
        sum += A.at(i);
        //cout << A.at(i) << " ";
    }
    /*
    cout << endl;
    cout << sum / (4 * m)-1 << endl;
    */

    sort(A.rbegin(),A.rend());
    
    /*
    rep(i, n) {
        cout << A.at(i) << " ";
    }
    cout << endl;
    */
    rep(i, m) {
        if (4 * m * A.at(i) < sum) {
            cout << "No" << endl;
            break;
        }
        else if(i == m-1)
            cout << "Yes" << endl;
    }

    return 0;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const int inf = (int) 1e9+77;
const ll mod = (ll) 998244353;
const ld pi = acos(-1);

int main() {
    fast;
    int n, h[N], dp[N];
    cin >> n;
    forn(i, n) cin >> h[i], dp[i] = inf;
    dp[0] = 0;
    forn(i, n) {
        if (i + 1 < n) dp[i + 1] = min(dp[i + 1], abs(h[i] - h[i + 1]) + dp[i]);
        if (i + 2 < n) dp[i + 2] = min(dp[i + 2], abs(h[i] - h[i + 2]) + dp[i]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int x=100005;
int main()
{
long long p[x],s[x];
memset(p,0,sizeof(p));
p[1]=1;
for(int i=2;i*i<x;i++)
{
    if(!p[i])
    {
    for(int j=2*i;j<x;j+=i)
    {
        p[j]=1;

    }
    }
}
s[1]=0;
for(int i=2;i<x;i++)
{
    s[i]=s[i-1];
    if(!p[i]&&!p[(i+1)/2])
    s[i]++;
}
int q;
cin>>q;
//cout<<s[2017]<<" "<<s[2016]<<endl;
while(q--)
{
    int x,y;
    cin>>x>>y;
    cout<<s[y]-s[x-1]<<endl;
}
return 0;
}
 


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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int H, W;    // input

  int i, j;    // subscript
  bool line_flag;


  /* Input, Array_Proclamation */
  cin >> H >> W;
  vector< vector<char> > a(H, vector<char>(W)); //input
  vector<bool> adr_i(H, false); 
  vector<bool> adr_j(W, false); 
  
  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      cin >> a.at(i).at(j);
    }
  }


  /* Calculation */
  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      
      if(a.at(i).at(j) == '#')
      {
        adr_i.at(i) = true;
        adr_j.at(j) = true;
      }

    }
  }


  /* Output */
  cout << endl;

  for(i=0; i<H; i++)
  {
  
    line_flag = false;
    for(j=0; j<W; j++)
    {
      if(adr_i.at(i) == true && adr_j.at(j) == true)
      {
        cout << a.at(i).at(j);
        line_flag = true;
      }
    }

    if(line_flag == true)
    {
      cout << endl;
    }

  }


  return 0;

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vpll v(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    v[i]={b,a};
  }
  vsort(v);
  
  ll now=0;
  rep(i,n){
    ll a=v[i].second, b=v[i].first;
    now+=a;
    if(now>b){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3456