akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	freopen("d.in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
const int N = 2e5 + 1000;
ll n, F[N], E[N];ll A[N], S[N] ;
ll calfa(int f,int e){
    return abs(  S[e] - S[f] - S[f] );
}
void calf(){
    int f=1, e= 2;
    for(;e<=n;e++){
        while( f + 1 < e && (calfa(f,e) > calfa( f+1, e))){
                f ++;
        }
        F[e]=f;
    }
}
ll calea(int f,int e){
    return abs( S[n] - S[e-1] - (S[e-1] - S[f-1]) );
}
void cale(){
    int f,e;
    f = n-1, e = n;
    for(;f>=1;f--){
        while( e - 1 > f && ( calea( f, e ) > calea( f, e - 1 ) )) {
            e --;
        }
        E[f]=e;
    }
}
typedef ll (*Func)(ll,ll);
ll max(ll a,ll b){
    if( a > b)return a;
    return b;
}
ll min(ll a,ll b){
    if( a < b)return a;
    return b;
}
ll dist(ll a,ll b){
    return abs(a - b);
}
ll calfc(int i,Func func){
    //i --;
    int best = F[i];
    return func( S[best] , S[i] - S[best]);
}
ll calec( int f,Func func){
    f ++;
    int e= E[f];
    return func( S[n] - S[e-1], S[e-1] - S[f-1]);
}
ll calmax( int i ){
    return max( calfc(i, max) ,calec(i,max) );
}
ll calmin( int i ){
    return min( calfc(i, min) ,calec(i,min) );
}
void pA(ll *a,const char *s){
    puts(s);
    for(int i = 0;i<=n;i++){
        printf("%2lld ",a==NULL?i:a[i]);
    }
    putchar('\n');
}
void inp(){
    scanf("%lld", &n);for(int i =1 ;i<=n;i++)scanf("%lld", &A[i]);
    S[0]=A[0]=0;
    for(int i=1;i<=n;i++)S[i]=S[i-1]+A[i];
    calf();
    cale();
#ifdef XS
    pA(NULL,"I");
    pA(A,"A");
    pA(S,"S");
    pA(F,"F");
    pA(E,"E");
#endif
    ll ans = 1e18;
    for(int i = 2;i<n-1;i++){
        ll cur =  calmax(i)-calmin(i) ;
        cur =  max(cur, calfc(i, dist) );
        cur =  max(cur, calec(i, dist) );
        ans = min(ans, cur);
    }
    printf("%lld\n", ans);
}
//d.cc by xsthunder at Thu Aug  2 10:14:47 2018

/*
4
5
5
4
7
*/

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

#define MAX 100

void push(int x);
int pop();
void initialize();
int isEmpty();
int isFull();

int top,S[1000];

int main(void){
	int a,b;
	top=0;
	char s[100];
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}
		else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

void push(int x){
	top++;
	S[top]=x;
}

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

void initialize(){
	top=0;
}

int isEmpty(){
	if(top==0){
		return 0;
	}
	return 1;
}

int isFull(){
	if(top>=MAX-1){
		return MAX;
	}
	return 0;
}


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

long long n, m;

int main() {
   cin >> n >> m;
   if(n > m) swap(n, m);
   if(n == 1) {
      if(m == 1) cout << 1 << endl;
      else cout << max(0LL, m - 2LL) << endl;
   } else cout << (n - 2LL) * (m - 2LL) << endl;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
A = (h * 60 + m) * 360 / (12 * 60)
B = 6 * m
C = abs(A - B)

c = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C))) ** 0.5
print(c)

Measured memory_bytes: 9400
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int x;
	cin >> x;
	int ans = 0;
	ans += (x / 500) * 1000;
	ans += (x % 500) / 5 * 5;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int f(int x,int y){
    if(x>=y)return 0;
    return 1+f(x*2,y);
}
int n,k,x,ans1,ans2;
int main(void){
    cin>>n>>k;
    x=f(1,k);
    ans2=n*(1<<x);
    for(int i=1;i<=n;i++){
        ans1+=(1<<(x-f(i,k)));
    }
    cout<<setprecision(10)<<double(ans1)/double(ans2)<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
   
s=0
bb=sum(b)
for i in range(n-1):
       if a[i]+1==a[i+1]:
               s+=c[a[i]-1]
s+=bb
print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
  cin >>N;
  vl a(N);
  rep(i,N) {
cin >>a.at(i);
  }
  ll c;
  rep(i,N) {
    if(a.at(i)<0) {
      c++;
    }
  }
  
  ll sum=0;
    rep(i,N) {
      sum +=abs(a.at(i));
    }
  //cout<<c<<endl;
  if(c%2==0) {
    
    cout<<sum<<endl;
    //cout<<99<<endl;
    return 0;
  }
  else {
    rep(i,N) {
      a.at(i)=abs(a.at(i));
    }
sort(all(a));
    //cout<<a.at(0)<<sum<<endl;
    cout<<sum-2*a.at(0)<<endl;
    return 0;
  }
  
  
  
  
}



Measured memory_bytes: 1024
import java.io.*;
import java.util.InputMismatchException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            out.print((n - 1) * (m - 1));
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void print(int i) {
            writer.print(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int N,K,l[55]={};
int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  sort(l,l+N);
  reverse(l,l+N);
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,u,k,v,e[N][N],cnt;
int ans1[N],ans2[N];
bool used[N];
 
void dfs(int x){
  if(used[x])return;
  used[x]=true;
  ans1[x]=cnt++;
  for(int i=0;i<n;i++)
    if(e[x][i])dfs(i);
  ans2[x]=cnt++;
}
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      e[u-1][v-1]=1;
    }
  }
  cnt=1;
  for(int i=0;i<n;i++)
    if(!used[i])dfs(i);
  
  for(int i=0;i<n;i++)
    cout<<i+1<<' '<<ans1[i]<<' '<<ans2[i]<<endl;

  return 0;
}



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

int main() {
  int n,k,x,y;
  
  cin >> n >> k >> x >> y;
  
  int total;
  
  
  for(int i = 0; i<n; i++){

    if(k>i)
      total += x;
    
    else
      total += y;
  }
  
  cout << total;
  
  
  
}

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

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> q; //ゆうたらヒープ
  rep(i, n){
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i, m){
    int a = q.top(); q.pop();
    q.push(a/2);
  }
  ll ans = 0;
  rep(i, n){
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

	string S;
	cin >> S;

	ddvi kazu(10, vi(0));

	REP(i,N){
		int ind = S[i] - '0';
		// cout << ind;
		kazu[ind].eb(i);
	}

	ll ans = 0;
	int now = -1;
	REP(i,10){
		if(kazu[i].size() == 0) continue;
		REP(j,10){
			if(kazu[j].size() == 0) continue;
			REP(k,10){
				if(kazu[k].size() == 0) continue;
				now = kazu[k].back();
				auto p = find_if(kazu[j].rbegin(),kazu[j].rend(),[&](const auto& x){return x < now;});
				if(p==kazu[j].rend()) continue;
				else{
					now = *p;
					auto p = find_if(kazu[i].rbegin(),kazu[i].rend(),[&](const auto& x){return x < now;});
					if(p==kazu[i].rend()) continue;
					else{
						now = *p;
						ans += 1;
					}
				}
			}
		}
	}

	cout << ans << "\n";


return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(0);

	string s;
	cin >> s;

	for(int i=0;i<s.length();i++){
		if(i%2==0 && s[i]!='R' && s[i]!='U' && s[i]!='D') {puts("No"); return 0;}
		else if(i%2 && s[i]!='L' && s[i]!='U' && s[i]!='D') {puts("No"); return 0;}
	}

	puts("Yes");

	return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))

graph = [list() for i in range(N+1)]
for i in range(M):
    a, b = tuple(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)

pos_flag = False
for u in graph[1]:
    if N in graph[u]:
        pos_flag = True
        break
if pos_flag == True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int n,q;
string s;
vector<char> t(200010),d(200010);

bool left(int x){
  int now=x;
  rep(i,q){
    if(t[i]==s[now]){
      if(d[i]=='L') now--;
      else now++;
    }
    if(now==-1) return true;
    if(now==n) break;
  }
  return false;
} 

bool right(int x){
  int now=x;
  rep(i,q){
    if(t[i]==s[now]){
      if(d[i]=='L') now--;
      else now++;
    }
    if(now==n) return true;
    if(now==-1) break;
  }
  return false;
} 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>q;
  cin>>s;
  rep(i,q) cin>>t[i]>>d[i];
  int high=n,low=-1,mid;
  int ans1,ans2;
  while(high-low>1){
    mid=(high+low)/2;
    if(left(mid)) low=mid;
    else high=mid;
  }
  ans1=low;
  high=n,low=-1;
  while(high-low>1){
    mid=(high+low)/2;
    if(right(mid)) high=mid;
    else low=mid;
  }
  ans2=high;
  //cout<<ans1<<' '<<ans2<<endl;
  if(ans1>=ans2) cout<<0<<endl;
  else{
    cout<<ans2-ans1-1<<endl;
  }
}

Measured memory_bytes: 1104
## constants

PRIMES = [2, 3, 5]
N_PRIMES = PRIMES.length

### global variables

$ch_cache = []

### subroutines

def count_hamming(k, n)
  return 1 if k >= N_PRIMES
  return $ch_cache[k][n] if ! $ch_cache[k][n].nil?

  c = 0
  m = 1

  while m <= n
    c += count_hamming(k + 1, n / m)
    m *= PRIMES[k]
  end

  $ch_cache[k][n] = c
end

### main

$ch_cache = PRIMES.map{[]}

while true
  line = gets.strip
  break if line == '0'

  m, n = line.split(' ').map{|s| s.to_i}

  mh = count_hamming(0, m - 1)
  nh = count_hamming(0, n)

  puts (nh - mh)
end

Measured memory_bytes: 29700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0) cout<<0<<endl;
    else cout<<min({a*b,b*c,c*a})<<endl;
}

Measured memory_bytes: 256
#define taskname ""

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <queue>

using namespace std;
#define long long long

const int N = 1e5 + 10;

int n, m, deg[N], h[N], res;
vector<int> g[N];

void process()
{
    queue<int> q;
    for (int i = 1; i <= n; ++i) if (!deg[i]) q.push(i), h[i] = 1;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : g[u]) {
            --deg[v];
            if (!deg[v]) res = h[v] = h[u] + 1, q.push(v);
        }
    }
    cout << res - 1;
}

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);

    scanf("%d%d", &n, &m);
    for (int i = 0, u, v; i < m; ++i) {
        scanf("%d%d", &u, &v);
        g[u].push_back(v); ++deg[v];
    }
    process();

    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long a,b,c=0,d=4,e,g,h,i,j,k;
char m,n,o,p;
map<char,int>mp;
while(d--)
{
cin>>m;
mp[m]++;

}
if(mp.size()==2)
cout<<"Yes";
else
cout<<"No";




}


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

int main()
{
	int A, B;
	cin >> A >> B;

	if (A < 10){
		if(B < 10){
			cout << A * B << endl;
		}

		else
		{
			cout << "-1" << endl;
		}
	}

	else {
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define v_sum(a)         accumulate(a.begin(),a.end(),0)
#define v_max(a)         *max_element(a.begin(),a.end())
#define v_min(a)         *min_element(a.begin(),a.end())
#define v_uni(a)         a.erase(unique(a.begin(),a.end()),a.end())

using namespace std;



int main()
{
	Nayon;
	int n,x,t,sum=0,y;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t<<nl;
	return 0;
}

//Happy Coding........

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ld r;
	cin >> r;
	cout << fixed << setprecision(6) << 2 * r * 3.14159 << '\n';
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	string S;
	cin>>S;
	int ans;
	int N = S.size();
	rep1(i,N){
		string Sn=S.substr(0,N-i);
		int Nn=Sn.size();
		if(Nn%2==0&&Sn.substr(0,Nn/2)==Sn.substr(Nn/2,Nn/2)){
			ans = Nn;
			break;
		}
	}
	cout<<ans<<endl;
}

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;
const LL MOD = 1e9 + 7;
LL dp[2][N + 5];
vector<int> vec[N + 5];

LL solve(int col,int idx,int p) {
	if(dp[col][idx] != -1) return dp[col][idx];
	LL mul = 1;
	for(int i = 0;i < vec[idx].size();i++) {
		int nx = vec[idx][i];
		if(nx == p) continue;
		if(col == 0) mul = (solve(col, nx, idx) + solve(!col, nx, idx)) % MOD * mul % MOD;
		else mul = solve(!col, nx, idx) * mul % MOD;
	}
	dp[col][idx] = mul;
	return dp[col][idx];
}

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i < n;i++) {
		int u,v;
		cin>>u>>v;
		vec[u].PB(v);
		vec[v].PB(u);
	}
	memset(dp,-1,sizeof dp);
	cout<<((solve(0,1,1) + solve(1,1,1)) % MOD)<<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: 15616
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	ll tot = (n/500)*1000;
	n = n%500;
	tot += (n/5) * 5;
	cout << tot << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b,c;
	scanf("%d",&n);
	a=n/100;
	b=(n-a*100)/10;
	c=n%10;
	if((a*100+a*10+a)>=n)
	printf("%d",a*100+a*10+a);
	else
	printf("%d",(a+1)*100+(a+1)*10+a+1);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n,int r) {
//	n = n + r - 1;
//	return nCr(n,r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, X,res = 0;
	cin >> N >> X;
	vector<LLI>vec(N + 1);
	for (int i = 0; i < N;i++) {
		cin >> vec[i + 1];
	}
	LLI sum = 0;
	for (int i = 0; i < N + 1;i++) {
		sum += vec[i];
		if (sum <= X) {
			res++;
		}
		else {
			break;
		}
	}
	cout << res << endl;
}


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

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int /*激ムズすぎる*/n,m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) /*じかにみてみーひんとよー分からん*/<< '\n';
  return 0;
}

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

int main()
{
	int n, a;
	cin >> n >> a;
	auto x = vector<int>(n + 1);
	int m = 0;
	for(auto i = 1; i <= n; ++i){
		cin >> x[i];
		m = max(m, x[i]);
	}
	auto dp = vector<vector<vector<long long int>>>(n + 1, vector<vector<long long int>>(n + 1, vector<long long int>(n * m + 1)));
	dp[0][0][0] = 1;
	for(auto i = 1; i <= n; ++i){
		dp[i][0][0] = dp[i - 1][0][0];
		for(auto j = 1; j <= n; ++j){
			dp[i][j][0] = dp[i][j - 1][0];
			for(auto k = 0; k < x[i]; ++k){
				dp[i][j][k] = dp[i - 1][j][k];
			}
			for(auto k = x[i]; k <= n * m; ++k){
				dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
			}
		}
	}
	long long int ans = 0;
	for(auto i = 1; i <= n; ++i){
		ans += dp[n][i][i * a];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 52224
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcd = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var win = true;
            while (true)
            {
                abcd[2] -= abcd[1];
                if (abcd[2] <= 0) break;
                abcd[0] -= abcd[3];
                if (abcd[0] <= 0)
                {
                    win = false;
                    break;
                }

            }
            Console.WriteLine(win ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28292
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 1e5 + 5;

int vis[N];
deque <int> v;

int sq(int x) {
  return (x*x);
}

void solve() {
  int n, x, m;
  cin >> n >> x >> m;
  
  vis[x] = 1;
  v.pb(x);
  
  int rem = 0, ans = x, val;
  for(int i = 1; i < n; i++) {
     int y = sq(v[i-1]) % m;
     if(vis[y]) {
       rem = n-i;
       val = y;
       break;
     }
     ans += y;
     v.pb(y);
     vis[y] = y;
  }
  
  if(rem) {
    while(v.front() != val) {
      v.pop_front();
    }
    int si = sz(v);
    int cyc = rem/si;
    int ex = rem%si;
    int sum = 0;
    for(auto i : v) sum += i;

    ans += (cyc * sum);
    for(int i = 0; i < ex; i++) {
      ans += v[i];
    }
  }
  
  cout << ans << '\n';

}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1; // cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for (int i = 0; i < (n - 2); i++) {
    string a,b,c;
    a = s.at(i);
    b = s.at(i + 1);
    c = s.at(i + 2);
    string abc = a + b + c;
    if (abc == "ABC") {
      count = count + 1;
    }
  }
  cout << count;
}


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

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print(ab[index][0])


Measured memory_bytes: 25396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

int main(){
  ll R,C,RR,CC,ans=0;
  cin>>R>>C>>RR>>CC;
  COMinit();
  
  ans+=COM(RR+CC+2,RR+1);
  ans-=COM(R+CC+1,R);
  ans-=COM(RR+C+1,C);
  ans+=COM(R+C,R);
  
  ans%=MOD;
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 123120
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

int main(void){
  ll n,k;
  cin>>n>>k;
  vl a(n);
  vl f(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>f[i];
  sort(a.begin(),a.end());
  sort(f.begin(),f.end());
  ll l=0;
  ll r=2000000000000000000;
  while(l!=r){
    ll ans=(l+r)/2;
    ll sum=0;
    rep(i,n){
      sum+=max((a[i]*f[n-1-i]-ans + f[n-1-i]-1)/f[n-1-i],(ll)0);
    }
    if(sum>k){
      l=ans+1;
    }else{
      if(l+1==r){
        r-=1;
        break;
      }
      r=ans;
    }
  }
  cout<<l;
  return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int x,shift=0,elem[256],temp[sz];
  while(shift<32)
  {
    int bucket[256]={0};rep(i,sz){x=(a[i]>>shift)&255;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,255)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&255;a[elem[x]]=temp[i];elem[x]++;}
    shift+=8;
  }
}
int main(void)
{
  int N=IN(),p=0,m=0,z=0,A[N];long K=0,count=0,l=-1e18,r=-l,mid,x=getchar();
  while(x>47&&x<58){K=K*10+x-48,x=getchar();}
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  Radix32(A,m+p);
  if(K<=1l*m*p)r=1l;else l=-1l;x=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=x;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return printf("%ld\n",l),0;
}

Measured memory_bytes: 3000
N=int(input())
ls=[list(map(int,input().split())) for i in range(N)]
ls_a=sorted([ls[i][0] for i in range(N)])
ls_b=sorted([ls[i][1] for i in range(N)])
ls_b.reverse()

if N%2==1:
  print(ls_b[(N-1)//2]-ls_a[(N-1)//2]+1)
else:
  p=(ls_a[N//2-1]+ls_a[N//2])/2
  q=(ls_b[N//2-1]+ls_b[N//2])/2
  print(int((q-p)*2+1))

Measured memory_bytes: 50944
n,k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [(10**4)*(10**5)]*n
dp[0]=0
for i in range(n-1):
    loop = min(k+1,n-i)
    for j in range(1,loop):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j])) 
print(dp[n-1])  

Measured memory_bytes: 52448
N,M = map(int,input().split())

# kの値は特に必要ないので最初から取得しない
S=[list(map(int,input().split()))[1:] for i in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(1<<N): #スイッチのオンオフ状態
    
    for m in range(M):  #電球の状態 
        count = 0
        for s in S[m]:
            if i & (1<<(s-1)) != 0:
                count += 1
                # 電球に対するスイッチのonの数を取得する
        if count%2 != p[m]:
            break
    else:
        # あるスイッチのパターンに対して各電球がOKだったらカウントする
        ans +=1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;

class Program
{
    static void Main(String[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        var t = Console.ReadLine().ToCharArray();

        var count = 0;
        for (var i = 0; s.Length > i; i++)
        {
            if (s[i] != t[i])
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 28216
#include <stdio.h>
int main(void){        

    int i,a,b,c;
    int count=0;

    scanf("%d %d %d",&a,&b,&c);

   
   if(a-b>=0){
        for(i=b;i<=a;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    }else if(b-a>0){
         for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    }
    return 0;

}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;

    vector<vector<int>> graph(10, vector<int>(10, INF));
    REP(i, 10) REP(j, 10) cin >> graph[i][j];

    REP(k, 10) REP(i, 10) REP(j, 10){
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
    }

    int ans = 0;
    REP(i, h) REP(j, w){
        int x;
        cin >> x;
        if(x != -1){
            ans += graph[x][1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// AOJ 2015: Square Route
// 2017.11.04 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

int h[1502], w[1502];
int f[1500001];
char buf[20], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, j, sh, sw, s, ans;
#if TM
	clock_t start, end;
	start = clock();
#endif
	while (fgets(p=buf, 20, stdin) && *buf != '0') {
		n = getint(), p++, m = getint();
		for (sh = 0, i = 0; i < n; i++)	{
			fgets(p=buf, 10, stdin), sh += h[i] = getint();
		}
		for (sw = 0, i = 0; i < m; i++) {
			fgets(p=buf, 10, stdin), sw += w[i] = getint();
		}
		if (sh > sw) s = sh, sh = sw, sw = s;

		memset(f, 0, sizeof(int)*(sw+1));
		for (i = 0; i < n; i++) {
			for (s = 0, j = i; j < n; j++) {
				s += h[j], f[s]++;
				if (s > sh) break;
			}
		}
		ans = 0;
		for (i = 0; i < m; i++) {
			for (s = 0, j = i; j < m; j++) {
				s += w[j], ans += f[s];
				if (s > sh) break;
			}
		}
		printf("%d\n", ans);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 3760
n, k = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
n.times do
  a, b = gets.chomp.split(" ").map(&:to_i)
  h[a] += b
end

ret = 0
h.sort.each do |a, b|
  ret += b
  if ret >= k then
    puts a
    exit
  end
end

Measured memory_bytes: 9992
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main(){
    for(int i=0;i<3;i++){
        string s;
        cin>>s;
        s.at(0)+='A'-'a';
        cout<<s.at(0);
    }
    
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,str;
    cin>>s;
    cin>>t;
    int c=0;
    //cout<<s.size();
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==t[i])
        {
            c++;
        }
    }
    if(s.size()==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int N, C;
int T = 2e5;

int main() {
    cin >> N >> C;
    vector<vector<bool>> ch(T, vector<bool>(C));
    int last = 0;
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
      	s = max(2 * s - 1, 0);
        for (int j = s; j < 2 * t; j++) {
            ch[j][c - 1] = true;
        }
        last = max(last, 2 * t);
    }
    int ans = 0;
    for (int j = 0; j < last; j++) {
        int tmp = 0;
        for (int i = 0; i < C; i++) {
            if (ch[j][i]) tmp++;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,m,k;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n>>m>>k;
	cout<<min(k,n*m);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	vector<int> a(n), b(n), c(n);
	FOR(i, n) cin >> a[i];
	FOR(i, n) cin >> b[i];
	FOR(i, n) cin >> c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll cnt = 0;
	vector<ll> bb(n);
	for (int i = n-1; i >= 0; i--) {
		bb[i] = (ll)(c.end()-upper_bound(ALL(c), b[i]));
		bb[i] += (i==n-1 ? 0LL : bb[i+1]);
	}
	FOR(i, n) {
		cnt += bb[(int)(upper_bound(ALL(b), a[i])-b.begin())];
		// cout << cnt << endl;
		// auto itr = upper_bound(ALL(b), a[i]) - b.begin();
		// for (int j = itr; j < n; j++) {
		// 	cnt += (ll)(c.end()-upper_bound(ALL(c), b[j]));
		// }
		// cnt += lower_bound(ALL(c), *lower_bound(ALL(b), a[i]))-c.begin();
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
// 1~1e6までの値について素数:true, 合成数:falseの配列を返す
const ll P_SIZE_MAX = 1e6+1;
bitset<P_SIZE_MAX> eratosthenes_sieve(){
    bitset<P_SIZE_MAX> Primes;
    Primes.set();
    Primes[0] = Primes[1] = 0;
    for (ll i = 2; i < P_SIZE_MAX;i++){
        if (!Primes[i]) continue;   //falseなら素数ではないので飛ばす
        for (ll j = 2; i * j < P_SIZE_MAX;j++)
            Primes.reset(i*j);
    }
    return Primes;
}

int main() {
    init();
    ll N;
    cin >> N;
    bitset<P_SIZE_MAX> P = eratosthenes_sieve();
    ll cnt = 0;
    vl ans;
    repe(i, 2, 55556) {
		if(P[i]&&i%5==1){
			ans.eb(i);
			cnt++;
		}
		if(cnt==N)break;
	}
	rep(i,N)cout<<ans[i]<<" ";
	cout<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a, _, k;
        cin >> a >> _ >> _ >> _ >> _ >> k;
        if (_ - a <= k) {
            cout << "Yay!" << endl;
        } else {
            cout << ":(" << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace B___ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var countAll = S.Replace("BC","D")
            .Split(new char[]{'B','C'},StringSplitOptions.RemoveEmptyEntries)
            .Select(s => countSwap(s))
            .Sum();
            
            Console.WriteLine(countAll);
        }

        static long countSwap(string S)
        {
            long countA = 0;
            long swap = 0;
            foreach(char c in S)
            {
                if(c == 'A') countA += 1;
                if(c == 'D') swap += countA;
            }

            return swap;
        }
    }
}


Measured memory_bytes: 18400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  ll n,k,tmp;
  vector<ll> vec(0);
  cin >> n >> k;
  rep(i,n){
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(),vec.end());
  tmp=0;
  rep(i,n-k)tmp+=vec.at(i);
  cout << tmp << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    string nums = "0123456789";
    int lol = 0;
    string S; cin >> S;
    int n = S.size();
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 10; j++){
            if (S[i] == nums[j]){
                lol += j; lol %= 9;
                break;
            }
        }
    }
    if (lol == 0){
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3768
import java.util.Scanner;

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

        for (String s : S.split("")) {
            if (Character.isLowerCase(s.charAt(0))) {
                System.out.print(Character.toUpperCase(s.charAt(0)));
            } else if (Character.isUpperCase(s.charAt(0))) {
                System.out.print(Character.toLowerCase(s.charAt(0)));
            } else {
                System.out.print(s);
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 27228