akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int mod = 1e9;
int N, M, Q, K;
vector<int> vec[2];
int dp[16100][4010], dest[2];
bool dflag[2];

int rec(int pos, int vi, int init, int dir){
    if(vi >= vec[dir].size()){
        if(pos == dest[dir]) dflag[dir] = true;
        return 1;
    }
    int &ret = dp[pos][vi];
    if(ret != -1) return 1;
    ret = 1;

    rec(pos + vec[dir][vi], vi + 1, 0, dir);
    if(!init) rec(pos - vec[dir][vi], vi + 1, 0, dir);
    return 1;
}

int main()
{
    int i, j, k;
    string s;
    cin >> s >> dest[0] >> dest[1];

    int pos = 0;
    int dir = 0;
    int n= s.size();
    while(pos < n){
        int cnt = 0;
        while(pos < n && s[pos] == 'F') {cnt++; pos++;}
        vec[dir].push_back(cnt);
        pos++;
        dir = !dir;
    }
    dest[0] += 8000; dest[1]+= 8000;
    memset(dp, -1, sizeof(dp));
    rec(8000, 0, 1, 0);
    if(!dflag[0]){
        printf("No\n");
        return 0;
    }
    memset(dp, -1, sizeof(dp));
    rec(8000, 0, 0, 1);
    if(!dflag[1]){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
}


Measured memory_bytes: 252800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

const string YES = "Yes";
const string NO = "No";

vector<string> s;
string ans;

set<array<ll, 4>> ng;

bool solve(ll i, ll a, ll b, ll c){
    if(a < 0 || b < 0 || c < 0){ return false; }
    if(i >= s.size()){ return true; }
    if(ng.count({i, a, b, c})){ return false; }

    if(s.at(i) == "AB"){
        if(solve(i + 1, a - 1, min(b + 1, 2LL), c)){
            ans.push_back('B');
            return true;
        }else if(solve(i + 1, min(a + 1, 2LL), b - 1, c)){
            ans.push_back('A');
            return true;
        }
    }else if(s.at(i) == "BC"){
        if(solve(i + 1, a, min(b + 1, 2LL), c  -1)){
            ans.push_back('B');
            return true;
        }else if(solve(i + 1, a, b - 1, min(c + 1, 2LL))){
            ans.push_back('C');
            return true;
        }
    }else{
        assert(s.at(i) == "AC");
        if(solve(i + 1, min(a + 1, 2LL), b, c - 1)){
            ans.push_back('A');
            return true;
        }else if(solve(i + 1, a - 1, b, min(c + 1, 2LL))){
            ans.push_back('C');
            return true;
        }
    }

    ng.insert({i, a, b, c});
    return false;
}

int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    s.resize(n);
    REP(i, n){
        cin >> s.at(i);
    }
    a = min(a, 2LL);
    b = min(b, 2LL);
    c = min(c, 2LL);
    if(solve(0, a, b, c)){
        cout << YES << endl;
        for(ll i = n - 1; i >= 0; --i){
            cout << ans.at(i) << endl;
        }
    }else{
        cout << NO << endl;
    }
    return 0;
}


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

int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> ab(n, vector<int>(2));
    vector<vector<int>> cd(m, vector<int>(2));
    for(int i = 0; i < n; i ++) cin >> ab[i][0] >> ab[i][1];
    for(int i = 0; i < m; i ++) cin >> cd[i][0] >> cd[i][1];
    for(int i = 0; i < n; i++) {
        vector<int> ans(m);
        for(int j = 0; j < m; j++) {
            ans[j] = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]);
        }
        vector<int>::iterator iter = min_element(ans.begin(), ans.end());
        cout << distance(ans.begin(), iter) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

 int a[10000],A,i,j;
 for(i=0;i<10;i++){
scanf("%d",&a[i]);
 	}

  for(i=0;i<10;i++){
 for(j=0;j<10;j++){
if(i!=j){

if(a[i]>a[j]){
A=a[i];
a[i]=a[j];
a[j]=A;
	}
	
	}
	}
 	}

 	for(i=0;i<3;i++){
printf("%d\n",a[i]);
 		}


return 0;
	}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 5e15;
int main(){
    char A[4];
    for(ll i = 0; i < 4; i++) cin >> A[i];
    for(ll i = 0; i < (1 << 3); i++){
        string s = to_string(A[0] - '0');
        ll sum = A[0] - '0';
        for(ll j = 0; j < 3; j++){
            if(i & (1 << j)){
                sum += A[j + 1] - '0';
                s += '+';
            }else{
                sum -= A[j + 1] - '0';
                s += '-';
            }
            s += A[j + 1];
        }
        if(sum == 7){
            s += "=7";
            cout << s << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	string s;
	cin>>s;
	int ans =0;
	int pre = -1;
	rep(i,n)
	{
		if (pre == s[i]-'a') continue;
		ans++;
		pre = s[i] - 'a';
	}
	cout<<ans;



}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    ll ans=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l=1;l<=k;l++)
            {
                ans+=__gcd(i,__gcd(j,l));
            }
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3648
#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 a; cin>>a;
  int x = a%10;
  int y = a/100;
  if (x!=y) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

int main()
{
	int n;
	while (cin >> n, n) {
		map<int, long long> data;
		map<int, int> seq;
		for (int i = 0; i < n; ++i) {
			int bangou;
			long long tanka, kazu;
			cin >> bangou >> tanka >> kazu;
			if (data.find(bangou) == data.end()) {
				data[bangou] = 0;
				seq[bangou] = i;
			}
			if (data[bangou] < 1000000)
				data[bangou] += tanka * kazu;
		}
		vector<pair<int, int> > v;
		for (map<int, long long>::iterator it = data.begin(); it != data.end(); ++it)
			if (it->second >= 1000000)
				v.push_back(make_pair(seq[it->first], it->first));
		if (v.empty())
			cout << "NA" << endl;
		else {
			sort(v.begin(), v.end());
			for (int i = 0; i < v.size(); ++i) cout << v[i].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){


    int a,v,b,w,t;cin>>a>>v>>b>>w>>t;
    if(v<w && a!=b) return cout<<"NO",0;
    else if((v-w)*t>=abs(a-b)){trace(1);return cout<<"YES",0;}
    cout<<"NO";
    // trace(2);

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


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


using namespace std;

int gcd(int a, int b){
     int c;

     if (a < b) {
         a+=b; b=a-b; a-=b;
    }

     while (b != 0) {
         c = a % b;
        a = b;
         b = c;
     }

   return a;
 }

int main(void){
    int N,X;
    int x[1000000];
    int sa[1000000];
    cin>>N>>X;
    int temp ;
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    x[N] = X;

    sort(x,x+(N+1));

    if(N==1){
        cout<<x[1]-x[0]<<endl;
        return 0;
    }
    
    int min=x[1]-x[0];

    

    for(int i=0;i+1<N+1;i++){
        if(i==0){
            sa[i]=(x[i+1]-x[i]);
            continue;
        }
        sa[i]=(x[i+1]-x[i]);
        temp = gcd(sa[i],sa[i-1]);
        if(temp<1)continue;
        if(temp<min){
            //cout<<sa[i-1]<<"  "<<sa[i]<<"  "<<temp<<endl;
            min=temp;
        }
    }

    cout<<min<<endl;
    return 0;

 

}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll>A(N);
  //map<ll, ll> mp;
  for(int i=0; i < N; i++){
    cin >> A[i];
    //mp[A[i]] = 0;
  }
  //mp.size()
  sort(A.begin(), A.end());
  vector<ll>B(N, 0);
  int c = 0;
  int j = 0;
  for(int i=0; i < N-1; i++){
    if(A[i] == A[i+1])
      B[j]++;
    else{
      B[j]++;
      //cout << B[j] << endl;
      j += 1;
    }
  }
  B[j]++;
  //cout << B[j] << endl;
  sort(B.begin(), B.end());
  ll m = B.size() - K;
  ll ans = 0;
  for(int i=0; i < m; i++){
    ans += B[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <queue>
#include <deque>

using namespace std;

const int INF = 1e9;
int k;
int a[100005];
bool v[100005];
deque<int> qp, qq;

void f(int p, int q)
{
    if(a[p] <= q) return;
    a[p] = q;
    f(p * 10 % k, q);
    f((p + 1) % k, q + 1);
}

int main()
{
    scanf("%d", &k);
    for(int i = 0; i < k; i++) a[i] = INF;
//  f(1, 1);
    qp.push_front(1), qq.push_front(1);
    while(!qp.empty())
    {
        int p = qp.front(), q = qq.front();
        qp.pop_front(), qq.pop_front();
        if(v[p]) continue;
        v[p] = true;
        if(p == 0)
        {
            printf("%d", q);
            return 0;
        }
        qp.push_front(p * 10 % k), qq.push_front(q);
        qp.push_back((p + 1) % k), qq.push_back(q + 1);
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par, siz;

    UnionFind(int n) : par(n), siz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

template <typename T>
struct edge {
    int from, to;
    T cost;
    edge(int from, int to, T cost = 1) : from(from), to(to), cost(cost) {}
    bool operator<(const edge& e) const {
        return cost < e.cost;
    }
};

template <typename T>
T Kruskal(int V, vector<edge<T>>& es) {
    sort(es.begin(), es.end());  // reverseすると最大全域木
    UnionFind uf(V);
    T res = 0;
    for (edge<T> e : es) {
        if (!uf.same(e.from, e.to)) {
            uf.unite(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

signed main() {
    int n;
    cin >> n;
    ll x, y;
    pair<ll, int> xx[n], yy[n];
    rep(i, n) {
        cin >> x >> y;
        xx[i] = {x, i};
        yy[i] = {y, i};
    }
    sort(xx, xx + n);
    sort(yy, yy + n);
    vector<edge<ll>> es;
    rep(i, n - 1) {
        es.emplace_back(xx[i].second, xx[i + 1].second,
                        abs(xx[i].first - xx[i + 1].first));
        es.emplace_back(yy[i].second, yy[i + 1].second,
                        abs(yy[i].first - yy[i + 1].first));
    }
    cout << Kruskal(n, es) << endl;
    return 0;
}

Measured memory_bytes: 10572
//076 A - Rating Goal 2017/10/28

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int r , g; cin >> r >> g;
    cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func query(H *[][]int, from, to, sign, day int) {
  if to * sign <= (*H)[from][0] * sign {
    Write(day + 1)
    return
  }
  l := 0
  h := len((*H)[from]) - 1
  var m int
  for ; h - l > 1; {
    m = (h + l) / 2
    if (*H)[from][m] * sign < to * sign {
      l = m
    } else {
      h = m
    }
  }
  day += 1 << uint(l)
  query(H, (*H)[from][l], to, sign, day)
}

func main() {
  N := NextInt()
  X := NextIntVec()
  L := NextInt()
  H := make([][]int, N)
  RH := make([][]int, N)
  for i := range H {
    H[i] = make([]int, 0)
    RH[i] = make([]int, 0)
  }
  s := 0
  t := 0
  length := 0
  for ; s < N - 1; {
    for ; length <= L; t++{
      if t == N - 1 {
        for ; s < N - 1; s++ {
          H[s] = append(H[s], N - 1)
        }
        break
      }
      length += X[t + 1] - X[t]
    }
    for ; length > L; s++ {
      H[s] = append(H[s], t - 1)
      length -= X[s + 1] - X[s]
    }
  }
  length = 0
  for ; s > 0; {
    for ; length <= L; t-- {
      if t == 0 {
        for ; s > 0; s-- {
          RH[s] = append(RH[s], 0)
        }
        break
      }
      length += X[t] - X[t - 1]
    }
    for ; length > L; s-- {
      RH[s] = append(RH[s], t + 1)
      length -= X[s] - X[s - 1]
    }
  }
  var h, rh int
  for i := 1; i < N; i++ {
    h = 0
    for ; H[N - 1 - i][h] < N - 1; h++ {
      if len(H[H[N - 1 - i][h]]) < h + 1 {
        H[N - 1 - i] = append(H[N - 1 - i], N - 1)
      } else {
        H[N - 1 - i] = append(H[N - 1 - i], H[H[N - 1 - i][h]][h])
      }
    }
    rh = 0
    for ; RH[i][rh] > 0; rh++ {
      if len(RH[RH[i][rh]]) < rh + 1 {
        RH[i] = append(RH[i], 0)
      } else {
        RH[i] = append(RH[i], RH[RH[i][rh]][rh])
      }
    }
  }
  Q := NextInt()
  for i := 0; i < Q; i++ {
    ab := NextIntVec()
    a := ab[0]
    b := ab[1]
    if a < b {
      query(&H, a - 1, b - 1, 1, 0)
    } else {
      query(&RH, a - 1, b - 1, -1, 0)
    }
  }
  Output()
}

Measured memory_bytes: 72064
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",100i32.pow(a as u32)*if b>99{101}else{b})
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
int pre[maxn];
int main() {
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++) {if(i%k==0) {puts("OK");return 0;}}
    puts("NG");
    return 0;
}

Measured memory_bytes: 3628
#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 h, a;
    cin >> h >> a;
    cout << (h + (a-1)) / a << endl;
    
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a,b;

    if(n%2==0){
        a=n/2;
        b=n/2;
    }else{
        a=n/2;
        b=n/2+1;
    }
    int count_c=0;
    int count_d=0;
    int count_e=0;
    int m_n=n;
    for(int i=0;i<7;i++){
        count_c+=m_n%10;
        m_n=m_n/10;
        if(m_n==0)    break;
    }
    int m_a=a;
    int m_b=b;
    for(int i=0;i<7;i++){
        count_d+=m_a%10;
        m_a=m_a/10;
        if(m_a==0)  break;
    }
    for(int i=0;i<7;i++){
        count_e+=m_b%10;
        m_b=m_b/10;
        if(m_b==0)    break;
    }
    if(count_c<count_d+count_e && count_c!=1){
        cout << count_c << endl;
        
    }else{
        cout << count_d+count_e << endl;
    }
    
    
}

Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {

	long long N, M;
	long long min, cnt;

	cin >> N >> M;

	vector<long long>a(N), b(N);
	vector<long long>c(M), d(M);

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

	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; i++) {
		min = 10e8;
		cnt = 0;
		for (int j = 0; j < M; j++) {
			if (min > labs(a[i] - c[j]) + labs(b[i] - d[j])) {
				min = labs(a[i] - c[j]) + labs(b[i] - d[j]);
				cnt = j + 1;
			}
		}
		cout << cnt << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, X, N);
  auto Y = X;
  sort(all(Y));
  int m = N / 2;
  ll mid = Y[m];
  rep(i, 0, N) {
    if (X[i] < mid) {
      print(Y[m]);
    } else {
      print(Y[m - 1]);
    }
  }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using int64 = int_fast64_t;

int main() {
  int n,p;cin>>n>>p;
  int odd=0;
  for(int i=0;i<n;++i){
    int k;cin>>k;
    if(k%2==1) ++odd;
  }
  
  if(p==1 && odd==0){
    cout<<0<<endl;
    return 0;
  }
  
  int64 even=n-odd;
  int64 ans=1LL<<(max(odd-1,0)+even);
  cout<<ans<<endl;
  
  return 0;
}


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

using namespace std;

typedef long long lint;

lint n, m;

string a, b;

map <lint, char> rez;

int main()
{
    cin >> n >> m;
    cin >> a >> b;

    lint cmmdc = __gcd(n, m);
    lint l = n * m / cmmdc;

    lint p = l / n;
    lint cr = 0;
    for(lint i = 1; i <= l; i += p)
    {
       // cout << "PE " << i << " PUN " << a[cr] << "\n";
        rez[i] = a[cr];
        cr ++;
    }

    cr = 0;
    p = l / m;
    for(lint i = 1; i <= l; i += p)
    {
      //  cout << "PE I " << i << " AVEM " << rez[i] << " DAR VREAU " << b[cr] << "\n";
        if(rez[i] != 0 && rez[i] != b[cr])
        {
            cout << "-1\n";
            return 0;
        }

        cr ++;
    }

    cout << l << "\n";

    return 0;
}


Measured memory_bytes: 10880
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int NIL=-1;
int d[100005],l[100005],r[100005],p[100005];

void rec(int i,int p)
{
    d[i]=p;
    if(r[i]!=NIL)rec(r[i],p);
    if(l[i]!=NIL)rec(l[i],p+1);
}
void print(int i)
{
    printf("node %d: parent = %d, depth = %d, ",i,p[i],d[i]);
    if(p[i]==NIL)printf("root, ");
    else if(l[i]==NIL)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    int flag=0;
    for(int j=l[i];j!=NIL;j=r[j])
    {
        if(flag++)printf(", ");
        printf("%d",j);
    }
    printf("]\n");
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)p[i]=l[i]=r[i]=NIL;
    for(int i=0;i<n;i++)
    {
        int v,t;
        cin>>v>>t;
        for(int j=0,L;j<t;j++)
        {
            int o;
            cin>>o;
            if(j==0)l[v]=o;
            else r[L]=o;
            L=o;
            p[L]=v;
        }
    }
    int ROOT=0;
    for(int i=0;i<n;i++)if(p[i]==NIL)ROOT=i;
    rec(ROOT,0);
    for(int i=0;i<n;i++)print(i);
    return 0;
}



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

using namespace std;
ll N, a[100005], i, dp[100005], k, j;
int main()
{
   cin>>N>>k;
   for(i=1;i<=N;i++)
    {cin>>a[i]; dp[i]=INT_MAX;}
   for(i=1;i<=k;i++)
    dp[i]=abs(a[i]-a[1]);

   for(i=k+1;i<=N;i++){
             for(j=k;j>=1;j--)
    dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
   }
    cout<<dp[N];
    return 0;
}


Measured memory_bytes: 1792
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    if (s.back() != 's')  {
        s += 's';
    }
    else {
        s += 'e';
        s += 's';
    }
    cout << s;
    return 0;
}

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

int main() {
	int W;
	int H;
	int x;
	int y;
	int r;
	cin >> W >> H >> x >> y >> r;
	if (r <= y&&y <= H - r &&r<=x&& x <= W - r) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin>>n>>m;
	vector<vi> adj(n+1);
	vi dim(n+1);
	rep(i, m){
		int s, t; cin>>s>>t;
		adj[s].pb(t);
	}
	rep(i, n) dim[i+1] = adj[i+1].size();

	long double ans=(long double)n;
	for(int cut=1; cut<=n; cut++){
		vector<long double> dp(n+1, 0.0);
		for(int i=n-1; i>=1; i--){
			long double maxi = 0.0;
			for(auto e:adj[i]){
				maxi = max(maxi, dp[e]);
				dp[i] += dp[e]+1;
			}
			if (dim[i]>1 && cut==i){
				dp[i] -= maxi+1;
				dp[i] /= dim[i]-1;
			}else{
				dp[i] /= dim[i];
			}
		}
		ans = min(ans, dp[1]);
	}
	cout << setp(12) << ans << "\n";
	return 0;
}


Measured memory_bytes: 1408
a=int(input())
list1=[0]*4
list2=['AC','WA','TLE','RE']
for i in range(a) :
  b=input()
  if b=='AC' :
    list1[0]+=1
  elif b=='WA' :
    list1[1]+=1
  elif b=='TLE' :
    list1[2]+=1
  else :
    list1[3]+=1

for i in range(4) :
  print(list2[i]+' x '+str(list1[i]))

Measured memory_bytes: 74776
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
deg = 11451419
for i in range(n):
  if deg > abs(a - (t - h[i]*0.006)):
    deg = abs(a - (t - h[i]*0.006))
    ans = i+1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int answer = (a * 100) + (b * 10) + c;
  if (answer % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			PriorityQueue<State> pq = new PriorityQueue<State>();
			for(int i=0;i<n;i++){
				pq.add(new State(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()));
			}

			while(!pq.isEmpty()){
				System.out.println(pq.poll().l);
			}
			System.out.println("#");
		}
	}
}

class State implements Comparable<State>{
	String l;
	int p,a,b,c,d,e,f,s,m;
	double per;

	State(String l,int p,int a,int b,int c,int d,int e,int f,int s,int m){
		this.l = l;
		this.p = p;
		this.a = a;
		this.b = b;
		this.c = c;
		this.d = d;
		this.e = e;
		this.f = f;
		this.s = s;
		this.m = m;

		this.per = calcPer();
	}

	double calcPer(){
		return ((double)f*m*s-p) / (double)calcTime();
	}

	int calcTime(){
		return a + b + c + (d + e) * m;
	}

	public int compareTo(State st){
		if(this.per < st.per){
			return 1;
		}
		else if(this.per > st.per){
			return -1;
		}
		else{
			return this.l.compareTo(st.l);
		}
	}
}

Measured memory_bytes: 13000
'use strict';

const testcase = null;

function main(input) {
    const n = parseInt(input.shift());
    const s = input.shift();
    var p = null;
    var c = 0;
    for (var i = 0; i < n; i++) {
        if (p !== s[i]) {
            p = s[i];
            c += 1;
        }
    }
    console.log(c);
}

if (process.argv[1] == __filename) {
    const input = testcase
        || require('fs')
            .readFileSync('/dev/stdin', 'utf-8');
    main(input.split(/\s/));
}


Measured memory_bytes: 21192
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

satisfaction = 0
before = None
for i in range(N):
    num = A[i] - 1
    satisfaction += B[num]
    try:
        if A[i+1] - 1 == num + 1:
            satisfaction += C[num]
    except:
        pass
print(satisfaction)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

struct Process {
  char name[11];
  unsigned short time;
  int remaining;

  Process* next;
  Process* prev;
};

class Queue {
 public:
  Queue() : first_(NULL), last_(NULL), size_(0) {}

  bool Empty() const {
    return size_ == 0;
  }

  Process* Pop() {
    if (!first_) {
      return NULL;
    }
    Process* r = first_;
    first_ = first_->next;
    --size_;
    return r;
  }

  void Push(Process* p) {
    ++size_;
    if (!first_) {
      first_ = p;
    }
    if (!last_) {
      last_ = p;
      return;
    }
    p->prev = last_;
    last_->next = p;
    p->next = NULL;
    last_ = p;
  }

 private:
  Process* first_;
  Process* last_;
  int size_;
};

void RoundRobin(int quantum, vector<Process>& processes) {
  Queue q;
  for (size_t i = 0; i < processes.size(); ++i) {
    q.Push(&processes[i]);
  }

  int elapsed = 0;
  while (!q.Empty()) {
    Process* p = q.Pop();

    // evict
    if (p->remaining - quantum <= 0) {
      elapsed += p->remaining;
      p->remaining = 0;
      printf("%s %d\n", p->name, elapsed);
      continue;
    }
    p->remaining -= quantum;
    elapsed += quantum;
    q.Push(p);
  }
}

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

  vector<Process> processes;
  Process p;
  for (int i = 0; i < n; ++i) {
    cin >> p.name;
    cin >> p.time;
    p.remaining = p.time;
    p.next = NULL;
    p.prev = NULL;
    processes.push_back(p);
  }

  RoundRobin(q, processes);

  return 0;
}

Measured memory_bytes: 3776
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

import numpy as np
from scipy.sparse import *

N, M = ri_()
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    ai, bi, ci = ri_()
    a[i], b[i], c[i] = ai - 1, bi - 1, ci
G = csr_matrix((c, (a, b)), shape=(N, N))
d = csgraph.floyd_warshall(G, directed=False)
ans = 0
for i in range(M):
    if d[a[i], b[i]] != c[i]:
        ans += 1
print(ans)

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

int main(){
    int n,m,x,y;
    cin >> n >> m >> x >>y;
    vector<int> vx(n),vy(m);
    int maxx = -1000;
    int miny = 1000;
    for(int i =0;i<n;i++){
        cin >> vx[i];
        if(vx[i]>maxx){
            maxx = vx[i];
        }
    }
    for(int i=0;i<m;i++){
        cin >> vy[i];
        if(vy[i] < miny){
            miny = vy[i];
        }
    }
    //cout << maxx << " " << miny << endl;
    if((miny-maxx)>0&&(miny <= y) && (maxx >= x)){
        cout << "No ";
    }
    cout << "War" << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math
sys.setrecursionlimit(300000)

def circumcenter(ax, ay, bx, by, cx, cy):
    d = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    if d == 0:
        return None, None
    ux = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / d
    uy = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / d
    return (ux, uy)

def center(a, b, c, d, e, f):
    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    tmp = 2 * (e - a)*(b - d) - 2 * (c - a) * (b - f)
    if tmp == 0:
        return None, None
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / tmp
    if c == a:
        px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a))
    else:
        px = (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
    return (px, py)



def solve(N: int, x: "List[int]", y: "List[int]"):
    e = 10 ** -10
    def can(px, py, dis):
        for p in range(N):
            d = (px - x[p]) ** 2 + (py - y[p]) ** 2
            if d > dis + e:
                return False
        return True

    ret = float('inf')
    for i in range(N):
        for j in range(i + 1, N):
            dx = abs(x[i] - x[j])
            dy = abs(y[i] - y[j])
            dis = (dx / 2) ** 2 + (dy / 2) ** 2
            px = (x[i] + x[j]) / 2.0
            py = (y[i] + y[j]) / 2.0
            if can(px, py, dis):
                ret = min(ret, dis)
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                px, py = circumcenter(x[i], y[i], x[j], y[j], x[k], y[k])
                #px, py = center(x[i], y[i], x[j], y[j], x[k], y[k])
                if not px:
                    continue
                dis = (px - x[i]) ** 2 + (py - y[i]) ** 2
                if can(px, py, dis):
                    ret = min(ret, dis)
    #print(ret ** 0.5)
    print(math.sqrt(ret))
    #print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#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(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll A,B,K; cin>>A>>B>>K;
    
    cout<<A-min(K,A)<<" "<<B-min(K-min(K,A),B)<<endl;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x1 = max(a, b);
    ll x2 = min(a, b);
    ll y1 = max(c, d);
    ll y2 = min(c, d);
    ll ans = max(x1 * y1, x2 * y2);
    ans = max(ans, x1 * y2);
    ans = max(ans, x2 * y1);
    cout << ans << endl;
    return 0;
}


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

using ll =long long;

int main() {
int N,K,S;
  cin>>N>>K>>S;
  vector<int> vec(N);
for(int i=0;i<N;i++){
  if(i<K-1){
    vec[i]=S;}
if(i==K-1) {vec[i]=S+i-K+1;}
  if(i>K-1){vec[i]=815718;}


}
  
  for(int i=0;i<N;i++){
    cout<<vec[i]<<" ";
  }

    
}


Measured memory_bytes: 1664
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;

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

	cout << (n - 1)*(m - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
long long int n, a, b, c, ans;
scanf("%lld", &n);
a= sqrt(n);
if(a==1)
{
    b=1;
}
else{
for(a;n%a!=0 && a>1;a--)
{
b=a-1;
}
}

c=n/b;
ans= c+b-2;

printf("%lld", ans);

return 0;
}


Measured memory_bytes: 128
import sys
s = int(sys.stdin.readline().rstrip())
n = set([s])
for i in range(2, 10**6 + 1):
    if s % 2 == 0:
        s_next = s // 2
    else:
        s_next = 3 * s + 1
    if s_next in n:
        print(i)
        exit()
    s = s_next
    n.add(s)

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

int main(){
    int n,d;
    cin >> n >> d;
    d = 2*d +1;
    if(n%d==0){
        cout << n/d << endl;
    }else{
        cout << (n/d)+1 << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int main(){
	//file();
	fast();
	int n, a, s;
	cin >> n >> a >> s;
	cout << (n - a + 1)*(n - s + 1);

}

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

#define ll long long 
#define pb push_back
#define pu push
#define ins insert
#define f(s,e) for(i=s;i<e;i++)
#define loop(i) while(i--)
#define bg(v) v.begin()
#define ed(v) v.end()
#define sz(v) v.size()
#define len(v) v.length()
#define con continue;
#define brk break;
#define sn cout<<"\n";
#define in(n) cin>>n;
#define out(n) cout<<n;





int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t,op,i,j,k,m,h,n;
    
    cin>>n;
    k=100;
    ll sum=0;
    while(1)
    {
        k+=k/100;
        sum++;
        if(k>=n){
            break;
        }
    }
    cout<<sum;
	return 0; 
} 

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct node{
	int pri;
	int a[18];
} st[18];
int ans=1e9;
int b[18];
int d[18];
int n,m,x;
int len;
void dfs(int p)
{
	if(p==len+1)
	{
		int sum=0;
		memset(d,0,sizeof(d));
		for(int i=1;i<=len;i++)
		{
			sum+=st[b[i]].pri;
			for(int j=1;j<=m;j++)
			{
				d[j]+=st[b[i]].a[j];
			}
		}
		for(int i=1;i<=m;i++)
		{
			if(d[i]<x) return ;
		}
		ans=min(ans,sum);
		return ;
	}
	for(int i=b[p-1]+1;i<=n;i++)
	{
		b[p]=i;
		dfs(p+1);
	}
}
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>st[i].pri;
		for(int j=1;j<=m;j++)
		{
			cin>>st[i].a[j];
		}
	}
	for(len=1;len<=n;len++)
	{
		b[0]=0;
		dfs(1);
	}
	if(ans==1e9) cout<<-1<<"\n";
	else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 753;
  for (int i = 0; i < N - 2; i++) {
    ans = min(ans, abs((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + (S.at(i + 2) - '0') - 753));
  }
  cout << ans << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

pii A[100010];
int N;

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i].first;
		A[i].second = i + 1;
	}

	sort(A, A + N);

	rep(i, 0, N)
	{
		cout << A[i].second << " ";
	}
	cout << endl;

	return 0;
}

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

int max(int N,int A[]){
  int max=0;
  int max_i=0;
  for(int i=0;i<N;i++){
    if(max<A[i]){
      max=A[i];
      max_i=i;
    }
  }
  A[max_i]=0;
  return max;
}

int main(void){
  int N;
  int A[110];
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  
  int alice=0;
  int bob=0;
  bool flag=true;
  for(int i=0;i<N;i++){
    if(flag==true){
      alice+=max(N,A);
      flag=false;
    }else{
      bob+=max(N,A);
      flag=true;
    }
  }
  cout << alice-bob;
  return 0;
}

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

using namespace std;

int main() {
    int n, m;  cin >> n >> m;
    vector<int> cnt(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;   cin >> a >> b;
        cnt[a-1]++;
        cnt[b-1]++;
    }
    for (int i = 0; i < n; i++) {
        if (cnt[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3692
n, p=map(int, input().split())
a=list(map(int, input().split()))
for i in range(n):
  a[i]%=2
c=a.count(0)
if c==n:
  if p==1:
    print(0)
  else:
    print(2**n)
else:
  print(2**(n-1))

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        private class Restaurant
        {
            public int Order {get;set;}
            public string Sity {get;set;}
            public int Point {get;set;}
        }
        static void Main()
        {
            int n = NextInt;
            System.Console.WriteLine(string.Join("\n",
                Enumerable
                .Range(0, n)
                .Select(_ => StrArr)
                .Select((a, i) => new Restaurant{Order = i + 1, Sity = a[0], Point = int.Parse(a[1])})
                .OrderBy(r => r.Sity)
                .ThenByDescending(r => r.Point)
                .Select(r => r.Order)
            ));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

using namespace std;

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

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

	ans = n.at(2) - n.at(1);
	n.at(0) += ans;

	if ((n.at(2) - n.at(0)) % 2 == 0) {
		ans += (n.at(2) - n.at(0)) / 2;
	}
	else {
		ans += (n.at(2) - n.at(0) + 3) / 2;
	}

	cout << ans << endl;

	return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll a , b , k;

    cin >> k;

    cin >> a >> b;

    for(int i=min(a,b); i<=max(a,b); i++)
    {
        if(i%k==0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;




    return 0;
}



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

int main (void){
    int n = 700;
    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'o'){
            n += 100;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  int a[10010], b[10010];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  ll A = 0, B = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] == b[i]) continue;
    if (a[i] > b[i]) B += a[i] - b[i];
    else A += (b[i] - a[i] + 1) / 2, B += (b[i] - a[i]) % 2;
  }
  if (A == B) cout << "Yes" << endl;
  else if (A < B) cout << "No" << endl;
  else if (N == 1) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 512