akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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 (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n;
  cin>>n;
  vector<ll> a(n);
  set<ll> s;
  rep(i,n){
    cin>>a[i];
    if(s.find(a[i]) == s.end()) s.insert(a[i]);
  }
  /*
  sort(all(a));
  auto ac=*max_element(all(a));
  auto bc=*min_element(all(a));

  auto sa=s.find(ac);
  auto sb=s.find(bc);

  cout << *s.begin() << endl;

  cout << distance(s.begin(),sa) << ","  << distance(s.begin(),sb) << endl;
  */
  /*
  for(auto i=s.begin();i!=s.end();i++){
    cout << *i << ",";
  }
  */
  //cout << endl;
  cout << s.size() << endl;


  return 0;
}


Measured memory_bytes: 256
def LowLink(Graph, N):
    def dfs(v, k, prev):
        used[v] = True
        order[v] = k
        low[v] = order[v]
        k += 1
        is_aps = False
        count = 0
        for w in Graph[v]:
            if not used[w]:
                count += 1
                k = dfs(w, k, v)
                low[v] = min(low[v], low[w])
                if prev != -1 and order[v] <= low[w]:
                    is_aps = True
                if order[v] < low[w]:
                    bridges.append([min(v, w), max(v, w)])
            elif w != prev:
                low[v] = min(low[v], order[w])
        if prev == -1 and count >= 2:
            is_aps = True
        if is_aps:
            aps.append(v)
        return k
    
    used = [False] * N
    order = [0] * N
    low = [0] * N
    aps = []
    bridges = []
    k = 0
    for i in range(N):
        if not used[i]:
            k = dfs(i, k, -1)
    aps.sort()
    bridges.sort()
    
    return aps, bridges


N, M = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
aps, bridges = LowLink(G, N)
print(len(bridges))

Measured memory_bytes: 3064
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n,m;
int dp[3005][3005][2];
const int jt=1000000007;

int main(){
	scanf("%d%d",&n,&m);
	loop(i,n+1)dp[0][i][!i]=1;
	cont(i,m)loop(j,n+1){
		if(j>1)(dp[i][j][0]+=dp[i-1][j][0])%=jt;
		if(j<n)(dp[i][j][0]+=dp[i-1][j][0])%=jt;
		if(j)(dp[i][j][0]+=dp[i-1][j-1][0])%=jt;
		if(j<n)(dp[i][j][0]+=dp[i-1][j+1][0])%=jt;
		if(j)(dp[i][j][1]+=dp[i-1][j][1])%=jt;
		if(j<n)(dp[i][j][1]+=dp[i-1][j][1])%=jt;
		if(j)(dp[i][j][1]+=dp[i-1][j-1][1])%=jt;
		if(j<n)(dp[i][j][1]+=dp[i-1][j+1][1])%=jt;
		if(!j){
			(dp[i][j][1]+=dp[i][j][0])%=jt;
			dp[i][j][0]=0;
		}
		if(j==1)(dp[i][j][1]+=dp[i-1][j][0])%=jt;
	}
	int ans=0;
	loop(i,n+1)(ans+=dp[m][i][1])%=jt;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 74136
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int cnt = 0;
    char ans;
    rep(i, 0, s.size()){
        if(s[i] == '1') cnt++;
        else{
            ans = s[i];
            break;
        }
        
    }
    if(k <= cnt) cout << 1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int cnt = 0;
    while(N > 0)
    {
        N /= K;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

using namespace std;

int main(){
  string s;cin>>s;
  ll x,y;cin>>x>>y;
  vector<ll> moves, uds, lrs;
  ll ff=0;
  if(s[0]=='F')rep(i,s.size()){
    if(s[i]=='F')ff++;
    else break;
  }

  ll fcount=0;
  rep(i, s.size()-ff){
    int ci=i+ff;
    if(s[ci]=='F')fcount++;
    if(s[ci]=='T'){
      moves.push_back(fcount);
      fcount=0;
    }
  }
  if(fcount!=0)moves.push_back(fcount);

  rep(i,moves.size()){
    if(i%2==0) lrs.push_back(moves[i]);
    else uds.push_back(moves[i]);
  }

  ll lrsum=0, udsum=0;
  rep(i,lrs.size())lrsum+=lrs[i];
  rep(i,uds.size())udsum+=uds[i];

  set<ll> udset;
  udset.insert(0);
  rep(i,uds.size()){
    set<ll> tmpset;
    for(auto p : udset){
      tmpset.insert(p+uds[i]);
      tmpset.insert(p-uds[i]);
    }
    udset = tmpset;
  }

  set<ll>lrset;
  lrset.insert(ff);
  rep(i,lrs.size()){
    set<ll> tmpset;
    for(auto t : lrset){
      tmpset.insert(t+lrs[i]);
      tmpset.insert(t-lrs[i]);
    }
    lrset = tmpset;
  }

  if( udset.find(y)!=udset.end() && lrset.find(x)!=lrset.end() ){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;

cout<<endl;
for(auto p : udset)cout<<p<<' ';cout<<endl;
for(auto p : lrset)cout<<p<<' ';cout<<endl;

cout<<ff<<endl;
//rep(i,moves.size())cout<<moves[i]<<' ';cout<<endl;
rep(i,lrs.size())cout<<lrs[i]<<' ';cout<<endl;
rep(i,uds.size())cout<<uds[i]<<' ';cout<<endl;

  return 0;
}

Measured memory_bytes: 768
H, W, K = map(int, input().split())
c = []

for _ in range(H):
    c.append(input())
#こういうinputをすると，c_ij = c[i][j] (C[i]という文字列のj文字目)という構造になってくれて，とても嬉しい。
#print(c)

ans = 0

#bit全探索
for rows in range(1 << H):
    #bit演算子。1 << H は二進数で1000...という風に，1の後ろに0がH個並ぶ。
    #例えば rows = 110010 のときには，(2 ** 5ケタ目の1は無視して）（0-indexで）1行目と4行目を赤で塗る状態を指す。
    for cols in range(1 << W):
        black_count = 0

        for i in range(H):
            if (rows >> i) % 2 == 1:continue #i行目が赤で塗られていたならば，何もせずiを一歩進める。

            for j in range(W):
                if (cols >> j) % 2 ==1:continue #j列目が赤で塗られていたならば，何もせずjを一歩進める。
                if c[i][j] == "#":
                    black_count += 1

        if black_count == K:
            ans += 1

print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}

vector<vector<int>> adj;
vector<int> outdeg;
vector<int> dp;
vector<int> vis;

int dfs(int i){
	if (vis[i]) return dp[i];
	vis[i] = 1;
	dp[i] = 0;
	for (auto x:adj[i]){
		dp[i] = max(dp[i],dfs(x)+1);
	}
	return dp[i];
}


void solve()
{	
	int n,m;
	cin>>n>>m;
	adj.resize(n);
	outdeg.resize(n);
	dp.resize(n);
	vis.resize(n);
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		adj[a].pb(b);
	}
	int ans = 0;
	for (int i=0;i<n;i++){
		ans = max(ans,dfs(i));
	}
	cout<<ans<<endl;



}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}
	

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

int main(void) {
    long int n,d;


    cin>>d>>n;
if(n==100){n++;}
    double  a;
   a=pow(100.00,d);
   long int b=(long int)a;
   printf("%ld\n",b*n);


    return 0;
}


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

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int main(void){
  int n;
  point p[3],k,s;

  cin >> n;
  while(n--){
    for(int i=0;i<3;i++)
      cin >> p[i].x >> p[i].y;
    
    cin >> k.x >> k.y >> s.x >> s.y;
    int cnt=0;
    for(int i=0;i<3;i++)
      for(int j=i+1;j<3;j++)
	  cnt+=is_intersected_ls(p[i],p[j],k,s);
    
    if(cnt%2)cout << "OK" << endl;
    else cout << "NG" << endl;
    
  }

  return 0;
}

Measured memory_bytes: 948
#include<cstdio>

int main() {
    int a,b;
    std::scanf("%d %d",&a,&b);
        if(a < b) {
        std::printf("a < b");
    }
    else if(a > b ) {
        std::printf("a > b");
    }
    else if(a == b){
        std::printf("a == b");
    }
    std::printf("\n");
    return 0;
    }


Measured memory_bytes: 2612
/*
 © 2020-07-05 06:57:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
struct Node{
  lli x, y;
  lli val(){ return min(x, y);; }
  bool operator < (const Node & n) const {
    return min(x, y) < min(n.x, n.y);
  }
};
int main(){ _
  lli n; cin >> n;
  vector<lli> v(n);
  fore(i, 0, n) cin >> v[i];
  sort(rbegin(v), rend(v));
  priority_queue<Node> pq;
  lli ans = 0;
  for(auto i : v){
    if(pq.empty()) pq.push({i, i});
    else{
      auto x = pq.top(); pq.pop();
      ans += x.val();
      pq.push({x.x, i}); pq.push({x.y, i});
    }
  }
  cout << ans << ENDL;
  return 0;
}


Measured memory_bytes: 9000
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;

    ll N,M;
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    ans=(100*(N-M)+1900*M)*pow(2,M);
    DEB(100*(N-M))
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] P = new int[M];
            int[] Y = new int[M];
            for (int i = 0; i < M; i++) {
                P[i] = in.nextInt();
                Y[i] = in.nextInt();
            }

            ArrayList<Pair<Integer, Integer>> ps = new ArrayList<>();
            for (int i = 0; i < M; i++) {
                ps.add(new Pair<Integer, Integer>(Y[i], i));
            }
            Collections.sort(ps);

            int[] index = new int[M];
            int[] count = new int[N + 1];
            for (int m = 0; m < M; m++) {
                int i = ps.get(m).second.intValue();
                index[i] = ++count[P[i]];
            }

            for (int i = 0; i < M; i++) {
                System.out.println(String.format("%06d%06d", P[i], index[i]));
            }

        }
    }
}

class Pair<T extends Comparable<T>, S> implements Comparable<Pair<T, S>> {
    public T first;
    public S second;

    public Pair(T t, S s) {
        this.first = t;
        this.second = s;
    }

    private int hash = 0;

    @Override
    public int hashCode() {
        if (hash == 0) {
            final int prime = 31;
            int result = 1;
            result = prime * result + ((first == null) ? 0 : first.hashCode());
            result = prime * result + ((second == null) ? 0 : second.hashCode());
            hash = result;
        }
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair<T, S> other = (Pair<T, S>) obj;
        if (first == null) {
            if (other.first != null)
                return false;
        } else if (!first.equals(other.first))
            return false;
        if (second == null) {
            if (other.second != null)
                return false;
        } else if (!second.equals(other.second))
            return false;
        return true;
    }

    @Override
    public int compareTo(Pair<T, S> o) {
        return first.compareTo(o.first);
    }
}


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

vector<int> C(504),S(504),F(504);

ll G(int i,ll t){
  if(t>=S[i]){
    if(t%F[i]==0){
      return C[i];
    }
    else{
      return C[i]+F[i]-t%F[i];
    }
  }
  else{
    return S[i]-t+C[i];
  }
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N-1;i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  for(int i=0;i<N;i++){
    if(i==N-1){
      cout << 0 << endl;
      return 0;
    }
    ll ans=0; 
    for(int j=i;j<N-1;j++){
      ans+=G(j,ans);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3544
N, K = list(map(int, input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(K):
    ni = (cmb(K-1, i, mod)) * (cmb(N-K+1, i+1, mod))
    print(ni % mod)



Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;    
int main()
{
    long long n;
    cin>>n;
    long long a[n];
    long long sum=0;
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n,i,j,k, b,f,r,v;
  int h[4][3][10]={0};

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
      h[b-1][f-1][r-1]+=v;
    
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	if(k!=9){
	printf(" %d",h[i][j][k]);
	}
	else{
	  printf(" %d\n",h[i][j][k]);
	}
      }
    }
    if(i!=3){
      printf("####################\n");
    }
  }

  return 0;
}

Measured memory_bytes: 608
// #include "slimes.h"
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <vector>

long long helper(const std::vector<int>& slimes,
                 size_t first,
                 size_t last,
                 std::vector<std::vector<long long>>& dp);

long long min_cost(const std::vector<int>& slimes)
{
    // std::vector<std::vector<long long>> dp(
    //     slimes.size(), std::vector<long long>(slimes.size(), -1));
    // const auto ans = helper(slimes, 0, slimes.size() - 1, dp);
    // for (const auto& row : dp) {
    //     std::copy(cbegin(row),
    //               cend(row),
    //               std::ostream_iterator<
    //                   std::iterator_traits<decltype(cbegin(row))>::value_type>(
    //                   std::cout, ", "));
    //     std::cout << '\n';
    // }
    // return ans;

    std::vector<std::vector<long long>> dp(
        slimes.size(),
        std::vector<long long>(slimes.size(),
                               std::numeric_limits<long long>::max()));

    for (int right = 0; right < slimes.size(); ++right) {
        for (int left = right; left >= 0; --left) {
            if (left == right) {
                dp[left][right] = 0;
                continue;
            }
            const long long sum = std::accumulate(
                cbegin(slimes) + left, cbegin(slimes) + right + 1, 0ll);
            for (size_t b = left; b < right; ++b) {
                dp[left][right] = std::min(
                    dp[left][right], dp[left][b] + dp[b + 1][right] + sum);
            }
        }
    }
    // for (const auto& row : dp) {
    //     std::copy(cbegin(row),
    //               cend(row),
    //               std::ostream_iterator<
    //                   std::iterator_traits<decltype(cbegin(row))>::value_type>(
    //                   std::cout, ", "));
    //     std::cout << '\n';
    // }

    return dp.front().back();
}

long long helper(const std::vector<int>& slimes,
                 size_t first,
                 size_t last,
                 std::vector<std::vector<long long>>& dp)
{
    auto& cached = dp[first][last];

    if (cached != -1)
        return cached;
    if (first == last) {
        cached = 0;
        return cached;
    }

    long long cost_so_far{std::numeric_limits<long long>::max()};
    long long sum =
        std::accumulate(cbegin(slimes) + first, cbegin(slimes) + last + 1, 0ll);

    for (size_t i = first; i < last; ++i) {
        for (size_t j = first; j < last; ++j) {
            cost_so_far = std::min(cost_so_far,
                                   helper(slimes, first, j, dp) +
                                       helper(slimes, j + 1, last, dp) + sum);
        }
    }

    cached = cost_so_far;
    return cost_so_far;
}

int main(int argc, char* argv[])
{
    size_t num_slimes;
    std::cin >> num_slimes;
    std::vector<int> slimes;
    slimes.reserve(num_slimes);
    for (size_t i = 0; i < num_slimes; ++i) {
        int slime_length;
        std::cin >> slime_length;
        slimes.push_back(slime_length);
    }
    std::cout << min_cost(slimes) << std::endl;
    return 0;
}



Measured memory_bytes: 4232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = br.readLine().split(" ");

        for (int i = 0; i < m; i++) {
            n = n - Integer.parseInt(a[i]);
        }

        if (n < 0) {
            n = -1;
        }
        System.out.println(n);
    }
}


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

int main(int argc, char *argv[])
{
    int n, m, c;
    int i, j;

    int cnt = 0;

    scanf("%d", &n);
    scanf("%d", &m);
    scanf("%d", &c);

    int a[n][m];
    int b[m];
    int d[n];
    int ans[n];

    for (j = 0; j < m; j++)
    {
        scanf("%d", &b[j]);
    }

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

    for (i = 0; i < n; i++)
    {
        d[i] = 0;
        for (j = 0; j < m; j++)
        {
            d[i] += a[i][j] * b[j];
        }
    }

    for (i = 0; i < n; i++)
    {
        ans[i] = d[i] + c;

        if (ans[i] > 0)
        {
            cnt++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int n,a,min,max,i;
	long sum;
	scanf("%d",&n);
	scanf("%d",&a);
	min=a;
	max=a;
	sum=a;
	for(i=0;i<n-1;i++){
		scanf("%d",&a);
		if(min>a)min=a;
		if(max<a)max=a;
		sum+=a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    vector<int> ac(n+1), wa(n+1);
    fori(i,m) {
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC") {
            ac[p] = 1;
        } else {
            if(!ac[p]) wa[p]++;
        }
    }

    int tac = 0, twa = 0;
    fore(i,1,n) {
        if(ac[i]) {
            tac++;
            twa += wa[i];
        }
    }

    cout << tac << ' ' << twa << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long f(long long n){
  long long res = 0;
  for(long long i = 5; n / i >= 1; i *= 5){
    res += (n / i);
  }
  return res;
}
int main(){
  long long n;
  cin>>n;
  int r = 0;
  long long x = 5;
  while(x < n){
    x *= 5;
    if(x < n)r++;
  }
  int re = 0;
  if(n % 2){cout<<0<<endl;}
  else{
    long long a = f(n/2);
    cout<<a<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define forsn(i,s,n) for(int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};
char matriz[64][64];
bool works(int i, int j) {
	//!(matriz[i+2][j+1]=='#' or matriz[i+1][j+2]=='#' or matriz[i][j+1] or matriz[i+1][j])
	forn(d, 4){
		int vi=i+dx[d];
		int vj=j+dy[d];
		if(matriz[vi][vj]=='#'){
			return true;
		}
	}
	return false;
}
int main(){
	forn(i,64) forn(j,64) matriz[i][j] = '.';
	
	int h, t; cin >> h >> t;
	
	forn(i,h) {
		forn(j,t) {
			cin>>matriz[i+1][j+1];
		}
	}
	forn(i,h) {
		forn(j,t) {
			if(matriz[i+1][j+1]=='#' and !works(i + 1, j + 1)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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


void func (int *res, int st_p, int ch_p, int ed_p)
{
		int tmp_r = ch_p - st_p;
		int tmp_l = ed_p - (ch_p - 1);

		if (tmp_r % 2) {
		    res[ch_p - 1] += tmp_r / 2 + 1;
		    res[ch_p] += tmp_r / 2;
		} else {
		    res[ch_p - 1] += tmp_r / 2;
		    res[ch_p] += tmp_r / 2;
		}

		if (tmp_l % 2) {
		    res[ch_p - 1] += tmp_l / 2;
		    res[ch_p] += tmp_l / 2 + 1;
		} else {
		    res[ch_p - 1] += tmp_l / 2;
		    res[ch_p] += tmp_l / 2;
		}
}

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

	int st_p = 0;
	int ed_p = 0;
	int ch_p = 0;
	char now_c = s[0];
	int res[(int)s.size()];
	rep (i, 0, s.size())
	    res[i] = 0;

	for (int i = 1; i < s.size(); i++) {
	    if (now_c == s[i]) {
		continue;
	    } else if (now_c == 'L' && s[i] == 'R') {
		ed_p = i - 1;

		func(res, st_p, ch_p, ed_p);

		now_c = s[i];
		st_p = i;
	    } else {
		ch_p = i;
		now_c = s[i];
		continue;
	    }
	}

	ed_p = s.size() - 1;
	func(res, st_p, ch_p, ed_p);

	for (int tmp : res)
	    cout << tmp << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1104
#include<stdio.h>

int main(void)
{
  int n,d,x;
  scanf("%d%d%d",&n,&d,&x);

  int i,j,a[110],ans = x;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    for(j=0;j<d;j+=a[i])
      ans++;
  }

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

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n, m;
	cin >> n >> m;
	int i;
	int a[110];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll dp[55][55][3501];
	dp[0][0][0] = 1;
	for (i = 0; i < n; i++) { // i番目まで見て
		for (int j = 0; j <= i; j++) { // j個ピックした時の
			for (int k = 0; k <= 2500; k++) { // 総和がkになるようなものの数え上げ
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + a[i]] += dp[i][j][k];
			}

		}
	}
	ll ans = 0;
	for (i = 1; i <= n; i++) {
		ans += dp[n][i][i * m];
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 78080
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

int main()
{
    int h{}, n{};
    std::cin >> h >> n;

    int result = h / n;
    if (h % n > 0) result++;
    std::cout << result << std::endl; 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a; int b, c;
  scanf("%lld %d.%d", &a, &b, &c);
  cout << a*b+a*c/100 << endk;
  return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int N = 2e5 + 100;
const ll MX = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-9 ;

char grid[1100][1100] ;
int n, m, dp[1100][1100] = { } ;

int _3102_{
	Gamed
	cin >> n >> m ;
	for ( int i = 0 ; i < n ; i ++){
		for ( int j = 0 ; j < m ; j ++){
			cin >> grid[i][j] ;
		}
	}
	dp[0][0] = 1 ;
	for ( int i = 1 ; i < n ; i ++){
		dp[i][0] = (grid[i][0] == '#' ? 0 : dp[i-1][0])  ;
	}
	for ( int i = 1 ; i < m ; i ++){
		dp[0][i] = (grid[0][i] == '#' ? 0 : dp[0][i-1] ) ;
	}
	for ( int i = 1 ; i < n ; i ++){
		for ( int j = 1 ; j < m ; j ++){
			if ( grid[i][j] == '#'){
				dp[i][j] = 0 ;
				continue ;
			}
			dp[i][j] = ((dp[i-1][j]%mod) + (dp[i][j-1]%mod))%mod ;
		}
	}
	cout << dp[n-1][m-1] << endl ;
	return 0;
}

/*
3 4
...#
.#..
....
*/


Measured memory_bytes: 8968
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int64_t a, b, x;

  cin >> a >> b >> x;

  if (a > 0) {
    cout << (b / x) - ((a - 1) / x);
  } else {
    cout << (b / x) + 1;
  }

  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    string str;
    cin >> N >> str;

    ll ans = 0;
    map<pair<string, string>, int> ct;

    auto go = [&](string half, bool count) {
        for (int i = 0; i < (1 << N); i++) {
            stringstream a, b;
            for (int j = 0; j < N; j++)
                (i & (1 << j) ? a : b) << half[j];

            if (count)
                ct[{ a.str(), b.str() }]++;
            else
                ans += ct[{ a.str(), b.str() }];
        }
    };

    go(str.substr(0, N), true);
    reverse(all(str));
    go(str.substr(0, N), false);

    cout << ans << endl;

    return 0;
}



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

int main()
{
  int res;
  string S;
  cin >> S;
  int number_length;

  number_length = S.length();

  int even0=0;
  int even1=0;
  int odd0=0;
  int odd1=0;

  for(int i;number_length>i;++i){
    if(S.at(i)== '0'){
      if(i%2==0){
        ++even0;
      }
      else ++odd0;
    }
    else{
      if(i%2==0){
        ++even1;
      }
      else ++odd1;
    }
  }
  int odd, even;
  odd = odd0 + even1;
  even = odd1 + even0;
  res = (odd < even)? odd : even;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define MAXN  50005 
#define mx 10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(ll i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
ll a[mx]={0};
void calc(){
	for(ll i=2;i<mx;i++){
		ll j=2;
		while(j*i<=mx){
			a[j*i]++;
			j++;
		}
	}
}
int main(){
	IOS;
	ll t,n,l;
	ll i,j,m,mn,d,x,y,ans=0,temp=0,k,c;
	string s,s1;
	cin>>n;
//	l=sqrt(n);
//	ll a[10000005];
	calc();
	ans=1;
	rep(i,2,n+1){
		ans+=i*(a[i]+2);
	}
//	rep(i,1,n+1)ans+=i*a[i];
	cout<<ans;
}

Measured memory_bytes: 81768
using System;
 
namespace aaaa
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int money = int.Parse(Console.ReadLine());
            int happiness = 1000 * (money / 500);
            int amari = money % 500;
          if (amari != 0) {
            happiness = happiness + 5 * (amari / 5);
            Console.Write(happiness);
          }
          else
            Console.Write(happiness);
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
}

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


int main() {
    int N;
    cin>>N;
    ll a[N];
    map<int,int>mp;
    rep(i,N){
        cin>>a[i];
        mp[a[i]]++;
    }
    int ans =0;
    for(auto p:mp){
        int x=p.first;
        int n=p.second;
        if(n<x)ans += n;
        else ans += n-x;
    }
    cout<<ans<<endl;
}

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

int main() {
  int A, B;
  cin >> A;
  cin >> B;
  
  if (A == 1) {
    if (B == 2) {
      cout << 3 << endl;
    }
    else if (B == 3) {
      cout << 2 << endl;
    }
  }
  else if (A == 2) {
    if (B == 1) {
      cout << 3 << endl;
    }
    else if (B == 3) {
      cout << 1 << endl;
    }
  }    
  if (A == 3) {
    if (B == 1) {
      cout << 2 << endl;
    }
    else if (B == 2) {
      cout << 1 << endl;
    }
  }
}

Measured memory_bytes: 256
fun main() {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()

    var answer = 1

    for (i in 0 until n) {
        if (answer * 2 <= answer + k) {
            answer = answer * 2
        } else {
            answer += k
        }
    }

    println(answer)
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

bool is_prime(int a){
    rep(i,2,a) if(a%i==0) return false;
    return true;
}

void solve(){
    int n;
    cin >> n;
    
    int64_t ans=1;
    rep(i,2,n+1){
        if(!is_prime(i)) continue;
        vector<int> count(100000);
        int j=i,k=0;
        for(;;){
            int a=n/j;
            if(a==0) break;
            count[k++]=a;
            j*=i;
        }
        int sum=0;
        rep(i_,0,k) sum+=count[i_];
        ans=((sum+1)*ans)%1000000007;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int max=1000000;
	int[] prime;
	boolean[] isPrime;

	void run(){
		int p=0;
		prime=new int[max];
		isPrime=new boolean[max+1];
		Arrays.fill(isPrime, true);
		isPrime[0]=isPrime[1]=false;
		for(int i=2; i<=max; i++){
			if(isPrime[i]){
				prime[p++]=i;
				for(int j=2*i; j<=max; j+=i){
					isPrime[j]=false;
				}
			}
		}

		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			int ans=0;
			for(int i=0; i<p; i++){
				if(prime[i]>n/2){
					break;
				}
				if(isPrime[n-prime[i]]){
					ans++;
				}
			}
			println(""+ans);
		}
	}

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

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 17000
# Greatest Common Divisor

numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

gcd = 1
while a != 0 and b != 0:
    if a >= b:
        a %= b
    else:
        b %= a
if a == 0:
    gcd = b
else:
    gcd = a

print(gcd)



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


int fact(int n){


	int ans = 1;

	for(int i = n ; i >= 1 ; i--) ans*=i;

		return ans;
}








int main()
{

   
int a,b,c,x,y;

cin >> a >> b >> c >> x >> y;


int pa = a * x;
int pb = b * y;
int p = (pb + pa);

if(x > y){

int n = c * y * 2;

x-=y;

n+= min( x * a ,  x * c * 2);

cout << min(p,n);
return 0;

}


else {

int n = c * x * 2;

y-=x;


n+= min( y * b ,  y * c * 2);

cout << min(p,n);
return 0;

}





	return 0;
}		


Measured memory_bytes: 256
/*alurquiza*/
//Q:Flowers
#include <bits/stdc++.h>

using namespace std;

const int SIZE = 2e5 + 1;

struct ABI{
    long long T[SIZE];

    ABI(){
        fill(T,T + SIZE,0);
    }

    void update(int pos,long long value){
        for(;pos < SIZE;pos += (pos & -pos))
            T[pos] = max(value,T[pos]);
    }

    long long query(int pos){
        long long r = 0;
        for(;pos > 0;pos -= (pos & -pos))
            r = max(T[pos],r);
        return r;
    }

}A;

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

//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);

    int N;
    cin >> N;

    vector<int> H(N + 1);
    for(int i = 1;i <= N;i++)
        cin >> H[i];

    vector<int> B(N + 1);
    for(int i = 1;i <= N;i++)
        cin >> B[i];

    for(int i = 1;i <= N;i++){
        long long aux = A.query(H[i] - 1);
        A.update(H[i],aux + B[i]);
    }

    cout << A.query(N) << '\n';

    return 0;
}













Measured memory_bytes: 3328
#include <iostream>

#define MAXN 200001
#define MAXC 30

using namespace std;

int A[MAXC][MAXN];

int main()
{
  int N,C;
  int s,t,c,max;

  cin >> N >> C;
  while ( N-- ) {
    scanf("%d%d%d", &s, &t, &c);
    --c;
    if ( A[c][s*2] < 0 ) ++A[c][s*2];
    else ++A[c][s*2-1];
    if ( A[c][t*2-1] > 0 ) --A[c][t*2-1];
    else --A[c][t*2];
  }

  for ( int i = 0; i < C; ++i ) {
    for ( int j = 1; j < MAXN; ++j ) A[i][j] = A[i][j-1]+A[i][j];
  }
  max = 0;

  for ( int i = 0; i < MAXN; ++i ) {
    int tmp = 0;
    for ( int j = 0; j < C; ++j ) {
      tmp += A[j][i];
    }
    if ( tmp > max  ) max = tmp;
  }

  cout << max << "\n";

  /*
  cout << "\n";
  for ( int i = 0; i < C; ++i ) {
    for ( int j = 0; j < 31; ++j ) cout << A[i][j] << " ";
    cout << "\n";
  }
  */
}


Measured memory_bytes: 23680
use std::cmp::max;

struct DFS {
    n: u64,
    k: u64,
    an: Vec<u64>,
}

impl DFS {
    fn new() -> DFS {
        let (n, k) = read_tuple::<u64>();
        let an = read_vec::<u64>();
        DFS {
            n: n,
            k: k,
            an: an,
        }
    }

    fn dfs(&self, i: i32, buf: &Vec<u64>) -> u64 {
        if i < 0 {
            *buf.iter().max().unwrap()
        } else {
            let digit = (self.k >> i) & 1;

            let attr = 1 << i;
            let b: u64 = self.an.iter().map(|x| (x >> i) & 1).sum();
            let a = self.n - b;

            let (mut b0, mut b1) = (0, 0);
            if buf[0] != 0 {
                b0 = buf[0] + max(a, b) * attr;
            }
            b1 = buf[1] + if digit == 1 { a } else { b } * attr;
            if digit == 1 {
                b0 = max(b0, buf[1] + b * attr);
            }
            // println!("{:?}", buf);
            self.dfs(i - 1, &vec![b0, b1])
        }
    }
}

fn main() {
    let d = DFS::new();
    println!("{:?}", d.dfs(63, &vec![0, 0]));
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 8444
import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


N = II()
AS = list(LI())

MP = {}

MX = 10**10
LIS = [10**10]*N
RES = [1]*N
for i in range(N-1):
    a, b = LI()
    a -= 1
    b -= 1
    if not a in MP:
        MP[a] = []
    if not b in MP:
        MP[b] = []
    MP[a].append(b)
    MP[b].append(a)


def dfs(v, mp, lis, p):
    for u in mp[v]:
        if u != p:
            i = bisect.bisect_left(lis, AS[u])
            bef = lis[i]
            lis[i] = AS[u]
            longest = bisect.bisect_left(lis, MX)
            RES[u] = longest
            dfs(u, mp, lis, v)
            lis[i] = bef


LIS[0] = AS[0]
dfs(0, MP, LIS, -1)

print(*RES, sep='\n')


Measured memory_bytes: 235232
#include <iostream>
#include <cstdio>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

const int maxn =  2e5 + 7;

string s;

int main() {
  cin >> s;
  int len = s.length();
  int cnt = 0;
  ll ans = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'A') ++cnt;
    else if (s[i] == 'B') {
      if (s[i + 1] == 'C') {
        ans += cnt;
        i += 1;
      }
      else cnt = 0;
    }
    else cnt = 0;
  }
  printf("%lld\n", ans);
  return 0;
}

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

typedef struct{
  int parent;
  int left;
  int right;
}node;

void preOrder(node*,int);
void inOrder(node*,int);
void postOrder(node*,int);

int findParent(node*);
#define NIL -1

int main(){
  int n,id,frag,count;
  int i,j,k;
  int p;

  node T[25];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i==T[j].left){
	T[i].parent=j;
      }
      if(i==T[j].right){
	T[i].parent=j;
      }
    }
  }
  
  p=findParent(T);

  printf("Preorder\n");
  preOrder(T,p);
  printf("\nInorder\n");
  inOrder(T,p);
  printf("\nPostorder\n");
  postOrder(T,p);
  printf("\n");
  return 0;
}

void preOrder(node *T,int u){
  if(u==NIL) return;
  printf(" %d",u);
  preOrder(T,T[u].left);
  preOrder(T,T[u].right);
}

void inOrder(node *T,int u){
  if(u==NIL) return;
  inOrder(T,T[u].left);
  printf(" %d",u);
  inOrder(T,T[u].right);
}

void postOrder(node *T,int u){
  if(u==NIL) return;
  postOrder(T,T[u].left);
  postOrder(T,T[u].right);
  printf(" %d",u);

}

int findParent(node *T){
  int i=0;
  while(1){
    if(T[i].parent==NIL) return i;
    i++;
  }
}

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

bool in_judge(std::vector<int> &a){
	int n = a.size();
	for(int i=0; i<n-1; i++){
		if(a[i]==a[n-1]){
			return true;
		}
	}
	return false;
}

int main(){
	int s;
	std::cin >> s;
	std::vector<int> a(1, s);
	for(int i=1; ; i++){
		if(a[i-1]%2==0){
			a.push_back(a[i-1] / 2);
		}else{
			a.push_back(3*a[i-1] + 1);
		}
		if(in_judge(a)){
			std::cout << i+1 <<std::endl;
			return 0;
		}
	}

	return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	vector<int> r = p;
	sort(r.begin(), r.end());
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			vector<int> q = p;
			swap(q[i], q[j]);
			if(r == q){
				cout << "YES" << '\n';
				return 0;
			}
		}
	}
	cout << "NO" << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 20
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, mp[MAXN][MAXN];
LL f[1 << 17];

int main()
{
	scanf("%d", &n);
	for(rint i = 0; i < n; ++i)
		for(rint j = 0; j < n; ++j)
			scanf("%d", &mp[i][j]);

	for(rint sta = 0; sta < (1 << n); ++sta)
	{
		for(rint i = 0; i < n; ++i)
			if((sta >> i) & 1)
				for(rint j = i + 1; j < n; ++j)
					if((sta >> j)&1) f[sta] += mp[i][j];
		for(rint i = sta; i; i = (i-1) & sta)
		{
			int j = sta ^ i;
			f[sta] = max(f[sta], f[i] + f[j]);
			//printf("%d %d %d %lld %lld!!\n", sta, i, j, f[i], f[j]);
		}
	}
	printf("%lld\n", f[(1 << n) - 1]);
}

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

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
          ans++;
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define db(x) cerr << #x << ": " << x << "\n";

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

    int N;
    cin >> N;
    ll sum = 0;
    for(int i=1; i<=N; i++)
        if(i%3 && i%5)
            sum += i;
    cout << sum << "\n";
}


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

using namespace std;

long long inf=1000000007;

int main(){
	string s;
	cin>>s;
	char hoge=s.at(s.size()-1);

	if(hoge=='3') cout<<"bon"<<endl;
	else if(hoge=='0' || hoge=='1' || hoge=='6' || hoge=='8') cout<<"pon"<<endl;
	else cout<<"hon"<<endl;

	return 0;
}


Measured memory_bytes: 3624