akhauriyash/Code-Regression huggingface dataset:
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  string s;
  cin >> s;
  int n = s.size();
  vector<int> v(n+1,-1);
  vector<bool> check(n+1);

  for(int i=0;i<s.size();i++)
  {
    if(i==0 && s[i] == '<') v[0] = 0;
    else if(i==0 && s[i] == '>') check[i] = true;
    else if(i>0)
    {
      if(s[i-1] == '>' && s[i] == '<') v[i] = 0;
      else if(s[i-1] == '<' && s[i] == '>') check[i] = true;
    } 
  }

  if(s[n-1] == '>') v[n] = 0;
  else if(s[n-1] == '<') check[n] = true;

  for(int i=0;i<v.size();i++)
  {
    // Simulate left
    if(v[i] == 0)
    {
      int sum1 = 0;
      for(int j=i-1;j>=0;j--)
      {
        sum1++;
        v[j] = max(v[j],sum1);
        if(check[j]) break;
      }

      sum1 = 0;
      for(int j=i+1;j<=n;j++)
      {
        sum1++;
        v[j] = max(v[j],sum1);
        if(check[j]) break;
      }
    }
  }



  ll sum1 = 0;
  for(int i=0;i<=n;i++) sum1 += v[i];
  // t(v);
  // t(check);

  cout << sum1 << endl;
  return 0;
}



Measured memory_bytes: 2844
n = int(input())
A = [[] for _ in range(n)]
for i in range(n):
    m = int(input())
    for j in range(m):
        A[i].append(tuple(map(int, input().split())))
ans = 0

for bits in range(2 ** n):
    l = [0] * n
    for i in range(n):
        l[i] = (bits >> i) % 2

    fail = False
    for i in range(n):
        if fail: break
        if l[i] == 0: continue
        for x, y in A[i]:
            if y != l[x-1]:
                fail = True
                break
    else:
        if not fail:
            ans = max(ans, sum(l))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

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> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int N;string S;
  cin >> N >> S;
  if (N%2==0 && S.substr(0,N/2) == S.substr(N/2,N/2)) cout << "Yes";
  else cout << "No"; 
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    P = list(map(int, readline().split()))
    P = list(map(lambda x: x-1, P))

    cnt = 0
    for i in range(0, N):
        if i == N-1:
            if P[i] == i:
                P[i], P[i-1] = P[i-1], P[i]
                cnt += 1
        elif P[i] == i:
            if P[i+1] == i+1 and i != N-1:
                P[i], P[i+1] = P[i+1], P[i]
                cnt += 1
            elif i != 0:
                P[i], P[i-1] = P[i-1], P[i]
                cnt += 1
            else:
                P[i], P[i+1] = P[i+1], P[i]
                cnt += 1

    print(cnt)


main()


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

int main()
{
	int M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;

	int ans = 0;
	if( M2 = M1 + 1 && D2 == 1 ) ans = 1;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
int main() {

    int N, X;
    
    while(true){
        cin >> N >> X;
        if(N == 0 && X == 0) return 0;
        
        int ans_Count = 0;
        for(int i = 1; i <= 100; i++){
            for(int j = i + 1; j <=100; j++){
                int k = X - (i + j);
                if(k > 0 && k <= N){
                    if(k > j){
                        ans_Count++;
                    }
                }
            }
        }
        
        cout << ans_Count << endl;
        
    }
    
    
    return 0;
}



Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main()
{
      int A,B,C,D;
      cin>>A>>B>>C>>D;
      if(A+B>C+D)
      cout<<"Left";
      if(A+B==C+D)
      cout<<"Balanced";
      if(A+B<C+D)
      cout<<"Right";
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SIZE = 2005;
typedef long long ll;
ll A[SIZE], dp[SIZE][SIZE];
pair<int, int> lr[SIZE][SIZE];

bool comp (const pair<ll, ll> &p1, const pair<ll, ll> &p2){
    return p1 > p2;
}

int main(){
    int N; cin >> N;

    lr[0][0] = make_pair(1, N);

    vector<pair<ll, ll> > big;

    for (int i = 1; i <= N; i++){
        cin >> A[i];
        big.push_back(make_pair(A[i], i));
    }

    sort(big.begin(), big.end(), comp);

    for (int i = 0; i < N; i++){
        for (int j = 0; j <= i; j++){
            if (dp[i-j+1][j] < dp[i-j][j]+big[i].first*(big[i].second-lr[i-j][j].first)){
                dp[i-j+1][j] = dp[i-j][j]+big[i].first*(big[i].second-lr[i-j][j].first);
                lr[i-j+1][j] = make_pair(lr[i-j][j].first+1, lr[i-j][j].second);
            }
            if (dp[i-j][j+1] < dp[i-j][j]+big[i].first*(lr[i-j][j].second-big[i].second)){
                dp[i-j][j+1] = dp[i-j][j]+big[i].first*(lr[i-j][j].second-big[i].second);
                lr[i-j][j+1] = make_pair(lr[i-j][j].first, lr[i-j][j].second-1);
            }
        }
    }

    ll ans = 0;

    for (int i = 0; i < N; i++)
        ans = max(ans, dp[N-i][i]);

    cout << ans << endl;

}

Measured memory_bytes: 49008
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,n2[201][201],number[201][3],tokuten[201];
	memset(number,0,sizeof(number));
	memset(tokuten,0,sizeof(tokuten));
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>n2[i][j];
		}
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			number[n2[j][i]][i]++;
		}
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			if(number[n2[j][i]][i]==1){
				tokuten[j]+=n2[j][i];
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<tokuten[i]<<endl;
	}
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	vector<ll> p(a);
	vector<ll> q(b);
	priority_queue<ll> r;
	for(int i = 0; i < a; i++) {
		cin>>p[i];
	}
	for(int i = 0; i < b; i++) {
		cin>>q[i];
	}
	ll tmp;
	for(int i = 0; i < c; i++) {
		cin>>tmp;
		r.push(tmp);
	}
	sort(ALL(p),greater<ll>());
	sort(ALL(q),greater<ll>());
	vector<ll> sump(a + 1,0LL);
	vector<ll> sumq(b + 1,0LL);
	for(int i = 0; i < a; i++) {
		sump[i + 1] = sump[i] + p[i];
	}
	for(int i = 0; i < b; i++) {
		sumq[i + 1] = sumq[i] + q[i];
	}
	int ip = 0;
	ll ans = 0LL;
	for(int i = 0; i < x; i++) {
		if (ip < a && p[ip] > r.top()){ 
			ans += p[ip];
			ip++;
		}
		else{
			ans += r.top();
			r.pop();
			r.push(p[ip]);
			ip++;
		}
	}
	int iq = 0;
	for(int i = 0; i < y; i++) {
		if (iq < b && q[iq] > r.top()){ 
			ans += q[iq];
			iq++;
		}
		else{
			ans += r.top();
			r.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k;
    int tmp[200000] = {};
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int tp;
        cin >> tp;
        tmp[tp]++;
    }
    vector<pair<int, int>> m;
    for (int i = 0; i <= n; i++)
    {
        if (tmp[i] > 0)
        {
            m.push_back(make_pair(tmp[i], i));
        }
    }
    sort(m.begin(), m.end());

    int ret = m.size() - k;
    int sum = 0;
    if (ret < 0)
    {
        ret = 0;
    }
    else
    {
        for (int i = 0; i < ret; i++)
        {
            sum += m[i].first;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 7664
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[310000];
int L[310000];
int R[310000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int cur=0;
	for(int i=0;i<a;i++){
		if(in[i]=='W')cur++;
		L[i+1]=cur;
	}
	cur=0;
	for(int i=0;i<a;i++){
		if(in[a-1-i]=='E')cur++;
		R[i+1]=cur;
	}
	int ret=mod;
	for(int i=0;i<a;i++){
		ret=min(ret,L[i]+R[a-1-i]);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 4224
import System.IO
import Control.Monad

solve l r y = do
  let mid = (r+l) `div` 2

  x <- (print mid >> hFlush stdout >> getLine)

  when (x /= "Vacant") $ do
    if (even mid && x == y) || (odd mid && x /= y) then
      solve (mid+1) r y
      else
      solve l mid y

main = do
  n <- readLn :: IO Int

  x <- (print 0 >> hFlush stdout >> getLine)

  when (x /= "Vacant") $ do
    solve 1 n x

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

int n;
int a[1000010];
long long cnt;

void insertionSort(int g){
	for(int i = g; i < n; ++i){
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v){
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j + g] = v;
	}
}

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

	cin >> n;

	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}

	cnt = 0;

	vector<int> G;
	int h = 1;
	while(1){
		if(h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for(int i = G.size() - 1; i >= 0; --i){
		insertionSort(G[i]);
	}

	cout << G.size() << endl;

	for(int i = G.size() - 1; i >= 0; --i){
		cout << G[i];
		if(i != 0)
			cout << " ";
		else
			cout << endl;
	}

	cout << cnt << endl;
	for(int i = 0; i < n; ++i){
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5124
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

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

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

bool check(ll n){
    cout2("?",n);
    char c; cin>>c;
    return (c=='Y');
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll num=1000000000;
    while(num&&!check(num)) num/=10;
    
    if(num!=1000000000){
        ll lb=num*10, ub=lb*10-1, mid;
        while(ub-lb>1){
            mid=(ub+lb)/2;
            if(check(mid)) ub=mid;
            else lb=mid;
        }
        ll ans=lb;
        if(!check(ans))ans++;
        cout2("!",ans/10);
    }else{
        ll ans=9;
        while(!check(ans)) ans*=10;
        cout2("!",ans/9);
    }
    return 0;
}

Measured memory_bytes: 596
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())

sentences = [None]*N

dp = {}

for i in range(N):
     k = list(map(str,input()))
     k.sort()
     k = ''.join(k)
     if k in dp:
         dp[k] += 1
     else:
         dp[k] = 1

ans = 0

for i in dp.values():
    if not i==1:
        ans += i*(i-1)/2

print(int(ans))

Measured memory_bytes: 18704
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean anskey = false;
    if (check(S) 
    		&& check(S.substring(0,(S.length()-1)/2)) 
    		&& check(S.substring(((S.length()+3)/2) - 1))) {
    	anskey = true;
    }
    System.out.println(anskey ? "Yes" : "No");
  }
  
  public static boolean check(String s) {
	  boolean key = true;
	  int N = s.length();
	  int L = N - 1;
	  for (int i = 0; i < N/2; i++) {
		  if (s.charAt(i) != s.charAt(L)) {
			  key = false;
			  break;
		  }
		  L--;
	  }
	  return key;
  }
}


Measured memory_bytes: 23380
#include<stdio.h>
int main()
{
  int n,a[1001];
  int x=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        x=1;
      }
    }
  }
  if(x==0){
    printf("APPROVED\n");
  }
  else{
    printf("DENIED\n");
  }
  return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MAX = 100010;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int N;
long long A[100001], K;

int main(){
	long long cnt = 0;
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		int a, b;
		cin >> a >> b;
		A[a] += b;
	}
	for(int i = 1; i < 100001; i++){
		cnt += A[i];
		if(cnt >= K){
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


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

int main() {
    int X, Y, Z;
    while ( cin >> X >> Y >> Z ) {
        if ( X == 0 && Y == 0 && Z == 0 ) {
            break;
        }
        vector <int> V(X);
        for ( int i = 0; i < X; i++ ) {
            cin >> V[i];
        }
        vector <int> N(Z);
        vector <int> E(Z);
        vector <int> A(Z);
        for ( int i = 0; i < Z; i++ ) {
            cin >> N[i] >> E[i] >> A[i];
        }
        map <int, int> T;
        for ( int i = 0; i < Z; i++ ) {
            T[N[i]] = i;
        }

        vector < vector <double> > dp( 51, vector <double>( 5001, 0.0 ) );
        dp[0][0] = 1.0;
        for ( int i = 0; i < Y; i++ ) {
            for ( int j = 0; j < 5001; j++ ) {
                if ( dp[i][j] > 0.0 ) {
                    for ( int k = 0; k < X; k++ ) {
                        int cost = j;
                        int cell = i + V[k];
                        if ( T.count( cell ) ) {
                            int ind = T[cell];
                            int type = E[ind];
                            int cost = A[ind];
                            if ( type == 1 ) {
                                cell += cost;
                                if ( cell > Y ) cell = Y;
                                dp[cell][j] += dp[i][j] * ( 1.0 / X );
                            } else if ( type == 2 ) {
                                dp[cell][j+cost] += dp[i][j] * ( 1.0 / X );
                            } else if ( type == 3 ) {
                                int next_cost = j-cost;
                                if ( next_cost < 0 ) next_cost = 0;
                                dp[cell][next_cost] += dp[i][j] * ( 1.0 / X );
                            }
                        } else {
                            if ( cell > Y ) cell = Y;
                            dp[cell][j] += dp[i][j] * ( 1.0 / X );
                        }
                    }
                }
            }
        }

        double answer = 0.0;
        for ( int i = 0; i < 5001; i++ ) {
            answer += i * dp[Y][i];
        }
        cout << (int)answer << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#pragma GCC diagnostic ignored "-Wunused-variable" 
#include <bits/stdc++.h>
using namespace std;

#define BOOST
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/range/adaptor/reversed.hpp>
using namespace boost;
using ml = boost::multiprecision::cpp_int;
using md = boost::multiprecision::cpp_dec_float_100;
#define forir(i, ...) if(ll i=(ll)v.size())for(__VA_ARGS__)if(i--,1)
#define eachr(i, e, c) forir(i, auto &&e: adaptors::reverse(c))
#endif

/***** type *****/
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define coutd cout << fixed << setprecision(10)  // cout double
#define output(x) do{cout<<x;return 0;}while(0)  // cout return
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define fori(i, ...) if (ll i = -1) for(__VA_ARGS__) if (i++, 1)
#define each(i, e, c) fori (i, auto&& e: c)      // for each
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define pi 3.1415926535897932                    // 3.14 ...


int main(void)
{
	ll X, Y; cin >> X >> Y;
	rep(i, 0, X+1)
	{
		if (2 * i + 4 * (X - i) == Y) output("Yes");
	}
	output("No");
	return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  string s;
  cin >> s;

  int n = (int)s.size();
  vector<vector<int>> nxt(n + 1, vector<int> (26, n));
  vector<int> dp(n + 2, 1e7);

  for (int i = n-1; i >= 0; --i) {
    nxt[i] = nxt[i + 1];
    nxt[i][s[i] - 'a'] = i;
  }

  dp[n + 1] = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) {
      dp[i] = min(dp[i], 1 + dp[nxt[i][j] + 1]);
    }
  }

  int x = 0;
  while (x < n) {
    for (int j = 0; j < 26; ++j) {
      if (dp[x] == 1 + dp[nxt[x][j] + 1]) {
        cout << char('a' + j);
        x = nxt[x][j] + 1;
        break;
      }
    }
  }
  cout << '\n';
}


Measured memory_bytes: 27796
using System;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            HashSet<string> hash = new HashSet<string>();
            for(int i = 0; i < N; i++)
            {
                line = Console.ReadLine();
                if (hash.Contains(line)) continue;
                hash.Add(line);
            }
            Console.WriteLine(hash.Count);
        }
    }
}


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

namespace ABC055_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            long sum = 0;
            if (2 * N >= M)
            {
                sum = M / 2;
            }
            else
            {
                sum = N + (M - 2 * N) / 4;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11348
H, W = map(int, input().split())
lst = []
res = []

for _ in range(H):
	S = list(map(int, input().split()))
	lst.append(S)
	
for i in range(H - 1):
	for j in range(W):
		if lst[i][j] % 2 == 1:
			lst[i][j] -= 1
			lst[i + 1][j] += 1
			res.append([i + 1, j + 1, (i + 1) + 1, j + 1])

for j in range(W - 1):
	if lst[H - 1][j] % 2 == 1:
		lst[H - 1][j] -= 1
		lst[H - 1][j + 1] += 1
		res.append([H, j + 1, H, (j + 1) + 1])
		
print(len(res))

for i in range(len(res)):
	print(*res[i])

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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 3005;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int maxs(int &a, int b) { return a = max(a, b);}
int mins(int &a, int b) { return a = min(a, b);}
int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int n;
double p, dp[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    
    dp[0] = 1;
    for (int i = 0; i < n; ++i)
    {
        cin >> p;
        for (int h = i + 1; h >= 0; --h)
            dp[h] = (h ? dp[h - 1] * p : 0) + dp[h] * (1 - p);
    }
       
    double res = 0;
    for (int h = n / 2 + (n % 2); h <= n; ++h)
        res += dp[h];
    
    cout << fixed << setprecision(10) << res;
}


Measured memory_bytes: 256
// ABC167B.cpp

#include <iostream>
using namespace std;
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if (a >= k) { // 1のカードがたくさんある時
        ans = k;
        cout << ans << endl;
        return 0;
    }
    else { // 1のカードがあまりない時
        ans = a;
        k -= a;
    }
    if (b < k) { // 0のカードを使う
        k -= b;
        ans -= k; // 0のカードがなくなったら、-1のカードを使う
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3144
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  set<string> a;
  for (int i = 0; i < n; i++) {
    cin >> s;
    a.insert(s);
  }
  cout << a.size() << endl;
}

Measured memory_bytes: 19248
import sys
readline = sys.stdin.readline
INF = 10 ** 8


def main():
    H, N = map(int, readline().rstrip().split())
    dp = [INF] * (H + 1)  # HPを減らすのに必要な最小のMP
    dp[0] = 0

    for _ in range(N):
        hp, mp = map(int, readline().rstrip().split())

        for i in range(H):
            j = min(i+hp, H)
            dp[j] = min(dp[j], dp[i] + mp)

    print(dp[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 73868
#include<stdio.h>

int main(void)
{
  int a, b, c;

  while( scanf("%d %d", &a, &b) != EOF )
    {
      c = a + b;
      if(0 <= c&&c <= 9)
	{
	  printf("1\n");
	}

      else if(10 <= c&&c <= 99)
	{
	  printf("2\n");
	}

      else if(100 <= c&&c <= 999)
	{
	  printf("3\n");
	}

      else if(1000 <= c&&c <= 9999)
	{
	  printf("4\n");
	}

      else if(10000 <= c&&c <= 99999)
	{
	  printf("5\n");
	}

      else if(100000 <= c&&c <= 999999)
	{
	  printf("6\n");
	}

      else
	{
	  printf("7\n");
	}
    }
  return 0;
}

Measured memory_bytes: 584
import collections, bisect

def resolve():

    n = int(input())
    ai = [int(input()) for _ in range(n)]

    d = collections.deque()

    for i in range(n):
        change_index = bisect.bisect_left(d, ai[i]) - 1
        if change_index == -1:
            d.appendleft(ai[i])
        else:
            d[change_index] = ai[i]

    print(len(d))
    
resolve()

Measured memory_bytes: 53592
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int n, t, T, c, min = 10000;

  cin >> n >> T;

  for (int i = 0; i < n; i++)
  {
    cin >> c >> t;

    if (t<=T && min > c)
    {
      min = c;
    }
  }

  if (min == 10000)
  {
    cout << "TLE" << endl;
  } else {
    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_N = 100000;

int N;
int a[MAX_N];
int s;
int bit[32], ans;

int main()
{
  std::cin >> N;
  rep( i, N )
    std::cin >> a[i], s ^= a[i];

  rep( i, N )
  {
    int diff = a[i]^(a[i]-1);
    int k = log(diff+1)/log(2);

    bit[k] = i;
  }

  for( int k = 31; k >= 1; --k )
  {
    if( s >> (k-1) & 1 )
    {
      ++ans;
      s ^= a[bit[k]]^(a[bit[k]]-1);
    }
  }

  printf( "%d\n", s ? -1 : ans );

  return 0;
}

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

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

using namespace std;

void solve(ll A, ll B){
	cout << (A + B) % 24 << endl;
	
}

int main(){

	ll B;
	ll A;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);

	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N; cin >> N;
  ll x[N]; rep(i,N) cin >> x[i];
  ll M, K; cin >> M >> K;
  ll a[M]; rep(i,M) { cin >> a[i]; a[i]--; }
  ll diff[N-1]; rep(i,N-1) diff[i] = x[i+1] - x[i];

  ll pos[N-1]; rep(i,N-1) pos[i] = i;
  ll p_bit[N-1]; rep(i,N-1) p_bit[i] = i;
  for (int i=0; (1ull<<i)<=K; i++) {
    if (i==0) rep(i,M) swap(p_bit[a[i]-1], p_bit[a[i]]);
    else {
      ll p_tmp[N-1]; rep(i,N-1) p_tmp[i] = p_bit[i];
      rep(i,N-1) p_bit[i] = p_tmp[p_tmp[i]];
    }
    if (K&(1ull<<i)) rep(i,N-1) pos[i] = p_bit[pos[i]];
    // cout << i << ":"; rep(i,N-1) cout << p_bit[i] << " "; cout << endl;
    // rep(i,N-1) cout << pos[i] << " "; cout << endl;
  }
  ll result[M]; result[0] = x[0];
  rep(i,N-1) result[i+1] = result[i] + diff[pos[i]];
  rep(i,N) cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 5888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;
 
void solve(){
	int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int>v;
    int cnt;
    int cur=0;
    int judge=0;
    if(s[0]=='0')v.pb(0);
    while(cur<n){
        cnt=cur;
        while(cnt<n&&s[cur]==s[cnt]){
            ++cnt;
        }
        v.pb(cnt-cur);//切り替わるところを順番に格納
        cur=cnt;
    }
    if(s.back()!='1')v.pb(0);//最初と最後を1の数で合わせる
    int maxv=0;
    vector<int>sum(v.size()+1,0);//そのまま数えると間に合わないため累積和、二分探索、しゃくとり法のいずれかを使う
    rep(i,v.size())sum[i+1]=sum[i]+v[i];
    for(int left=0;left<v.size();left+=2){//始まりは必ず1から(端に0があるパターンも番兵によって無くしたから)
        int right=left+2*k+1;
        if(right>=sum.size())right=sum.size()-1;
        maxv=max(maxv,sum[right]-sum[left]);
    }
    cout<<maxv<<"\n";
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    int ans = X;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    for(int i = 0; i < D; i++){
        for(int j = 0; j < N; j++){
            if(a[j] * i + 1 <= D) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

table = [[0] * n for _ in [0] * 64]
table[0] = a

for i in range(61):
    for j in range(n):
        table[i + 1][j] = table[i][table[i][j]]

ans = 0
for i in range(61, -1, -1):
    if k >> i & 1:
        ans = table[i][ans]
print(ans + 1)


Measured memory_bytes: 188956
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    int n;
    long[] as;
    PriorityQueue<Long> maxQueue;
    PriorityQueue<Long> minQueue;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        as = new long[3 * n];
        for (int i = 0; i < as.length; i++) {
            as[i] = sc.nextLong();
        }
    }

    private void solve() {
        maxQueue = new PriorityQueue<>();
        minQueue = new PriorityQueue<>(Comparator.reverseOrder());
        long[] maxs = new long[n+1];
        long[] mins = new long[n+1];
        for (int i = 0; i < n; i++) {
            maxQueue.add(as[i]);
            maxs[0] += as[i];
            minQueue.add(as[3*n-1 - i]);
            mins[mins.length-1] += as[3 * n - 1 -i];
        }
        for (int i = n; i < 2 * n; i++) {
            maxQueue.add(as[i]);
            long e = maxQueue.poll();
            maxs[i-n+1] = maxs[i-n] + as[i] - e;
        }
        for (int i = 2 * n - 1; i >= n; i--) {
            minQueue.add(as[i]);
            long e = minQueue.poll();
            mins[i-n] = mins[i-n+1] + as[i] - e;
        }
        long ans = maxs[0] - mins[0];
        for (int i = 0; i <= n; i++) {
            ans = Math.max(ans, maxs[i] - mins[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 102324
<?php
/*
    Problem URL : http://agc013.contest.atcoder.jp/tasks/agc013_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $N, $K);

$arr = array();

for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    $arr[$a] += $b;
}

ksort($arr);
$cursor = 0;

foreach ($arr as $key => $val) {
    $cursor += $val;
    if ($cursor >= $K) {
        echo $key . "\n";
        exit;
    }
}


Measured memory_bytes: 8952
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int N,k;
	cin >> N >> k;
	char s[N];
	rep(i,0,N){
		cin >> s[i];
	}
	if(s[k-1]=='A'){
		s[k-1]='a';
	}
	else if(s[k-1]=='B'){
		s[k-1]='b';
	}
	else if(s[k-1]=='C'){
		s[k-1]='c';
	}

	rep(i,0,N){
    	cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())
mm = math.floor(math.sqrt(M)) + 1
ans = 0
for a in range(mm, 0, -1):
  if M % a == 0:
    b = M // a
    if a >= N:
      ans = max(ans, b)
    elif b >= N:
      ans = max(ans, a)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int MAX_N = 10000010; 
vector<ll> div_count(MAX_N);

void div(ll n){
    for(ll i = 1; i <= n; i++) div_count[i] = 0;
    for(ll i = 1; i <= n; i++){
            for(ll j = 1 * i; j <= n; j += i){
                div_count[j]++;
            }
    }
}

int main(){
    ll n; cin >> n;
    ll ans = 0;
    div(n);
    for(ll i = 1; i <= n; i++) ans += i * div_count[i];
    cout << ans << endl;
}


Measured memory_bytes: 81212
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n.length();i++){
        if(n[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 51
#define MOD 1000000007

int n,k;
int a[N][N], b[N][N], c[N][N], d[N][N]; // doubling, answer, temp, temp

void copy(int s[][N], int d[][N]){
    for(int i=0;i<n;i++) 
        for(int j=0;j<n;j++)
            d[i][j] = s[i][j];
}

void mult(int s[][N], int o[][N], int d[][N]){
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++){
            d[i][j] = 0;
            for(int k=0;k<n;k++)
                d[i][j] = (d[i][j] + s[i][k]*o[k][j])%MOD;
        }
    }
}

void program(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<n;i++) b[i][i] = 1;

    for(;k;k>>=1) {
        if(k&1) {
            mult(b,a,c);
            copy(c,b);
        }

        copy(a,c);
        mult(a,c,d);
        copy(d,a);
    }

    int res = 0;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) 
        res = (res + b[i][j])%MOD;
    cout<<res<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

int main() {
    int n, t;
    cin >> n >> t;

    vector<int> customers(t + 1);

    rep(i, n) {
        int l, r;
        cin >> l >> r;
        customers[l]++;
        customers[r]--;
    }
    CumulativeSum cs(t + 1);
    rep(i, t + 1) cs.set(i, customers[i]);
    cs.calculate();

    ll ans = 0;
    rep(i, t)cmax(ans, cs.getSum(i));
    cout << ans << endl;

}



Measured memory_bytes: 4648
#include <cstdio>

const int maxn = 450;

const int maxm = 1e5 + 100;

int n, m, ans;
int x[maxm], y[maxm];
bool f[maxn][maxn], ok[maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", x + i, y + i);
	}
	for (int i = 1; i <= n; ++i) {
		f[i][i] = 1;
		ok[i] = 1;
		for (int j = m; j >= 1; --j) {
			if(f[i][x[j]] && f[i][y[j]]) {
				ok[i] = 0;
				break;
			}
			if(f[i][x[j]]) {
				f[i][y[j]] = 1;
			}
			else if(f[i][y[j]]) {
				f[i][x[j]] = 1;
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		if(ok[i]) {
			for (int j = 1; j < i; ++j) {
				if(ok[j]) {
					bool f = 1;
					for (int k = 1; k <= n; ++k) {
						if(::f[i][k] && ::f[j][k]) {
							f = 0;
							break;
						}
					}
					ans += f;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
signed main(){
	string s, t;
	cin>>s>>t;
	ll i, cnt=0;
	for(i=0; i<3; i++){
		if(s[i]==t[i]){
			cnt++;
		}
	}
	cout<<cnt;
}

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

long long lunlun(long long p)
{
	long long u = p%10;
	long long t = p;
	t = t/10;
	long long tens = t%10;

	if((tens-u>=0 || p<10) && u!=9)
	{
		p++;
	}
	else
	{
		t = lunlun(t);
		long long h = t%10;
		if(h==0)
			h++;
		p = t*10 + h-1;
	}
	return p;
}

int main()
{
	long long n;
	cin>>n;
	if(n<=10)
	{
		cout<<n<<endl;
		return 0;
	}
	long long ans = 0;
	for (long long i = 0; i < n ; ++i)
	{
		// cout<<ans<<endl;
		ans = lunlun(ans);
	}
	cout<<ans<<endl;


	

	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const ll OO = 1LL << 60;
const double eps = 1e-9;

const int N = 100005;

int n;
int a[N];

ll valid(ll x) {
	for (int i = 0; i < n; i++) {
		x -= (x % a[i]);
	}
	return x;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll mn, mx;
	ll st = 0, en = OO;
	while (st < en) {
		ll mid = st + (en - st) / 2;
		if (valid(mid) == 0)
			st = mid + 1;
		else
			en = mid;
	}
	if (valid(st) != 2) {
		cout << -1 << endl;
		return 0;
	}
	mn = st;
	en = OO;
	while (st < en) {
		ll mid = st + (en - st + 1) / 2;
		if (valid(mid) == 2)
			st = mid;
		else
			en = mid - 1;
	}
	mx = st;
	cout << mn << " " << mx << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(){
  char input[101];
  int i,k;
  
  scanf("%d",&k);
  scanf("%s",input);
  
  if(k<strlen(input)){
    for(i=0;i<k;i++){
      printf("%c",input[i]);
    }
    printf("...");
  } else {
    printf("%s",input);
  }
}

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

const int mod = 1000000007;

int main() {
  int a[9];
  rep(i, 9) cin >> a[i];
  int n;
  cin >> n;
  bool ok[9];
  rep(i, 9) ok[i] = false;
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  rep(i, n) {
    rep(j, 9) {
      if (a[j] == b[i]) {
        ok[j] = true;
      }
    }
  }
  //rep(i, 9) cout << ok[i] << endl;
  bool ok2 = false;
  if (ok[0] && ok[1] && ok[2]) {
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[3]&&ok[4]&&ok[5]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[6]&&ok[7]&&ok[8]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[0]&&ok[3]&&ok[6]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[1]&&ok[4]&&ok[7]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[2]&&ok[5]&&ok[8]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[0]&&ok[4]&&ok[8]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(ok[2]&&ok[4]&&ok[6]){
    cout << "Yes" << endl;
    ok2 = true;
    return 0;
  }
  if(!ok2){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    ll D;
    cin >> D;
    vector<ll> c(26);
    for (int i = 0; i < 26; i++) {
        cin >> c.at(i);
    }
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s.at(i).at(j);
        }
    }
    vector<ll> v(26, 0);
    for (ll i = 0; i < D; i++) {
        ll sumc = 0;
        int vd;
        for (int j = 0; j < 26; j++) {
            ll sumca = c.at(j) * (i + 6 - v.at(j));
            if (sumc < sumca) {
                vd = j;
            }
            sumc = max(sumc, sumca);
        }
        v.at(vd) = i + 1;
        cout << vd + 1 << endl;
    }
}


Measured memory_bytes: 3688
[a]=[int(i) for i in input().split()]
[b]=[int(i) for i in input().split()]
[c]=[int(i) for i in input().split()]
[x]=[int(i) for i in input().split()]
ans=0
for ia in range(a+1):
    for ib in range(b+1):
        for ic in range(c+1):
            if(ia*500+ib*100+ic*50==x):
                ans+=1
print(ans)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

ll n,m,q;
struct Info{
    ll a,b,c,d;
};
vector<Info> vec(50);
ll ss = 0;
ll dfs(ll cou,string str,ll maxi){
  if(cou == n){
    ss++;
    ll sum = 0;
    rep(i,q){
      if(str[vec[i].a] - '0' + vec[i].c == str[vec[i].b] - '0'){
        sum += vec[i].d;
      }
    }
//    if(ss < 100){
//      cout << str << " " << sum << endl;
//    }
    return sum;
  }


  ll ans = 0;
  for(int i = maxi;i <= m-1;i++){
    chmax(ans,dfs(cou+1,str + (char)(i + '0'),i));
  }
  return ans;
}

int main(){
  cin >> n >> m >> q;

  ll a,b,c,d;
  rep(i,q){
    cin >> a >> b >> c >> d;
    Info info;
    a--;
    b--;
    info.a = a;
    info.b = b;
    info.c = c;
    info.d = d;
    vec[i] = info;
  }
  cout << dfs(0,"",0);
}

Measured memory_bytes: 3604