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

using namespace std;

char sa[101], sb[101], sc[101];

void init()
{
	while(scanf("%s %s %s", sa, sb, sc) == 3) 
	{
		int len_a = strlen(sa);
		int len_b = strlen(sb);
		int len_c = strlen(sc);
		
		int flag_a = 0;
		int flag_b = 0;
		int flag_c = 0;

		int count_a = 0;
		int count_b = 0;
		int count_c = 0;
		while(1) 
		{
			if (flag_a == 0)
			{
				if (sa[count_a] == 'a')
				{
					flag_a = 0;
					flag_b = 1;
					flag_c = 1;
				}
				else if (sa[count_a] == 'b')
				{
					flag_a = 1;
					flag_b = 0;
					flag_c = 1;
				}
				else if (sa[count_a] == 'c')
				{
					flag_a = 1;
					flag_b = 1;
					flag_c = 0;
				}
				count_a++;
				if (count_a > len_a)
				{
					printf("A\n"); break;
				}
			}

			else if (flag_b == 0)
			{
				if (sb[count_b] == 'a')
				{
					flag_a = 0;
					flag_b = 1;
					flag_c = 1;
				}
				else if (sb[count_b] == 'b')
				{
					flag_a = 1;
					flag_b = 0;
					flag_c = 1;
				}
				else if (sb[count_b] == 'c')
				{
					flag_a = 1;
					flag_b = 1;
					flag_c = 0;
				}
				count_b++;
				if (count_b > len_b)
				{
					printf("B\n"); break;
				}
			}

			else if (flag_c == 0)
			{
				if (sc[count_c] == 'a')
				{
					flag_a = 0;
					flag_b = 1;
					flag_c = 1;
				}
				else if (sc[count_c] == 'b')
				{
					flag_a = 1;
					flag_b = 0;
					flag_c = 1;
				}
				else if (sc[count_c] == 'c')
				{
					flag_a = 1;
					flag_b = 1;
					flag_c = 0;
				}
				count_c++;
				if (count_c > len_c)
				{
					printf("C\n"); break;
				}
			}
		}
	}
}

int main()
{

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

	init();

	return 0;
}

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


int main(void) {
    int n;
    vector<int> p;
    
    cin >> n;
    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    
    int count = 0;
    int min, max;
    for (int i=1; i<n-1; i++) {
        min=100, max=0;
        for (int j=-1; j<=1; j++) {
            if (p[i + j] < min) min = p[i + j];
            if (p[i + j] > max) max=p[i + j];
        }
        if (p[i] > min && p[i] < max) {
            count++;
        }
    }
    cout << count;

    return 0;
}


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

// auto MOD int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination MOD prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

int main() {
    int X,Y;
    cin >> X >> Y;
    
    mint ans = 0;

    rep(y,X+1) {
        int res = X - y;
        if (res%2==0 && res/2+2*y==Y) {
            int x = res/2;
            mint tmp = comb.fact[x+y];
            tmp /= comb.fact[x];
            tmp /= comb.fact[y];
            ans += tmp;
        }
    }

    cout << ans << endl;
}


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

int main(void){
    string S,T;
    cin >> S >> T;
    int cnt = 0;
    for(int i = 0 ; i < S.size() ; i++){
        if(S.at(i) != T.at(i)) cnt++;
    }
    cout << cnt << endl;
}

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

#define printl(s) cout << s << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;

const ll modSeed = pow(10,9) + 7;
const int INF = 1'000'000'000;

template <typename T>
vector<T> getVector(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
ll A,B,C,X,Y,ans;

int main(){
  ans = 0;
  cin >> A>>B>>C>>X>>Y;
  for(ll c=0;c<=max(2*X,2*Y);c++){
    if(c%2!=0) continue;
    ll a = max(0LL,X - c/2);
    ll b = max(0LL,Y -c/2);
    if(ans==0){
      ans = a*A+b*B+c*C;
    }else{
      ans = min(a*A+b*B+c*C,ans);
    }
  }
  printl(ans);
}


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

using namespace std;

// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


#define debug(x) cout << #x << "==" << x << endl;

typedef long long ll;

int N, A, B, C, D;


const int inf = 1e+8;

const int mod = 1e+9 + 7;

typedef long long ll;

#define MAX_N 1001

ll pow(ll a, int b){
    int ret = 1;
    while(b){
        if(b & 1) ret = (1ll) * ret * a % mod;
        b >>= 1;
        a = (1ll) * a * a % mod;
    }
    return ret;
}

inline ll add(ll a, ll b) { return (a + b) % mod; }
inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
inline ll mul(ll a, ll b) { return (a * b) % mod; }
inline ll div(ll a, ll b) { return mul( a, pow(b, mod-2) ); }


ll fact[MAX_N+1], fact_inv[MAX_N+1];
void create_fact() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < MAX_N; i++) {
    fact[i] = mul(fact[i-1], i);
    fact_inv[i] = pow(fact[i], mod - 2);
  }
}

ll nPk(int n, int k) {
  // n! / (n-r)!
  return mul(fact[n], fact_inv[n-k]);
}


int memo[1001][1001];
bool checked[1001][1001];
ll rec(int g, int i) {

  // debug(g); debug(i);

  if( checked[g][i] ) return memo[g][i];

  if( i == 0 ) return 1;
  if( g == 0 ) return 0;

  ll res = 0;

  // g人グループを使わない
  // cout << g-1 << "," <<  i << "\n";
  res += rec( g-1, i);

  // g人グループを使えない
  if( g < A or g > B ) {
    return res;
  }

  // g人グループを使える
  for(ll k = C; k <= D; k++) {
    if( k*g <= i ) {
      ll comb = nPk(i, k*g);
      comb = mul(comb, pow(fact_inv[g], k) );
      comb = mul(comb, fact_inv[k] );
      res = add(res, mul(comb, rec( g-1, i-k*g )));
    }
  }
  checked[g][i] = true;
  memo[g][i] = res;
  return res;


}


int main() {
  ios::sync_with_stdio(false);

  create_fact();

  cin >> N >> A >> B >> C >> D;

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

  cout << rec( B, N );
  // debug( rec( 2,3) );

  // debug( rec( 2,0) );

  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    int last = 1;
    long long int res = 0;
    if (v[0] <= 0) res = abs(1 - v[0]);
    else last = v[0];
    int target;
    for (int i = 1; i < n; i++) {
        if (last > 0) {
            target = -1;
        } else {
            target = 1;
        }
        last += v[i];
        if (target == 1) {
            if (last <= 0) {
                res += abs(1 - last);
                last = 1;
            }
        } else {
            if (last >= 0) {
                res += abs(-1 - last);
                last = -1;
            }
        }
    }

    long long int next_res = 0;
    last = -1;
    if (v[0] >= 0) next_res = abs(-1 - v[0]);
    else
        last = v[0];
    for (int i = 1; i < n; i++) {
        if (last > 0) {
            target = -1;
        } else {
            target = 1;
        }
        last += v[i];
        if (target == 1) {
            if (last <= 0) {
                next_res += abs(1 - last);
                last = 1;
            }
        } else {
            if (last >= 0) {
                next_res += abs(-1 - last);
                last = -1;
            }
        }
    }
    // cout << res << " " << next_res << endl;
    cout << min(res, next_res) << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
struct uftree{
    private:
    ll siz;
    vector<ll> par,rnk,val;
    public:
    uftree(ll n){
        siz=n;
        par.resize(siz+1,0);
        rnk.resize(siz+1,0);
        val.resize(siz+1,0);
        for(ll i=1;i<=n;i++) par[i]=i;
    }
    ll find(ll pos){
        if(par[pos]==pos) return pos;
        else return par[pos]=find(par[pos]);
    }
    bool same(ll a,ll b){
        return find(a)==find(b);
    }
    void add(ll pos,ll x){
        pos=find(pos);
        val[pos]+=x;
    }
    void unite(ll x,ll y){
        x=find(x); y=find(y);
        if(rnk[x]<rnk[y]){
            par[x]=y;
            val[y]+=val[x];
        }
        else{
            par[y]=x;
            val[x]+=val[y];
            if(val[x]==val[y]) val[x]++;
        }
    }
    ll sum(ll pos){
        pos=find(pos);
        return val[pos];
    }
};
int main(){
    ll n,q;
    cin>>n>>q;
    uftree uf(n);
    for(int i=0;i<q;i++){
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0) uf.unite(x,y);
        else cout<<(uf.same(x,y)?1:0)<<endl;
    }
}


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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   ll a,b;
   char c;
   cin >> a >> c >> b;
   if(c == '+') cout << a + b << endl;
   else cout << a - b << endl;

   return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll>A(100000 + 1, 0);
    REP(i, N){
        int x, y;
        cin >> x >> y;
        A.at(x) += y;
    }
    REP(i, 100000 + 1){
        if(K <= A.at(i)){
            print(i);
            return 0;
        }
        K -= A.at(i);
    }
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
#include <tuple>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

class UnionFind{
private:
  vector<int> par, rank;
public:
  UnionFind(int n){
	par.assign(n, 0);
	rank.assign(n, 0);
	for(int i=0;i<n;++i)
	  par[i] = i;
  }

  //find root of x
  int find(int x){
	if(par[x] == x)
	  return x;
	return (par[x] = find(par[x]));
  }

  void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rank[x] < rank[y])
	  par[x] = y;
	else{
	  par[y] = x;
	  if(rank[x] == rank[y])
		++rank[x];
	}
  }

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

int N, M;
vector<tuple<int,int,int>> es;

bool check(int idx){
  int H = (N - 2) / 2;
  if(idx < H || M - idx - 1 < H)
	return false;
	   
  UnionFind uf1(N);
  REP(i,idx+1)
	uf1.unite(get<1>(es[i]), get<2>(es[i]));
  VI edges;
  FOR(i,idx+1,M){
	int s, t, c;
	tie(c,s,t) = es[i];
	if(uf1.same(s, t)) continue;
	uf1.unite(s, t);
	edges.PB(i);
  }

  bool ok = true;
  REP(i,N) if(!uf1.same(i,0)) ok = false;
  if(SZ(edges) > H || !ok)
	return false;

  UnionFind uf2(N);
  uf2.unite(get<1>(es[idx]), get<2>(es[idx]));
  REP(i,SZ(edges)){
	int s, t, c;
	tie(c,s,t) = es[edges[i]];
	uf2.unite(s,t);
  }
  for(int i=idx+1;i<M&&SZ(edges)<H;++i){
	int s, t, c;
	tie(c,s,t) = es[i];
	if(uf2.same(s,t)) continue;
	uf2.unite(s,t);
	edges.PB(i);
  }
  if(SZ(edges) != H)
	return false;

  REP(i,idx){
	int s, t, c;
	tie(c,s,t) = es[i];
	if(uf2.same(s,t)) continue;
	uf2.unite(s,t);
  }

  ok = true;
  REP(i,N) if(!uf2.same(i,0)) ok = false;
  return ok;
}

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

  while(cin>>N>>M,N){
	es.assign(M, tuple<int,int,int>());
	REP(i,M){
	  cin >> get<1>(es[i]) >> get<2>(es[i]) >> get<0>(es[i]);
	  get<1>(es[i])--;
	  get<2>(es[i])--;
	}
	SORT(es);

	for(int i=0;i<M;++i){
	  if(check(i)){
		cout << get<0>(es[i]) << endl;
		break;
	  }
	}
  }
  
  return 0;
}

Measured memory_bytes: 1356
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int ans = ceil((double)(N - 1) / (K - 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    const long long mod = 1e9+7;
    int n;
    cin >> n;
    long long res = 1;
    int color[3] {0,0,0};
    while(n --){
        int num;
        cin >> num;
        int p = 0;
        for(int i = 0; i < 3; i ++){
            if(color[i] == num){
                p++;
                if(p == 1) color[i] ++;
            }
        }
        res *= p;
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int k,a,b;
        cin>>k>>a>>b;
        int l = a/k;
        int r = b/k;
        int ok = 1;
        if(l == r)
        {
            if(a%k)ok=0;
        }
        cout<<(ok?"OK":"NG")<<endl;
    }
    return 0;
}


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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (n = in()){
    vector<int> ss;
    for (int i = 0; i < n; i++){
      vector<int> vs = inpt<int>(5);
      ss.push_back(acum(vs));
    }
    sort(ss);
    printf("%d %d\n", ss[ss.size() - 1], ss[0]);
  }
  return (0);
}

Measured memory_bytes: 1252
#include <iostream>
#include <deque>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    deque<char> str;
    for (int i = 0; i < s.size(); ++i) {
        str.push_back(s[i]);
    }

    int q;
    cin >> q;
    int t, f;
    char ci;
    bool reversed = false;
    for (int j = 0; j < q; ++j) {
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
        } else {
            cin >> f >> ci;
            if (f == 1) {
                if (reversed) {
                    str.push_back(ci);
                } else {
                    str.push_front(ci);
                }
            } else {
                if (reversed) {
                    str.push_front(ci);
                } else {
                    str.push_back(ci);
                }
            }
        }
    }

    if (!reversed) {
        for (int k = 0; k < str.size(); ++k) {
            cout << str[k];
        }
    } else {
        for (int k = str.size() - 1; k >= 0; --k) {
            cout << str[k];
        }
    }


    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b)
    swap(a,b);
  if(b>c)
    swap(b,c);
  if(a>b)
    swap(a,b);
  cout << a << ' ' << b << ' ' << c << endl;
}
  


Measured memory_bytes: 3044
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000000
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

vector<lli>ara;

int main()
{
    lli n;
    cin>>n;

    for(lli i=0; i<n; i++)
    {
        lli a;
        scanf("%lld", &a);

        ara.push_back(a);
    }

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


    lli ans=0;

    for(lli i=0; i<n; i++)
    {
        for(lli j=i+1; j<n; j++)
        {
            for(lli k=j+1; k<n; k++)
            {
                if(ara[i]!=ara[j] && ara[i]!=ara[k] && ara[j]!=ara[k])
                if(ara[i]+ara[j]>ara[k]) ans++;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code
    int N,Y;
    cin >> N >> Y;

    for (int i=0;i<=N;i++){
        for (int k=0;k<=N;k++){
            int l=N-(i+k);
            if (Y==((10000*l)+(5000*k)+(1000*i))&&N==(i+k+l)&&l>=0){
                cout << l << ' ' <<k<<' '<<i<<endl;
                return 0;
            }
        }
    }
    cout << -1 <<' '<<-1<<' '<<-1<<endl;
}


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

int main() {
  int n, x, m, minm, total;
  std::cin >> n >> x;
  
  minm = 10000;
  for (int i = 0; i < n; i++) {
    std::cin >> m;
    if (m < minm) {
      minm = m;
    }
    total += 1;
    x -= m;
  }
  total += x / minm;
  
  std::cout << total << '\n';
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
K = []
for _ in range(N):
    K.append(list(map(int, input().split())))

d = {i+1:0 for i in range(M)}
for k in K:
    for i in range(1, len(k)):
        d[k[i]] += 1

ans = 0
for m in d.values():
    if m == N:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,A,B;cin >> N >> A >> B;
  if(abs(A-B)&1)cout << "Borys" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%d\n",c>a-b?c-(a-b):0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int mix_id(int l, int r) {
	if (l > r) {
		swap(l, r);
	}
	return l * 1000 + r;
}

bool has_cycle(const vector<vector<int>>& nodes, int id, unordered_set<int>& rec_stack, vector<bool>& visited) {
	if (rec_stack.count(id) > 0) return true;
	if (visited[id]) return false;
	visited[id] = true;
	rec_stack.insert(id);
	bool res = false;
	for (int next_id : nodes[id]) {
		if (has_cycle(nodes, next_id, rec_stack, visited)) {
			res = true;
			break;
		}
	}
	rec_stack.erase(id);
	return res;
}

int depth(const vector<vector<int>>& nodes, int id, vector<int>& depth_cache) {
	if (depth_cache[id] >= 0) return depth_cache[id];
	int max_depth = 0;
	for (int next_id : nodes[id]) {
		max_depth = max(max_depth, depth(nodes, next_id, depth_cache) + 1);
	}
	return depth_cache[id] = max_depth;
}

int main (int argc, char* argv[]) {
	vector<vector<int>> nodes(1001000);
	int n;
	cin >> n;
	vector<int> targets(n - 1);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> targets[j];
			targets[j]--;
		}
		for (int j = 0; j < n - 2; j++) {
			nodes[mix_id(i, targets[j])].push_back(mix_id(i, targets[j + 1]));
		}
	}

	unordered_set<int> rec_stack;
	vector<bool> visited(1001000);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int id = mix_id(i, j);
			if (has_cycle(nodes, id, rec_stack, visited)) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	int max_depth = 0;
	vector<int> depth_cache(1001000, -1);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			max_depth = max(max_depth, depth(nodes, mix_id(i, j), depth_cache));
		}
	}
	cout << max_depth + 1 << endl;
}


Measured memory_bytes: 43520
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>

using namespace std;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (int)1e9
#define N (int)1e5 * 5
#define mod (int)1e9 + 7
#define all(x) (x).begin(), (x).end()
int in(){
    int a;
    cin >> a;
    return a;
}
int gcd(int a, int b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

void solve(){
    lo a;
    double b;
    cin >> a >> b;
    lo tmp = b * 100 + 0.1;
    lo res = a * tmp;
    cout << res / 100 << endl;
}

int main(){
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    fast
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
/*

*/


Measured memory_bytes: 3740
import sys


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


N, M = LI()
ans = [-1]*N
for _ in range(M):
    a, b = LI()
    if ans[a-1] == b or ans[a-1] == -1:
        ans[a-1] = b
    else:
        print(-1)
        sys.exit()
if ans[0] == -1:
    if N==1:
        print(0)
        sys.exit()
    ans[0] = 1
if ans[0] == 0:
    if N == 1:
        print(0)
    else:
        print(-1)
    sys.exit()
S = ""
for i in range(N):
    if ans[i] == -1:
        ans[i] = 0
    S += str(ans[i])
print(S)


Measured memory_bytes: 8968
#include <stdio.h>
#include <string.h>

int main(void){
  int playlist;
  scanf("%d",&playlist);
  
  char set[playlist][100];
  int time[playlist];
  int i;
  for(i=0;i<playlist;i++){
  	scanf("%s %d",set[i],&time[i]);
  }
  char sleep[100]; 
  scanf("%s",sleep);
  
  i=0;
  do{
    ++i;
  }while(strcmp(sleep,set[i-1])!=0);
  // set[i]と一致
  int ans=0;
  for(;i<playlist;i++){
    ans+=time[i];
  }
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()

//use (__int128)to extend ll range
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
   if(a>b){
       return b;
   }
   return a;
}

ll max(ll a, ll b){
   if(a>b){
       return a;
   }else return b;
}
 
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
//-----comparision for pairs------
 
bool comp(const pair<int,int>pia,const pair<int,int>pib)
{
	if(pia.fi==pib.fi) return pia.se>pib.se;
	else return pia.fi>pib.fi;
}

const ll N=1e9+7;
int main()
{
  string s;
  cin>>s;
  int n=s.len;
  int ch=1;
  forl(i,0,n/2)
  {
      if(s[i]!=s[n-1-i])ch=0;
  }
  string y=s.substr(0,(n-1)/2);
  forl(i,0,y.len/2)
  {
      if(y[i]!=y[y.len-1-i])ch=0;

  }
  if(ch) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        g.append(list(map(int, input().split())))
    for i in range(h):
        k = list(map(int, input().split()))
        for j in range(w):
            g[i][j] = abs(g[i][j] - k[j])

    m = (h + w) * 50

    if m == 0:
        print(0)
        exit()

    dp = [[False] * m for _ in range(w)]
    dp[0][g[0][0]] = True
    for j in range(1, w):
        for k in range(m):
            if dp[j-1][k]:
                dp[j][abs(k - g[0][j])] = True
                try:
                    dp[j][k + g[0][j]] = True
                except:
                    pass
    
    for i in range(1, h):
        new_dp = [[False] * m for _ in range(w)]
        for k in range(m):
            if dp[0][k]:
                new_dp[0][abs(k - g[i][0])] = True
                try:
                    new_dp[0][k + g[i][0]] = True
                except:
                    pass
        
        for j in range(1, w):
            for k in range(m):
                if new_dp[j-1][k] or dp[j][k]:
                    new_dp[j][abs(k - g[i][j])] = True
                    try:
                        new_dp[j][k + g[i][j]] = True
                    except:
                        pass
        dp = new_dp

    for j in range(m):
        if dp[w-1][j]:
            print(j)
            break

main()

Measured memory_bytes: 249340
from scipy.misc import comb
from math import factorial

N, P = map(int, input().split())
A = list(map(int,input().split()))

e = len([a for a in A if a % 2 == 0])
o = N - e

ans = 0
if P == 0:
  for i in range(0, o+1, 2):
    ans += comb(o, i, exact=True)
  print(ans * pow(2, e))
else:
  for i in range(1, o+1, 2):
    ans += comb(o, i, exact=True)
  print(ans * pow(2, e))

Measured memory_bytes: 13836
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

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

ll lcm(ll a, ll b){
    return a*b / gcd(a,b);
}

ll bytwo(ll a){
    if(a%2 == 1) return 0;
    return 1+bytwo(a/2);
}

int main(){
    ll n,m;
    cin >> n >> m;
    map<ll,ll> a;
    for(int i = 0; i < n; i++){
        ll tmp;
        cin >> tmp;
        a[tmp] = 1;
    }

    ll ans = 0;
    ll lcmn = (a.begin()->first/2);
    ll cut = bytwo(a.begin()->first/2);
    for(auto it = a.begin(); it != a.end(); it++){
        lcmn = lcm(lcmn,it->first/2);
        if(bytwo(it->first/2) != cut){
            ans = -1;
            break;
        }
    }

    if(ans == -1){
        ans = 0;
    } else {
        ll tmp = m/lcmn;
        ans = tmp/2 + tmp%2;
    }

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

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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> F(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];
    sort(all(A));
    sort(all(F),greater<ll>());
    ll mx = (ll)1e12;
    rep(i,N) mx = max(mx,A[i]*F[i]);
    ll l = -1; ll r = mx;
    while(l<r-1){
        ll t = (l+r)/2;
        ll k = K;
        bool flag = true;
        rep(i,N){
            if(A[i]*F[i]>t) k-=(A[i]-(t/F[i]));
            if(k<0){
                flag = false;
                break;
            }
        }
        if(flag) r = t;
        else l = t;
    }
    cout << r << endl;
}

Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

const int N = 3005;
const int mod = 1e9+7;
char s[N];
int dp[N][N];

void add(int &a,int b){
	a += b;
	if(a >= mod)	a -= mod;
}

signed main(){
	IOS
	int n;
	scanf("%lld", &n);
	scanf("%s", s);
	dp[1][1] = 1;
	for(int len = 2; len <= n; len++){
		for(int a = 1; a <= len; a++)	add(dp[len-1][a],dp[len-1][a-1]);
		for(int b = 1; b <= len; b++){
			int L, R;
			if(s[len-2] == '<')	L = 1, R = b - 1;
			else				L = b, R = len - 1;

			// for(int i = L; i <= R; i++)	add(dp[len][b], dp[len-1][i]);	// prefix sum
			add(dp[len][b], dp[len-1][R] - dp[len-1][L-1] + mod);

			// for(int a = 1; a <= len - 1; a++){
			// 	// previous pos
			// 	int real_a = a;
			// 	if(a >= b)	real_a++;
			// 	assert(real_a != b);
			// 	if((real_a < b) != (s[len-2] == '<'))	continue;
			// 	add(dp[len][b],dp[len-1][a]);
			// }
		}
	}
	int ans = 0;
	rep(i,n)	add(ans, dp[n][i+1]);
	printf("%lld\n", ans);
}


Measured memory_bytes: 69120
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int n,cnt=0;cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i%2==0&&a[i]%2==1)cnt++;
	}
	cout<<cnt;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, k, s;
// string s;

int main() {
    cin >> n >> k >> s;

    REP(i, k) {
        std::cout << s << ' ';
    }
    int x;
    if (s == 1e9) {
        x = 1;
    } else {
        x = s+1;
    }
    REP(i, n-k) {
        std::cout << x << ' ';
    }
    std::cout << '\n';

    return 0;
}


Measured memory_bytes: 1280
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    ans1 = ans2 = 0
    for i, c in enumerate(S):
        if i % 2 == int(c):
            ans1 += 1
        else:
            ans2 += 1

    print(min(ans1, ans2))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int r; int g;
    cin >> r >> g;
    int x = 2 * g - r;
    cout << x << endl;
}


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

int main(){
  int A,B,C;
  cin >> A>> B >>C;
  if(A==B&&B==C&&C==A)
  cout << "No";
  else if(A!=B&&B!=C&&C!=A)
  cout << "No";
  else
  cout << "Yes";
}

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

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> cnt(n + 1, 0);
    for (int p = 1; p <= n; ++p) {
        for (int x = p; x <= n; x += p) ++cnt[x];
    }

    lint ans = 0;
    for (int x = 1; x <= n; ++x) ans += x * cnt[x];
    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 81344
module S = Set.Make(struct type t=int let compare=compare end)
let n,m=Scanf.scanf " %d %d" (fun n m->n,m)
let graph=Array.make (n+1) []
let _ = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b->
  graph.(a) <- b::graph.(a);
  graph.(b) <- a::graph.(b)
let rec dfs i d visited =
  if d=n then 1 else
  graph.(i) |> List.fold_left (fun n j->
    if S.mem j visited then n else
    n+dfs j (d+1) (S.add j visited)
  ) 0
let _ =
  dfs 1 1 (S.singleton 1) |> Printf.printf "%d\n"


Measured memory_bytes: 2560
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int n,k;
	std::cin >> n>> k;
	int ans = 1;
	for (int i = 0; i < n; ++i) {
		ans = std::min(ans * 2, ans + k);
	}
		std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 256
// abc172_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll X = 0;
    REPN(i, 2, N) X ^= A[i];
    ll S = A[0] + A[1];
    ll D = (S - X) / 2;

    // 解法2
//    if ((D & X) > 0 || D < 0 || D > A[0] || (S - X) % 2){
//        print(-1);
//        return 0;
//    }

//    ll Y = 0;
//    REP_REV(d, 50){
//        ll y = X & (1ll << d);
//        if ((D ^ (Y | y)) <= A[0]){
//            Y |= y;
//        }
//    }
//    ll a = D ^ Y;

//    if (a == 0){
//        print(-1);
//        return 0;
//    }
//
//    ll ans = A[0] - a;
//    print(ans);

    // 解法3
    if (S < X || (S - X) % 2){
        print(-1);
        return 0;
    }

    int K = 50;
    vector<vector<ll>> dp(K+1, vector<ll>(2, -1)); // i番目まで見たaの最大値, 0,1: 小さいか確定してるかどうか。

    dp[0][0] = 0;
    REP(i, K){
        int k = K-1 - i;
        ll cd = (D >> k) & 1;
        ll cx = (X >> k) & 1;
        ll ca = (A[0] >> k) & 1;
        ll v = 1ll << k;

        if (cd & cx){ print(-1); exit(0); }

        REP(j, 2){
            if (dp[i][j] == -1) continue;

            REP(na, 2) REP(nb, 2){
                if ((na ^ nb) != cx) continue;
                if ((na & nb) != cd) continue;

                int nj;
                if (na < ca) {
                    nj = 1;
                } else if (na == ca) {
                    nj = j;
                } else {
                    if (j == 0) continue;
                    nj = j;
                }

                if (na){
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] | v);
                } else {
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]);
                }

            }

        }

    }
    ll a = max(dp[K][0], dp[K][1]);
    if (a == 0 || a == -1){
        print(-1);
        return 0;
    }

    ll ans = A[0] - a;
    print(ans);

    return 0;
}


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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  ll N;
  cin >> N;
  vi A(N), B(N);
  rep(i, 0, N) cin >> A[i];
  rep(i, 0, N) cin >> B[i];
  ll ans = -1;
  rep(i, 0, (1 << N)) {
    vi v(N);
    rep(j, 0, N) {
      if ((1 << j) & i) v[j] = 1;
    }
    dump(v);
    {
      ll cnt = 0;
      rep(j, 0, N) cnt+= v[j];
      if (cnt % 2 == 1) {
        continue;
      }
    }
    vi correct(N);
    vpii a, b;
    rep(j, 0, N) {
      if (v[j] == 0) {
        if (j % 2 == 0) a.push_back(make_pair(A[j], j));
        else b.push_back(make_pair(A[j], j));
      } else {
        if (j % 2 == 0) b.push_back(make_pair(B[j], j));
        else a.push_back(make_pair(B[j], j));
      }
    }
    if (a.size() != b.size() && a.size() != b.size() + 1) continue;
    dump(a);
    dump(b);
    stable_sort(all(a));
    stable_sort(all(b));
    {
      vi check;
      rep(i, 0, N / 2) {
        check.push_back(a[i].first);
        check.push_back(b[i].first);
      }
      if (N % 2) check.push_back(a.back().first);
      dump(check);
      bool sorted = true;
      rep(i, 0, N - 1) {
        if (check[i] > check[i + 1]) {
          sorted = false;
        }
      }
      if (!sorted) continue;
    }
    rep(j, 0, a.size()) {
      correct[a[j].second] = j * 2;
    }
    rep(j, 0, b.size()) {
      correct[b[j].second] = j * 2 + 1;
    }
    dump(correct);
    ll cnt = 0;
    while (true) {
      bool updated = false;
      rep(j, 0, N - 1) {
        if (correct[j] > correct[j + 1]) {
          swap(correct[j], correct[j + 1]);
          cnt++;
          updated = true;
        }
      }
      if (updated == false) break;
    }
    dump(cnt);
    if (ans == -1) ans = cnt;
    else ans = min(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  ll a, b, k;
  cin >> a >> b >> k;

  ll x, y;
  x = max<ll>(a-k,0);
  k -= a-x;
  y = max<ll>(b-k,0);
  cout << x SP y << endl;
  return 0;
}

Measured memory_bytes: 256