akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define x first
#define y second

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

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

    int n;
    int a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 1;
    vector<string> res;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == "AB") {
            if (a == 0) {
                res.push_back("A");
                a++;
                b--;
            } else if (b == 0) {
                res.push_back("B");
                a--;
                b++;
            } else {
                if (i + 1 == n || s[i + 1] == "AC") {
                    res.push_back("A");
                    a++;
                    b--;
                } else {
                    res.push_back("B");
                    b++;
                    a--;
                }
            }
        } else if (s[i] == "AC") {
            if (a == 0) {
                res.push_back("A");
                a++;
                c--;
            } else if (c == 0) {
                res.push_back("C");
                a--;
                c++;
            } else {
                if (i + 1 == n || s[i + 1] == "AB") {
                    res.push_back("A");
                    a++;
                    c--;
                } else {
                    res.push_back("C");
                    c++;
                    a--;
                }
            }
        } else {
            if (b == 0) {
                res.push_back("B");
                b++;
                c--;
            } else if (c == 0) {
                res.push_back("C");
                b--;
                c++;
            } else {
                if (i + 1 == n || s[i + 1] == "AB") {
                    b++;
                    c--;
                    res.push_back("B");
                } else {
                    b--;
                    c++;
                    res.push_back("C");
                }
            }
        }
        if (a < 0 || b < 0 || c < 0) {
            ans = 0;
            break;
        }
    }
    if (ans == 0) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for (auto &el : res) {
        cout << el << "\n";
    }

    return 0;
}

Measured memory_bytes: 10620
#include <stdio.h>

int n, A[2000];

int a(int,int);

int main()
{
  
  int q, i, m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(a(0, m)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  
  return 0;
  
}


int a(int x,int y)
{
  
  int res;
    
  if(y==0) return 1;
  if(x>=n) return 0;
  res = a(x+1,y) || a(x+1,y-A[x]);
  return res;
  
}



Measured memory_bytes: 2108
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	var ym, my bool
	fmt.Scan(&s)
	b, _ := strconv.Atoi(s[:2])
	a, _ := strconv.Atoi(s[2:])
	if b > 0 && b < 13 {
		my = true
	}
	if a > 0 && a < 13 {
		ym = true
	}
	if ym && my {
		fmt.Println("AMBIGUOUS")
		return
	}
	if ym {
		fmt.Println("YYMM")
		return
	}
	if my {
		fmt.Println("MMYY")
		return
	}
	fmt.Println("NA")

}

Measured memory_bytes: 512
// AOJ 2242

#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct P {
	string name;
	int s, e;
	P(string name, int s, int e)
	: name(name), s(s), e(e) {}
};
int main(void)
{
	int n, q;
	while (cin >> n >> q, n && q){
		vector <P> data;
		int y1, y2;
		string str;
		for (int i = 0; i < n; i++){
			cin >> str >> y1 >> y2;
			data.push_back(P(str, (y2-y1+1), y2));
		}
		int year;
		for (int i = 0; i < q; i++){
			cin >> year;
			string ret = "Unknown";
			for (int j = 0; j < data.size(); j++){
				if (data[j].s <= year && year <= data[j].e){
					cout << data[j].name << " " << year - data[j].s + 1 << endl;
					goto OK;
				}
			}
			cout << ret << endl;
			OK :;
		}
	}

	return 0;
}

Measured memory_bytes: 1288
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

def main():
    #N, M = map(int, input().split())
    S = input().strip()
    if S == 'ARC':
        print("ABC")
    else:
        print("ARC")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9336
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    int n = s.size();
    int res = 0;
    rep(i,n){
        if(s[i] == '+')res++;
        else res--;
    }
    cout<<res;
}



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

bool isprime(int num){
    if(num<2) return false;
    else if(num==2) return true;
    else if(num%2==0) return false;

    float sqrtNum=sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
        if(num%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    long X;
    long i=0;
    bool flag=false;
  	cin >> X;
  
    while(!flag){
        flag=isprime(X+i);
      	i++;
    }
  	i--;
    cout << X+i << endl;
}

Measured memory_bytes: 256
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

n, k = li()
as = li()

hash = {}

as.each{|a|
  if hash[a] == nil
    hash[a] = 1
  else
    hash[a] += 1
  end
}

arr = hash.sort_by{|k, v| v}.to_ary

if arr.length-1-k >= 0
  puts arr[0..arr.length-1-k].reduce(0){|acc, a| acc+a[1]}
else
  puts 0
end


Measured memory_bytes: 40968
#include <iostream>
#include <stdio.h>
int main(void){
  int n;
  int s[100];
  int cnt = 0;
  int sum=0;
  int min=101;
  std::cin >> n;
  for(int i=0;i<n;i++){
    std::cin >> s[i];
    sum+=s[i];
    if(s[i] % 10 == 0){
      cnt++;
      continue;
    }
    if(min > s[i]){
      min = s[i];
    }
  }
  if(cnt == n){
    printf("0");
    return 0;
  }
  if(sum % 10 != 0){
    printf("%d",sum);
    return 0;
  }
  printf("%d",sum-min);
  return 0;
}

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

int main()
{
  int a[3][3];
  int ab[3][3]={{0,0,0},{0,0,0},{0,0,0}};
  int n;
  int b[10];

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> a[i][j];
    }
  }
  
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
  }
  
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if(b[i] == a[j][k]){
          ab[j][k]=1;
        }
      }
    }   
  }
  
  // for (int i = 0; i < 3; i++)
  // {
  //   for (int j = 0; j < 3; j++)
  //   {
  //     cout << ab[i][j];
  //   }
  //   cout << endl;
  // }


  bool flag=false;
  // vertical
  for (int i = 0; i < 3; i++)
  {
    if(ab[i][0] == 1 && ab[i][1] ==1 && ab[i][2] ==1){
      flag=true;
    }
  }
  if(flag){
    cout << "Yes" << endl;
    return 0;
  }

  // horizontal
  for (int i = 0; i < 3; i++)
  {
    if(ab[0][i] == 1 && ab[1][i] ==1 && ab[2][i] ==1){
      flag=true;
    }
  }
  if(flag){
    cout << "Yes" << endl;
    return 0;
  }

  // diagonal
  if(ab[0][0] == 1 && ab[1][1] ==1 && ab[2][2] ==1){
      flag=true;
  }else if(ab[2][0] == 1 && ab[1][1] ==1 && ab[0][2] ==1){
      flag=true;
  }
     if(flag){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/intrusive/rbtree.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<0>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 1000000007
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint n;
    cin>>n;
    vec a(n);
    rep(i,n)cin>>a[i];
    lint ans=0;
    lint now=0;
    if(a[0]>0){
        cout<<-1;
        return 0;
    }
    rrep(i,n){
        if(a[i]==now){
            now--;
        }else if(a[i]>now){
            now=a[i];
            ans+=now;
            now--;
        }else{
            cout<<-1;
            return 0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a,z;
    a = -1;
    z = -1;
    for (int i=0; i<n; i++) {
        if (a==-1 && s[i] == 'A') a = i;
        if (s[i] == 'Z') z = i;
    }

    cout << z - a + 1 << endl;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"

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

using namespace std;
const long long MOD = 998244353;
const long long INF = 1LL << 61;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N - 1);

	rep(i, N)cin >> A[i];
	rep(i, N)cin >> B[i];
	rep(i, N - 1)cin >> C[i];

	int ans = 0;
	int ate = -1;
	rep(i, N) {
		if (A[i] - 1 == ate)ans += C[ate - 1];
		ans += B[A[i] - 1];
		ate = A[i];
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


const int nax = 1e5+7;
int dp[nax];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}
	dp[0] = 0;

	for (int i = 0; i <= k; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if((i-v[j] >= 0) && dp[i - v[j]] == 0){
				dp[i] = 1;
			}
		}
	}
	if(dp[k] == 0)std::cout << "Second" << "\n";
	else std::cout << "First" << "\n";

	return 0;
}


Measured memory_bytes: 4048
def combination(n, k, mod=10**9+7):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % mod
    d = 1
    for x in range(1, k+1):
        d = (d * x) % mod
    comb *= pow(d, mod-2, mod)
    return comb % mod

N = int(input())
K = int(input())

x = [0] * 101
i = 0
NN = N
while NN > 0:
    x[i] = NN % 10
    NN = NN // 10
    i += 1

ans = 0
sum_non0 = 0
rK = K
for j in reversed(range(i)):
    if x[j] == 0:
        continue
    # 0 ~ 10^j
    _ans = combination(j, rK) * (9 ** rK)
    #print(j, _ans)
    if rK != 1:
        _ans += (x[j] - 1) * combination(j, rK-1) * (9 ** (rK - 1))
        #print(j, _ans)
    else:
        _ans += x[j]
        #print(j, _ans)

    ans += _ans
    rK -= 1
    if rK == 0:
        break

print(ans)

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

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var N = nk[0];
			var K = nk[1] + 1;
			var V = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

			var ans = 0;
			foreach (var a in Enumerable.Range(0, K))
			{
				var queueA = V.Take(a).ToList();
				foreach (var b in Enumerable.Range(0, K - a))
				{
					var queueB = queueA.Concat(V.Skip(Math.Max(a, N - b))).OrderBy(x => x).ToList();
					foreach (var c in Enumerable.Range(0, Math.Min(K - (a + b), queueB.Count() + 1)))
					{
						var queueC = queueB.Skip(c);
						ans = Math.Max(ans, queueC.Sum());
					}
				}
			}
			Console.WriteLine(ans);
		}
	}
}


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

int main() {
  string s;
  cin >> s;
  bool found = 0;
  for (int i = -1; i < 2; i += 2) {
    for (int j = -1; j < 2; j += 2) {
      for (int k = -1; k < 2; k += 2) {
        int sum = s[0] - '0';
        sum += i * (s[1] - '0') + j * (s[2] - '0');
        sum += k * (s[3] - '0');
        if (sum == 7) {
          found = 1;
          cout << s[0];
          cout << ((i == 1) ? '+' : '-') << s[1];
          cout << ((j == 1) ? '+' : '-') << s[2];
          cout << ((k == 1) ? '+' : '-') << s[3];
          cout << "=7";
          break;
        }
      }
      if (found)
        break;
    }
    if (found)
      break;
  }
}


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

inv_table = [0]+[1]
for i in range(2,K+2):
  inv_table.append(-(MOD//i)*inv_table[MOD%i]%MOD)

def powmod(a,p):
  if p==0:
    return 1
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD
def invmod(a):
  return powmod(a,MOD-2)

if M==1:
  if K<N-1:
    print(0)
  else:
    print(1)
else:
  ans=0
  term1=powmod(M-1,N-1)
  term2=1
  inv_M1=invmod(M-1)
  for i in range(K+1):
    ans+=term1*term2
    ans%=MOD
    term1=term1*inv_M1%MOD
    term2=term2*(N-i-1)*inv_table[i+1]%MOD
    
  answer=M*ans%MOD
  print(answer)

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int A, B;
    cin >> A >> B;
    if (A != 1 && B != 1) {
        cout << 1 << endl;
    } else if (A != 2 && B != 2) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main()
{
    int X;
    cin >> X;
    if(X <= 599){
        cout << 8 << endl;
    }
    else if(X <= 799){
        cout << 7 << endl;
    }
    else if(X <= 999){
        cout << 6 << endl;
    }
    else if(X <= 1199){
        cout << 5 << endl;
    }
    else if(X <= 1399){
        cout << 4 << endl;
    }
    else if(X <= 1599){
        cout << 3 << endl;
    }
    else if(X <= 1799){
        cout << 2 << endl;
    }
    else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3632
a=list(input())
b=list(input())
c=list(input())
k=a[0]

for i in range(1000000):
    if k=='a':
        if len(a)==0:
            print('A')
            break
        else:
            k=a[0]
            del a[0]
    elif k=='b':
        if len(b)==0:
            print('B')
            break
        else:
            k=b[0]
            del b[0]
    else:
        if len(c)==0:
            print('C')
            break
        else:
            k=c[0]
            del c[0]

        


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  int n ; cin >> n;
  vector<int> h(n);
  rep(i,n){ cin >> h[i]; }; 

  int cnt = 0;
  int max_cnt = 0;
  for(int i = 0 ; i < n - 1; i++){
      if( h[i] >= h[i+1]){
        cnt++;
      }else{
        cnt = 0;
      }
      max_cnt = max(max_cnt,cnt);
  }
  cout << max_cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std; 

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

  // O(MN)
  vector<int> s[M];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k; 
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      s[i].push_back(x - 1); // Wow. This one thing can ruin everything.
    }
  }

  // O(M)
  int p[M];
  for (int l = 0; l < M; l++) {
    cin >> p[l];
  }

  // O(MN * 2^N)
  int num = 0;
  for (int b = 0; b < (1 << N); b++) { 
    // Each b contains info for the ith switch at bit position i from right 
    bool good = true;
    for (int c = 0; c < M; c++) {
      // For each light 
      int sum = 0;
      for (int sw : s[c]) {
        // For each switch connected to light
        // Note: != takes precedence over &, be careful!
        if ((b >> sw) & 1) {
          ++sum;
        }
      }
      sum %= 2;
      if (sum != p[c]) {
        good = false;
      }
    }
    if (good) {
      num++;
    }
  }

  cout << num << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

struct ToUpper {
	char operator()(char c) { return toupper(c); }
};

int main() {
	string st;
	getline(cin, st);
	transform(st.begin(), st.end(), st.begin(), ToUpper());
	cout <<st<< endl;
	return 0;
} 

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

const int N = 1000; 

inline int read()
{
	char c = getchar(); int f = 1, x = 0;
	while( c < '0' || c>'9' ) { if(c == '-') f = -1;  c = getchar(); }
	while( c >= '0'&&c<='9' ) { x = x * 10 + c - '0'; c = getchar(); }
	return f * x;
}

int n, m, tot = 0, color[N]; 

bool g[N][N], f[N][N<<1]; 

struct tData {
	int a[3]; 
	
	tData() { a[1] = a[2] = 0; }
} p[N];

bool dfs( int u, int now )
{
	p[now].a[ color[u] ] ++; 
	
	for( int i = 1; i <= n; i ++ )
	{
		if( !g[u][i] ) continue;
		if( color[i] ) 
		{
			if( color[i] != color[u] ) continue;
			return false;
		}
		
		color[i] = color[u] == 1 ? 2 : 1;
		if( !dfs( i, now ) ) return false; 
	}
	
	return true; 
}

inline int calc( int size ) { return size * ( size - 1 ) / 2; }

int main()
{
	n = read(); m = read(); 
	
	int u, v; 
	for( int i = 1; i <= m; i ++ )
	{
		u = read(); v = read(); 
		g[u][v] = g[v][u] = true; 
	}
	
	for( int i = 1; i <= n; i ++ )
		for( int j = 1; j <= n; j ++ )
			if( i != j ) g[i][j] ^= 1;
	
	bool flag = true;
	for( int i = 1; i <= n && flag; i ++ )
		if( !color[i] ) color[i] = 1, flag = dfs( i, ++tot );  
	
//	for( int i = 1; i <= n; i ++ )
//		printf( "%d ", color[i] ); printf( "\n" );
	
	if( !flag ) {
		printf( "-1\n" ); return 0;
	}
	
	int small = 0, large = 0;
	for( int i = 1; i <= tot; i ++ )
		p[i].a[3] = abs( p[i].a[1] - p[i].a[2] );
		
	f[0][1000] = 1; 
	for( int i = 1; i <= tot; i ++ )
		for( int j = 1000-n; j <= 1000+n; j ++ )
		{
			int k = j + p[i].a[3]; 
			f[i][j] |= f[i-1][k]; 
			k = j - p[i].a[3]; 
			f[i][j] |= f[i-1][k]; 
		}

	int ans; 
	for( int i = 0; i <= n; i ++ )
		if( f[tot][1000+i] || f[tot][1000-i] ) 
			{ ans = i; break; }

	small = ( ans + n ) / 2; large = n - small; 
		
	printf( "%d\n", calc( small ) + calc( large ) );
	
	return 0; 
}

Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int N = 200005;
int n, k; LL a[N], b[N], sum[N], ans;

int read() {
	int x = 0; char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	return x;
}
int find(LL x) {
	int l = 1, r = n;
	while (l <= r) {
		int mid = l + (r - l >> 1);
		if (a[mid] == x) return mid;
		if (a[mid] < x) l = mid + 1;
		else r = mid - 1;
	}
}
int lowbit(int x) {
	return x & (-x);
}
int query(int x) {
	int res = 0;
	while (x) res += b[x], x -= lowbit(x);
	return res;
}
void update(int x) {
	while (x <= n) ++b[x], x += lowbit(x);
}

int main() {
	n = read(), k = read();
	for (int i = 1; i <= n; ++i) {
		a[i] = sum[i] = sum[i-1] + read() - k;
		if (sum[i] >= 0) ++ans;
	}
	std::sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		int x = find(sum[i]);
		ans += query(x); update(x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main { 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			int q = stdIn.nextInt();
			if(n == 0 && m == 0 && q == 0) break;
			String[] S = new String[q];
			String[] B = new String[q];
			for(int i = 0; i < q; i++) {
				S[i] = stdIn.next();
				B[i] = stdIn.next();
			}
			boolean[][] SX = new boolean[q][n];
			boolean[][] BX = new boolean[q][m];
			for(int i = 0; i < q; i++) {
				for(int j = 0; j < n; j++) {
					SX[i][j] = (S[i].charAt(j) == '1')?true:false;
				}
				for(int j = 0; j < m; j++) {
					BX[i][j] = (B[i].charAt(j) == '1')?true:false;
				}
				if(i != 0) {
					for(int j = 0; j < n; j++) {
						SX[i][j] = (S[i].charAt(j) == '1')?!SX[i-1][j]:SX[i-1][j];
					}
					for(int j = 0; j < m; j++) {
						BX[i][j] = (B[i].charAt(j) == '1')?true:false;
					}
				}
			}
			boolean[][] list = new boolean[n][m];
			for(int i = 0; i < q; i++) {
				for (int j = 0; j < n; j++) {
					if (SX[i][j]) {
						for (int k = 0; k < m; k++) {
							if (!BX[i][k]) {
								list[j][k] = true;
							}
						}
					}
					if (!SX[i][j]) {
						for (int k = 0; k < m; k++) {
							if (BX[i][k]) {
								list[j][k] = true;
							}
						}
					}
				}
				
			}
			if(n == 1) {
				for(int i = 0; i < m; i++) {
					System.out.print(0);
				}
				System.out.println();
				continue;
			}
			int[] ans = new int[m];
			for(int i = 0; i < m; i++) {
				ans[i] = -1;
				int count = 0;
				int id = 0;
				for(int j = 0; j < n; j++) {
					if(!list[j][i]) {
						id = j;
						count++;
					}
				}
				if(count == 1) {
					ans[i] = id+1;
				}
			}
			for(int i = 0; i < ans.length; i++) {
				if(ans[i] == -1) {
					System.out.print("?");
				}
				else if(ans[i] <= 10) {
					char a = '0';
					a += ans[i]-1;
					System.out.print(a);
				}
				else {
					char a = 'A';
					a += (ans[i] - 11);
					System.out.print(a);
				}
			}
			System.out.println();
		}
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if(n % (2 * m + 1) == 0)
    cout << n / (2 * m + 1) << endl;
  else
    cout << n / (2 * m + 1) + 1 << endl;
}

Measured memory_bytes: 256
import math
import itertools
import sys
x, k, d = map(int, input().split())
tmp = abs(x)//d
if(k < tmp):
    if(x < 0):
        print(abs(x+k*d))
    else:
        print(abs(x-k*d))
else:
    if((k-tmp) % 2 == 0):
        if(x < 0):
            print(abs(x+tmp*d))
        else:
            print(abs(x-tmp*d))
    else:
        if(x < 0):
            print(abs(x+(tmp+1)*d))
        else:
            print(abs(x-(tmp+1)*d))


Measured memory_bytes: 62424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int y = 0;
  int i = 0;
  while(i < N) {
 
  int x;
    cin >> x;
    if(K - x > x){
      y = y + 2 * x;}
    else if (x >= K - x){
      y = y + 2 * (K - x);}
      
  i++;
  }
  cout << y << endl;
      
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    int N;
    cin >> N;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    ll sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if( i != j) sum += v[i]*v[j];
        } 
    }
    cout << (sum / 2 )<< endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A  = [int(_n) for _n in input().split()]
    if N == 0:
        print(1 if A[0]==1 else -1)
        return

    l = A[-1]
    L = [(1,1)]
    for i in range(1,N):
        L.append((A[i]+1, (L[i-1][1]-A[i-1])*2))
        if (L[i-1][1]-A[i-1])*2 < A[i]:
            print(-1)
            return
    L.append((A[N], (L[N-1][1]-A[N-1])*2))
    # print(L)
    if (L[N-1][1]-A[N-1])*2 < A[N]:
        print(-1)
        return
    
    R = [(A[-1],A[-1])]
    for i in reversed(range(N)):
        R.append(((R[-1][0]+1)//2+A[i], R[-1][1]+A[i]))
    res = 0
    for i in range(N+1):
        r = R[i]
        l = L[N-i]
        if r[0] > l[1] or r[1] < l[0]:
            print(-1)
            return
        # print(r,l)
        res += min(r[1], l[1])
    print(res)

        
main()

Measured memory_bytes: 713348
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  vector<int> a(6);
  rep(i,6)
    cin>>a[i];
  sort(all(a));
  bool b=1;
  if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])||(a[2]==a[3]&&a[3]==a[4])||(a[3]==a[4]&&a[4]==a[5]))
  b=0;
  YESNO(b);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		do{
			int x = i;
			if(x%3==0){
				System.out.print(" "+i);
			}else{
				while(true){
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
					x/=10;
					if(x!=0)continue;
					else break;
				}
			}
		}while(++i<=n);
		System.out.println();
	}
}

Measured memory_bytes: 28804
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int n;
    cin>>n;
    int a[114514];
    int c4=0,c2=0,c1=0,c=0;
    for (int i=0;i<n;i++){
        cin>>a[i];
        if (a[i]%4==0) c4++;
        else if (a[i]%2==0) c2++;
        else c1++;
    }
    c=n-1;
    if (c4>0){
        c-=c4*2;
    }
    if (c2>0){
        c-=c2;
        c+=1;
    }
    if (c<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> a = {1, 3, 5, 7, 8, 10, 12};
    set<int> b = {4, 6, 9, 11};
    int x, y;
    cin >> x >> y;
    if(a.count(x)*a.count(y) || b.count(x)*b.count(y) || (x == 2 && y == 2)){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,k = map(int, input().split())
mod = 10**9+7

ans = 0
for i in range(k, n + 2):
    mi = (i - 1) * i // 2
    ma = (n + n - i + 1) * i // 2
    ans += ma - mi + 1
print(ans % mod)


Measured memory_bytes: 9180
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  	vector<int> tasks(3);
  	for(int i = 0; i < 3; ++i) cin >> tasks[i];
  	sort(tasks.begin(), tasks.end());
  	cout << tasks[2] - tasks[0] << endl;
}


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

int main()
{
    char a;
    cin>>a;
    if(a == 'A'){
        cout<<"T";
    }
    else if(a == 'T'){
        cout<<"A";
    }
    else if(a == 'C'){
        cout<<"G";
    }
    else{
        cout<<"C";
    }

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n,w[100000],b[100000];
vector<vector<int>> conn;
bool done[100000];

int fb(int node);

int fw(int node)
{
	if(done[node])
		return w[node];
	done[node]=1;
	w[node]=1;
	b[node]=1;
	for(int i:conn[node])
	{
		if(!done[i])
		{
			b[node]=(b[node]*fw(i))%mod;
			w[node]=(w[node]*(fw(i)+fb(i)))%mod;
		}
	}
	return w[node];
}

int fb(int node)
{
	if(done[node])
		return b[node];
	done[node]=1;
	w[node]=1;
	b[node]=1;
	for(int i:conn[node])
	{
		if(!done[i])
		{
			b[node]=(b[node]*fw(i))%mod;
			w[node]=(w[node]*(fw(i)+fb(i)))%mod;
		}
	}
	return b[node];
}

signed main()
{
	fio
	cin>>n;
	conn.resize(n);
	fo(i,n-1)
	{
		inp(x) inp(y)
		x--,y--;
		conn[x].pb(y);
		conn[y].pb(x);
	}
	memset(done,0,sizeof(done));
	memset(w,-1,sizeof(w));
	memset(b,-1,sizeof(b));
	cout<<(fw(0)+fb(0))%mod<<'\n';
	printclock;
}

Measured memory_bytes: 14336
var input = require('fs').readFileSync('/dev/stdin', 'utf8')
var lines = input.split('\n')
var h = parseInt(lines.shift().split(' ')[0])
var dist = [...Array(10)].map(() =>
	lines
		.shift()
		.split(' ')
		.map(v => parseInt(v, 10))
)

var counts = new Array(10).fill(0)
for (var i = 0; i < h; i++) {
	lines
		.shift()
		.split(' ')
		.map(v => parseInt(v, 10))
		.forEach(v => counts[v]++)
}

for (var k = 0; k < 10; ++k) {
	for (var i = 0; i < 10; ++i) {
		for (var j = 0; j < 10; ++j) {
			dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])
		}
	}
}
// console.log(dist)

console.log(
	[...Array(10).keys()].reduce((p, c) => p + counts[c] * dist[c][1], 0)
)


Measured memory_bytes: 23220
n=int(input())
ab = []
for _ in range(n):
    s=int(input())
    ab.append(s)

ab.sort()

goukei=sum(ab)

if goukei%10 != 0:
    print(goukei)
else:
    ans=[]
    for i in range(n):
        if (goukei-ab[i])%10 != 0:
            ans.append(goukei-ab[i])
        else:
            ans.append(0)
    ans.sort(reverse=True)
    print(ans[0])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int N = 805;
int dis[N][N];
char g[N][N];

int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int R, C, K;
vector<int> v;
void bfs(int x, int y) {

	dis[x][y] = 0;
	queue<pair<int, int> > q;
	q.push( { x, y });
	int T = min(x, min(R - x - 1, min(C - y - 1, y)));
	v.push_back((T + K - 1) / K);
	while (!q.empty()) {
		x = q.front().first;
		y = q.front().second;
		q.pop();
		if (dis[x][y] == K) continue;
		for (int i = 0; i < 4; i++) {
			int tx = dx[i] + x;
			int ty = dy[i] + y;
			if (tx < 0 || tx >= R || ty < 0 || ty >= C || dis[tx][ty] != -1
					|| g[tx][ty] != '.') continue;
			dis[tx][ty] = dis[x][y] + 1;
			int T = min(tx, min(R - tx - 1, min(C - ty - 1, ty)));
			v.push_back((T + K - 1) / K);
			q.push( { tx, ty });
		}
	}
}

int main() {

//	freopen("readin.txt", "r", stdin);

	scanf("%d%d%d", &R, &C, &K);
	int sx, sy;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			scanf(" %c", &g[i][j]);
			if (g[i][j] == 'S') {
				sx = i, sy = j;
			}
		}
	}
	memset(dis, -1, sizeof dis);
	bfs(sx, sy);
	sort(v.begin(), v.end());
	cout << v[0] + 1 << endl;

	return 0;
}


Measured memory_bytes: 9076
function kumiawase(start,end,len){
   var ans=[];
   var loop=function(a,arr){
      if(arr.length==len)ans.push(arr);
      else{
         for(var i=a;i<=end;i++)loop(i+1,arr.concat(i));
      }
   }
   loop(start,[]);
   return ans;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.some(function(v,i){
   if(v=="0 0 0")return true;
   var nks=v.split(" ").map(Number);
   var ary=kumiawase(1,nks[0],nks[1]);
   var cnt=0;
   ary.forEach(function(v){
      var sum=v.reduce(function(a,b){return a+b;});
      if(sum==nks[2])cnt++;
   });
   console.log(cnt);
});

Measured memory_bytes: 93508
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define sz size()
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=2e5+6;
    const int M=998244353;
    vector<int> v;
    signed main()
    {
        FAST
        string a,b;
        cin>>a>>b;
        b+=a;
        cout<<b;
        
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, C;
vector<vector<ll>> imos;

int main() {
	cin >> N >> C;
	imos.resize(C, vector<ll>(100000+2, 0));
	for (ll n = 0; n < N; n++) {
		ll s, t, c;
		cin >> s >> t >> c;
		c--;
		imos[c][s]++;
		imos[c][t+1]--;
	}
	for (ll c = 0; c < C; c++) {
		for (ll t = 1; t <= 100000; t++) {
			imos[c][t] += imos[c][t - 1];
		}
	}
	ll ans = 0;
	for (ll t = 0; t <= 100000; t++) {
		ll count = 0;
		for (ll c = 0; c < C; c++) {
			if (imos[c][t] > 0)count++;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);

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

    sort(a.begin(), a.end());

    int ans;
    ans = (a.at(n - 1) - a.at(0));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

ll n, x, ans;

void solve(ll a, ll b)
{
    if (a > b) swap(a, b);
    if (b % a == 0) {
		ans += (2 * (b / a) - 1) * a;
        return;
    }
    ans += 2 * (b / a) * a;
    solve(a, b % a);
}

int main()
{
	cin >> n >> x;
    ans = n;
    solve(x, n-x);
    cout << ans;
}


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

struct Node{
  int key,priority;
  Node *right,*left,*parent;
};

Node *root,*NIL;

Node* rightRotate(Node *t){
  Node *s = t->left;
  t->left = s->right;
  s->right = t;
  return s;
}

Node* leftRotate(Node *t){
  Node *s = t->right;
  t->right = s->left;
  s->left = t;
  return s;
}

Node* treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node* find(Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node* treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
}

Node* createNode(int key, int priority) {
    Node *p;
    p = (Node *)malloc(sizeof(Node));
    p->key = key;
    p->priority = priority;
    p->left = NULL;
    p->right = NULL;
    p->parent = NULL;
    return p;
}

Node* insert(Node *t, int key, int priority){
  if(t == NIL) return createNode(key, priority);
  if(key == t->key) return t;
  if(key < t->key){
    t->left = insert(t->left, key, priority);
    if(t->priority < t->left->priority) t = rightRotate(t);
  } else {
    t->right = insert(t->right, key, priority);
    if(t->priority < t->right->priority) t = leftRotate(t);
  }
  return t;
}

Node* _treeDelete(Node *t,int key);
Node* treeDelete(Node *t, int key);

Node* _treeDelete(Node *t,int key){
  if(t->left == NIL && t->right == NIL) return NIL;
  else if(t->left == NIL) t = leftRotate(t);
  else if(t->right == NIL) t = rightRotate(t);
  else{
    if(t->left->priority > t->right->priority) t = rightRotate(t);
    else t = leftRotate(t);
  }
  return treeDelete(t, key);
}

Node* treeDelete(Node *t, int key){
  if(t == NIL) return NIL;
  if(key < t->key) t->left = treeDelete(t->left, key);
  else if(key > t->key) t->right = treeDelete(t->right, key);
  else return _treeDelete(t, key);
  return t;
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
  int n,i,x,y;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin >> com;
        if(com=="find"){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if(com=="insert"){
	  scanf("%d%d",&x,&y);
	  root=insert(root,x,y);
        } else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "delete"){
            scanf("%d",&x);
            root=treeDelete(root,x);
        }
    }

    return 0;
}


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

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

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

    set<pair<int,int>>s;
    map<int,int>row,col;
    int mxrow=-1,mxcol=-1;

    for (int i=0;i<m;i++){

        int a,b;
        cin >> a >> b;

        s.insert(make_pair(a,b));
        row[a]++;
        col[b]++;
        mxrow = max(mxrow,row[a]);
        mxcol = max(mxcol,col[b]);
    }

    vector<int>x,y;

    for (auto k : row) if (k.second == mxrow)x.push_back(k.first);
    for (auto k : col) if (k.second == mxcol)y.push_back(k.first);

    int ans = mxrow + mxcol - 1;

    bool f = 0 ;
    for (int i=0;i<(int)x.size();i++){
        for (int j=0;j<(int)y.size();j++){
            auto pp = make_pair(x[i],y[j]);
            if (s.find(pp)==s.end()){ 
                ans++;
                f=1;
                break;
            }
        }
        if (f) break;
    }

    cout<<ans<<'\n';    
}


Measured memory_bytes: 67768
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        string a,b;
        cin>>a>>b;
        ll i,j,ans=1e6,p=0;
        for(i=0;i<=(ll)a.size()-(ll)b.size();i++)
        {
            p=0;
            for(j=0;j<(ll)b.size();j++)
            {
                if(a[j+i]!=b[j])
                    p++;
            }
            //cout<<i<<" "<<p<<endl;
            ans=min(ans,p);
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void)
{
    char N[3];
    scanf("%s",&N);
    if(N[0] == 'R'){
        if(N[1] == 'R'){
            if(N[2] == 'R'){
                printf("%d",3);
            }
            else printf("%d",2);
        }
        else printf("%d",1);
    }
    else if(N[1] == 'R'){
        if(N[2] == 'R'){
            printf("%d",2);
        }
        else printf("%d",1);
    }
    else if(N[2] == 'R'){
        printf("%d",1);
    }
    else printf("%d",0);
	return 0;
}

Measured memory_bytes: 1732