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

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

using namespace std;

#define MAX_V 100010

int V,E;
vector<int> G[MAX_V];
bool used[MAX_V];

inline bool check(int p) {
  rep(i,(int)G[p].size()) if( !used[G[p][i]] ) return false;
  return true;
}

int move(int p) {
  rep(i,(int)G[p].size()) if( !used[G[p][i]] ) return G[p][i];
  return -1;
}

void compute(deque<int> &endpoint) {
  bool update = true;
  while( update ) {
    update = false;
    vector<int> ps;
    ps.push_back(endpoint.front());
    ps.push_back(endpoint.back());
    rep(i,2) if( !check(ps[i]) ) {
      update = true;
      int nex = move(ps[i]);
      used[nex] = true;
      if( i == 0 ) endpoint.push_front(nex);
      else         endpoint.push_back(nex);
    }
  }
  cout << endpoint.size() << endl;
  rep(i,(int)endpoint.size()) {
    cout << endpoint[i]+1 << " ";
  } puts("");
}

int main() {
  cin >> V >> E;
  deque<int> endpoint;
  rep(i,E) {
    int s,t;
    cin >> s >> t;
    --s, --t;
    if( endpoint.empty() ) {
      endpoint.push_back(s);
      endpoint.push_back(t);
      used[s] = used[t] = true;
    }
    G[s].push_back(t);
    G[t].push_back(s);
  }
  compute(endpoint);
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  if (90 <= n || n % 10 == 9) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string n;
    cin >> n;
    cout << (n[0] == '7' || n[1] == '7' || n[2] == '7' ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s, t;
    cin >> s >> t;
    int insertI = -1;
    rep(i,s.size()){
        int j = i + t.size() - 1;
        if (j >= s.size()) break;
        bool ok = true;
        int cnt = 0;
        for(int k = i; k <= j; k++){
            if (s[k] != t[cnt] && s[k] != '?') ok = false;
            cnt++;
        }
        if (ok) insertI = i;
    }
    if (insertI == -1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }else{
        rep(i,s.size()){
            if (i == insertI){
                int j = i + t.size() - 1;
                int cnt = 0;
                for(int k = i; k <= j; k++){
                    s[k] = t[cnt];
                    cnt++;
                } 
            }
            if (s[i] == '?') s[i] = 'a';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
N = gets.to_i
A = gets.split.map(&:to_i)

if (N-1).times.all?{|i| A[i] < A[i+1]}
    puts 1
    exit
end

def check(k)
    st = [[-1, -1]]
    (N-1).times do |i|
        if A[i] >= A[i+1]
            st.pop while st[-1][0] > A[i+1]
            if st[-1][0] == A[i+1]
                st[-1][1] += 1
                while st[-1][1] == k
                    d = st[-1][0]
                    return false if d == 1
                    st.pop
                    if st[-1][0] == d-1
                        st[-1][1] += 1
                    else
                        st.push([d-1, 1])
                    end
                end
            else
                st.push([A[i+1], 1])
            end
        end
    end
    true
end

puts (2..N).bsearch{|k| check(k)}

Measured memory_bytes: 19988
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        int s1 = n / 6, s2 = n / 9;
        int[] TS = new int[n + 10];
        int[] TN = new int[n + 10];
        for (int i = 0; i <= n; i += 6) {
            int temp = i;
            while (temp / 6 > 0) {
                temp /= 6;
                TS[i] += temp % 6;
            }
            for (int j = 0; j < 6; j++) {
                if (i + j <= n) TS[i + j] = TS[i] + j;
            }
        }
        for (int i = 0; i <= n; i += 9) {
            int temp = i;
            while (temp / 9 > 0) {
                temp /= 9;
                TN[i] += temp % 9;
            }
            for (int j = 0; j < 9; j++) {
                if (i + j <= n) TN[i + j] = TN[i] + j;
            }
        }
        for (int i = 0; i <= s2; i++) {
            int nine=9*i;
            int six=(n-nine)-(n-nine)%6;
            if(six+nine<=n)ans=min(TS[six]+TN[nine]+(n-six-nine),ans);
        }
        out.println(ans);
    }
}

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

using namespace std;

#define whole(xs) xs.begin(),xs.end()

#define MAX_R 101000

namespace {

    typedef double real;
    typedef long long ll;
    typedef unsigned long long ull;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    ull x;
    inline ll xorshift() {
        ll r = x;
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
        return r;
    }

    int N, K, X0;
    void input() {
        cin >> N >> K >> X0;
        K--;
    }

    int _count[MAX_R*2 + 1000];
    void solve() {

        if (X0 == 0) {
            cout << 0 << endl;
            return;
        }

        auto count = _count + MAX_R + 500;
        x = X0;
        for (int i = 0; i < N; i++) {
            count[ int(floor(xorshift() / 1e14)) ]++;
        }
        ll s = 0;
        real z = -1;
        for (int i = -MAX_R-1; i <= MAX_R+1; i++) {
            s += count[i];
            if (s > K) {
                z = i;
                s -= count[i];
                break;
            }
        }

        x = X0;
        vector<ll> ts;
        for (int i = 0; i < N; i++) {
            ll t = xorshift();
            int r = floor(real(t) / 1e14);
            if (r == z) {
                ts.push_back(t);
            }
        }
        sort(whole(ts));
        cout << ts[K - s] << endl;
    }
}

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

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
template <class T>

inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '1')
            ans++;
    }
    cout << ans << endl;
}


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

using namespace std;
int main()
{
    // 文字列の入力
    int N, M, K;
	cin >> N >> M >> K;
	
	static long long a[200001];
	static long long b[200001];
	
	long long temp;
	for(int i = 1; i <= N; i++) {
		cin >> temp;
		a[i] = a[i - 1] + temp;
	}
	
	for(int i = 1; i <= M; i++) {
		cin >> temp;
		b[i] = b[i - 1] + temp;
	}

	int redcnt = 0;
	int j = M;
	for(int i = 0; i <= N; i++) {
		if(a[i] > K) {
			break;
		}
		while(b[j] > K - a[i]) {
			j -= 1;
		}

		redcnt = max(redcnt, i + j);
	}
	printf("%d\n", redcnt);
	
    return 0;
}

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

int main(){
  
  int L;
  cin >> L;
  int total=0;
  for(int i=1;i<L+1;i++){
    for(int j=1;j<L+1;j++){
      for(int k=1;k<L+1;k++){
        total += __gcd(__gcd(i,j),k);
      }
    }
  }
  cout << total << endl;
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
bool judge(string s,char c){
    //文字cが文字列sに含まれるかどうか
    rep(i, 0, s.length()){
        if(s[i] == c)return 1;
    }
    return 0;
}
string func(string s){
    string ans = "";
    ans += s[0];
    rep(i,0,s.length()-1){
        if(judge("aiueo",s[i]) ){
            ans += s[i+1];
        }
    }
    return ans;
}
main(){
    int N;
    cin >> N;
    while(N){
        vector<string> V(N);
        rep(i,0,N){
            string s;
            cin >> s;
            V[i] = func(s);
        }
        int ans = -1;
        rep(i,1,51){
            set<string> st;
            rep(j,0,N){
                st.insert( V[j].substr(0,min(i, (int)V[j].length()) ) );
            }
            if(st.size() == N){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
        cin >> N;
    }
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll;  
const ll inf=1ll<<50;  
typedef pair<ll,ll> ii;  
const int N=4e3+20;  
ll d[N],n,m;  
vector<ii> e[N];  
bool neg[N];  
void calc()  
{  
    fill(d,d+1+n,inf);  
    memset(neg,false,sizeof(neg));  
    d[1]=0;  
    for(int k=1;k<n;k++)//无环 最多经过n-1条边   
    {  
        for(int i=1;i<=n;i++)  
        {  
            for(int j=0;j<e[i].size();j++)  
            {  
                ll v=e[i][j].first,w=e[i][j].second;  
                if(d[i]==inf)  
                    continue;  
                if(d[v]>d[i]+w)  
                    d[v]=d[i]+w;  
            }  
        }  
    }  
      
      
    for(int k=1;k<=n;k++)  
    {  
        for(int i=1;i<=n;i++)  
        {  
            for(int j=0;j<e[i].size();j++)  
            {  
                ll v=e[i][j].first,w=e[i][j].second;  
                if(d[i]==inf)  
                    continue;  
                if(d[v]>d[i]+w)  
                {  
                    d[v]=d[i]+w;  
                    neg[v]=true;//标记负环上的点   
                }  
                if(neg[i]==true)  
                    neg[v]=true;  
            }  
        }  
    }  
    if(neg[n]==false)  
        cout<<-d[n]<<endl;  
    else  
        puts("inf");      
      
}  
int main()  
{  
    while(cin>>n>>m)  
    {  
        for(int i=0;i<=n;i++)  
            e[i].clear();  
        ll u,v,w;  
        while(m--)  
        {  
            cin>>u>>v>>w;  
            e[u].push_back(ii(v,-w));     
        }  
        calc();   
    }  
    return 0;  
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
// #define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vvll            vector<vll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
// vll pwx(32);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] =  x*pwx[i-1]; }
 
/* ################################################################ */

#define space 100005

void solve() {
    ll n; cin >> n;

    if(n == 1) {
        cout << 0 << nl; return;
    }   

    ll ans1 = 1, ans2 = 1, ans3 = 1, n2 = n, n3 = n;

    while(n--) {
        ans1 *= 10;
        ans1 %= mod;
    }

    while(n2--) {
        ans2 *= 9;
        ans2 %= mod;
    }
    ans2 *= 2;
    ans2 %= mod;

    while(n3--) {
        ans3 *= 8;
        ans3 %= mod;
    }
    
    cout << (ans1 - ans2 + ans3 + mod) % mod << nl;
}
 
int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;

  long long A[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> A[i][j];

  long long B[m][l];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < l; j++)
      cin >> B[i][j];

  long long C[n][l] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }

  for (int i = 0; i < n; i++){
    for (int j = 0; j < l; j++) {
      if (j) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[2];

ll from[3][3],to[3][3];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cin>>S[0]>>S[1];
	
	if(S[0][0]==S[1][0]) {
		from[0][0]=from[1][1]=from[2][2]=1;
	}
	else {
		from[0][1]=from[0][2]=from[1][0]=from[1][2]=from[2][0]=from[2][1]=1;
	}
	
	int a1,b1,a2,b2;
	for(i=1;i<N;i++) {
		ZERO(to);
		FOR(a1,3) FOR(b1,3) FOR(a2,3) FOR(b2,3) {
			if((S[0][i-1]==S[0][i]) != (a1==a2)) continue;
			if((S[1][i-1]==S[1][i]) != (b1==b2)) continue;
			if((S[0][i]==S[1][i]) != (a2==b2)) continue;
			(to[a2][b2]+=from[a1][b1])%=mo;
		}
		
		swap(from,to);
	}
	
	ll tot=0;
	FOR(x,3) FOR(y,3) tot+=from[x][y];
	cout<<tot%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (2 * b == a + c) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
#include<utility>
#include<stdlib.h>
#include<ctime>
using namespace std;
 
 
 
int main()
{
	string s;
	cin >> s;
	s.erase(3);
	cout << s << endl;
	return 0;
}

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //?§???????????????¢??????????????????
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int n[4];
    string str;
 
    while (cin >> str, str != "0000"){
        REP(i, 4){
            n[i] = str[i] - '0';
        }
 
        if (n[0] == n[1] && n[0] == n[2] && n[0] == n[3]){
            CL("NA");
        }
        else {
            int c = 0;
            while (n[0] != 6 || n[1] != 1 || n[2] != 7 || n[3] != 4){
                 
                char l[4], s[4];
                REP(i, 4){
                    l[i] = s[i] = n[i];
                }
 
                sort(l, l + 4);
                reverse(l, l + 4);
                sort(s, s + 4);
 
                for (int i = 3; 0 <= i; i--){
                    n[i] = l[i] - s[i];
                    if (n[i] < 0){
                        n[i] += 10;
                        l[i - 1]--;
                    }
                }
                c++;
            }
            CL(c);
        }
    }
    return (0);
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,K,T,U,V,L;
bool mp[10010];

int main(){
  cin>>N>>K>>T>>U>>V>>L;
  int cnt=0;
  for(int i=0,a,A;i<N;i++){
    cin>>a;
    A=a;
    while(mp[a])a++;
    while((1.0*a-A)/V/T>K)a--;
    for(int j=a;j<L&&j<a+T*V;j++)cnt+=!mp[j],mp[j]=1;
  }

  printf("%.8f\n",(1.0*cnt/V)+(1.0*(L-cnt)/U));
  return 0;
}

Measured memory_bytes: 1204
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;
  cin >> s;

  /*
  cout << s[5] << endl;
  cout << (s[6] > '4') << endl;    
  */
  if(s[5] != '0') {
    cout << "TBD" << endl;
    return 0;
  }
  if(s[6] > '4'){
    cout << "TBD" << endl;
    return 0;    
  }
  if(s[6] == '4' && s[8] == '3' && s[9] > '0'){
    cout << "TBD" << endl;
    return 0;    
  }
  cout << "Heisei" << endl;
  return 0;
}


Measured memory_bytes: 256
N,A=map(int,input().split())
l=list(map(int,input().split()))
d={}
def func(n,s,i):
	if n<0:
		return
	if (n,s,i) in d:
		return
	if n==0:
		if s==0:
			d[(n,s,i)]=1
		else:
			d[(n,s,i)]=0
		return
	if i>=N:
		if s==0 and n==0:
			d[(n,s,i)]=1
		else:
			d[(n,s,i)]=0

		return
	else:
		func(n-1,s-l[i],i+1)
		func(n,s,i+1)
		d[(n,s,i)]=d[(n-1,s-l[i],i+1)]+d[(n,s,i+1)]
ans=0
for j in range(1,N+1):
	func(j,j*A,0)
	ans+=d[(j,j*A,0)]
print(ans)

Measured memory_bytes: 130864
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
ll ans = 0;
for(int i = 1; i <= n / 2; i++){
    if(n - i != i)
        ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 3616
/**< Winter is Coming - Game Of Thrones */
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = 1e9 + 7;
const ll mode = 1e6 + 3;

ll min(ll a, ll b)
{
    if(a > b) return b;
    else return a;
}
ll min_third(ll a, ll b ,ll c)
{
    return min(min(a,b),c);
}
ll GCD(ll A, ll B) {
    if(B == 0)
        return A;
    else
        return GCD(B, A % B);
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int fun(int x, int y)
{
    return x*y;
}
//4
//10 30 40 20

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

    ll A = 0,B = 0;cin >> A >> B;
    ll total = 6;
    cout << (total - A - B) << endl;


    return 0;
}


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

long A[100000]={};

long gcd(long a, long b){
  if(b==0) return a;
  return gcd(b, a%b);
}

int main(){
  long N;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  long ans = A[0];
  for(int i=1; i<N; i++){
    ans = gcd(ans, A[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a = 0, b = 0, c = 0, d = 0;
  cin >> a >> b >> c >> d;
  if(a + b > c + d)
    cout << "Left" << endl;
  else if(a + b == c + d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	return;
}

int main(){
  int a[3], i, j;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  for(i = 0; i < 3; i++){
    for(j = i; j < 3; j++){
      if(a[i] > a[j]){
        swap(&a[i], &a[j]);
      }
    }

  }
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
struct P {
  int x,y,r,k;
}p[30];
bool u[30],b[1<<24];
int n,ans,c[30];
vector<int> g[30];
 
bool ck(int a, int b) {
  double d=sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y));
  double c=p[a].r+p[b].r;
  return d<c;
}

void dfs() {
  int cnt=0,t=0;
  for(int i=0; i<n; i++) {
    cnt+=u[i];
    t|=u[i]<<i;
  }
  if(ans<cnt) ans=cnt;
  if(b[t]) return;
  b[t]=1;
  vector<int> v;
  for(int i=0; i<n; i++) {
    if(!u[i]&&!c[i]) v.push_back(i);
  }
  for(int i=0; i<v.size(); i++) {
    for(int j=i+1; j<v.size(); j++) {
      if(p[v[i]].k==p[v[j]].k) {
        for(int l=0; l<g[v[i]].size(); l++) c[g[v[i]][l]]--;
        for(int l=0; l<g[v[j]].size(); l++) c[g[v[j]][l]]--;
        u[v[i]]=u[v[j]]=1;
        dfs();
        u[v[i]]=u[v[j]]=0;
        for(int l=0; l<g[v[i]].size(); l++) c[g[v[i]][l]]++;
        for(int l=0; l<g[v[j]].size(); l++) c[g[v[j]][l]]++;
      }
    }
  }
}
   
 
int main() {
  while(cin >> n && n) {
    for(int i=0; i<n; i++) {
      int a1,a2,a3,a4;
      cin >> a1 >> a2 >> a3 >> a4;
      p[i]=(P){a1,a2,a3,a4};
      g[i].clear();
    }
    fill(b,b+(1<<n),0);
    memset(u,0,sizeof(u));
    memset(c,0,sizeof(c));
    for(int i=0; i<n; i++) {
      for(int j=0; j<i; j++) {
        if(ck(i,j)) {
          c[i]++;
          g[j].push_back(i);
        }
      }
    }
    ans=0;
    dfs();
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 17604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N, K;
	vector<int> h;
	cin >> N >> K;
	vector<int> dp(vector<int>(N, INT_MAX));
	for (int i = 0; i < N; ++i) {
		int _h;
		cin >> _h;
		h.push_back(_h);
	}
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = max(i - K, 0); j < i; ++j) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}

	cout << dp[N - 1] << endl;



	return 0;
}

Measured memory_bytes: 1276
#include <cstdio>

int lrc[501][501];


int main()
{
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < m; ++i)
  {
    int l, r;
    scanf("%d %d", &l, &r);
    lrc[l][r]++;
  }
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 2; j <= n; ++j)
    {
      lrc[i][j] += lrc[i][j - 1];
    }
  }
  for (int i = 2; i <= n; ++i)
  {
    for (int j = 1; j <= n; ++j)
    {
      lrc[i][j] += lrc[i - 1][j];
    }
  }
  
  for (int i = 0; i < q; ++i)
  {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", lrc[r][r] - lrc[r][l - 1] - lrc[l - 1][r] + lrc[l - 1][l - 1]);
  }
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

  int st = h1 * 60 + m1;
  int ed = h2 * 60 + m2;
  int tmp = ed - st;
  cout << tmp - k << endl;

}
























Measured memory_bytes: 3652
import itertools


def main():
    h, w = (int(z) for z in input().split())
    n, m = (int(z) for z in input().split())
    res = 0
    for r, c in itertools.product(range(h), range(w)):
        if 0 <= r < n or 0 <= c < m:
            pass
        else:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <limits>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong x[100005], l[100005];
pair<llong, llong> a[100005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> l[i];
        a[i].first = x[i] + l[i];
        a[i].second = x[i] - l[i];
    }

    sort(a, a + n);
    llong t = numeric_limits<llong>::min();
    llong ans = 0;
    for (int i = 0; i < n; i++) {
        if (t <= a[i].second) {
            ans++;
            t = a[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <stdlib.h>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;

ll DP[210][10];
int main(){
    int H,W,K;
    cin >> H >> W >> K;

    DP[0][0] = 1;
    for(int h = 1; h < H+1; h++){
        int X[8],Y[8],Z[8];
        for(int i = 0; i < W; i++){
            X[i] = Y[i] = Z[i] = 0;
        }
        for(int i = 0; i < (1 << W-1); i++){
            if(i & (i<<1)) continue;
            for(int w = 0; w < W; w++){
                bool left = false;
                bool right = false;
                if(w != 0 && (i >> (w-1)) & 1) left = true;
                if(w != W-1 && (i >> w) & 1) right = true;
                if(left) X[w]++;
                if(right) Z[w]++;
                if(!(left||right)) Y[w]++;
            }
        }
        for(int w = 0; w < W; w++){
            //printf("(h,w)=(%d,%d)\tX:%d Y:%d Z:%d\n", h,w,X[w],Y[w],Z[w]);
            DP[h][w] += Y[w]*DP[h-1][w];
            if(w != 0) DP[h][w] += X[w]*DP[h-1][w-1];
            if(w != W-1) DP[h][w] += Z[w]*DP[h-1][w+1];
            DP[h][w] %= MOD;
        }
    }

    
    cout << DP[H][K-1]<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define ll long long
#define pii pair < ll , ll >
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;


int main(){
    int k;
    cin >> k;
    int a, b;
    cin >> a>> b;
    int flag = 1;
    for(int i = a; i <= b; i++){
        if(i % k == 0){cout <<"OK";flag = 0;break;
        }
    }
    if(flag)cout <<"NG";


}

Measured memory_bytes: 3628
def main():
    import sys
    import numpy as np

    def input(): return sys.stdin.readline().rstrip()

    h, w = map(int, input().split())
    g = np.zeros((h, w), dtype=int)
    for i in range(h):
        g[i] = [int(s == '.') for s in input()]
    
    L = g.copy()
    R = g.copy()
    U = g.copy()
    D = g.copy()
    
    for i in range(1,h):
        U[i] = (U[i-1]+1)*g[i]
        D[~i] = (D[~i+1]+1)*g[~i]
    for j in range(1, w):
        L[:, j] = (L[:, j-1]+1)*g[:,j]
        R[:, ~j] = (R[:, ~j+1]+1)*g[:, ~j]
     
    ans = np.max(L+R+U+D-3)
    print(ans)
            
                
if __name__ == '__main__':
    main()

Measured memory_bytes: 214540
#include <iostream>

using namespace std;

const int MAX_PRIME = (1 << 15);
bool prime[MAX_PRIME + 1];

void init_prime()
{
    for (int i = 0; i <= MAX_PRIME; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i <= MAX_PRIME; i++) 
        if (prime[i])
            for (int j = 2 * i; j <= MAX_PRIME; j += i)
                prime[j] = false;
}

void solve(int n)
{
    int ans = 0;

    for (int i = 2; i <= n / 2; i++) {
        if (n - i < 2)
            break;
        if (prime[i] && prime[n - i]) 
            ans++;
    }

    cout << ans << endl;
}

int main()
{
    int n;
    
    init_prime();
    while (cin >> n, n) {
        solve(n);
    }

    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
//#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}

signed main(){
	
	int n;
	cin >> n;
	unordered_set<string>st;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		string str1;
		cin >> str1;
		if (str == "insert") {
			st.emplace(str1);
		}
		else {
			if (st.count(str1)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}



}	






Measured memory_bytes: 31848
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main{

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
	void run() {
		Scanner sc = new Scanner(System.in);
		pow = new int[8];
		pow[0] = 1;
		for (int i=1;i<8;i++) pow[i] = pow[i-1]*10;
		solve();
//		debug(map.size(), 2*3*4*5*6*7*8);
		for (;sc.hasNext();) {
			String num = "";
			for (int i=0;i<8;i++) {
				num += sc.nextInt();
			}
			System.out.println(map.get(Integer.parseInt(num)));
		}
	}

	void solve() {
		LinkedList<Integer> q = new LinkedList<Integer>();
		LinkedList<Integer> d = new LinkedList<Integer>();
		q.add(1234567);
		d.add(0);
		map.put(1234567,  0);
		while(!q.isEmpty()) {
			int cp = q.removeFirst(), cd = d.removeFirst();
//			debug(nextState(cp));
			for (int i: nextState(cp)) if (! map.containsKey(i)) {
				map.put(i, cd + 1);
				q.add(i); d.add(cd + 1);
			}
		}
	}
	
	int[] pow;
	int[] nextState(int s) {
		int p=0;
		String num = "" + s;
		if (num.length() == 7) p = 0;
		else for (;p<8;p++) if (num.charAt(p) == '0') break;
		p = 7-p;
		if (p == 1 || p == 2 || p == 5 || p == 6) {
			int[] next = new int[3];
			next[0] = swap(s, p, p-1);
			next[1] = swap(s, p, p+1);
			next[2] = swap(s, p, (p+4)%8);
			return next;
		}
		if (p == 0 || p == 4) {
			int[] next = new int[2];
			next[0] = swap(s, p, p+1);
			next[1] = swap(s, p, (p+4)%8);
			return next;
		}
		int[] next = new int[2];
		next[0] = swap(s, p, p-1);
		next[1] = swap(s, p, (p+4)%8);
		return next;
	}

	int swap(int a, int s, int t) {
		int tmp1 = (a / pow[s]) % 10;
		int tmp2 = (a / pow[t]) % 10;

		return a + (tmp2 - tmp1) * pow[s] + (tmp1 - tmp2) * pow[t];
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 40844
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef long long LL;

const int MOD = 1000000;
const int SIZE = 1001;

const string utf8[4][4] = {
    { "0xxxxxxx" },
    { "110yyyyx", "10xxxxxx" },
    { "1110yyyy", "10yxxxxx", "10xxxxxx" },
    { "11110yyy", "10yyxxxx", "10xxxxxx", "10xxxxxx" }
};
int n;
LL dp[SIZE];

LL calc( VS& L, int k, int len ) {
    LL res = 1;
    int y1 = 0, yx = 0;
    for ( int i = 0; i < len; ++ i ) {
        const string& s = L[k+i];
        const string& u = utf8[len-1][i];
        LL ret = ([&]( const string& s, const string& u ) -> LL {
                LL res = 1;
                auto isNumber = []( const char c ) -> bool { return c == '0' || c == '1'; };
                for ( int i = 0; i < 8; ++ i ) {
                    if ( isNumber( u[i] ) ) {
                        if ( s[i] != 'x' && s[i] != u[i] ) return 0;
                    
                    } else if ( u[i] == 'x' ) {
                        if ( s[i] == 'x' ) {
                            res *= 2;
                        }
                    } else if ( u[i] == 'y' ) {
                        if ( s[i] == 'x' ) {
                            yx ++;
                        } else if ( s[i] == '1' ) {
                            y1 ++;
                        }
                    }
                }
                return res;
            })( s, u );
        if ( ret == 0 ) return 0;
        res *= ret;
        res %= MOD;
    }

    if ( len == 1 ) {
        return res;
    }
    if ( y1 == 0 && yx == 0 ) return 0;
    if ( y1 > 0 ) {
        res *= 1 << yx;
    } else {
        res *= ( 1 << yx ) - 1;
    }
    res %= MOD;
    
    return res;
}

LL solve( VS L ) {
    bool flag = true;
    fill( dp, dp + SIZE, 0 );
    dp[0] = 1;
    for ( int i = 1; i <= n; ++ i ) {
        for ( int j = 1; j <= 4; ++ j ) {
            if ( i - ( j - 1 ) - 1 < 0 ) continue;
            LL ret = calc( L, i - ( j - 1 ) - 1, j );
            if ( ret == 0 ) continue;
            flag = false;
            dp[i] += ( dp[i-j] * ret ) % MOD;
            dp[i] %= MOD;
        }
    }
    
    return flag ? 0 : dp[n];
}

int main() {
    while ( cin >> n && n ) {
        VS lines(n);
        for ( int i = 0; i < n; ++ i ) cin >> lines[i];
        cout << solve( lines ) << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll



void solve()
{
    lf r;
    cin>>r;
    lf ans = M_PI*2.0*r;
    cout<<setprecision(15)<<ans<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


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

typedef long long LL;

int n,q,k;
string s;
LL dp[3][1000005];

void solve(int x){
   LL bm = 0;
   for(int i=0;i<s.size();i++){
      if(i>0){
         for(int j=0;j<3;j++) dp[j][i] = dp[j][i-1];
      }
      else{
         for(int j=0;j<3;j++) dp[j][i] = 0LL;
      }
      if(i>=x){
         if(s[i-x] == 'M') bm--;
         else if(s[i-x] == 'D') dp[1][i]-=bm, dp[0][i]--;
      }
      if(s[i] == 'C') dp[2][i]+=dp[1][i];
      else if(s[i] == 'M') dp[1][i]+=dp[0][i], bm++;
      else if(s[i] == 'D') dp[0][i]++;
   }
   printf("%lld\n",dp[2][s.size()-1]);
   return;
}

int main()
{
   cin >> n;
   cin >> s;
   cin >> q;
   for(int i=1;i<=q;i++){
      cin >> k;
      solve(k);
   }
 	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 080_abc_d / Link: https://abc080.contest.atcoder.jp/tasks/abc080_d?lang=en  ----- */
/* ------問題------

joisinoお姉ちゃんは、録画機を用いて N 個のテレビ番組を録画しようとしています。
テレビが受信できるチャンネルは C 個あり、1 から C までの番号がついています。
joisinoお姉ちゃんの録画したいテレビ番組のうち、i 個目のテレビ番組は、時刻 si から時刻 ti まで、チャンネル ci で放送されます。(ただし時刻 si を含み、時刻 ti を除く)
ただし、同じチャンネルで複数のテレビ番組が同時に放送されることはありません。
また、録画機は、あるチャンネルの時刻 S から時刻 T までを録画するとき、時刻 S−0.5 から時刻 T までの間、他のチャンネルの録画に使うことができません。(ただし時刻 S−0.5を含み、時刻 T を除く)
N 個のテレビ番組の全ての放送内容が含まれるように録画するとき、必要な録画機の最小個数を求めてください。

-----問題ここまで----- */
/* -----解説等-----

同じチャンネルは一回ということに注意して適当にimos法で区間を管理する。
また埋める区間は[2s-1,2t)

----解説ここまで---- */

LL N,C;

LL ans = 0LL;

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

	cin >> N>>C;
	VVI m(C, VI(2e5 + 10, 0));
	FOR(i, 0, N) {
		int s, t, c;
		cin >> s >> t >> c;
		m[c - 1][2*s-1]++;
		m[c - 1][2*t]--;
	}
	FOR(i, 0, C) {
		FOR(j, 0, 2e5) {
			m[i][j + 1] += m[i][j];
		}
	}
	FOR(i, 0, C) {
		FOR(j, 0, 2e5) {
			if (m[i][j])m[i][j] = 1; // 同じチャンネルは一回
		}
	}
	FOR(i, 0, 2e5) {
		LL cnt = 0;
		FOR(c, 0, C) {
			cnt += m[c][i];
		}
		ans = max(ans, cnt);
	}
	cout << ans << "\n";

	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi ans(n);
    rep(i, n) ans[a[i]-1] = i+1;
    rep(i, n) cout << ans[i] << (i!=n-1?' ':'\n');
    return 0;
}


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

int n,p[10],q[10],a[10];

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) a[i] = i + 1;
	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i < n; i++) cin >> q[i];
	int cnt = 0, c = 0, b = 0;
	while(next_permutation(a, a + n)){
		cnt++;
		int flag = 1;
		for(int i = 0; i < n; i++) if(a[i] != p[i]) flag = 0;
		if(flag) c = cnt;
		flag = 1;
		for(int i = 0; i < n; i++) if(a[i] != q[i]) flag = 0;
		if(flag) b = cnt;
 	}
 	cout << abs(c - b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main (){
    long long int a, b, c;
    long double d,e,f;
    cin >> a >> b >> c;

    if(c<a+b){
        cout << "No" << endl;
        return 0;
    }
  d=a*1.0;
  e=b*1.0;
  f=c*1.0;
    if(d*e<(f-(d+e))*(f-(d+e))/4){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
int dp[N + 5];
int arr[N + 5];

void hora(int tc) {
	int n,k;
	cin>>n>>k;
	for(int i = 1;i <= n;i++) {
		dp[i] = 1e9;
		cin>>arr[i];
	}
	dp[1] = 0;
	dp[0] = 1e9;
	for(int i = 2;i <= n;i++) {
		for(int j = 1;j <= k;j++) {
			if(i - j < 1) break;
			dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
		}
	}
	cout<<dp[n]<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

void DICE(char x, int *dice1, int *dice2, int *dice3, int *dice4, int *dice5, int *dice6){
    int tmp1, tmp2, tmp3, tmp4;
    if(x=='S'){
        tmp1=*dice1;
        tmp2=*dice2;
        tmp3=*dice5;
        tmp4=*dice6;
        *dice1=tmp3;
        *dice2=tmp1;
        *dice5=tmp4;
        *dice6=tmp2;
    }
        else if(x=='W'){
        tmp1=*dice1;
        tmp2=*dice3;
        tmp3=*dice4;
        tmp4=*dice6;
        *dice1=tmp2;
        *dice3=tmp4;
        *dice4=tmp1;
        *dice6=tmp3;
    }
    else if(x=='N'){
        tmp1=*dice1;
        tmp2=*dice2;
        tmp3=*dice5;
        tmp4=*dice6;
        *dice1=tmp2;
        *dice2=tmp4;
        *dice5=tmp1;
        *dice6=tmp3;
    }
    else if(x=='E'){
        tmp1=*dice1;
        tmp2=*dice3;
        tmp3=*dice4;
        tmp4=*dice6;
        *dice1=tmp3;
        *dice3=tmp1;
        *dice4=tmp4;
        *dice6=tmp2;
    }
}


int main(void){
    int dice1, dice2, dice3, dice4, dice5, dice6;
    char x;
    
    scanf("%d %d %d %d %d %d", &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
    
    while(scanf("%c", &x)!=EOF){
        DICE(x, &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
    }
    
    printf("%d\n", dice1);
    return 0;
    
}





Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	lld k;cin>>k;
	int n=50;
	cout<<n<<'\n';
	for(int i=0;i<n-1;i++){
		lld kn = k/n;
		if(i<k%n) kn++;
		cout<<n*kn-(k-kn)+n-2<<' ';
	}
	lld kn = k/n;
	cout<<n*kn-(k-kn)+n-1<<'\n';
	return 0;
}

Measured memory_bytes: 256