akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    for (int i=0; i<H; ++i) cin >> c[i];

    int res = 0;
    for (int bi=0; bi<(1<<H); ++bi) {
        for (int ts=0; ts<(1<<W); ++ts) {
            int cnt = 0;
            for (int i=0; i<H; ++i) {
                for (int j=0; j<W; ++j) {
                    if (c[i][j] == '#' && !(bi & (1<<i)) && !(ts & (1<<j))) ++cnt;
                }
            }
            if (cnt == K) ++res;
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3620
N = int(input())
values = [int(i) for i in input().split()]

def alchemy(minNum1, minNum2):
    return (minNum1 + minNum2) / 2

while len(values) > 1:
    minNum1 = values.pop(values.index(min(values)))
    minNum2 = values.pop(values.index(min(values)))
    values.append(alchemy(minNum1, minNum2))

print(values[0])

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int ans=1e18;
	int n=in();int m=in();
	int mx,mn;
	for(int i=1;i<=n;i++)
	{
		int a1=m*i;
		int rem=n-i;
		int a2=rem/2;int a3=rem-a2;
		a2*=m;a3*=m;
		if(a1 and a2 and a3)
		{
			mx=max({a1,a2,a3});
			mn=min({a1,a3,a2});
			ans=min(ans,mx-mn);
		}
		
		a2=m/2;a3=m-a2;
		a2*=rem;a3*=rem;
		if(a1 and a2 and a3)
		{
			mx=max({a1,a2,a3});
			mn=min({a1,a3,a2});
			ans=min(ans,mx-mn);
		}	
	}
	for(int i=1;i<=m;i++)
	{
		int a1=n*i;
		int rem=m-i;
		int a2=rem/2;int a3=rem-a2;
		a2*=n;a3*=n;
		if(a1 and a2 and a3)
		{
			mx=max({a1,a2,a3});
			mn=min({a1,a3,a2});
			ans=min(ans,mx-mn);
		}
		
		a2=n/2;a3=n-a2;
		a2*=rem;a3*=rem;
		if(a1 and a2 and a3)
		{
			mx=max({a1,a2,a3});
			mn=min({a1,a3,a2});
			ans=min(ans,mx-mn);
		}	
	}
	cout<<ans;
	
	
	
}

Measured memory_bytes: 3756
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	int A, B ;
	cin >> A >> B;

	cout << max(A+B,max(A-B,A*B)) << endl;

}


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

int main(){
	char ch;
	
	while(1){
		scanf("%c", &ch);
		
		if(islower(ch)) printf("%c", toupper(ch));
		else if(isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);
		
		if(ch=='\n') break;
	}

	return 0;
}


Measured memory_bytes: 2604
import re

S = input()

l = []
for m in re.finditer(r'(R+)(L+)', S):
    part = ''.join(m.groups())
    # print(part)
    lst = [0] * len(part)
    idx = re.search(r'RL', part).start()
    if len(part) % 2:
        lst[idx] = len(part) // 2 + (idx + 1) % 2
        lst[idx + 1] = len(part) // 2 + idx % 2
    else:
        lst[idx] = len(part) // 2
        lst[idx + 1] = len(part) // 2
    l += lst
print(' '.join(map(str, l)))


Measured memory_bytes: 11636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

set<int> st[200005];
template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(auto& in:A) cin >> in;
    for(int i = 0; i < N;i++){
        st[A[i]].emplace(i);
    }

    ll now = 0;
    ll cnt = 1;
    while(true){
        ll val = A[now];

        auto next_it = st[val].upper_bound(now);

        if(next_it == st[val].end()){
            next_it = st[val].begin();
            cnt++;
        }
        now = (*next_it + 1)%N;
        if(now == 0) break;
    }
    K %= cnt;

    now = 0;
    cnt = 0;
    while(cnt < K-1){
        ll val = A[now];
        auto next_it = st[val].upper_bound(now);
        if(next_it == st[val].end()){
            next_it = st[val].begin();
            cnt++;
        }
        now = (*next_it + 1)%N;
    }

    while(now < N){
        ll val = A[now];
        auto next_it = st[val].upper_bound(now);
        if(next_it == st[val].end()){
            res.emplace_back(val);
            now++;
        }else{
            now = (*next_it + 1);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<vector<ll>>() << endl;
    return 0;
}

Measured memory_bytes: 25512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int a, b; cin >> a >> b;

    if(a < 10 && b < 10) cout << a*b;
    else cout << -1;

    return 0;

}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, N);
    ll x = min(B - 1, N);
    OUT(A * x / B - A * (x / B));
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(double x){
  printf("%.15f",x);
}
int N;
int K;
int main(){
  double res=0, tmp;
  int i, j;
  rd(N);
  rd(K);
  for(i=1;i<N+1;i++){
    j = i;
    tmp = 1.0 / N;
    while(j < K){
      j *= 2;
      tmp /= 2;
    }
    res += tmp;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N, K;
// {
//   int i, j;
//   double res = 0, tmp;
// 
//   rd(N, K);
//   rep(i,1,N+1){
//     j = i;
//     tmp = 1.0 / N;
//     while(j < K) j *= 2, tmp /= 2;
//     res += tmp;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


int n;
vector<P>G[114514];
int a[114514], b[114514];
int ans[114514];

bool used[114514];
void dfs(int x, int use = -1) {
	used[x] = true;
	int now = 0;
	for (P p : G[x]) {
		if (used[p.first])continue;
		now++;
		if (now == use)now++;
		ans[p.second] = now;
		dfs(p.first, now);
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
		G[a[i]].push_back({ b[i],i }); G[b[i]].push_back({ a[i],i });
	}
	dfs(0);
	int ma = 0;
	rep(i, n - 1)chmax(ma, ans[i]);
	cout << ma << endl;
	rep(i, n - 1) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 10880
#include <stdio.h>
#include <math.h>

//問題文より、入力されるデータの最大個数
#define MAXSTUDENT 1000

int main(void)
{
	//student_numは生徒数を、ansは標準偏差を、avgは得点の平均値を、scoreには試験の得点を格納
	int i, student_num;
	double ans, avg;
	double score[MAXSTUDENT];
	
	//生徒数を入力
	scanf("%d", &student_num);

	//生徒数が0なら終了
	while(student_num != 0){
		ans = 0;
		avg = 0;

		//生徒数分の得点を入力し、平均値を求める
		for(i = 0; i < student_num; i++){
			scanf("%lf", &score[i]);
			avg += score[i];
		}
		avg /= (double)student_num;

		/*
		分散 = (Σ[i = 0 → student_num] (score[i] - avg)^2) / student_num
		標準偏差 = sqrt(分散)
		*/
		for(i = 0; i < student_num; i++){
			ans += pow((score[i] - avg), 2.0);
		}
		ans /= (double)student_num;
		ans = sqrt(ans);

		//結果を出力
		printf("%lf\n", ans);

		//生徒数を入力
		scanf("%d", &student_num);
	}

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
bool is7(int n) {
    int tmp = n;
    while (tmp > 0) {
        if (tmp % 10 == 7) return true;
        tmp /= 10;
    }
    return false;
}
/* main */
int main(){
    int N;
    cin >> N;
    if (is7(N)) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3624
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let st: Vec<String> = read_vec();
    let ab: Vec<u64> = read_vec();
    let u: String = read();

    if st[0] == u { println!("{} {}", ab[0] - 1, ab[1]); return; }
    if st[1] == u { println!("{} {}", ab[0], ab[1] - 1); return; }
    println!("{} {}", ab[0], ab[1]);
}


Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
cnt = []
for i in range(N):
    cnt_sub = 0
    while a[i] % 2 == 0:
        a[i] = a[i] / 2
        cnt_sub += 1
    cnt.append(cnt_sub)
print(sum(cnt))

Measured memory_bytes: 4148
#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,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,M;
int dp[305][305][305][3];
vector<P>order[305];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>M;
	rep(i,M){
		int l,r,x;cin>>l>>r>>x;l--;
		order[r].push_back({l,x});
	}
	dp[0][0][0][0]=1;
	rep(i,N){
		rep(j,i+1)rep(k,i+1){
			bool flag=false;
			for(auto l:order[i]){
				int cnt=0;
				if(l.first<i)cnt++;
				if(l.first<j)cnt++;
				if(l.first<k)cnt++;
				if(cnt!=l.second)flag=true;
			}
			if(flag)continue;
			//012->012
			(dp[i+1][j][k][0]+=dp[i][j][k][0])%=mod;
			//012->102
			(dp[i+1][i][k][1]+=dp[i][j][k][0])%=mod;
			//012->201
			(dp[i+1][i][j][2]+=dp[i][j][k][0])%=mod;
			//102->012
			(dp[i+1][i][k][0]+=dp[i][j][k][1])%=mod;
			//102->102
			(dp[i+1][j][k][1]+=dp[i][j][k][1])%=mod;
			//102->201
			(dp[i+1][j][i][2]+=dp[i][j][k][1])%=mod;
			//201->012
			(dp[i+1][k][i][0]+=dp[i][j][k][2])%=mod;
			//201->102
			(dp[i+1][j][i][1]+=dp[i][j][k][2])%=mod;
			//201->201
			(dp[i+1][j][k][2]+=dp[i][j][k][2])%=mod;
		}
	}
	int sum=0;
	rep(i,N)rep(j,N){
		bool flag=false;
		for(auto k:order[N]){
			int cnt=0;
			if(k.first<N)cnt++;
			if(k.first<i)cnt++;
			if(k.first<j)cnt++;
			if(k.second!=cnt)flag=true;
		}
		if(flag)continue;
		(sum+=dp[N][i][j][0])%=mod;
		(sum+=dp[N][i][j][1])%=mod;
		(sum+=dp[N][i][j][2])%=mod;
	}
	cout<<sum<<endl;
}

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    if((b-a+1)<=2*k){
        for(int i=a;i<=b;i++){
            cout << i << endl;
        }
    }
    else{
        for(int i=a;i<a+k;i++){
            cout << i << endl;
        }
        for(int i=b-k+1;i<=b;i++){
            cout << i << endl;
        }
    }
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string s, t;
  IN(s,t);
  if(s.size() < t.size()) swap(s, t);
  ll SL = s.size();
  ll TL = t.size();
  vector<vector<string>> dp(2, vector<string>(TL, ""));
  if(s[0] == t[0]){
    REP(i,TL) dp[0][i] = s[0];
  }
  REP(i,SL){
    REP(j,TL){
      if(s[i] == t[j]){
        if(i && j){
          if(dp[1][j].size() < dp[0][j-1].size() + 1){
            dp[1][j] = dp[0][j-1] + s[i];
          }
        }else{
          dp[1][j] = s[i];
        }
      }
      if(i) if(dp[0][j].size() > dp[1][j].size()) dp[1][j] = dp[0][j];
      if(j) if(dp[1][j-1].size() > dp[1][j].size()) dp[1][j] = dp[1][j-1];
    }
    swap(dp[0], dp[1]);
  }

  mat_print(dp);

  OUT(dp[0][TL-1]);

  return 0;
}

Measured memory_bytes: 18740
n, m = map(int, input().split())
a = [-1] * n
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if -1 != a[s] != c:
        print(-1)
        exit()

    else:
        a[s] = c

if n > 1:
    if a[0] == 0:
        print(-1)
        exit()
    else:
        if a[0] == -1:
            a[0] = 1
        for p in range(len(a)):
            if a[p] == -1:
                a[p] = 0

        for C in a:
            print(C, end='')

else:
    if a[0] == -1:
        print(0)
        exit()
    print(a[0])


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }.sorted()
    val s = LongArray(n + 1)
    for (i in 0 until n) {
        s[i + 1] = s[i] + a[i]
    }

    var min = 0
    for (i in 1 until n) {
        if (s[i] * 2 >= a[i]) continue
        min = i
    }

    println(n - min)
}


Measured memory_bytes: 76980
#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 n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int ans = 0;
    bool flag = 1;
    while (flag) {
        flag = 0;
        for (int j = n-1; j > 0; j--) {
            if (a[j] < a[j-1]) {
                ans++;
                swap(a[j], a[j-1]);
                flag = 1;
            }
        }
    }

    rep(i, n) {
        cout << a[i];
        if (i != n-1) cout << ' ';
    }

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



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec X(N), L(N);
    pairs p(N);
    REP(i, N){
        cin >> X[i] >> L[i];
        p[i] = Pii(X[i] + L[i], i); 
    }
    Sort(p);

    int ans = 0, t = -INF;
    REP(i, N){
        int i0 = p[i].s;
        if(X[i0] - L[i0] >= t){
            ans++;
            t = X[i0] + L[i0];
        }
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 3456
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))



Measured memory_bytes: 5596
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
struct Struct;

fn gcd(a: u64, b: u64) -> u64 {
    if a < b {
        gcd(b, a)
    } else {
        let k = a / b;
        if a - k * b == 0 {
            b
        } else {
            gcd(b, a - k * b)
        }
    }
}

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        v: [u64;n],
    }

    {
        // not coprime の判定
        let mut g = v[0];
        for i in 1..n {
            g = gcd(g, v[i]);
        }
        if g != 1 {
            println!("not coprime");
            return;
        }
    }

    const MAX_A: usize = 1000_000;
    let mut hurui = vec![0; MAX_A + 1];
    let mut ahist = vec![0; MAX_A + 1];
    for i in 0..n {
        ahist[v[i] as usize] += 1;
    }

    let mut have_common_div = false;
    for i in 2..=MAX_A {
        let mut common_div_count = 0;
        if hurui[i] == 0 {
            for j in (i..=MAX_A).step_by(i) {
                common_div_count += ahist[j];
                hurui[j] = 1;
            }
            if common_div_count >= 2 {
                have_common_div = true;
                //println!("i={}, common_div_count={}", i, common_div_count);
            }
        }
    }

    if have_common_div {
        println!("setwise coprime");
    } else {
        println!("pairwise coprime");
    }
}


Measured memory_bytes: 24440
#include <stdio.h>
#include <stdlib.h>
#define FAIR (long long)(1e18)
typedef long long ll;

int main()
{
	ll a, b, c, k;
	ll ans;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

	if (k & 1) {
		ans = b - a;
	} else {
		ans = a - b;
	}

	if (llabs(a - b) > FAIR) {
		puts("Unfair");
	} else {
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
#include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=3e2+10;
const double inf = /*0x3f3f3f3f*/-1.0;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
double dp[N][N][N],d[N][N][N];int n,A[N];
double f(int i,int j,int k){
  if(d[i][j][k]!=inf)return d[i][j][k];
  if((i||j||k)==0)return 0;
  d[i][j][k]=n;
  //F(x,y,z) = 1 + p0F(x,y,z) + p1F(x-1,y,z) + p2F(x+1,y-1,z) + p3F(x,y+1,z-1)
  //p's are probabilitites
  //p0 for picking a dish with 0 sushi
  //p1 for picking a dish with 1 sushi
  //p2 for picking a dish with 2 sushi
  //p3 for picking a dish with 3 sushi
  //F(x,y,z) = (1+p1F(x-1,y,z) + p2F(x+1,y-1,z) + p3*F(x,y+1,z-1))/(1-p0)
  double p0=(double)(n-i-j-k)/(double)n;
  if(i!=0)d[i][j][k]+=(double)i*(f(i-1,j,k));
  if(j!=0)d[i][j][k]+=(double)j*(f(i+1,j-1,k));
  if(k!=0)d[i][j][k]+=(double)k*(f(i,j+1,k-1));
  d[i][j][k]=d[i][j][k]/(double)(i+j+k);
  return d[i][j][k];
}
int a,b,c;
void solve(){
  cin>>n;rep(i,1,n)cin>>A[i];
  rep(i,1,n){
    if(A[i]==1)a++;
    if(A[i]==2)b++;
    if(A[i]==3)c++;
  }
  dp[a][b][c]=1;
  per(k,n,0)
    per(j,n,0)
      per(i,n,0){
        d[i][j][k]=inf;
        // if((i==0 and j==0) or (j==0 and k==0) or (i==0 and k==0))continue;
        if(i!=0){dp[i-1][j][k]+=dp[i][j][k]*(double)i/(i+j+k);}
        if(j!=0){dp[i+1][j-1][k]+=dp[i][j][k]*(double)j/(i+j+k);}
        if(k!=0){dp[i][j+1][k-1]+=dp[i][j][k]*(double)k/(i+j+k);}
      }
  //dp[i][j][k] is the probability of reaching the i j k state
  cout<<setprecision(20)<<f(a,b,c);
        // cout<<d[i][j][k];
}
int32_t main()
{
  // ibs;cti; 
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 907520
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define Hkill(x)                    cout << x << endl; exit(0);
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 998244353; //1e9 + 7
const ld PI = 4 * atan((ld) 1);
vector<ll> v;

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        auto it = lower_bound(all(v), x);
        if (it == v.begin())
            v.insert(v.begin() , x);
        else
            it--, *it = x;

    }
    cout << sz(v) << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    ll N,M,ansa=0,ansb=0;
    int a=1;
    cin >> N >> M;

    vector<ll> H(N+1),data(N+1),C(N+1),D(N+1,0);

    for (int i = 1; i < N+1; i++) {
        cin >> H.at(i);
    }
    for (int i = 1; i < M+1; i++) {
        ll A, B; cin >> A >> B;
        C[A]++; C[B]++;
        if(H[A] > H[B]){
            D[B]--;
        }
        else if(H[A] < H[B]){
            D[A]--;
        }
        else if(H[A] == H[B]){
            D[A]--; D[B]--;
        }
    }
    
    // for (int i = 1; i < N+1; i++) {
    //     if(data[i] > 0) ans++;
    // }
    for (int i = 1; i < N+1; i++) {
        if(C[i] == 0) ansa++;
        if(D[i] < 0) ansb++;
    }
    
    cout << N - ansb << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	ll T = 0,A = 0;
	ll t,a;
	cin >> n;
	rep(i,n){
		cin >> t >> a;
		ll k = 1;
		if(t != 0)k = max ( k , (T+t-1)/t );
		if(a != 0)k = max ( k , (A+a-1)/a );
		T = t*k;
		A = a*k;
	}
	cout << T+A << endl;
}



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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
//
//

ll lcm ( ll a , ll b ){
	return (a*b)/(__gcd(a,b)); 
}
ll n(ll x , ll l , ll r ){
	return  ( -l / x + r / x + (l % x == 0 )) ; 
}
int main(){
	ll a , b , c , d ; 
	cin >> a >> b >> c >> d ; 
	cout << b - a + 1 - (  n (c,a,b) + n (d,a,b) -n(lcm(c,d),a,b)) << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<pair<ll, ll>> v(N);
	for(int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());

	for(int i = 0; i < N; i++) {
		K -= v[i].second;
		if(K <= 0) {
			cout << v[i].first << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll maki,ans=0;
	cin>>maki;
	ll niko[maki];
	for(int i=0;i<maki;i++){
		cin>>niko[i];
	}
	sort(niko,niko+maki);
	reverse(niko,niko+maki);
	for(int i=0;i<maki;i++){
		if(i%2==0){
			ans+=niko[i];
		}
		else{
			ans-=niko[i];
		}
	}
	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def num_2n(i):
    count = 0
    while(i % 2 == 0):
        i = i / 2
        count += 1
    return count



def main():
    num_ans = int(input())
    ans_list = list(map(int, input().split()))
    num_2n_list =[]
    for i in ans_list:
        num_2n_list.append(num_2n(i))
    num_2n_list.sort()
    print(num_2n_list[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
using namespace std;
char s[1000000];
int main(){
    while(~scanf("%s",s)){
        int st=0,en=0;
        int len=strlen(s);
        for(int i=0;i<len;i++){
            if(s[i]=='A'&&!st&&s[0]!='A')st=i;
            if(s[i]=='Z')en=i;
        }printf("%d\n",en-st+1);
    }return 0;
}

Measured memory_bytes: 384
S = str(input())
T = str(input())

SLEN = len(S)
TLEN = len(T)
ans = len(T)
for i in range(SLEN-TLEN+1):
    tmp = 0
    for j in range(TLEN):
        if S[i+j] != T[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp

print(ans)

Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    string S;
    cin >> N;
    cin >> S;

    vector<int> E(N),W(N);
    int w,e;
    w = e = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( S[i] == 'W' ) { w++; }
        W[i] = w;
    }
    for ( int i = N-1; i >= 0; i-- ) {
        if ( S[i] == 'E' ) { e++; }
        E[i] = e;
    }

    int ans = INT_MAX;
    for ( int i = 0; i < N; i++ ) {
        int w = 0;
        if ( i ) { w = W[i-1]; }
        int e = 0;
        if ( i != N-1 ) { e = E[i+1]; }
        ans = min( ans, w+e );
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

int solve(int *, int, int);
int n;

int main()
{
  int a[20] ,m[200], q, i, hantei;
  
  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&a[i]);
    }

  scanf("%d",&q);

  for(i = 0; i < q; i++)
    {
      scanf("%d",&m[i]);
    }

  for(i = 0; i < q; i++)
    {
      hantei = solve(a, 0, m[i]);
      if(hantei == 1)printf("yes\n");
      else printf("no\n");
    }

  return 0;
}

int solve(int *a, int i, int m)
{
  int res;
  
  if(m == 0)return 1;
  else if(i >= n)return 0;
  else if(res = solve(a, i + 1, m) || solve(a, i + 1, m - a[i]))return res;
}



Measured memory_bytes: 2048
#include<cstdio>
 
int main()
{
	int X;
	scanf("%d", &X);
	for (int A = 0; A < 120; ++A) {
      	for (int B = -120; B < A; ++B) {
			if (A * A * A * A * A - B * B * B * B * B == X)
			{
				printf("%d %d", A, B);
				return 0;
            }
		}
    }
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>//Aizu - CGL_2_A  （线段平行和垂直）
using namespace std;
double dot(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3){
    return (x1 - x0) * (x3 - x2) + (y1- y0) * (y3 - y2);
}
double dist(double x0, double y0, double x1, double y1){
    return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
}
int main(){
    int n, i, f;
    double x0, y0, x1, y1, x2, y2, x3, y3, r;
    scanf("%lf%lf%lf%lf", &x0, &y0, &x1, &y1);
    cin >> n;
    while(n --){
        f = 0;
        scanf("%lf%lf", &x2, &y2);
            r = dot(x0, y0, x1, y1, x0, y0, x2, y2) / dist(x0, y0, x1, y1)  / dist(x0, y0, x1, y1); 
            printf("%.8lf %.8lf\n", x0 + r * (x1 - x0), y0 + r * (y1 - y0));
        
    }
    return 0;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

/////////////////////////////////////////////////////////

const int N = 1e5;

string str;

int solve(){
	int cnt = 0, cnt2 = 1, ret = 0;
	if(str[0] == 'p') ret++;
	REP(i,1,str.length()-1){
		if(str[i] == 'p'){
			if(cnt+1 <= cnt2){
				cnt++;
			}
			else{
				cnt2++;
				ret--;
			}
		}
		else{
			if(cnt+1 <= cnt2){
				cnt++;
				ret++;
			}
			else cnt2++;
		}
//		printf("cnt %d, cnt2 %d -> %d\n",cnt,cnt2,ret);
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> str;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> k(n,0);
  rep(i,n-1){
    int y;
    cin >> y;
    y--;
    k[y]++;
  }
  rep(i,n){
    cout << k[i] << endl;
  }
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );
ll fact(ll i){
    if(i==0) return 1;
    else return fact(i-1)*i%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    if (n==m){
        cout<<2*fact(n)*fact(m)%MOD<<endl;
    }else if(abs(n-m)==1){
        cout<<fact(n)*fact(m)%MOD<<endl;
    }else cout<<0<<endl;
    
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

int n;
int d[MAX_N];

int main() {

  cin >> n;
  rep(i, n) cin >> d[i];

  sort(d, d+n);

  cout << d[n/2]-d[n/2-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char st[11];
int main() {
	scanf("%s",st+1);int len=strlen(st+1);
	if(st[1]!='A'){printf("WA\n");return 0;}
	int cnt=0;
	for(int i=2;i<=len;++i) {
		if(st[i]=='C')++cnt;
		if(st[i]!='A' && st[i]!='C' && st[i]>='A' && st[i]<='Z'){printf("WA\n");return 0;}
	}
	if(st[2]=='C')cnt--;if(st[len]=='C')cnt--;
	if(cnt!=1)printf("WA\n");
	else printf("AC\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {
    }
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            uf.unite(u, v);
        }
        if (t == 1) {
            cout << uf.find(u, v) << '\n';
        }
    }
}

Measured memory_bytes: 3756
#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(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	int a[3];
	REP(i, 3) cin >> a[i];
	sort(a, a + 3);
	
	if (a[0] != a[1]) cout << a[0] << endl;
	else cout << a[2] << endl;
	
	return 0;
}


Measured memory_bytes: 256