akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll n;cin>>n;
  string s[n];
  for(ll i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);
  ll ans=1;
  for(ll i=1;i<n;i++){
    if(s[i]!=s[i-1])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<pair<int, pair<int,int>>> v;
        int t, s, d;
        for(int i = 0; i < m; i++){
            cin >> t >> s >> d;
            v.push_back({t,{s,d}});
        }
        sort(v.begin(), v.end());

        bool infected[20001] = {};
        infected[1] = true;

        for(auto p : v){
            if(infected[p.second.first]){
                infected[p.second.second] = true;
            }
        }

        int cnt = 0;
        for(int i = 1; i <= n; i++) if(infected[i]) cnt++;

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3408
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W,N;
vector<int> vec[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W>>N;
    
    rep(i,N){
        int x,y; cin>>x>>y;
        vec[y].push_back(x);
    }
    
    rep1(i,W) sort(all(vec[i]));
    
    int mn=H, nowx=1;
    rep1(i,W){
        nowx++;
        for(auto x:vec[i]){
            if(x<nowx) continue;
            chmin(mn,x-1)
            if(x==nowx){
                cout1(mn)
                return 0;
            }
            break;
        }
        
        bool f=true;
        if(i<W&&vec[i+1].size()){
            f=false;
            vec[i+1].push_back(H+1);
            for(auto x:vec[i+1]){
                if(x<nowx) continue;
                if(x==nowx) nowx++;
                else{
                    f=true;
                    break;
                }
                if(nowx>=mn) break;
            }
        }
        if(!f) break;
    }
    cout1(mn)
}


Measured memory_bytes: 8832
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 11:02:59
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

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

    sort(all(l), rev(int));

    int ans = 0;
    for (int i = 0; i < k; i++)
        ans += l[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll n;
    cin >> n;
    set<string> S;
    string buf;
    REP(i,n){
        cin >> buf;
        S.insert(buf);
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 19180
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
#define EPS 10e-8
typedef long long ll;
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<ll>A(N),B(N);
    rep(i,0,N){
        cin >> A[i] >> B[i];
    }
    ll cnt=0;
    rep(i,0,N){
        ll cur =A[N-i-1]+cnt;
        ll b=B[N-i-1];
        cnt+=min(b*(cur%b),b-(cur%b));
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
import math
a, b, x = map(int, input().split())
rest = a * a * b - x

if rest == 0:
    print(0)
    sys.exit()

if x >= a * a * b / 2:
    temp = 2 * rest / (a*a)
    ans = math.degrees(math.atan(temp / a))
    print(ans)
else:
    temp = 2 * x / (a*b)
    ans = math.degrees(math.atan(b / temp))
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#define N 500000
#define INF 2000000000
using namespace std;
int c;

void merge(int *A,int l,int m,int r){
  vector<int> L,R;
  for(int i=l;i<m;i++)L.push_back(A[i]);
  for(int i=m;i<r;i++)R.push_back(A[i]);  
  int i=0,j=0;
  L.push_back(INF);
  R.push_back(INF);
   for(int k=l;k<r;k++){
     if(R[j]>L[i])A[k]=L[i++];
     else A[k]=R[j++];
     c++;
  }
}

void mergesort(int *A,int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}
 
 
int main(){
  int n,S[N];
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  mergesort(S,0,n);
  for(int i=0;i<n-1;i++)cout<<S[i]<<" ";
  cout<<S[n-1]<<endl<<c<<endl;
  return 0;
}


Measured memory_bytes: 7296
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())

    mod = 10**9+7
    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans=(ans+cnt)%mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

int sumofdigits(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 ans = 0;
  
  for(int i = 1; i <= n; i++){
    if(sumofdigits(i) <= b &&sumofdigits(i) >=a){
      ans += i;
    }
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <assert.h> //assert
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string.h>
#include <string>
#include <queue>
#include <sstream>
#include <iomanip> //precision
using namespace std;
#define precision(x) setprecision(x) << fixed
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<vector<ll > > matrix;
const ll mod = 1000000007LL;

const int MAX_N = 1001;

int N, M;
int sum[100001];
int L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> L >> R;
		sum[L - 1]--;
		sum[R]++;
	}

	int res = 0;
	for (int i = N; i >= 1; --i) {
		sum[i - 1] += sum[i];
		if (sum[i] == M) res++;
	}
	cout << res;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
using namespace std;
const int N=(1<<19);
int n,m,a[N],fac[N],de[N],sum[N],ans;
int vi[N];
vector <int> p;
inline void add(int &a,int b){a=(a+b)%mod;}
inline void del(int &a,int b){a=(a-b+mod)%mod;}
inline void mul(int &a,int b){a=(a*b)%mod;}
inline int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) mul(ans,a);
		b>>=1;
		mul(a,a);
	}
	return ans;
}
void dfs(int x,int depth)
{
	de[x]=depth;
	if (x+x<(1<<n)) fac[x+x]=(fac[x]*(x+x))%mod,dfs(x+x,depth+1);
	if (x+x+1<(1<<n)) fac[x+x+1]=(fac[x]*(x+x+1))%mod,dfs(x+x+1,depth+1);
}
void change_path(int x,int v)
{
	mul(v,x);
	x/=2;
	while (x)
	{
		if (!vi[x]) p.push_back(x);
		vi[x]=1;
		mul(v,x);
		add(sum[x],v);
		x=x/2;
	}
}
void query(int x,int v)
{
	int last;
	mul(v,x);
	last=x;x/=2;
	while (x)
	{
		add(ans,v*(sum[x]-x*sum[last]%mod+mod)%mod);
		mul(v,x);
		last=x;
		x/=2;
	}
}
signed main()
{
	scanf("%lld",&n);m=(1<<(n-1));
	for (int i=1;i<=m;i++) scanf("%lld",&a[i]);
	fac[0]=fac[1]=1;
	dfs(1,1);
	for (int i=1;i<m;i++)
	{
		int full=(1<<(n-de[i]-1))-1;
		int x=(i<<1),div=m_pow(fac[i],mod-2);
		p.clear();
		for (int mask=0;mask<=full;mask++)
		{
			int now=((x<<(n-de[i]-1))|mask);
			change_path(a[now-m+1]+m-1,fac[now]*div%mod);
		}
		x=((i<<1)|1);
		div=m_pow(fac[i/2],mod-2);
		for (int mask=0;mask<=full;mask++)
		{
			int now=((x<<(n-de[i]-1))|mask);
			query(a[now-m+1]+m-1,fac[now]*div%mod); 
		} 
		for (int j=0;j<(int)p.size();j++) sum[p[j]]=vi[p[j]]=0;
	}
	printf("%lld\n",ans);
}

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

using namespace std;

int main(){

    int X, t;
    cin >> X >> t;

    if(X - t <= 0){
        cout << 0 << endl;
    }else{
        cout << X - t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int, input().split())

def score(a,b,c):
  return (abs(a-b)+abs(b-c)+abs(c-a))


x = [(a,b,c,0,score(a,b,c))]

while True:
  x = sorted(x, key=lambda x: x[4])
  aa,bb,cc,ii,ss = x.pop(0)

  if aa==bb and bb==cc:
    print(ii)
    break

  x.append((aa+1,bb+1,cc,ii+1,score(aa+1,bb+1,cc)))
  x.append((aa+1,bb,cc+1,ii+1,score(aa+1,bb,cc+1)))
  x.append((aa,bb+1,cc+1,ii+1,score(aa,bb+1,cc+1)))

  x.append((aa+2,bb,cc,ii+1,score(aa+2,bb,cc)))
  x.append((aa,bb+2,cc,ii+1,score(aa,bb+2,cc)))
  x.append((aa,bb,cc+2,ii+1,score(aa,bb,cc+2)))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n == 1) cout << "Hello World";
    else{
        int a, b;
        cin >> a >> b;
        cout << a + b;
    }
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

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

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<double> a(n);
	cin >> a;
	double gsum = 0;
	for (int i = 0; i < n; i++) {
		gsum += 1.0/a[i];
	}
	cout << 1/gsum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  ll ans=0;
  rep(i,n){
    ll a;
    cin >> a;
    while(a){
      if(a%2==0){
        a/=2;
        ans++;
      }
      else break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10 , P = 1e9 + 7;
int n , x , y , fac[N] , ifac[N];
int c[N] , w[N];
vi col[N] , contain[N];
int fa[N];
int inv(int x) {return x<=1?x:P-ll(P/x)*inv(P%x)%P;}
inline int F(int x){return fa[x]==x?x:fa[x]=F(fa[x]);}
inline void merge(int a,int b){
  a=F(a);b=F(b);
  if(a!=b) fa[b]=a;
}

int main(){
  scanf("%d%d%d",&n,&x,&y);
  rep(i,0,n) scanf("%d%d",c+i,w+i) , col[c[i]].pb(i);
  rep(i,0,n) fa[i]=i;
  fac[0]=1;rep(i,1,n+1) fac[i]=ll(fac[i-1])*i%P;
  ifac[n]=inv(fac[n]);per(i,1,n+1) ifac[i-1]=ll(ifac[i])*i%P;
  vector<pii> Mns;
  rep(i,1,n+1) if(sz(col[i])){
    int Mn=2e9,id=0;
    for(auto j:col[i]) if(w[j]<Mn)
      Mn=w[j],id=j;
    Mns.pb(mp(Mn,id));
    for(auto j:col[i]) if(Mn+w[j]<=x)
      merge(id,j);
  }
  sort(all(Mns));
  rep(d,0,min(2,sz(Mns))) {
    int i=Mns[d].se;
    rep(j,0,n) if(c[j]!=c[i]&&w[j]+w[i]<=y)
      merge(i,j);
  }
  rep(i,0,n) contain[F(i)].pb(i);
  int ans=1;
  rep(i,0,n) if(sz(contain[i])){
    map<int,int> times;
    for(auto e : contain[i])
      times[c[e]]++;
    ans=ll(ans)*fac[sz(contain[i])]%P;
    for(auto e : times)
      ans=ll(ans)*ifac[e.se]%P;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 26480
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s;
    cin >> s;
    int rr = s % 100;
    int ss = (s - rr) / 100;

    if(rr < 13 && ss < 13 && rr != 0 && ss != 0) cout << "AMBIGUOUS" << endl;
    else if((rr < 13 && ss >= 13 && rr != 0) || (ss == 0 && rr < 13 && rr != 0)) cout << "YYMM" << endl;
    else if(ss < 13 && (rr >= 13 || rr == 0) && ss != 0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;



signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<vector<int> > dp(1 << n, vector<int>(n));
    vector<vector<bool> > g(n, vector<bool>(n));

    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a][b] = true;
        g[b][a] = true;
    }

    dp[1][0] = 1;

    rep(bit, 1 << n){
        rep(i, n){
            rep(j, n){
                if(i != j && (bit & 1 << j) == 0 && bit & 1 << i && g[i][j]){
                    dp[bit | 1 << j][j] += dp[bit][i];
                }
            }
        }
    }

    int res = 0;

    for(int i = 1; i < n; ++i){
        res += dp[(1 << n) - 1][i];
    }

    cout << res << '\n';

    return 0;
}

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

int main(){
    int a[1000];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        cout<<a[i];
        if(i>0){
            cout<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(void){
   long m,n;
   scanf("%ld %ld",&m,&n);
 long y=1;
   while(n>0){
      if(n % 2 != 0){         
	y=(y*m) % 1000000007;     
      }
      m=(m*m) % 1000000007;  
      n=n/2;
    } 
   
   printf("%ld\n",y);
   return 0;
}




Measured memory_bytes: 2108
a, b, c, d = gets.chomp.split().map(&:to_i)
a -= 1
lcm = [c, d].inject(:lcm)
quoA = a.div(c) + a.div(d) - a.div(lcm)
quoB = b.div(c) + b.div(d) - b.div(lcm)

puts b - quoB - a + quoA

Measured memory_bytes: 1788
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    c = collections.defaultdict(int)
    for _ in range(3):
        a,b = LI()
        c[a] += 1
        c[b] += 1
    if max(c.values()) == 3:
        return 'NO'

    return 'YES'



print(main())




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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	int f[n][10];
	ll p[n][11];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin>>f[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 10; j++){
			cin>>p[i][j];
		}
	}
	ll ans = LLONG_MIN;
	for(int mask = 1; mask < (1<<10); mask++){
		ll sum = 0;
		for(int i = 0; i < n; i++){
			int cnt = 0;
			for(int j = 0; j < 10; j++){
				if(!f[i][j])continue;
				if(mask&(1<<j))cnt++;
			}
			sum += p[i][cnt];
		}
		ans = max(ans, sum);
	}
	cout<<ans<<endl;

	return 0;
}

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

#define n 2000001
#define s 10000

int main(){
  int  *A,*B,C[s],a,i,j;

  scanf("%d",&a);

  A = malloc(sizeof(int) * a + 1);
  B = malloc(sizeof(int) * a + 1);

  for(i = 0; i < s; i++){
    C[i] = 0;
  }

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

  for(i = 0; i < s-1; i++){
    C[i+1] += C[i];
  }

  for(i = a-1; i >= 0; i--){
    if(C[A[i]] == 0) continue;
    else {
      B[C[A[i]]-1] = A[i];
      C[A[i]]--;
    }
  }

  for(i = 0; i < a; i++){
    printf("%d",B[i]);
    if(a-1 != i) printf(" ");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16276
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>0) cout << "Positive";
    else if(b>=0) cout << "Zero" ;
    else cout << ((b - a) % 2 ? "Positive" : "Negative");
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if B < A:
    dist = A - B
    if dist <= (V - W)*T:
        print('YES')
    else:
        print('NO')
else:
    dist = B - A
    if dist <= (V - W)*T:
        print('YES')
    else:
        print('NO')

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

string getResult(const string &w){
  map<char, int> charCount;
  for(char c = 'a'; c <= 'z'; c++){
    charCount[c] = 0;
  }
 
  for(char c : w){
    charCount[c]++;
  }
  for(auto itr = charCount.begin(); itr != charCount.end(); itr++){
    if(itr->second % 2 != 0){
      return "No";
    }
  }
  return "Yes";
}

int main(){
  string w;
  cin >> w;
  string result = getResult(w);
  cout << result << endl;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	cout << (N + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc073.contest.atcoder.jp/tasks/arc073_c>
 問題文============================================================
 2 個の白いボールが入った袋が N 個あります。
 i 個目の袋にはそれぞれ整数 xi と yi が書かれたボールが 1 個ずつ入っています。
 
 あなたはこの袋それぞれについて、片方のボールを赤く塗り、もう片方を青く塗ります。
 
 そのあと 2N 個のボールを、塗られた色で分類します。
 
 そして
 
 赤く塗られたボールに書かれた整数の最大値を Rmax
 赤く塗られたボールに書かれた整数の最小値を Rmin
 青く塗られたボールに書かれた整数の最大値を Bmax
 青く塗られたボールに書かれた整数の最小値を Bmin
 
 としたときに、(Rmax−Rmin)×(Bmax−Bmin) の最小値を求めてください。
 
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = LLONG_MAX;
    ll N; cin >> N;
    vector<ll> x(N),y(N);
    vector<pll> ps(N);
    ll Ri = LLONG_MAX,Ra = -1;
    for(int i = 0; i < N;i++){
        cin >> x[i] >> y[i];
        if(x[i] > y[i]) swap(x[i],y[i]);
        Ri = min(Ri,x[i]);
        Ra = max(Ra,y[i]);
        ps[i] = {x[i],y[i]};
    }
    
    sort(ps.begin(),ps.end());
    ll La = ps[N-1].first, Rb = Ra;
    for(auto& p:ps) Rb = min(Rb,p.second);
    res = min(res,(La-Ri)*(Ra-Rb));
    
    set<pll> s;
    s.insert({ps[0].second,LINF});
    for(int i = 1; i < N;i++) s.insert({ps[i].second,i});
    
    while(true){
        ll dif = s.rbegin()->first-s.begin()->first;
        res = min(res,(Ra-Ri)*dif);
        
        auto t = *s.rbegin();
        s.erase(*s.rbegin());
        if(t.second >= LINF) break;
        s.insert({ps[t.second].first,LINF});
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 19072
N, K = map(int,input().split())
mod = 10**9+7
gcd_num = [1]*(K+1)
for i in range(K//2, 0, -1):
    gcd_num[i] = pow((K//i), N, mod)
    for j in range(2, K//i + 1):
        gcd_num[i] -= gcd_num[i*j]
    gcd_num[i] = gcd_num[i]%mod
ans = 0
for i in range(1,K+1):
    ans += i * gcd_num[i] % mod
print(ans%mod)

Measured memory_bytes: 11104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BPictureFrame {
public:
    void solve(istream& cin, ostream& cout) {
        int h, w; cin >> h >> w;
        vector<string> st;
        for(int i=0; i<h; i++) {
            string s;
            cin >> s;
            st.push_back(s);
        }
        for(int i=0; i<w+2; i++) cout << "#";
        cout << '\n';
        for(auto k: st) cout << "#" << k << "#\n";
        for(int i=0; i<w+2; i++) cout << "#";
        cout << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BPictureFrame solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;

    cin>>n>>s;

    for(int i=0;i<s.length();i++)
    {
        if(s[i]+n>90)
            s[i]=s[i]+n-26;
        else
            s[i]=s[i]+n;

    }

    cout<<s<<"\n";


    return 0;
}


Measured memory_bytes: 256
import sys
#import time
#import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import itertools
#input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def ri():
    return list(map(int, input().split()))
def rs():
    return list(input().strip())

n = str(input())

lst = n[-1]
if lst == "0" or lst =="1" or lst =="6" or lst =="8":
    print("pon")
elif lst=="3":
    print("bon")
else:
    print("hon")

Measured memory_bytes: 79748
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

set<string> sub;

signed main() {
    string S;
    int K;
    cin >> S >> K;

    int nk = 0;
    for (int i=0; i<S.size(); i++) {
        for (int j=i; j<min(S.size(), (size_t)(i+K)); j++) {
            auto ret = sub.insert(S.substr(i, j-i+1));
            if (ret.second) nk++;
        }
    }

    int cnt = 0;
    for (auto& i : sub) {
        if (++cnt == K) {
            cout << i << LF;
            return 0;
        }
    }

    return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, A, B;
  int cnt_foregin_clear = 0;
  int cnt_clear = 0;
  string S;
  cin >> N >> A >> B >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'a') {
      if (cnt_clear >= A + B) {
        cout << "No" << endl;
        continue;
      }
      cout << "Yes" << endl;
      cnt_clear++;
    } else if (S[i] == 'b') {
      if (cnt_clear >= A + B || cnt_foregin_clear >= B) {
        cout << "No" << endl;
        continue;
      }
      cout << "Yes" << endl;
      cnt_clear++;
      cnt_foregin_clear++;
    } else {
      cout << "No" << endl;
    }
  }
  return 0; 
}


Measured memory_bytes: 848
# C - Sum of gcd of Tuples (Easy)

import math

K = int(input())

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        ab = math.gcd(a, b)
        for c in range(1, K + 1):
            abc = math.gcd(ab, c)
            ans += abc

print(ans)

Measured memory_bytes: 9176
fun main(args :Array<String>) {
    val n = readInteger()
    val aArray = readIntegerList().toIntArray()

    var m = 0
    val boxes = IntArray(n)
    for (i in (n - 1) downTo 0) {
        var count = 0
        val s = i + 1
        for (j in i until n step s) {
            count += boxes[j]
        }

        if (count % 2 != aArray[i]) {
            m++
            boxes[i] = 1
        }
    }

    println(m)
    boxes.mapIndexed { index, it ->
        if (it == 1) index + 1 else 0
    }.filter { it > 0 }
    .joinToString(" ")
    .let { println(it) }
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 77436
import math
A ,B = list(map(int,input().split()))
 
def problem_koganemaru(A,B):  
  for price in range(10000):
    if math.floor(price*0.08) == A and math.floor(price*0.1) == B:
      return price
  return -1
 
print(problem_koganemaru(A,B))

Measured memory_bytes: 3064
K,N=[int(i) for i in input().split()]
a = [int(i) for i in input().split()]

max = 0
skip = 0
for i in range(N-1):
    if a[i+1]-a[i] > max: 
        max=a[i+1]-a[i]
    if i == N-2: 
        if a[0] + K -a[i+1] > max: 
            max = a[0] + K -a[i+1]
print(K-max)


Measured memory_bytes: 24908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, w, a, b, c, s;
  in2(h, w);
  s = min(h, w);
  if(h % 3 == 0 || w % 3 == 0)
    s = 0;
  rep(i, h + 1){
    rep(j, 1000){
      a = i * w;
      b = (h - i) * (w / 2 - j);
      c = (h - i) * (w - w / 2 + j);
      s = min(s, max({a, b, c}) - min({a, b, c}));
    }
  }
  rep(i, w + 1){
    rep(j, 1000){
      a = i * h;
      b = (w - i) * (h / 2 - j);
      c = (w - i) * (h - h / 2 + j);
      s = min(s, max({a, b, c}) - min({a, b, c}));
    }
  }
  out(s);
  memi;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main  {
  static int n;
  static Node node;

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

    n = sc.nextInt();
    BinTree tree = new BinTree();
    sc.nextLine();
    String com;

    for (int i = 0; i < n; i++) {
      com = sc.next();
      if (com.equals("insert")) {
        tree.insert(sc.nextInt());
      } else {
        tree.inorder(tree.root);
        out.println();
        tree.preorder(tree.root);
        out.println();
      }
    }
  }
}

class BinTree {
  Node root = null;

  void insert(int v) {
    Node x = root;
    Node y = null;
    Node z = new Node();

    z.key = v;
    while (x != null) {
      y = x;
      if (z.key < x.key) {
        x = x.l;
      } else {
        x = x.r;
      }
    }

    z.p = y;
    if (y == null) {
      root = z;
    } else {
      if (z.key < y.key) {
        y.l = z;
      } else {
        y.r = z;
      }
    }
  }

  void preorder(Node n) {
    if (n == null) return;

    out.print(" " + n.key);
    preorder(n.l);
    preorder(n.r);
    return;
  }

  void inorder(Node n) {
    if (n == null) return;

    inorder(n.l);
    out.print(" " + n.key);
    inorder(n.r);
    return;
  }
}

class Node {
  Integer key = null;
  Node r, l, p;
}



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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> area(s.size()+1,0);
    vector<int> hei(40000,1e9),wid(40000,1e9);


    int maxh=20000,minh=400000;
    int loch=20000;
    hei[20000]=0;
    for(int i=1;i<=s.size();i++){
//        cout << s[i-1];
//        cout <<"loch : "<< loch << endl;
        if(s[i-1]=='\\'){
            loch--;
        }else if(s[i-1]=='/'){
            loch++;
            if(hei[loch]!=1e9){
                area[i]=(i-hei[loch]-1); //area
                wid[i]=hei[loch]; //start i of area
            }
        }
        hei[loch]=i;
    }
//    for(int i=0;i<=s.size();i++){
//        cout << i;
//        cout << " area : "<< area[i];
//        cout << " begin wid : "<<wid[i] << endl;
//    }
//
    int bw=0,cou=-1;
    stack<pair<int,ll> > st;
    for(int i=0;i<=s.size();i++){
        if(area[i]!=0){
            if(wid[i]>=bw){
                st.push(make_pair(i,area[i]));
                bw=wid[i];
            }else{
                for(;!st.empty();){
                    int j=st.top().first;
                    ll a=st.top().second;
                    if(wid[j]>wid[i]){
                        area[i]+=a;
                        st.pop();
                    }else{
                        break;
                    }
                }
                st.push(make_pair(i,area[i]));
            }
        }
    }

    ll sumare=0;
    int siz=st.size();
    vector<ll> vc;
    for(int i=0;i<siz;i++){
        sumare += st.top().second;
        vc.push_back(st.top().second);
        st.pop();
    }

    cout << sumare << endl;
    cout << siz << (siz!=0?" ":"\n");
    for(int i=vc.size()-1;i>=0;i--){
        cout << vc[i] << (i!=0?" ":"\n");
    }
}



Measured memory_bytes: 3532
n, k = map(int, input().split())
a = list(map(int, input().split()))

s = [] # 訪れた頂点をメモ
ord = [-1]*(n+1) # 訪れた順番をメモ

c = 1 # 周期
l = 0 # 例外部分
v = 1 # 現在地

while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1] # ワープさせる

c = len(s) - ord[v]
l = ord[v]

if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])

    
    

Measured memory_bytes: 32384
import sys
input = sys.stdin.readline
from math import floor

def main():
    A,B,M=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    ans=2*10**5
    for i in range(M):
        x,y,c=map(int,input().split())
        ans=min(ans,a[x-1]+b[y-1]-c)
    a.sort()
    b.sort()
    ans=min(ans,a[0]+b[0])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18616
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int l, r;
    int ch;
}node;

int cmpAsc(const void* a, const void* b){
    int x = ((node*)a)->ch, y = ((node*)b)->ch;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    int p = ((node*)a)->l, q = ((node*)b)->l;
    if(p > q){
        return 1;
    }
    if(p < q){
        return -1;
    }
    return 0;
}

int main(){
    int n, c;
    scanf("%d %d", &n, &c);
    int imos[100002] = {0};
    node a[n+1];
    a[n].ch = 31; a[n].l = 1000000, a[n].r = 1000000;
    rep(i, 0, n){
        int l, r, ch;
        scanf("%d %d %d", &l, &r, &ch);
        a[i].l  = l;
        a[i].r  = r;
        a[i].ch = ch;
    }
    qsort(a, n+1, sizeof(node), cmpAsc);
    int f = 1;
    rep(i, 0, n){
        if(f){
            imos[a[i].l - 1] += 1;
            f = 0;
        }
        if(a[i].ch != a[i+1].ch || a[i].r != a[i+1].l){
            imos[a[i].r] -= 1;
            f = 1;
        }
    }
    int ans = 0;
    rep(i, 1, 100000){
        imos[i] += imos[i-1];
        if(ans < imos[i]){
            ans = imos[i];
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(long long i = 0;i<n;i++)

int main(void)
{
	long long	N, allCount = 0;
	vector<long long> A(3 * 100000);
	vector<long long> count(3 * 100000,0);
	vector<long long> comb(3 * 100000, 0);
	cin >> N;
	rep(i, N) {
		cin >> A[i];
		count[A[i]-1]++;
	}

	rep(i, N) {
		if (count[i] > 1) {
			comb[i] = count[i] * (count[i] - 1) / 2;
			allCount += comb[i];
		}
	}

	rep(i, N) {
		cout << allCount - (count[A[i]-1] - 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 9600
# C 
# import numpy as np

# n = 127
n = int(input())

max_n = 100000
# memo = np.full(max_n,999999,dtype=np.int32)
memo = [999999]*(max_n+1)
memo[0] = 0

# nl6 = [1, 6, 36, 216, 1296, 7776, 46656]
# nl9 = [1, 9, 81, 729, 6561, 59049]


for i in range(1,n+1):
    memo[i] = memo[i-1]+1
    k = 6
    while i-k >= 0:
        memo[i] = min(memo[i], memo[i-k]+1)
        k *= 6
    k = 9
    while i-k >= 0:
        memo[i] = min(memo[i], memo[i-k]+1)
        k *= 9
        
print(memo[n])

Measured memory_bytes: 3828
use std::io;
use std::str::FromStr;

fn input_u64_tuple() -> (u64, u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn gcd(a: u64, b: u64) -> u64 {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}

fn calc(n: u64, c: u64, d: u64) -> u64 {
    n - n/c - n/d + n/(c*d/gcd(c, d))
}

fn main() {
    let (a, b, c, d) = input_u64_tuple();
    println!("{}", calc(b, c, d) - calc(a - 1, c, d));
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
    int N,maxi,mini;
    cin>>N>>mini;
    maxi=mini;
    for(int i=1;i<N;i++){
        int x;
        cin >>x;
        maxi=max(maxi,x);
        mini=min(mini,x);
    }
    cout<<maxi-mini<<endl;
    
}

Measured memory_bytes: 256
n = int(input())
number = list(map(int,input().split()))
o = 0
for i in range(n-2):
    if number[i+2]<number[i+1]<number[i] or number[i]<number[i+1]<number[i+2]:
        o+=1
    else:
        None
print(o)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e3+5;
const int MOD = 1e9+7;

pair<int,int> dp[MSIZE][MSIZE];

int main(){
    FIO
    string s, t; cin>>s>>t;

    f(i,0,s.length())   dp[i][0] = {0,0};
    f(i,0,t.length())   dp[0][i] = {0,0};

    f(i,1,s.length()) f(j,1,t.length())
    {
        if(s[i-1]==t[j-1])  {
            dp[i][j] = {1+dp[i-1][j-1].F,0};
        }
        else if(dp[i-1][j].F>dp[i][j-1].F) {
            dp[i][j] = {dp[i-1][j].F,1};
        }
        else {
            dp[i][j] = {dp[i][j-1].F,2};
        }
    }

    string res;
    int i = s.length(), j = t.length();
    while(i!=0 && j!=0){
        if(s[i-1]==t[j-1])  res+=s[i-1];
        switch(dp[i][j].S) {
            case 0: i--; j--; break;
            case 1: i--; break;
            case 2: j--; break;
        }
    }
    reverse(all(res));
    cout<<res<<endl;
    return 0;

}
    


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    int n,ans = 0;
    cin >> n;
    int p[n];
    rep(i,n) {
        cin >> p[i];
    }
    rep(i,n) {
        if(p[i] == i+1) {
            ans++;
            i++;
        }
    }
    cout << ans;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && b != c) || (b == c && c != a) || (c == a && a != b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;cin >> n;
	ll ans = 0;
	for(ll i=2;i*i<=n;i++){
		ll ch = 0;
		while(n%i == 0){
			n /= i;
			ch++;
		}
		double nn = (-1.0+sqrt(1.0+(8.0*ch)))/2.0;
		ans += (ll)floor(nn);
//		cout << i << ' ' << floor(nn) << '\n';
	}
	ans += (n != 1);
	cout << ans << '\n';
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

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

void hawawa()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x)) {
		cout << "A\n";
	}
	else {
		cout << "B\n";
	}
}

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


Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%d", $N);

	$A = split(' ', fgets(STDIN));

// 	var_dump($A);
	$cnt = 0;
	while(true) {
		for($i = 0; $i < count($A); $i++) {
			if ($A[$i] % 2 === 0) {
				$A[$i] = intval($A[$i] / 2);
			} else {
				echo $cnt.PHP_EOL;
                return;
			}

		}
		$cnt++;
	}
?>

Measured memory_bytes: 3700
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$n = $sc->nextInt();
$k = $sc->nextInt();
$s = $sc->next();

$s[$k - 1] = strtolower($s[$k - 1]);
out::println($s);


Measured memory_bytes: 3828