akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll w,h;
    cin>>w>>h;
    V<ll> p(w),q(h+1);
    ll ans=0;
    for(int i=0;i<w;i++){
        cin>>p[i];
        ans+=p[i];
    }
        V<ll> sum(h+1,0);
    for(int i=0;i<h;i++){
        cin>>q[i+1];
        ans+=q[i+1];
    }
    q[0]=-1;
    sort(all(q));
    for(int i=0;i<h;i++){
        sum[i+1]+=q[i+1]+sum[i];
    }
    for(int i=0;i<w;i++){
        int t=upper_bound(all(q),p[i])-q.begin();
        t--;//cout<<t<<" "<<sum[t]<<"\n";
        ans+=sum[t]+(h-t)*p[i];
    }
    cout<<ans<<"\n";
}


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

bool solve(int CX,int CY,vector<vector<int>> &G,int N){
	int htmp;
	for(int i=0;i<N;i++){
		if(G.at(i).at(2)!=0){
			htmp = G.at(i).at(2)+abs(G.at(i).at(0)-CX)+abs(G.at(i).at(1)-CY);
		}
	}
	bool ptmp=true;
	for(int i=0;i<N;i++){
		if(G.at(i).at(2)==0){
			if(htmp<=abs(G.at(i).at(0)-CX)+abs(G.at(i).at(1)-CY)){
				continue;
			}
			else{
				ptmp=false;
				break;
			}
		}
		else{
			if(htmp!=G.at(i).at(2)+abs(G.at(i).at(0)-CX)+abs(G.at(i).at(1)-CY)){
				ptmp=false;
				break;
			}
		}
	}
	return ptmp;
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> G(N,vector<int>(3));
	for(int i=0;i<N;i++){
		cin>>G.at(i).at(0)>>G.at(i).at(1)>>G.at(i).at(2);
	}
	
	int CX,CY;
	bool pro=false;
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			if(solve(i,j,G,N)){
				CX=i;
				CY=j;
				pro=true;
				break;
			}
		}
		if(pro)break;
	}
	int H;
	for(int i=0;i<N;i++){
		if(G.at(i).at(2)!=0){
			H=G.at(i).at(2)+abs(G.at(i).at(0)-CX)+abs(G.at(i).at(1)-CY);
			break;
		}
	}
	
	cout<<CX<<" "<<CY<<" "<<H<<endl;
}



Measured memory_bytes: 256
import math

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

max_idx = int(math.log2(1000000000))
exp2 = [1] * max_idx + [1]
for i in range(1, max_idx + 1):
  exp2[i] = 2 ** i

ans = 0
for i in range(len(A)):
  for j in range(max_idx, 0, -1):
    if A[i] % exp2[j] == 0:
      ans += j
      break
print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1010,A=5001,OO=1e9;
int dp[N],kn[A],nkn[A],x[N];
vector<int> g[N];
int32_t main(){
    int n;
    cin>>n;
    for(int i=2;i<=n;++i){
        int p;cin>>p;
        g[p].pb(i);
    }
    for(int i=1;i<=n;++i)cin>>x[i];
    for(int i=n;i>=1;--i){
        forn(j,A)kn[j]=OO;
        kn[0]=0;
        for(int to:g[i]){
            forn(j,x[i]+1){
                nkn[j]=OO;
                if(j>=x[to])upn(nkn[j],kn[j-x[to]]+dp[to]);
                if(j>=dp[to])upn(nkn[j],kn[j-dp[to]]+x[to]);
            }
            memcpy(kn,nkn,sizeof kn);
        }
        dp[i]=*min_element(kn,kn+x[i]+1);
    }
    if(dp[1]==OO)cout<<"IM";
    cout<<"POSSIBLE\n";
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define STT(it,n,order) sort(it,it+n,order)
#define st(it) sort(it.begin(),it.end())
#define ST(it,n) sort(it,it+n)
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)
#define ms(a,v) memset(a,v,sizeof(a))
#define cp(a,b,n) rep(i,n)a[i] = b[i]
#define pi(a) printf("%d\n",a)
#define ps(a) printf("%s\n",a)
#define si(a) scanf("%d",&a)
#define print_int_matrix(mat,n) rep(i,n-1){printf("%d ",mat[i]);}printf("%d\n",mat[n-1]);
#define print_string_matrix(mat,n) rep(i,n-1){printf("%s ",mat[i]);}printf("%s\n",mat[n-1]);
#define mkp(a,b) make_pair(a,b)
#define fnd(table,e) (find(table.begin(),table.end(),e) != table.end())

//TYPOS DE DATOS PERSONALES
typedef unsigned int _set;
typedef unsigned long _lset;
typedef pair<int,int> pii;

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

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

#define N 1000002
bool is_prime[N];
vector<int> primes;

void sieve(){
   ms(is_prime,1);
   is_prime[0] = is_prime[1] = false;
   for(int x=2;x<N;++x){
      if( is_prime[x] ){
         pb(primes,x);
         for(int i = x+x;i<N;i+=x){
            is_prime[i] = false;
         }
              
      }
   }
}

int main(){
   sieve();
   int n;
   while( si(n) != EOF , n){
      int t = 0;
      rep(i,primes.size()){
         if( primes[i] > n/2 )break;
         if( is_prime[ n - primes[i] ] )t++;
      }
      printf("%d\n",t);
   }
   return 0;
}

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

int main() {
  string c, ans;
  
  cin >> c;
  
  if ((c[0]==c[1] && c[0]==c[2]) || (c[3]==c[2] && c[3]==c[1])) ans = "Yes";
  else ans = "No";
  
  cout << ans << endl;
}


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

int main() {
	int n;
	cin>>n;
	vector<int>a(100000);
	a[0]=0;
	a[n+1]=0;
	for(int i=1;i<n+1;i++){
		cin>>a[i];
	}
	int sum =0;
	for(int i=0;i<n+1;i++){
		sum=sum+abs(a[i+1]-a[i]);
	}
	for(int i=1;i<n+1;i++){
		cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
	}
	
	
	
	
	return 0;
}

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

int x, y;

int main(){
  cin >> x >> y;

  int ans = 2e9 + 10;

  if(y >= x){
    ans = min(ans, y - x);
  }
  ans = min(ans, 1 + abs(y + x));
  ans = min(ans, 2 + abs(y - x));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
long double l;

int main(){
	IOS
	cin >> l;
	cout << setprecision(12) << fixed;
	cout << l*l*l/27 << '\n';
}

Measured memory_bytes: 3744
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll mul(ll a, ll b, ll md){
	return a*b % md;
}
const int N = 1e5 + 5;
vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}
ll komb(ll a, ll b){
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	double a, b, h, m; cin>>a>>b>>h>>m;
	h = h + m/60;
	double a1 = h*30, a2 = h*360;
	double ara = a2-a1;
	while(ara > 360) ara -= 360;
	ara = min(ara, 360 - ara);
	ara = ara*atan(1)/45;
	//cout<<atan(1)<<endl;
	cout<<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos(ara))<<endl;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
using ll = long long;
ll exp(ll a,ll b){
	if(b==0)return 1;
	if(b%2==1)return exp(a,b-1)*a;
	ll t = exp(a,b/2);
	return t*t;
}

int main(){
	int n;cin>>n;
	string h;ll s;
	vector<vector<ll>> ans(19,vector<ll>(19,0LL));
	rep(i,n){
        s=0;
		cin>>h;
		bool dot=false;
		int now=0;
		rep(j,h.size()){
			if(h[j]=='.'){
				dot=true;s*=exp(10,9);
				now=8;
				continue;
			}
			if(!dot){s*=10;s+=(h[j]-'0');}
			if(dot){
				s+=(h[j]-'0')*exp(10,now);
				now--;
			}
		}
		if(!dot)s*=exp(10,9);
        int num=0,num2=0;
		while(s%2==0&&num<20){num++;s/=2;}
		while(s%5==0&&num2<20){num2++;s/=5;}
		if(num>18)num=18;
		if(num2>18)num2=18;
		ans[num][num2]++;
	}
	ll res=0;
	rep(i,19)rep(j,19){
		//i,jとペアに出来るのは18-i,18-j以上
		rep2(k,18-i,19)
          rep2(l,18-j,19){
            if(i==k&&j==l)
                res+=ans[i][j]*(ans[i][j]-1);
		    else res+=ans[i][j]*ans[k][l];
          }
	}
	cout<<res/2<<endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int H, W; cin >> H >> W;
	vector<bool> h(H, false), w(W, false);
	vector<vector<char>> a(H, vector<char>(W));

	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> a.at(i).at(j);
			if (a.at(i).at(j) == '#')h[i] = true;
		}
	}
	rep(j, 0, W) {
		rep(i, 0, H) {
			if (a.at(i).at(j) == '#')w[j] = true;
		}
	}

	rep(i, 0, H) {
		rep(j, 0, W) {
			if (h[i] && w[j])cout << a.at(i).at(j);
		}
		if (h[i])cout << endl;
	}
	if (!h[h.size()-1])cout << endl;

	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

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

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

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  cout << "square1001" << endl;
}


Measured memory_bytes: 3108
#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	ll x;
	cin >> x;
	if (x <= 6) return cout << 1 << '\n', 0;
	ll ans = x/11;
	ans *= 2;
	x %= 11;
	cout << ans + (x + 6 - 1) / 6 << '\n';
	return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
int n,m,cc,vis[705],col[705],num[705][2],f[2][705]={{1}},e[705][705],ans=1e9;
void dfs(int x,int c)
{
	num[cc][c]++;col[x]=c;vis[x]=1;
	for (int i=1;i<=n;i++) if (x!=i && !vis[i] && !e[x][i]) dfs(i,c^1);
	else if (x!=i && !e[x][i] && col[i]==c) __builtin_exit((int)puts("-1")*0);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		e[u][v]=e[v][u]=1;
	}
	for (int i=1;i<=n;i++) if (!vis[i])
	{
		cc++;
		dfs(i,0);
	}
	for (int i=1,b=1;i<=cc;i++,b^=1)
	{
		__builtin_memset(f[b],0,sizeof(f[b]));
		for (int j=0;j<=n;j++) if (f[b^1][j]) f[b][j+num[i][0]]=f[b][j+num[i][1]]=1;
	}
	for (int i=0;i<=n;i++) if (f[cc&1][i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2176
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define PI 3.141592


using namespace std;

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

	for (int i = 0; i < N.length(); i++)
	{
		char tmp = N[i];
		if (tmp + S <= 'Z')
		{
			printf("%c", tmp + S);
		}
		else
		{
			char xxx = (tmp + S) - ('Z');
			xxx += 'A' - 1;
			printf("%c", xxx);
		}
	}
	
	int result = 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[15][15];
int c[15];
int state[15];
int ans=0x3f3f3f3f;
int x;

void dfs(int sum,int step) {
	if(step==n+1) {
		for(int i=1;i<=m;i++) {
			if(state[i]<x) {
				return;
			}
		}
		ans=min(ans,sum);
		return;
	}
	if(sum>=ans) {
		return;
	}
	for(int i=1;i<=m;i++) {
		state[i]+=a[step][i];
	}
	dfs(sum+c[step],step+1);
	for(int i=1;i<=m;i++) {
		state[i]-=a[step][i];
	}
	dfs(sum,step+1);
}

int main() {
  	cin>>n>>m>>x;
  	for(int i=1;i<=n;i++) {
		cin>>c[i];
  		for(int j=1;j<=m;j++) {
  			cin>>a[i][j];
		}
  	}
  	dfs(0,1);
  	if(ans==0x3f3f3f3f) {
  		ans=-1;
  	}
  	cout<<ans;
  	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n; cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<int> idx(n+1);
  rep(i, n) idx[p[i]] = i;
  vector<int> ans(n+1, 1);
  for(int i = n-1; i > 0; --i) {
    if(idx[i] < idx[i+1]) ans[i] += ans[i+1];
  }
  cout <<  n - *max_element(ALL(ans)) << endl;
}


Measured memory_bytes: 5636
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  string str;

  cin >> str;

  if (str == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}

Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
  int a = n / 100;
  int b = n - 100 * a;
  int c = a * 5;
  if ( b <= c ){ 
    System.out.println(1);
  } else {
      System.out.println(0);
    }
    }
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int C = max(A, B);

	if (A > B || A < B) {
		cout << C + (C - 1) << endl;
	}
	else {
		cout << A + B << endl;
	}
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

namespace tree {
struct union_find {
  static const int Max = 22;
  int par[Max], rank[Max], size[Max], compnum;

  union_find(int N) {
    compnum = N;
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

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

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int N, M;
unordered_map<string, int> idmap;
vector<string> langs;
bool speaks[23][33];

void input() {
  langs.clear(); langs.resize(N);
  rep(i, N) {
    cin >> langs[i];
    idmap[langs[i]] = i;
  }
  memset(speaks, 0, sizeof speaks);
  rep(i, M) {
    int k; cin >> k;
    rep(_, k) {
      string s; cin >> s;
      speaks[i][idmap[s]] = 1;
    }
  }
}

bool next_combination(int& comb, int const BitSize) {
  // Assume: comb := (1 << K) - 1, K <= BitSize
  int x = comb & -comb, y = comb + x;
  comb = ((comb & ~y) / x >> 1) | y;
  return comb < 1 << BitSize;
}

void solve() {

  REP(K, 1, min(N + 1, 6)) {
    int comb = (1 << K) - 1;
    do {
      vector<int> uselangs;
      rep(i, N) {
        if(!(comb & 1 << i)) continue;
        uselangs.push_back(i);
      }

      tree::union_find uf(M);

      rep(i, M) REP(j, i + 1, M)
        for(auto langid: uselangs)
          if(speaks[i][langid] && speaks[j][langid])
            uf(i, j);

      if(uf.num_of_comps() == 1) {
        printf("%d\n", (int)uselangs.size());
        for(auto e: uselangs) printf("%s\n", langs[e].c_str());
        return;
      }
    } while(next_combination(comb, N));
  }
  puts("Impossible");
}

string to_binary(int x, int const LeastDigit = 0) {
  string ret;
  while(x) ret.push_back(x % 2 + '0'), x /= 2;
  for(int i=ret.size(); i<LeastDigit; i++) ret.push_back('0');
  reverse(ret.begin(), ret.end());
  return ret;
}

int main() {
  bool first = 0;
  for(; cin >> N >> M && (N|M);) {
    if(first) cout << endl;
    first = 1;
    input();
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3376
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define PLUS 0
#define MINUS 1

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

lli goal = 0;

void func(lli *data,lli now,lli sum,lli *flag){
	if(DEBUG)cout<<now<<" "<<sum<<endl;
	if(goal==1)return;
	if(now == 4){
		if(sum==7){
			for(lli i=0;i<4;i++){
				cout<<data[i];
				if(i==3)cout<<"=";
				else if(flag[i]==0)cout<<"+";
				else cout<<"-";
			}
			cout<<7<<endl;
			goal=1;
		}
		return;
	}
	lli tmpFlag = flag[now-1];
	flag[now-1]=PLUS;
	func(data,now+1,sum+data[now],flag);
	flag[now-1]=MINUS;
	func(data,now+1,sum-data[now],flag);
	flag[now-1]=tmpFlag;
}

int main(){

	string str;
	cin >> str;
	lli data[4];
	lli flag[4];
	REP(i,4){
		data[i] = str.at(i)-'0';
		if(DEBUG)cout<<data[i]<<endl;
		flag[i]=0;
	}

	func(data,1,data[0],flag);

	return 0;
}

Measured memory_bytes: 256
while True:
  N,M,P = map(int, raw_input().split())
  if N==M==P==0: break
  tip = 0
  winner = 0
  for i in xrange(N):
    c = int(raw_input())
    tip += c
    if i == M-1:
      winner = c
  if winner == 0:
    print "0"
  else:
    print tip * 100 * (100-P) / 100 / winner

Measured memory_bytes: 6324
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[101];

int main()
{
    fast_io;
    ll n, k, i, j, d, v, s = 0;
    cin >> n >> k;
    for (i = 1; i <= k; i++)
    {
        cin >> d;
        for (j = 1; j <= d; j++)
        {
            cin >> v;
            a[v]++;
        }
    }
    for (i = 1; i <= n; i++)
        if (!a[i]) s++;
    cout << s;
    return 0;
}

Measured memory_bytes: 3696
#include<stdio.h>

int A[100000], n;

int binarySearch(int key){
  int left = 0, right = n, mid;

  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}


int main(){

  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%d", &k);
    if(binarySearch(k)) sum++;
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int cnt;

int main(){
	int tmp;
	rep(i,3){
		cin >> tmp;
		if(tmp==5)
			cnt++;
		else if(tmp==7)
			cnt+=10;
	}
	if(cnt==12)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 3524
#include<stdio.h>
#include <unistd.h>
int main(){
	char c;
	int ans=0;
	while(read(0,&c,1)){
		if(c==10)printf("%d\n",ans),ans=0;
		else if(!ans&&c==48)break;
		else ans+=c-48;
	}
}


Measured memory_bytes: 2112
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] abc = new int[3];
		Arrays.setAll(abc, i -> sc.nextInt());
		Arrays.sort(abc);
		
		int cnt = 0;
		for (int i = 0; i < 2; i++) {
			int dif = abc[2] - abc[i];
			int quo = dif / 2;
			cnt += quo;
			abc[i] += 2 * quo;
		}
		
		Arrays.sort(abc);
		for (int i = 0; i < 3; i++) {
			abc[2 - i] -= abc[0];
		}
		
		for (int i : abc) {
			cnt += i;
		}
		
		System.out.println(cnt);
	}	
}


Measured memory_bytes: 27984
#include <iostream>
#include <string>

using namespace std;

int main(){
  int i, ans1=0, ans2=0;
  string S;
  cin >> S;
  for(i=0; i<S.size(); i++){
    if(i%2 == 0 && S[i] == '0') ans1++;
    if(i%2 == 1 && S[i] == '1') ans1++;
  }
  for(i=0; i<S.size(); i++){
    if(i%2 == 0 && S[i] == '1') ans2++;
    if(i%2 == 1 && S[i] == '0') ans2++;
  }
  if(ans1 > ans2) ans1 = ans2;
  cout << ans1 << endl;
  return 0;
}


Measured memory_bytes: 512
while True:
    n, r = map(int, input().split())
    if n == 0:
        break
    cards = [i+1 for i in range(n)][::-1]
    for _ in range(r):
        p, c = map(int, input().split())
        cards = cards[p-1:p+c-1] + cards[:p-1] + cards[p+c-1:]
    print(cards[0])

Measured memory_bytes: 7540
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

int isKaibun(string s){
	int ret = 1;
	for(int i=0; i<s.size(); i++){
		if(s[i] != s[s.size()-1-i]){
			ret = 0;
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S;

	for(int i=0; i<S.size(); i++){
		if(S[i] != 'x'){
			T.push_back(S[i]);
		}
	}

	if(isKaibun(S) == 1){
		printf("0\n");
		return 0;
	}
	if(isKaibun(T) == 0){
		printf("-1\n");
		return 0;
	}

	LL tl = T.size();
	LL m = tl/2;
	LL ls = -1, rs = -1, c = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] != 'x'){
			if(tl == 1){
				rs = i;
				break;
			}
			c++;
		}
		if(ls == -1 && c == m){
			ls = i;
		}
		if(rs == -1 && c == m+1){
			rs = i;
		}

	}

	if((tl % 2) == 1){
		ls = rs;
	}

	LL ans = 0;
	LL u = ls, v = rs;
	while(true){
		if(S[u] == S[v]){
			if(u == 0 && v == S.size()-1){
				break;
			}
			if(u > 0){
				u--;
			}
			else if(S[u] == 'x'){
				ans++;
			}
			if(v < S.size() - 1){
				v++;
			}
			else if(S[v] == 'x'){
				ans++;
			}
		}
		else{
			ans++;
			if(u == 0 && v == S.size()-1){
				break;
			}
			if(S[u] == 'x'){
				u--;
			}
			else{
				v++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4012
#include<iostream>
#include<algorithm>
#include<string>

std::string s;
char SS[10010];
int ans;

int main() {
	std::cin >> s;
	int size = s.size();
	int fro = 0;
	int bac = 0;
	int sta1 = 0;
	int sta2 = size - 1;
	while (sta1<sta2) {
		if (s[sta1] == s[sta2]) {
			sta1++;
			sta2--;
		}
		else if (s[sta1] == 'x') {
			sta1++;
			ans++;
		}
		else if (s[sta2] == 'x') {
			sta2--;
			ans++;
		}
		else {
			std::cout << -1 << std::endl;
			return 0;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 512
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  const d = parseInt(input.split(" ")[3], 10);
  console.log(Math.max.apply(null, [a*b,c*d]));
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
	ll n, ans = 0, i, j, k;
	string s;cin>>n>>s;
	fo(i,n) {
		if(i+2==n)break;
		if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')ans++;
	}
	cout<<ans;
}

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 256
N = int(input())
S = [input().split() for i in range(N)]
S_P = S[:]
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])  
S_P.sort()
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])
for i in range(N):
    print(S.index(S_P[i])+1)

Measured memory_bytes: 3064
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n, m = map(int, input().split())

    #output
    #先頭が犬の場合
    #犬同士の隙間はn-1通りある。
    #ここのすべてに猿が入らないといけない
    #したがって、m = n-1でないといけない。
    #犬の並び方はn!通り
    #猿の並び方はm!通り

    #先頭が猿の場合
    #n = m-1でないといけない。
    mod = pow(10, 9) + 7
    dog = 1
    monkey = 1

    for i in range(1, n+1):
        dog *= i
        dog %= mod
    for j in range(1, m+1):
        monkey *= j
        monkey %= mod

    answer = 0
    # %%
    if m - n == 1:
        answer = dog * monkey % mod
    elif n- m == 1:
        answer = dog * monkey % mod
    elif n - m == 0:
        answer = dog * monkey * 2 % mod

    # %%
    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	cin >> N;

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);

	long long b = 1;
	long long bCpy;
	long long a[100001];

	bool flag = false;
	for (long long i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	for (long long i = 0; i < N; i++)
	{
		bCpy = b;
		b *= a[i];
		if (b < bCpy)
		{
			flag = true;
		}
		if (a[i] == 0)
		{
			flag = false;
			break;
		}
	}

	if (flag == true || b > 1000000000000000000)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << b << endl;
	}

}

Measured memory_bytes: 4376
/*
 *    author:  Gary Shih
 *    created: 2020-05-03 22:59:20
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; ++i) cin >> grid[i];
  vector<vector<int>> dp(h, vector<int>(w));
  dp[0][0] = 1;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (i > 0 && grid[i - 1][j] == '.') {
        dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
      }
      if (j > 0 && grid[i][j - 1] == '.') {
        dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
      }
    }
  cout << dp.back().back() << '\n';
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long D) {
  ll X = 2 * D + 1;
  cout << (N + X - 1) / X << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  solve(N, D);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){

  
  ll N;
  cin>>N;
  
  vector<ll>A(N);
  ll max2=0;
  rep(i,N){
    cin>>A[i];
    max2=max(max2,A[i]);
  }

  vector<ll>date(max2+1);
 ll sum=0;
  
  rep(i,N){
    date[A[i]]++;
  }
for(ll i=1;i<max2+1;i++){
  ll num2=date[i];
  sum+=(num2*(num2-1))/2;
}
  
  rep(i,N){
    ll num=date[A[i]]-1;
    ll num3=date[A[i]];
    cout<<sum-(num3*(num3-1))/2+(num*(num-1))/2<<endl;
  }
}


Measured memory_bytes: 5632
def inpl(): return [int(i) for i in input().split()]
n = int(input())
a = inpl()
ans = [0 for _ in range(n)]
if n%2:
    for i,ai in enumerate(a):
        if i%2:
            ans[n//2+(i+1)//2] = ai
        else:
            ans[n//2-(i+1)//2] = ai
else:
    for i,ai in enumerate(a):
        if i%2:
            ans[n//2-(i+1)//2] = ai
        else:
            ans[n//2+(i+1)//2] = ai
print(*ans)

Measured memory_bytes: 26180
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


inf = 10 ** 18
mod = 10 ** 9 + 7

n,C = lr()
sc = [[] for i in range(C)]
sct = [0 for i in range(10**5+1)]
scts = [[0 for i in range(10**5+1)] for j in range(C)]
for i in range(n):
    s,t,c = lr()
    sc[c-1].append([s,t])
for i,S in enumerate(sc):
    pre = -1
    for s,t in S:
        if s == pre or s == pre+1:
            scts[i][s-1]=1
        for j in range(s,t+1):
            scts[i][j]=1
ans = 0
for i in range(10**5+1):
    pre = 0
    for j in range(C):
        pre+=scts[j][i]
    ans=max(ans,pre)
print(ans)

Measured memory_bytes: 187972
//encoded utf-8
//tested with jdk 11

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //br.readLine(); return String one line.
        //Integer.parseInt(); String to Integer(Primitive).
        //String[] hoge = str.split(" ", 0);
        String[] NX = br.readLine().split(" ", 0);
        String[] aStr = br.readLine().split(" ", 0);
        LinkedList<Integer> a = new LinkedList<>();
        for(int i = 0; i < Integer.parseInt(NX[0]); i++){
            a.add(Integer.parseInt(aStr[i]));
        }
        a = sort(a);
        int X = Integer.parseInt(NX[1]);
        int counter = 0;
        for(int i = 0; i < Integer.parseInt(NX[0]); i++) {
            X -= a.get(i);
            if(X < 0){
                break;
            }
            counter ++;
        }
        if(X > 0) counter --;
        System.out.println(counter);
    }

    public static LinkedList<Integer> sort(LinkedList<Integer> linkedList){
        //conquer finish
        if(linkedList.size() <= 1){
            return linkedList;
        }
        //pivot select
        Random rmg = new Random();
        int pivId = rmg.nextInt(linkedList.size());
        //divide
        LinkedList<Integer> leftPart = new LinkedList<Integer>();
        LinkedList<Integer> rightPart = new LinkedList<Integer>();
        int temp = linkedList.get(pivId);
        //left and right added
        for(int i = 0; i < linkedList.size(); i ++){
            if(i == pivId){
                leftPart.add(linkedList.get(i));
                continue;
            }
            if(linkedList.get(i) < temp){
                leftPart.add(linkedList.get(i));
            } else{
                rightPart.add(linkedList.get(i));
            }
        }
        //conquer
        leftPart = sort(leftPart);
        rightPart = sort(rightPart);
        //combine to one linkedlist
        for(int i = 0; i < leftPart.size(); i ++){
            linkedList.set(i, leftPart.get(i));
        }
        for(int i = leftPart.size(); i < linkedList.size(); i ++){
            linkedList.set(i, rightPart.get(i - leftPart.size()));
        }
        return linkedList;
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    rep(i, n){
        string t;
        cin >> t;
        if (t == "print"){
            int m, l; cin >> m >> l;
            string u = s.substr(m, l-m+1);
          	cout << u << endl;
        }
        if (t == "replace"){
            int m, l; cin >> m >> l;
            string u; cin >> u;
            s.replace(m, l-m+1, u);
        }
        if (t == "reverse"){
            int m, l; cin >> m >> l;
            string u = s.substr(m, l-m+1);
            reverse(u.begin(), u.end());
            s.replace(m, l-m+1, u);
        }
    }
}


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

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

vector<int> G[N];
int val[N];
int cnt[20];
int dp[1 << 20];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i ++) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        u ++, v ++;
        val[u] ^= w;
        val[v] ^= w;
    }

    int ans = n;
    for(int i = 1; i <= n; i ++) cnt[val[i]] ++;

    vector<int> v;
    v.clear();
    for(int i = 0; i <= 15; i ++) {
        if(! i) ans -= cnt[i];
        else {
            ans -= cnt[i] / 2;
            if(cnt[i] % 2) v.push_back(i);
        }
    }

    int sz = SZ(v);
    dp[0] = 0;
    for(int mask = 1; mask < (1 << sz); mask ++) {
        for(int sub = mask; sub; sub = (sub - 1) & mask) {
            int cur = 0;
            for(int i = 0; i < sz; i ++) {
                if((sub >> i) & 1) cur ^= v[i];
            }
            if(cur == 0) dp[mask] = max(dp[mask], dp[sub] + 1);
        }
    }
    ans -= dp[(1 << sz) - 1];
    cout << ans << endl;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{      
      List<string> youso = new List<string>();
      string line = "";
      while((line=Console.ReadLine()) != null)
      {
        youso.Add(line.ToString());
      }
      int indata_n = int.Parse(youso[0]);
      string[] indata_s = youso[1].Split(' ');
      double answer;
      double gyaku = 0;
      for (int i = 0; i < indata_n; i++)
      {
        gyaku = gyaku + 1 /double.Parse(indata_s[i]);
      }

      answer = 1 / gyaku;
      Console.WriteLine(answer);        
    }
}

Measured memory_bytes: 11220
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**15
mod = 10**9+7

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():
    a = LI()
    a.sort()
    r = 0
    while a[0] != a[2]:
        r += 1
        if a[0] < a[1]:
            a[0] += 2
        else:
            a[0] += 1
            a[1] += 1
        a.sort()


    return r


print(main())




Measured memory_bytes: 7748
#include <iostream>
#include <string>

using namespace std;

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

    for (int i = 0; i < n; i++) {
        cout << (s[i] == s[k - 1] ? s[i] : '*');
    }

    cout << endl;
}


Measured memory_bytes: 256
#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(params char[] sep) { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
    public static long Mod = 1000000007;

    public static long ModFact(long x)
    {
        checked
        {
            var r = 1L;
            for (var i = 1L; i <= x; i++) { r *= i; r %= Mod; }
            return r;
        }
    }
}

static class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve(new IO());
        Console.Out.Flush();
    }

    static void Solve(IO io)
    {
        io.R();
        var n = io.L;
        var m = io.L;

        if (Abs(n - m) > 1)
        {
            io.Write(0);
            return;
        }
        if (n == m)
        {
            checked { io.Write((ModFact(n) * ModFact(m) * 2) % Mod); }
            return;
        }
        if (Abs(n - m) == 1)
        {
            checked { io.Write((ModFact(n) * ModFact(m)) % Mod); };
            return;
        }

        throw new Exception();
    }
}

Measured memory_bytes: 13396