akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;
char expr[10000];
int main() {
    stack<long> S;
    cin.getline(expr, 10000);
    char* s = expr;
    while(1){
        if(*s == '\0')  break;
        if('0'<=*s && *s<='9'){
            S.push(strtol(s,&s,10));
            if (*s ==' ')  ++s;
        }else{
            long b=S.top();
        	S.pop();
            long a=S.top();
        	S.pop();
            long r=0;
            switch (*s){
            	case '+':
            	r=a+b;
            	break;
            	case '-':
            	r=a-b;
            	break;
            	case '*':
            	r=a*b;
            	break;
            }
        	++s;
        	if(*s==' ')  ++s;
            S.push(r);
        }
    }
    cout<<S.top()<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(void)
{
	int takasa[10];
	int a, i, j;
	
	for(i = 0; i < 10; i++)
	{
		scanf("%d", &takasa[i]);
	}
	
	for(i = 0; i < 10; i++)
	{
		for(j = 9; j > i; j--)
		{
			if(takasa[j] < takasa[j - 1])
			{
				a = takasa[j - 1];
				
				takasa[j - 1] = takasa[j];
				
				takasa[j] = a; 
			}
		}
	}
	
	for(i = 9; i > 6 ; i--)
	{
		printf("%d\n", takasa[i]);
	}
	
	return 0;
}

Measured memory_bytes: 600
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
a=ll()
xor=0
for i in a:
    xor^=i
for i in a:
    print(xor^i,end=" ")

Measured memory_bytes: 105924
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        int[] weights = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = kbd.nextInt();
        }
        int min = 10000000;
        int temp = 0;
        for (int i = 1; i < n; i++) {
            int d = diff(weights, i, n);
            if (min > d) {
                min = d;
                temp = i + 1;
            }
        }
        System.out.println(min);
    }

    static int diff(int[] weights, int ind, int n) {
        int s1 = 0;
        int s2 = 0;
        for (int i = 0; i < ind; i++) {
            s1 += weights[i];
        }
        for (int j = n - 1; j >= ind; j--) {
            s2 += weights[j];
        }
        return Math.abs(s1 - s2);
    }
}

Measured memory_bytes: 21716
"use strict"

function main(input) {
    const parsedInput = parser(input);
    console.log(minX(parsedInput.a, parsedInput.b, parsedInput.n));
}

function parser(inputStr) {
    const splitInput = inputStr.split(' ');
    return {
        a: Number(splitInput[0]),
        b: Number(splitInput[1]),
        n: Number(splitInput[2]),
    };
}

function minX(a, b, n) {
    if ( b - 1 < n ) {
        return Math.floor((a * (b - 1)) / b) - (a * Math.floor((b - 1) / b));
    } else {
        return Math.floor((a * n) / b) - (a * Math.floor(n / b));
    }
}
// test
// const Q1 = '5 7 4'
// const Q2 = '11 10 2000';
// main(Q1);
// main(Q2);
// main(Q2);
// main(Q3);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int n,k,r,s,p;
int tokuten(char te)
{
    if(te == 'r') return p;
    if(te == 's') return r;
    if(te == 'p') return s;
}

int main()
{
    cin >> n >> k >> r >> s >> p;
    string t;cin >> t;
    int len = (int)t.length();
    vector<char> choku(len);
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        if(i>=k)
        {
            if(t[i]==t[i-k])
            {
                if(choku[i-k]=='w')
                {
                    choku[i] = 'l';
                    continue;
                }else
                {
                    choku[i] = 'w';
                    ans += tokuten(t[i]);
                    continue;
                }
            }
        }
        choku[i] = 'w';
        ans += tokuten(t[i]);
    }
    cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int k = (i^j), c = 0;
      while (!(k>>c&1)) c++;
      cout << c+1 << ' ';
    }
    cout << endl;
  }
}


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

int main()
{
    char s[100005];
    while(cin >> s)
    {
        int len = strlen(s);
        if(len % 2 != 0)
        {
            if(s[0] == s[len - 1])
            cout << "Second" << endl;
            else
            cout << "First" << endl;

        }
        else
        {
            if(s[0] == s[len - 1])
            cout << "First" << endl;
            else
            cout << "Second" << endl;
        }
    }
    return 0;
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(M), B(M);
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i]; A[i]--, B[i]--;
    }
    ll ans = 0;
    for(int i = 0; i < M; i++){
        UnionFind tree(N);
        for(int j = 0; j < M; j++){
            if(i==j) continue;
            tree.unite(A[j], B[j]);
        }
        if(tree.root(A[i]) != tree.root(B[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main{
 public static void main (String[] args) throws java.lang.Exception
 {
 InputStreamReader is = new InputStreamReader(System.in);
 BufferedReader br = new BufferedReader(is);
  int x = Integer.parseInt(br.readLine());
  double a = (double)x;
  double kotae = Math.pow(a,3);
  int ans = (int)kotae;
  
  System.out.println(ans);
 }
}


Measured memory_bytes: 24308
#include<stdio.h>
#include<math.h>

long long calcf(long long x,long long y,long long z){

    return x*x + y*y + z*z + x*y + y*z +z*x;
}

int main (void){

    long long n,x,y,z;
    double rotN;
    long long count=0;
    long long N;

    scanf("%lld",&N);

    rotN=sqrt(N);

    for(n=1;n<=N;n++){
        if(n<6){
            printf("%lld\n",count);
            count=0;
            continue;
        }

        for(x=1;x<(int)rotN;x++){
            if(calcf(x,1,1)>n){
                continue;
            }
            for(y=1;y<(int)rotN;y++){
                if(calcf(x,y,1)>n){
                    continue;
                }
                for(z=1;z<(int)rotN;z++){
                    if(calcf(x,y,z)>n){
                        break;
                    }

                    if(calcf(x,y,z)==n){
                        count++;
                    }
                }
            }
        }
        printf("%lld\n",count);
        count=0;
    }



    return 0 ;

}

Measured memory_bytes: 2104
a, b, h, m = map(int, input().split())
import math

a_ang = (h/12 + (1/12)*(m/60))*2*math.pi
b_ang = (m/60)*2*math.pi
ax = a*math.cos(a_ang)
bx = b*math.cos(b_ang)
ay = a*math.sin(a_ang)
by = b*math.sin(b_ang)

x = ax - bx
y = ay - by
ans = (x**2+y**2)**0.5
print(ans)


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

using namespace std;

const long long INF = 1e11;

int main(){
	long long A, B, Q;
	cin >> A >> B >> Q;
	vector<long long> s(A + 2), t(B + 2), x(Q);
	for (long long i = 1; i <= A; i++){
		cin >> s[i];
	}
	for (long long i = 1; i <= B; i++){
		cin >> t[i];
	}
	s[0] = -INF;
	s[A + 1] = INF;
	t[0] = -INF;
	t[B + 1] = INF;

	for (long long i = 0; i < Q; i++){
		long long x;
		cin >> x;

		long long sindex = distance(s.begin(), lower_bound(s.begin(), s.end(), x));
		long long tindex = distance(t.begin(), lower_bound(t.begin(), t.end(), x));

		long long ans = INF;
		ans = min(ans, abs(s[sindex - 1] - x) + abs(t[tindex - 1] - s[sindex - 1]));
		ans = min(ans, abs(t[tindex - 1] - x) + abs(s[sindex - 1] - t[tindex - 1]));

		ans = min(ans, abs(s[sindex] - x) + abs(t[tindex - 1] - s[sindex]));
		ans = min(ans, abs(t[tindex - 1] - x) + abs(s[sindex] - t[tindex - 1]));
		
		ans = min(ans, abs(s[sindex - 1] - x) + abs(t[tindex] - s[sindex - 1]));
		ans = min(ans, abs(t[tindex] - x) + abs(s[sindex - 1] - t[tindex]));
		
		ans = min(ans, abs(s[sindex] - x) + abs(t[tindex] - s[sindex]));
		ans = min(ans, abs(t[tindex] - x) + abs(s[sindex] - t[tindex]));

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
use proconio::*;
use std::cmp::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        e: [(usize, usize); n - 1],
    }
    let mut ans = 0;
    for i in 1..=n {
        ans += i * (n + 1 - i);
    }
    for (a, b) in e {
        ans -= min(a, b) * (n + 1 - max(a, b));
    }
    println!("{}", ans);
}

fn main() {
    run();
}

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

int binarySearch(vector<int> &S, int x){
    int l = -1;
    int r = S.size()-1;
    while(r-l > 1){
        int c = (l+r)/2;
        if(x <= S[c]) r = c;
        if(x > S[c]) l = c;
    }
    return (S[r] == x ? 1 : 0);
}

int main(){
    int n, q, tmp;
    cin >> n;
    vector<int> S(n);
    for (int i=0;i<n;i++){
        cin >> S[i];
    }
    cin >> q;
    int tot = 0;
    for (int i=0;i<q;i++){
        cin >> tmp;
        tot += binarySearch(S, tmp);
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;


//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  return ((x * y) / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  vector<int> edge[200005];
  cin >> n;
  int a;
  rep(i, n - 1){
    cin >> a;
    edge[a].pu(i + 1);
  }
  reps(i, n){
    cout << edge[i].size() << '\n';
  }
  return 0;
}


Measured memory_bytes: 14500
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<int, int>
#define po pop_back
#define hell 1000000007
#define PI 3.1415926535897
using namespace std;

void solve(){
	int n;
	cin>>n;
	int temp;
	int a[n+1];
	memset(a,0,sizeof(a));
	for(int i=1;i<n;i++){
		cin>>temp;
		a[temp]++;
	}	
	for(int i=1;i<=n;i++) cout<<a[i]<<'\n';
}

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

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e13;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    long long n;
    scanf("%lld",&n);
    ll x,y;

    ll mix = INF;
    for(long long i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll x1 = n/i;
            ll y1 = n/(n/i);

            if(abs(x1-y1)<mix)
            {
                x = x1;
                y = y1;
            }
        }
    }
    cout<<x+y-2<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.nextLine();
        int N = sc.nextInt();
        int[] a = new int[N];
        double sum = 0;
        double ans = 101;
        int I = 0;
        //char[] c = str.toCharArray();
        //char[] W = {'x',' ','x',' ','x',' ','x'};
        for(int i = 0; i<N; i++){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        sum /= N;
        for(int i = 0; i<N; i++){
            if(ans > Math.abs(a[i]-sum)){
                ans = Math.abs(a[i]-sum);
                I = i;
            }
        }
        System.out.println(I);
    }
}


Measured memory_bytes: 23764
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let ab = get!(usize, usize; 3);

    let mut c = vec![0; 4];

    for (a, b) in ab {
        c[a - 1] += 1;
        c[b - 1] += 1;
    }

    c.sort();

    if c == &[1, 1, 2, 2] {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 8572
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
import math
A, B, H, M = mi()

M_ratio = (M * 12 /60) /12
H_ratio = H / 12 + M_ratio / 12
k = 360 * abs(H_ratio-M_ratio)
k = min(k, 360-k)
k = math.radians(k)
print(math.sqrt(A**2+B**2-(2*A*B)*math.cos(k)))

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

int main() {
 int a,b,c,d;
 cin >>a ;
  d = a%10 ;
  c = (a-d)/10%10 ;
  b =(a-d-10*c)/100%10;
  a =(a-d-10*c-100*b)/1000;
//  cout <<a<<b<<c<<d<<endl;
   bool finish =true;
  if((a+b+c+d) == 7 &&finish){
    cout <<  a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7;
    finish = false;
  }
  if((a+b+c-d) == 7 &&finish){
    cout << a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7;
     finish = false;
  }
  if((a+b-c+d) == 7 &&finish){
    cout <<  a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7;
     finish = false;
  }
  if((a+b-c-d == 7) &&finish){
    cout <<  a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7;
     finish = false;
  }
  if((a-b+c+d == 7) &&finish){
    cout << a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7;
     finish = false;
  }
  if((a-b+c-d == 7) &&finish){
    cout << a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7;
     finish = false;
  }
  if((a-b-c+d == 7) &&finish){
    cout <<  a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7;
     finish = false;
  }
  if((a-b-c-d == 7) &&finish){
    cout <<  a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7;
     finish = false;
  }
}
  

Measured memory_bytes: 256
l=bin(int(input()))[2:];n=len(l);print(n,2*n+l.count("1")-3)
for i in range(1,n):print(i,i+1,0);print(i,i+1,1<<(i-1))
w=1<<(n-1)
for i in range(1,n)[::-1]:
  if l[n-i]=="1":print(i,n,w);w+=1<<(i-1)

Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	var h, w, k int
	count := 0
	fmt.Scan(&h, &w, &k)
	c := make([]string, h, h)
	for i := range c {
		fmt.Scan(&c[i])
	}
	for i := 0; i < 1<<h; i++ {
		for l := 0; l < 1<<w; l++ {
			sharpNum := countSharp(c, i, l)
			if sharpNum == k {
				count++
			}
		}
	}
	fmt.Println(count)
}

func countSharp(c []string, h, w int) int {
	count := 0
	for i := 0; i < len(c); i++ {
		if (h >> i & 1) == 1 {
			continue
		}
		for k := 0; k < len(c[0]); k++ {
			if (w >> k & 1) == 1 {
				continue
			}
			if c[i][k] == '#' {
				count++
			}
		}
	}
	return count
}


Measured memory_bytes: 1768
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);
const lint MOD = 1000000007;

bool ascs(pair<pair<string, int>, int> l, pair<pair<string, int>, int> r) {
    if (l.first.first != r.first.first) {
        return l.first.first < r.first.first;
    } else {
        return l.first.second > r.first.second;
    }
}

int main(){
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> R(N);
    rep(i, N) {
        R[i].second = i;
        cin >> R[i].first.first >> R[i].first.second;
    }
    sort(R.begin(), R.end(), ascs);
    rep(i, N) cout << R[i].second+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;int tot;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();++i)
	 tot+=s[i]-'0';
	if(tot%9) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3724
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n, k;

int inp[N + N];

int Solve(){
  int ans = 1;
  if((inp[n] <= 0) & (k & 1)){
    for(int i = n; i >= 1 && k > 0; i--){
      ans = 1ll * ans * inp[i] % mod;
      ans += mod; ans %= mod;
      k--;
    }
    return ans;
  }
  int l = 1, r = n;
  if(k & 1){
    ans = 1ll * ans * inp[n] % mod;
    r = n - 1;
    k--;
  }
  while(k > 0){
    ll lft = 1ll * inp[l] * inp[l + 1];
    ll rgt = 1ll * inp[r] * inp[r - 1];
    if(rgt > lft){
      rgt %= mod;
      ans = 1ll * ans * rgt % mod;
      ans += mod; ans %= mod;
      r = r - 2;
    } else {
      lft %= mod;
      ans = 1ll * ans * lft % mod;
      ans += mod; ans %= mod;
      l = l + 2;
    }
    k -= 2;
  }
  return ans;
}

int main(){
  fastScan(n);
  fastScan(k);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
  }
  sort(inp + 1, inp + n + 1);
  printf("%d\n", Solve());
}


Measured memory_bytes: 4536
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
long long n,m;
struct qwq{
	long long mon,num;
};
qwq a[100005];
long long sum;
long long cmp(qwq a,qwq b){
	return a.mon<b.mon;
}
int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i].mon>>a[i].num;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		m-=a[i].num;
		if(m<=0){
			sum+=a[i].mon*(m+a[i].num);
			break;
		}
		else {
			sum+=a[i].mon*a[i].num;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,A[11];
map<vi,int> M[2];

void bfs(vi start,int mode){
	queue<vi> Q;
	Q.push(start);
	M[mode][start]=0;
	while(sz(Q)){
		vi v=Q.front();Q.pop();
		int d=M[mode][v];
		if(d==4)break;
		rep(i,N)rep2(j,i+1,N){
			vi w=v;
			rep2(k,i,j+1){
				w[k] = v[j-(k-i)];
			}
			if(M[mode].find(w)==M[mode].end()){
				M[mode][w]=d+1;
				Q.push(w);
			}
		}
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>A[i],A[i]--;
	
	vi v;
	rep(i,N)v.pb(A[i]);
	bfs(v,0);
	v.clear();
	rep(i,N)v.pb(i);
	bfs(v,1);
	int ans=9;
	foreach(it,M[0]){
		if(M[1].find(it->fir)!=M[1].end()){
			ans=min(ans,it->sec+M[1][it->fir]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 81200
#include<iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

 
int main(){
  int a,b,c,d;
  cin >> a>>b>>c>>d; 

  if(abs(b-a)<=d&&abs(c-b)<=d ||abs(c-a)<=d) cout << "Yes" <<endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	ll a, b;
	cin >> n >> a >> b;
	vector<ll> sx, hx;
	ll s;
	cin >> s;
	sx.push_back(0);
	hx.push_back(0);
	rep(i, n-1) {
		ll k;
		cin >> k;
		k -= s;
		if (k > 0) sx.push_back(k);
		else hx.push_back(k);
	}
	sort(sx.begin(), sx.end());
	sort(hx.rbegin(), hx.rend());
	ll ans;
	ll tor = 0, tol = 0;
	rep(i, sx.size() - 1) {
		if ((sx[i + 1] - sx[i]) * a < b) {
			tor += (sx[i + 1] - sx[i]) * a;
		}
		else tor += b;
	}
	rep(i, hx.size() - 1) {
		if ((hx[i] - hx[i+1]) * a < b) {
			tol += (sx[i] - sx[i+1]) * a;
		}
		else tol += b;
	}
	ans = min(2 * tor + tol, 2 * tol + tor);
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
	int ss;
	int s;
	int counter;

	scanf("%d", &ss);

	s = ss;

	while(s != 0)
	{
		counter += s%10;
		s = s -s%10;
		if(s!=0) s = s/10;
	}
	
	if(ss%counter == 0) printf("Yes");
	else if(ss%counter != 0) printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator<(const Puzzle &p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'}; // dir:direction

bool isTarget(Puzzle p) {
    for (int i = 0; i < N2; i++)
        if (p.f[i] != (i + 1)) return false;
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while (!Q.empty()) {
        u = Q.front();
        Q.pop();
        if (isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }

    return "unsolvable";
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Puzzle in;

    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;  // set space
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;
}


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

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrep1(i, n) for (int i = ((int)(n)); i > 0; --i)
#define sz(x) ((int)(x).size())
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define pb push_back

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<double>    vd;
typedef vector<long long> vl;

// template<class T>bool maxc(T &a, const T &b) { if (a<b) { a=b; return 1; } }
// template<class T>bool minc(T &a, const T &b) { if (b<a) { a=b; return 1; } }

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

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

    // 入力
    int l, r;
    cin >> l >> r;

    // 処理
    int a, b;
    int ans = 2019;
    for (int i = l; i < r; i++) {
        for (int j = l + 1; j <= r; j++) {
            a   = i % 2019;
            b   = j % 2019;
            ans = min(ans, (a * b) % 2019);
            if (ans == 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    // 出力
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int K;
int dp[301][301][301];
main()
{
	cin>>s>>K;
	int N=s.size();
	for(int i=0;i<=N;i++)for(int k=0;k<=N;k++)for(int j=0;j<=K;j++)dp[i][k][j]=-1e9;
	dp[0][N-1][K]=0;
	int ans=0;
	for(int i=0;i<N;i++)for(int j=N-1;j>=0&&j>=i-1;j--)for(int k=0;k<=K;k++)
	{
		if(dp[i][j][k]<0)continue;
		ans=max(ans,dp[i][j][k]+(i<=j));
		dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
		if(j>0)dp[i][j-1][k]=max(dp[i][j-1][k],dp[i][j][k]);
		if(i<j)dp[i+1][j-1][k-(s[i]!=s[j])]=max(dp[i+1][j-1][k-(s[i]!=s[j])],dp[i][j][k]+2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 106752
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const char unit[] = { 'm', 'c', 'x', 'i' };
const int  u[] = { 1000, 100, 10, 1 };
int ston (string s )
{
	int n = s.length();	
	int res = 0;
	rep (i, 4 ){
		string::size_type p;
		if ((p = s.find (unit[i] ) ) != string::npos ){
			if (p > 0 && isdigit(s[p-1] ) ){
				res += (int)(s[p-1] - '0')*u[i];
			}else{
				res += u[i];
			} // end if
		} // end if
	} // end rep
	if (isdigit(s[n-1] ) ){
		res += (int)(s[n-1] - '0' );
	} // end if
	
	return res;
}

string itos (int n )
{
	string res = "";

	int m = n/1000;
	int c = (n/100 % 10);
	int x = (n/10 % 10);
	int i = n % 10;
	
	if (m != 0 ){
		if (m != 1 ) res += (char)(m+'0');
		res += 'm';
	} // end if
	if (c != 0 ){
		if (c != 1 ) res += (char)(c+'0');
		res += 'c';
	} // end if
	if (x != 0 ){
		if (x != 1 ) res += (char)(x+'0');
		res += 'x';
	} // end if
	if (i != 0 ){
		if (i != 1 ) res += (char)(i+'0');
		res += 'i';
	} // end if

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.NS", "r", stdin );
	int n;
	scanf ("%d", &n );
	while (n-- ){
		string ex1 = "", ex2 = "";
		cin >> ex1 >> ex2;

		int m1 = ston (ex1 ), m2 = ston (ex2 );
		int add = m1 + m2;
		string res = itos (add );

		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
using namespace std;
//R := >
//L := <
int cntR[100000];
int cntL[100000];

int main(){
    string S;
    int N;
    cin>>N;
    cin>>S;
    cntR[0]+=S[0]=='>';
    cntL[0]+=S[0]=='<';
    for(int i=1;i<N;i++){
        cntR[i]=cntR[i-1]+(S[i]=='>');
        cntL[i]=cntL[i-1]+(S[i]=='<');
    }
    int ans = 0;
    for(int i=0,idx=0;i<N;i++){
        while(cntL[idx]-cntL[i]<cntR[i]&&idx<N)idx++;
        if(idx==N) break;
        ans = max(ans,idx+1);
    }
    for(int i=N-1,idx=N-1;i>=0;i--){
        while(cntR[i]-(idx?cntR[idx-1]:0)<cntL[N-1]-cntL[i]&&idx>=0)idx--;
        if(idx<0) break;
        ans = max(ans,N-idx);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

const int N=2e5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,p;
	string s;
	cin>>n>>p>>s;
	ll ans=0;
	if(p==2){
		for(int i=0;i<n;++i){
			if((s[i]-'0')%2==0){
				ans+=i+1;
			}
		}
	}
	else if(p==5){
		for(int i=0;i<n;++i){
			if((s[i]-'0')%5==0){
				ans+=i+1;
			}
		}
	}
	else{
		vector<int> num(n+1);
		ll pow10=1;
		for(int i=n-1;i>=0;--i){
			int now=s[i]-'0';
			num[i]=(pow10*now+num[i+1])%p;
			pow10=(pow10*10)%p;
		}
		map<int,ll> num_appears;
		for(int i=n;i>=0;--i){
			ans+=num_appears[num[i]];
			//~ cout<<num_appears[num[i]]<<endl;
			++num_appears[num[i]];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1812
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BCanYouSolveThis {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), c = in.nextInt();

            int[] b = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = in.nextInt();
            }

            int answer = 0;
            for (int test = 0; test < n; test++) {
                int sum = c;
                for (int i = 0; i < m; i++) {
                    int a = in.nextInt();
                    sum += a * b[i];
                }
                if (sum > 0) {
                    answer++;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
/// Author: Wang, Yen-Jen
#include <bits/stdc++.h>

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int i = 0; i + 1 < (int)S.size(); i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long

ll gcd(ll x, ll y) {
	ll r;

	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}

ll lcm(ll x, ll y) {
	if (x < y) return (x / gcd(y, x) * y);
	else return (x / gcd(x, y) * y);
}

int main()
{
	int N;
	ll T[101];
	ll ans;

	cin >> N;
	REP(i, 0, N) {
		cin >> T[i];
	}

	if (N == 1) cout << T[0] << endl;
	else {
		ans = lcm(T[0], T[1]);
		REP(i, 2, N) {
			ans = lcm(ans, T[i]);
		}

		cout << ans << endl;
	}

	return 0;
}

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

using namespace std ; 

int main () { 
	bool dis[10] ; 
	for ( int i = 0 ; i < 10 ; i ++ ) 
		dis[i] = false ; 
		
	int pay , k , a ; 
	
	cin >> pay >> k ; 
	for ( int i = 0 ; i < k ; i ++ ) {
		cin >> a ; 
		dis[a] = true ; 
	}
	while (true) { 
		int sol = pay ;
		bool check = true ; 
		while(sol) {
			if ( dis[sol%10] ) {
				check = false ; 
				break ; 
				}
			sol /= 10 ; 		
		}
		if (check){
			cout << pay << endl ;
			return 0 ; 
		} 
		pay ++ ;
		
	}
	
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
	int N,C;
	cin>>N>>C;
	int program[C+1][110000];
	fx(C+1){
		fy(110000){
			program[x][y]=0;
		}
	}
	fx(N){
		int s,t,c;
		cin>>s>>t>>c;
		program[c][s-1]++;
		program[c][t]--;
	}
	
	fx(C+1){
		fyg(110000,1){
			program[x][y]+=program[x][y-1];
		}
	}
	
	int ans=0;
	fy(110000){
		int sum=0;
		fx(C+1){
			if(program[x][y]>0){program[x][y]=1;}
			sum+=program[x][y];
		}
		ans=max(ans,sum);
	}
	ce(ans)
}

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

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s;
ll n,m;
ll arr[500000];
ll brr[500000];

int main()
{__
        ll i,j,a,b;
        cin>>n;

        for(i=0,j=0;i<n;i++){
            cin>>m;
            if(m==j+1) j++;
        }
        if(j!=0)
        cout<<n-j<<endl;
        else cout<<-1<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

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

    return 0;
}


Measured memory_bytes: 3592
import numpy as np
import sys

N, K = map(int, input().split())
K2 = K * 2
Mij = [[0 for _ in range(K2 + 1)] for _ in range(K2 + 1)]

def imos(i1, j1, i2, j2):
    Mij[i1][j1] += 1
    Mij[i1][j2] -= 1
    Mij[i2][j1] -= 1
    Mij[i2][j2] += 1

for _ in range(N):
    i, j, s = sys.stdin.readline().split()
    i = int(i) % K2
    j = int(j) % K2
    if s == "B":
        i = (i + K) % K2
    i1 = i % K
    j1 = j % K
    if (i < K and j < K) or (K <= i and K <= j):
        imos(0, 0, i1, j1)
        imos(0, j1 + K, i1, K2)
        imos(i1 + K, 0, K2, j1)
        imos(i1 + K, j1 + K, K2, K2)
        imos(i1, j1, i1 + K, j1 + K)
    else:
        imos(0, j1, i1, j1 + K)
        imos(i1 + K, j1, K2, j1 + K)
        imos(i1, 0, i1 + K, j1)
        imos(i1, j1 + K, i1 + K, K2)

# 累積和
Mij = np.array(Mij)
for x in range(K2):
    Mij[:, x + 1] += Mij[:, x]
for y in range(K2):
    Mij[y + 1, :] += Mij[y, :]
print(Mij.max())

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

const long long MAX = 2000001;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long jouyo(long long a, long long mod){
    if(a>=0){
        return a%mod;
    }else{
        return (a+(abs(a)/mod+1)*mod)%mod;
    }
}

int main(){
    COMinit();
    long long K;
    cin >> K;
    string S;
    cin >> S;
    long long N=S.length();
    long long nigobe[2000000+1];
    nigobe[0]=1;
    long long i;
    for(i=1; i<=2000000; i++){
        nigobe[i]=25*nigobe[i-1];
        nigobe[i]%=MOD;
    }
    long long ans=0;
    for(i=N; i<=N+K; i++){
        ans += COM(N+K,i)*nigobe[N+K-i];
        ans %= MOD;
    }

    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 66936
import kotlin.math.pow

fun main()
{
  val n = readLine()!!.toLong() - 1

  // 文字列長を求める
  var keta = 0
  var k: Long = 0
  while (true) {
    var tmp: Long = 1;
    for (x in 0..keta) tmp *= 26
    k += tmp
    keta++
    if (k > n) break
  }

  // その桁内で何番目かを求める
  var idx = n
  for (b in 1..keta-1) {
    var tmp: Long = 1
    for (x in 1..b) tmp *= 26
    idx -= tmp
  }
  //println("keta: $keta")
  //println("idx: $idx")

  // 26進数とみなして変換
  val alphabets = ('a'..'z').toList()
  val s = mutableListOf<Char>()
  for (x in 1..keta) {
    s.add(alphabets[(idx % 26).toInt()])
    idx = ((idx - (idx % 26)) / 26)
  }
  println(s.asReversed().joinToString(""))
}


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

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> res;
  for(int i=2;i*i<=n;i++) {
    while(n%i==0) {
      res[i]++;
      n/=i;
    }
  }
  if(n!=1) {
    res[n]++;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << n << ":";
  map<ll,ll> ans=prime_factor(n);
  for(auto p:ans) {
    ll count=p.second;
    ll out=p.first;
    while(count) {
      cout << " " << out;
      count--;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3112
import itertools
N, M, X = [int(_) for _ in input().split()]
B = []
for i in range(N):
    B.append([int(_) for _ in input().split()])
l = [i for i in range(N)]
NUM = (10**5) * 12 + 1
ans = NUM
for i in range(1, N+1):
    C = itertools.combinations(l, i)
    for c in C:
        amount = 0
        U = [0 for i in range(M)]
        for k in range(i):
            amount += B[c[k]][0]
            for j in range(M):
                U[j] += B[c[k]][j+1]
        if min(U) >= X:
            ans = min(ans, amount)
if ans == NUM:
    print(-1)
else:
    print(ans)


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<pair<int, int>> red;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		red.emplace_back(x, y);
	}

	vector<pair<int, int>> blue;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		blue.emplace_back(x, y);
	}

	sort(red.begin(), red.end());
	sort(blue.begin(), blue.end());

	vector<bool> used(n);
	int ans = 0;
	for (auto b : blue) {
		int maxY = -1;
		int maxYIndex = 0;
		for (int i = 0; i < n; i++) {
			if (used[i] 
				|| red[i].first >= b.first
				|| red[i].second >= b.second) {
				continue;
			} else if (maxY < red[i].second) {
				maxY = red[i].second;
				maxYIndex = i;
			}
		}

		if (maxY != -1) {
			ans++;
			used[maxYIndex] = true;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256