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

int main() {
	int n,m;
	cin >> n >> m;
	vector<bool> from_1(n,false), to_n(n,false);
	rep(i,m) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		if (a==0) from_1[b] = true;
		if (b==n-1) to_n[a] = true;
	}
	bool ans = false;
	rep(i,n) if (from_1[i] && to_n[i]) ans = true;
	if (ans) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    string s;
    cin>>n>>s;

    int r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R')r++;
        else if(s[i]=='G')g++;
        else b++;
    }


    ll ans=(ll)r*g*b;
    // cerr<<r<<","<<g<<","<<b<<","<<ans<<"\n";
    rep(i,n-2){
        repa(j,i+1,n-1){
            if(2*j-i>n-1)continue;
            if(s[i]!=s[j] && s[i]!=s[2*j-i] && s[j]!=s[2*j-i])ans--;
        }
    }

    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  if(2*K-1>N) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}

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


int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n, vector<ll>(m));
    REP(i, n){
        REP(j, m){
            cin >> a.at(i).at(j);
            a.at(i).at(j)--;
        }
        reverse(ALL(a.at(i)));
    }

    ll ans = n;
    vector<bool> use(m, true);
    REP(_, m){
        vector<ll> count(m, 0);
        REP(i, n){
            while(!use.at(a.at(i).back())){
                a.at(i).pop_back();
            }
            count.at(a.at(i).back())++;
        }
        const ll max_idx = max_element(ALL(count)) - count.begin();
        ans = min(ans, count.at(max_idx));
        use.at(max_idx) = false;
    }
    cout << ans << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
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...));
}


    const int MOD=1000000007;
    void add(long long &a,long long b){
        a+=b;
        if(a>=MOD)a-=MOD;
    }

    long long solve(int N){
        auto dp=make_vec<long long>(N+1,5,5,5);
        dp[0][0][0][0]=1;
        for(int n=0;n<N;n++){
            for(int i=0;i<5;i++){
                for(int j=0;j<5;j++){
                    for(int k=0;k<5;k++){
                        for(int l=1;l<5;l++){
                            if (i == 1 && j == 2 && l == 3) continue;
                         if (i == 1 && k == 2 && l == 3) continue;
                         if (j == 1 && k == 2 && l == 3) continue;
                         if (j == 2 && k == 1 && l == 3) continue;
                         if (j == 1 && k == 3 && l == 2) continue;
                         add(dp[n+1][j][k][l], dp[n][i][j][k]);
                        }
                    }
                }
            }
        }
    
    long long res=0;
    for(int i=1;i<5;i++)
        for(int j=1;j<5;j++)
            for(int k=1;k<5;k++)
                add(res,dp[N][i][j][k]);
    return res;
    }

            
        
    


int main(){
    int N;
    while(cin>>N)cout<<solve(N)<<endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  int N, K;
  while( scanf("%d %d", &N, &K), N||K ){
    vector<int> bloods;
    for( int i=0; i<K; i++ ){
      int b;
      scanf("%d", &b);
      bloods.push_back(b);
    }

    for( int i=0; i<N; i++ ){
      for( int j=0; j<K; j++ ){
        int b;
        scanf("%d", &b );
        bloods[j] -= b;
      }
    }
    bool runout = false;
    for( int i=0; i<K; i++ ){
      if( bloods[i] < 0 ){
        runout = true;
        break;
      }
    }
    printf(runout?"No\n":"Yes\n");
  }
  return 0;
}

Measured memory_bytes: 804
// Solid <candgenesis>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e5 + 1;
const ll inf = 1e13 + 7;
typedef pair<ll,ll> LL;

ll n,i,x,y;
ll mx[3],mn[3];
void oper(ll cond,ll val){
    mn[cond] = min(mn[cond],val);
    mx[cond] = max(mx[cond],val);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define task "tst"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin>>n; mn[1] = mn[2] = inf; mx[1] = mx[2] = -inf;
    while(n--){
        cin>>x>>y;
        x += y;
        oper(1,x); x -= 2*y;
        oper(2,x);
    }
    cout<<max(mx[1] - mn[1],mx[2] - mn[2]);
}


Measured memory_bytes: 3608
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split(); if (line.length < args.length) return;foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
//------------------------------
const coin = [10,50,100,500];
void main(){
	int total;
	for(read(total); total ; read(total), write(total ? "\n":"")){
		auto have = new int[4];
		readArray(have);
		int howMany = int.max; 
		auto uses = new int[4];
		auto hia = have.map!("iota(a+1).array"); 
		foreach (I;cartesianProduct(hia[0],hia[1],hia[2],hia[3])){
			auto tmpuses = I.array;
			auto pay = coin.dotProduct(tmpuses);	
			if (pay < total) continue;
			int tmpHowMany = howManyCoins(pay - total) - tmpuses.sum;
			if (tmpHowMany < howMany ){
				howMany = tmpHowMany;
				uses = tmpuses;
			}
		}
		foreach(i,u;uses){if(u >0)writeln(coin[i]," ",u);}
	}
}
int howManyCoins(int pay){
	int res;
	foreach_reverse(c;coin){
		while(pay >= c){ 
			pay -= c;res ++;
		}
	} 
	return res;
}

Measured memory_bytes: 3172
n, T = map(int, input().split())
keiro = []
for _ in range(n):
    c, t = map(int, input().split())
    if t <= T:
        keiro.append((c,t))
if len(keiro) == 0:
  print('TLE')
else:
  sortedkeiro = sorted(keiro, key= lambda x: x[0])
  print(sortedkeiro[0][0])

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100

int top,arr[N];

void push(int);
int pop ();

int main (){
  int x,y;
  top=0;
  char input[N];
  
  while(scanf("%s",input)!= EOF){
  if(input[0]=='+'){
    x=pop();
    y=pop();
    push(x+y);
  }
  else if (input[0] =='-'){
    x=pop();
    y=pop();
    push(y-x);
  }
  else if (input[0]=='*'){
    x=pop();
    y=pop();
    push(x*y);
  }
  else {
    push(atoi(input));
  }
  }

  printf("%d\n",pop());
  
  return 0;
}

void push (int a){
  arr[++top]=a;
}

int pop (){
  top--;
  return arr[top+1];
}



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

int main() {
  int N, K, i, l, r, a = 0;
  cin >> N >> K;
  
  for (int j = 0;j < N;j++){
    cin >> i;
    r = (K - i) * 2;
    l = i * 2;
    
    if (l < r) a += l;
    else a += r;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
template<class T> using VVV=vector<VV<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CamelTrain | diff CamelTrain.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CamelTrain.cpp && ./a.out

/*

 7/11/2020

 6:03-6:40 give up
 14:25- read editorial

 https://twitter.com/hanseilimak/status/1282071734888230913
 https://img.atcoder.jp/aising2020/editorial.pdf

 */

const int MAX_N=1e6+1;
int K[MAX_N];
LL L[MAX_N],R[MAX_N];
int N;

void solve() {
  LL res=0;
  VV<int> xs(2);
  VVV<int> ps(2,VV<int>(N+1));
  REP(i,N) {
    res+=min(L[i],R[i]);
    if(L[i]>=R[i]) xs[0].push_back(i),ps[0][K[i]].push_back(i);
    else {
      xs[1].push_back(i);
      if(N-K[i]-2>=0) ps[1][N-K[i]-2].push_back(i);
    }
  }

  REP(i,2) {
    priority_queue<LL> Q;
    for(int j=N; j>=0; --j) {
      FORR(k,ps[i][j]) Q.emplace(abs(L[k]-R[k]));
      if(j<SZ(xs[i])&&SZ(Q)) {
        res+=Q.top(),Q.pop();
      }
    }
  }
  cout<<res<<endl;
}

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

  int t; cin>>t;
  while(t--) {
    cin>>N;
    REP(i,N) cin>>K[i]>>L[i]>>R[i],K[i]--;
    solve();
  }

  return 0;
}


Measured memory_bytes: 23504
function main(input) {
    const args = input.split(' ');
    var A = parseInt(args[0], 10);
    var B = parseInt(args[1], 10);
    var K = parseInt(args[2], 10);

    var max = A;
    if(A < B) {
        max = B;
    }

    var ans = [];
    var ans_cout = 0;

    for (var i = 1; i <= max; i++) {
        if(A % i === 0 && B % i === 0) {
            ans.push(i);
        }
    }

    console.log(ans[ans.length - K])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

const int N = 2e5 + 7;

int v[N], c[2 * N], n;

set < int > s;

bool ok(int val) {
    s.clear();
    for (int i = 1; i < n; ++i) {
        if (v[i] > v[i - 1]) {
            auto it = s.end();
            if (it == s.begin())///nu ai ce sterge dreq
                continue;
            it--;
            while (*it >= v[i - 1]) {///nu stergi ca bou' dreq
                s.erase(it);
                if (it == s.begin())///verifici si tu sa nu tai unghia din carne
                    break;
                it--;
            }
        }
        else {
            for (int j = v[i] - 1; j >= 0; --j) {
                if (s.find(j) == s.end()) {///lowl
                    s.insert(j);
                    c[j] = 1;
                    break;
                }
                else if (c[j] == val - 1) {
                    if (!j)
                        return false;
                    s.erase(j);
                    c[j] = 0;
                }
                else {
                    ++c[j];
                    break;
                }
            }
        }
    }
    return true;
}

int bs() {
    int pas(1<<17), r(1);
    while (pas) {
        if (!ok(r + pas))
            r += pas;
        pas >>= 1;
    }
    return r + 1;
}

int main()
{
    bool cresc(true);
    cin >> n;
    for (int i = 0; i < n; ++i)  {
        cin >> v[i];
        if (i && v[i] <= v[i - 1])
            cresc = false;
        v[i] = min(v[i], 2 * N - 7);
    }
    if (cresc)
        return cout << 1, 0;
    cout << bs();
    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

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

	cout << (b - a == c - b ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, ans = 0;
vector<long long> a;

void solve();

int main() {
  smodfact();
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  solve();
  cout << ans << endl;
  return 0;
}

void solve() {
  long long now = 0;
  for(long long i = 1; i <= n; ++i) {
    now += factorial[n] * inverse[i] % N;
    now %= N;
  }
  for(long long i = 0; i < n; ++i) {
    ans += a[i] * now % N;
    ans %= N;
    now -= factorial[n] * inverse[n - i] % N;
    now += factorial[n] * inverse[i + 2] % N;
    while(now < 0) now += N;
    now %= N;
  }
}

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

int findSumOfDigits(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int res = 0;
    REP(i, N) {
        int I = i+1;
        int sum = findSumOfDigits(I);
        if (sum >= A && sum <= B) {
            res += I;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


signed main(){
    int H, W, K;
    cin >> H >> W >> K;

    vector<string> s(H);

    for (int i = 0; i < H; ++i) {
        cin >> s[i];
    }

    int cnt = 0;
    vector<vector<int>> f(H, vector<int>(W));

    for (int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                f[i][j] = ++cnt;
            }
        }
    }

    for (int i = H - 2; i >= 0; --i) for (int j = 0; j < W; ++j) {
        if (f[i][j] == 0)
            f[i][j] = f[i + 1][j];
    }

    for (int i = 1; i < H; ++i) for (int j = 0; j < W; ++j) {
        if (f[i][j] == 0)
            f[i][j] = f[i - 1][j];
    }

    for (int i = 0; i < H; ++i) for (int j = 1; j < W; ++j) {
        if (f[i][j] == 0)
            f[i][j] = f[i][j - 1];
    }

    for (int i = 0; i < H; ++i) for (int j = W - 2; j >= 0; --j) {
        if (f[i][j] == 0)
            f[i][j] = f[i][j + 1];
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << f[i][j] << (j == W - 1 ? "\n" : " ");
        }
    }

    return 0;
}


Measured memory_bytes: 1664
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
s = []
s.extend(p[:x])
s.extend(q[:y])
s.sort()
num = 0
for j,i in enumerate(s):
  if num >= len(r):
    break
  if i < r[num]:
    s[j] = r[num]
    num += 1
print(sum(s))

Measured memory_bytes: 23328
#include <iostream>
using namespace std;
int main (void) {
	int n; cin >> n;
	int schedule[n-1][3];
	

	for (int i = 0; i < n-1; i++) 
		for (int j = 0; j < 3; j++) 
			cin >> schedule[i][j];

	for (int i = 0; i < n; i++) {
		if (i == n-1) {
			cout << 0 << endl;
			break;
		}
    
		int time_now = schedule[i][1];
		for (int j = i; j < n-1; j++) {
			if (time_now % schedule[j][2] != 0) 
				time_now += schedule[j][2] - time_now % schedule[j][2];
			
      if (time_now < schedule[j][1])
				time_now = schedule[j][1];
			
      time_now += schedule[j][0];
		}
    
		cout << time_now << endl;
	}
		
  return 0;
}

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

using int64 = long long;
using uint64 = unsigned long long;

std::string conv(const std::vector<int>& kinds) {
    std::string res(kinds.size(), ' ');

    for (int i = 0; i < res.size(); i++) {
        res[i] = (kinds[i] == 0 ? 'S' : 'W');
    }
    return res;
}

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

    int N;
    std::cin >> N;

    std::string s;
    std::cin >> s;

    std::vector<int> kinds(N);   // 0:羊, 1:狼

    for (int mask = 0; mask < (1 << 2); mask++) {
        std::fill(kinds.begin(), kinds.end(), -1);

        kinds[0] = (mask >> 0) & 1;
        kinds[1] = (mask >> 1) & 1;

        bool ok = true;
        for (int i = 1; i <= N; i++) {
            int c = i % N,
                p = (i - 1 + N) % N,
                n = (i + 1) % N;
            
            int k;
            if ((kinds[c] == 0 and s[c] == 'o') or (kinds[c] == 1 and s[c] == 'x')) {
                k = kinds[p];
            } else {
                k = kinds[p] ^ 1;
            }

            if (kinds[n] < 0) kinds[n] = k;
            else if (kinds[n] != k) ok = false;
        }

        if (ok) {
            std::cout << conv(kinds) << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1000;
char s[20];
const char t[10]={"YAKI"};
int main()
{
	while(~scanf("%s",s)){
        bool flag=0;
        for(int i=0;i<4;i++)
            if(s[i]!=t[i]){
                flag=1;break;
            }
        if(flag) printf("No\n");
        else printf("Yes\n");


	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }
    // output
    for(int i = 0; i < w+2; i++){
        cout << "#";
    }
    cout << endl;
    for(int i = 0; i < h; i++){
        cout << "#";
        for(int j = 0; j < w; j++){
            cout << mat[i][j];
        }
        cout << "#" << endl;

    }
    for(int i = 0; i < w+2; i++){
        cout << "#";
    }
    cout << endl;
    return 0;
}

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

const int N = 2e5 + 10 ;

typedef long long ll;

int a[N];
int k,n,ret=0;
int main()
{
    
    
    cin >>k>> n ;
    
    for(int i =0;i<n;i++)
    {
        cin >> a[i];
        if(i == 0) continue;
        else
        {
            ret = max(a[i]-a[i-1],ret);
        }
    }
    ret =  max(ret, k-a[n-1]+a[0]);
    cout<< k - ret ;
	
	
	return 0 ;
}

Measured memory_bytes: 1024
// AOJ 0278
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int N;
	scanf( "%d", &N );
	rep( i, N )
	{
		int x, y, b, p;
		scanf( "%d%d%d%d", &x, &y, &b, &p );
		
		int t = x*b+y*p;

		if( b >= 5 || p >= 2 )
		{
			b = std::max( b, 5 );
			p = std::max( p, 2 );
			printf( "%d\n", std::min( t, int((x*b+y*p)*0.8) ) );
		}
		else
			printf( "%d\n", t );
	}
		
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<long long, long long> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x = -x;
    a[x]++;
  }
  long long ans = 1, cnt = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
    long long tmp = i->second;
    while (true) {
      if (tmp <= 1) {
        break;
      }
      ans *= -i->first;
      tmp -= 2;
      cnt++;
      if (cnt == 2) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 6528
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    a=[0]+a
    lis=[x for i,x in enumerate(a) if i%2==0 ]
    p=sum(lis)
    #print(p)
    #print(sum(a)-2*p)
    ans=[sum(a)-2*p]

    for i in range(1,n):
        #print(i)
        ans.append(int(2*(a[i]-ans[i-1]/2)))

    ans=[str(x) for x in ans]
    ans = ' '.join(ans)
    print(ans)


if  __name__=='__main__':
    main()


Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=100001;
void solve()
{
    int n;
    cin>>n;
    int arr[n];
    int cur=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        cur=cur^arr[i];
    }
    for(int i=0;i<n;i++)
    {
        cout<<(arr[i]^cur)<<" ";
    }
    cout<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
const int MX = 1e9+7777;
vector<vector<int>>dp;
int dfs(vector<int>&p, vector<int>&c, int pos, int score){
	if(score <= 0)
		return 0;
	if(pos==p.size())
		return MX;
	int ret=MX;
	if(dp[pos][score]!=-1)
		return dp[pos][score];
	for(int i=0;i<=p[pos];i++){
		int bonus=(i==p[pos]?c[pos]:0);
		int recur_result=i+dfs(p,c,pos+1,score-((pos+1)*i)-bonus);
		ret = min(ret, recur_result);
	}
	dp[pos][score]=ret;
	return dp[pos][score];
}
int main(){
	int D,G; cin>>D>>G;
	G/=100;
	vector<int>p(D), c(D);
	for(int i=0;i<D;i++){
		cin>>p[i]>>c[i];
		c[i]/=100;
	}
	dp.resize(D,vector<int>(1e7,-1));
	cout<<dfs(p,c,0,G)<<'\n';
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a >= 13) {
    cout << b << endl;
  } else if(a >= 6 && a <= 12) {
    b = b / 2;
    cout << b << endl;
  } else {
    b = 0;
    cout << b << endl;
  }
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long k = scanner.nextLong();
		long[] list = new long[100001];

		for(int i=0;i<n;i++){
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			list[a] += b;
		}
		long x = k;
		for(int i=1;i<100001;i++){
			if(x <= list[i]){
				System.out.println(i);
				break;
			}
			x -= list[i];
		}
	}

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> t(n + 1, 0);
    vector<int> x(n + 1, 0);
    vector<int> y(n + 1, 0);
    bool doable = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
        int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (dis > (t[i] - t[i - 1]) ||
            dis % 2 != (t[i] - t[i - 1]) % 2)
            doable = 0;
    }

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

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
ll cnt, ans=INF;
map<char, int> MP;
char g;

bool isOK(string s){
    rep(i, s.size())
        if(s[i] != s[0]) return false;
    
    return true;
}

void solve(){
    rep(i,S.size())
        MP[S[i]]++;
    
    if(MP.size()==1)
        ans = 0;
    else{
        for(auto itr=MP.begin(); itr!=MP.end(); itr++){
            cnt = 0;
            string S_buff = S;
            g = itr->first;
        
            // cout << "g is " << g << endl;

            while(!isOK(S_buff)){
                cnt++;

                string buff = "";

                rep(i,S_buff.size()-1){
                    if(S_buff[i] == g|| S_buff[i+1] == g)
                        buff.push_back(g);
                    else
                        buff.push_back(S_buff[i]);
                }
                S_buff = buff;
            }
            // cout << S_buff << endl;

            ans = min(cnt,ans);
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c	 = scanner.nextInt();

		if(a<b && b<c) {
				System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    //  freopen("timber_input.txt", "r", stdin);
   // freopen("out3_test.txt", "w", stdout);
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) {
    ll n,i,j,k;
    cin>>n;
    ll arr[n+1],brr[n+1],crr[n+1],dp[n+1][3];

    for(i=0;i<n;i++)
        cin>>arr[i]>>brr[i]>>crr[i];


    dp[0][0]=arr[0];
    dp[0][1]=brr[0];
    dp[0][2]=crr[0];
    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+brr[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+crr[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    }

}


Measured memory_bytes: 8240
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <queue>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

const int INF = 1LL << 60;


signed main() {
    char c; cin >> c;
    string ans = "consonant";
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        ans = "vowel";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int D;
  cin >> D;
  if(D == 25) cout << "Christmas" << endl;
  if(D == 24) cout << "Christmas Eve" << endl;
  if(D == 23) cout << "Christmas Eve Eve" << endl;
if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        int x = 0;
        
        if(a > b){
            x = a;
            a = b;
            b = x;   
        }
        if(a > c){
            x = a;
            a = c;
            c = x;  
        }
        if(b > c){
            x = b;
            b = c;
            c = x;
        }
        System.out.println(a + " " + b + " " + c);
    }
}
 


Measured memory_bytes: 26192
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n, k = na()
ans = k
for i in range(1, n):
    ans *= (k - 1)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

struct DSU{
    vector<int> parent;
    vector<int> size;
    DSU(int N){
        parent.resize(N);
        size.resize(N);
        make_set();
    }
    void make_set(){
        for(int i=0;i<parent.size();i++){
            parent[i]=i;
            size[i]=1;
        }
    }
    int find_set(int v){
        if(v==parent[v]){
            return v;
        }
        return parent[v]=find_set(parent[v]);
    }
    void union_set(int a,int b){
        a=find_set(a);
        b=find_set(b);
        if(a!=b){
            if(size[a]<size[b]){
                swap(a,b);
            }
            parent[b]=a;            // attach smaller on bigger one
            size[a]+=size[b];
        }
    }
    int find_size(int v){
        return size[find_set(v)];
    }
};

void solve(){
    int N;
    cin>>N;
    vi x(N);
    vi y(N);
    F0R(i,N){
        cin>>x[i];
        cin>>y[i];
    }
    DSU dsu(200009);
    F0R(i,N){
        dsu.union_set(x[i],y[i]+100000);
    }
    map<int,int> eds;
    map<int,set<int>> ex,ey;
    F0R(i,N){
        eds[dsu.find_set(x[i])]++;
        ex[dsu.find_set(x[i])].insert(x[i]);
        ey[dsu.find_set(x[i])].insert(y[i]);
    }
    ll ret=0;
    for(auto pa:eds){
        ll n=dsu.find_size(pa.first);
        ret+=(ll)(ex[pa.first].size()*ey[pa.first].size()-pa.second);
    }
    out(ret);
    return;
}


int main(){
    solve();
    return 0;
}

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

int main(void)
{
  int n,m;
  cin >> n;
  m = n % 10;
  switch (m) {
    case 3:
      cout << "bon";
      break;
    case 2:
      cout << "hon";
      break;
    case 4:
      cout << "hon";
      break;
    case 5:
      cout << "hon";
      break;
    case 7:
      cout << "hon";
      break;
    case 9:
      cout << "hon";
      break;
    default:
      cout << "pon";
      break;
  }
  cout << endl;
  return 0;
}


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

typedef complex<double> P;

const double eps = 1e-8;

bool equals(double a, double b, double eps = 1e-8) {
  return abs(a-b) < eps;
}

struct C {
  P p;
  double r;
  C() {}
  C(P p, double r) : p(p), r(r) {}
};

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

int isIntersect(C a, C b) {
  double x = a.p.real() - b.p.real();
  double y = a.p.imag() - b.p.imag();
  double s = a.r + b.r;
  double d = x*x + y*y;
  s *= s;
  if(equals(d, s)) return 1;
  if(d > s) return 0;
  double r = abs(a.r - b.r);
  r *= r;
  if(equals(d, r)) return 01;
  if(d > r) return 2;
  return -2;
}

bool isIn(P p, C c) {
  double dist = abs(c.p - p);
  return equals(dist, c.r) || dist < c.r;
}

typedef vector<vector<int> > Graph;

int dfs(int p, vector<int> &dp, const Graph &g) {
  int &res = dp[p];
  if(dp[p] != 0) return dp[p];
  dp[p] = 1;
  for(int i = 0; i < g[p].size(); ++i) {
    res = max(res, dfs(g[p][i], dp, g)+1);
  }
  return res;
}

int main() {
  for(int n; cin >> n && n;) {
    P a, b;
    cin >> a.real() >> a.imag() >> b.real() >> b.imag();
    vector<C> u, v;
    for(int i = 0; i < n; ++i) {
      P p; double r;
      cin >> p.real() >> p.imag() >> r;
      C c(p, r);
      if(isIn(a, c) && !isIn(b, c)) u.push_back(c);
      if(!isIn(a, c) && isIn(b, c)) v.push_back(c);
    }

    Graph U(u.size()), V(v.size());
    vector<int> dpU(u.size()), dpV(v.size());
    for(int i = 0; i < u.size(); ++i) {
      for(int j = 0; j < u.size(); ++j) {
        if(i == j) continue;
        if(isIntersect(u[i], u[j]) == -2 && u[i].r > u[j].r) {
          U[i].push_back(j);
        }
      }
    }

    for(int i = 0; i < v.size(); ++i) {
      for(int j = 0; j < v.size(); ++j) {
        if(i == j) continue;
        if(isIntersect(v[i], v[j]) == -2 && v[i].r > v[j].r) {
          V[i].push_back(j);
        }
      }
    }


    int res = 0;
    for(int i = 0; i < u.size(); ++i) {
      res = max(res, dfs(i, dpU, U));
    }
    for(int j = 0; j < v.size(); ++j) {
      res = max(res, dfs(j, dpV, V));
    }
    for(int i = 0; i < u.size(); ++i) {
      for(int j = 0; j < v.size(); ++j) {
        if(isIntersect(u[i], v[j]) != 0) continue;
        res = max(res, dfs(i, dpU, U) + dfs(j, dpV, V));
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

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

    deque<int> q;
    q.push_front(1);
    vector<int> dist(k, 1e9); dist[1] = 0;
    bitset<100001> done;
    while (!q.empty()) {
        int c = q.front(); q.pop_front();
        if ((c*10) % k < k && !done[(c*10) % k]) {
            q.push_front((c*10) % k);
            dist[(c*10) % k] = min(dist[c], dist[(c*10) % k]);
        }
        if ((c+1) % k < k && !done[(c+1) % k]) {
            q.push_back((c+1) % k);
            dist[(c+1) % k] = min(dist[c] + 1, dist[(c+1) % k]);
        }
        done.set(c);
    }
    
    cout << dist[0] + 1 << endl;
}


Measured memory_bytes: 896
c=*0..n=gets.to_i
x=c.map{|i|[i]}
t,*q=n*~-n/2
[*$<].reverse.map{|s|
	q<<t
	a,b=s.split.map{|e|c[e.to_i]}
	a,b=b,a if x[a].size>x[b].size
	(t-=x[b].size*x[a].size;x[a].map{|e|c[e]=b;x[b]<<e})if a!=b
}
p *q.reverse

Measured memory_bytes: 45180
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
      void call(int);
      int n;
      cin>>n;
      call(n);
}
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}



Measured memory_bytes: 3136
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	ans = 0
	for i in range(n-2):
		l = v[i:i+3]
		# print(l)
		t = l[1]
		if t == sorted(l)[1]:
			ans += 1
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int *a, n, t, l, h, c, p;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = (int *)calloc(n, sizeof(int));
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		cin >> t;
		l = c = 0;
		h = n-1;
		while(l <= h){
			p = (l + h)/2;
			c++;
			if(t == a[p]){
				break;
			} else if(t < a[p]){
				h = p - 1;
			} else {
				l = p + 1;
			}
		}
		cout << c << endl;
		
		free(a);
	}
	
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int N,M;
int a[100010];
int b[100010];

int main ()
{
    cin >> N >> M;
    REP(i,M) cin >> a[i] >> b[i];

    vector < pair < int,int > > ord;
    REP(i,M) ord.push_back(make_pair(b[i], a[i]));
    sort(ord.begin(), ord.end());

    int max_t = -1;
    int ans = 0;
    REP(i,M) {
        if (max_t <= ord[i].second) {
            max_t = ord[i].first;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
using namespace std;
long long a[100005];
long long dp[3005][3005];
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n-i+1;j++)
			dp[j][j+i-1]=max(a[j]-dp[j+1][j+i-1],a[j+i-1]-dp[j][j+i-2]);
	}
	cout << dp[1][n];
	return 0;
}

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

int main(){
  int s[10][10];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&s[i][j]);
    }
  }
  int n;
  scanf("%d",&n);
  int b[30];
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<n;k++){
        if(s[i][j]==b[k]){
          s[i][j]=-1;
        }
      }
    }
  }
  
  int count=0;
  if((s[0][0]&s[1][1]&s[2][2])==-1){
    count++;
  }
  if((s[0][2]&s[1][1]&s[2][0])==-1){
    count++;
  }
  for(int i=0;i<3;i++){
    if((s[i][0]&s[i][1]&s[i][2])==-1||((s[0][i]&s[1][i]&s[2][i])==-1)){
      count++;
    }
  }
  
  if(count!=0){
    printf("Yes");
  }else{
    printf("No");
  }
  
      
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    xy = []
    for _ in range(N):
        xy.append(LI())
    xy2g = defaultdict(int)
    g2xy = defaultdict(set)
    for x, y in xy:
        y = -y
        gx = xy2g[x]
        gy = xy2g[y]
        if gx == gy != 0:
            continue
        elif gx != 0 and gy != 0:  # merge
            if len(g2xy[gx]) < len(g2xy[gy]):
                gx, gy = gy, gx
            for xy in g2xy[gy]:
                xy2g[xy] = gx
            g2xy[gx] |= g2xy[gy]
            g2xy[gy].clear()
        else:
            g = gx or gy or x
            xy2g[x] = xy2g[y] = g
            g2xy[g] |= {x, y}
    ans = -N
    for xys in g2xy.values():
        nx = sum(xy > 0 for xy in xys)
        ny = len(xys) - nx
        ans += nx * ny
    return ans

print(main())

Measured memory_bytes: 52992
# include <iostream>
# include <cmath>
 
using namespace std;
 
long long f(long long b, long long n) {
    if(n < b) return n;
    return f(b, n / b) + n % b;
}
 
int main()
{
    long long n, s, ans = 1e13;
    
    cin >> n >> s;
    
    if(s == n) 
    {
        ans = n + 1;
    } 
    else if(s < n) 
    {
        for(long long  b = 2ll; b * b <= n; ++b) {
            if(f(b, n) == s) {
                ans = min(ans, b);
            }
        }
 
        for(long long i = 1ll; i * i <= (n - s); i++) {
            if((n - s) % i == 0) {
                if(f(i + 1, n) == s) {
                    ans = min(ans, i + 1);
                }
                if(f((n - s) / i + 1, n) == s) {
                    ans = min(ans, (n - s) / i + 1);
                }
            }
        }
        if(ans == 1e13)
            ans = -1;
    } else {
        ans = -1;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		long x = Long.parseLong(scan.next());
		long ans = 0;
		long yen = 100;
		while (yen < x){
			++ans;
			yen*=1.01;
		}

		System.out.print(ans);

	}
}

//end


Measured memory_bytes: 35708
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,l=0,N;
    string s;char c;
  vector<string>v;
   map<char,int>m,n,p;
    set<char>S;
    cin>>N;
 n['a']=100; n['b']=100; n['c']=100; n['d']=100;
   n['e']=100; n['f']=100; n['g']=100; n['h']=100; n['i']=100; n['j']=100;n['k']=100;
 n['l']=100; n['m']=100; n['n']=100; n['o']=100;
 n['p']=100; n['q']=100; n['r']=100; n['s']=100;
 n['t']=100; n['w']=100; n['x']=100; n['y']=100;
 n['z']=100; n['u']=100; n['v']=100;
    for(i=0;i<N;i++){
      cin>>s;
       v.push_back(s);
    }
    for(i=0;i<N;i++){
  for(j=0;j<v[i].size();j++){m[v[i][j]]++;}
 for(j=0;j<v[i].size();j++){
  n[v[i][j]]=min(m[v[i][j]],n[v[i][j]]);}
     set<char>::iterator it;   
         for(j=0;j<v[i].size();j++) 
          {S.insert(v[i][j]);}
for(it=S.begin();it!=S.end();it++){p[*it]++;}
        m.clear();S.clear();
     }
    for(c='a';c<='z';c++){
  if(p[c]==N){for(k=0;k<n[c];k++){cout<<c;}}
      else{l++;}
     }
    
   cout<<endl;
  


}

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

int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  
 if(n ==1 && m ==1){
    cout << 0 << endl;
    return 0;
  }
  
  if(n*2 >m){
  ans += m/2;
    cout << ans << endl;
    return 0;
  }
  
  if(n*2<=m){
    ans += n;
    m -= n*2;
    ans += m/4;
    cout << ans << endl;
    return 0;
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 10000000
#define nl "\n"
#define pb push_back
#define MOD 1000000007
#define pi acos(-1)
#define f first
#define s second

typedef long long ll;
typedef double dd;
//typedef vector<int> vi;
//typedef vector<ll> vll;

using namespace std;

bool seven(int x)
{
    int mod;
    while(x!=0)
    {
        mod = x%10;
        if(mod == 7)
        {
            return true;
            break;
        }
        x = x/ 10;
    }
    return false;
}

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    int t;
    cin >> t;

    if(seven(t))
        cout << "Yes" << nl;
    else
        cout << "No" << nl;

    /// Atlast DONE 
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    string s;
    cin >> s;
    cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
int main(){
    
    char s[50];
    
    scanf("%s",s);
    getchar();    
    if ("%s",s[1] == 'B'){
        s[1]=s[1]+16;
    }
    else if("%s",s[1] == 'R'){
        s[1]=s[1]-16;
    }
    printf("%s",s);
    
    return 0;
}

Measured memory_bytes: 2148
n, k, q = list(map(int, input().split()))
score_list =[k-q]*n
for _ in range(q):
    a = int(input())
    score_list[a-1] += 1
    
#print(score_list)
for i in range(n):
    print('Yes' if score_list[i] > 0 else 'No')



Measured memory_bytes: 11444
import math

A, B, H, M = list(map(int, input().split()))
#print(A, B, H, M)

A_degree = 30 * H + 0.5 * M
B_degree = 6 * M
#print(A_degree, B_degree)
diff_degree = A_degree - B_degree
#print(diff_degree)
diff_rad = math.radians(diff_degree)
#print(diff_rad)

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(diff_rad)))

Measured memory_bytes: 9472