akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <functional>
using namespace std;

template<class Type>
Type Syakutori(int st,int en,Type init,function<bool(int)> condition,function<void(int)> rightUpdate,function<Type(int,int,Type)> ansUpdate,function<void(int)> leftUpdate){
  int r = st;
  Type ans = init;
  for(int l = st;l < en;l++){
    while(r < en && condition(r)){
      rightUpdate(r);
      r++;
    }
    ans = ansUpdate(l,r,ans);
    if(l == r){
      r++;
    }
    else{
      leftUpdate(l);
    }
  }
  return ans;
}

int N;
i64 A[202020];

int main(){
  cin >> N;
  rep(i,0,N - 1){
    cin >> A[i];
  }
  i64 now = 0;
  cout << Syakutori<i64>(0,N,0LL,
      [&](int r){return (now & A[r]) == 0;},
      [&](int r){now |= A[r];},
      [&](int l,int r,i64 a){return a + r - l;},
      [&](int l){now &= ~A[l];}) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

struct char_len{
	char c;
	int num;
};

int main(){
	
	vector<char_len> v;
	
	string str;
	
	cin >> str;
	
	char c1 = str[0];
	int num1 = 1;
	int count = 0;
	char_len p1;
	for(int i = 1; i < str.size(); i++){
		if(str[i] == c1){
			num1++;
		}else{
			p1.c = c1;
			p1.num = num1;
			v.push_back(p1);
			count++;
			c1 = str[i];
			num1 = 1;
		}
	}
	p1.c = c1;
	p1.num = num1;
	v.push_back(p1);
	count++;
	
	int ans = 0;
	
	for(int i = 0; i < count - 2; i++){
		if(v.at(i).c == 'J' && v.at(i + 1).c == 'O' && v.at(i + 2).c == 'I' && v.at(i).num >= v.at(i + 1).num && v.at(i + 1).num <= v.at(i + 2).num && v.at(i + 1).num > ans){
			ans = v.at(i + 1).num;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 11308
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
using namespace std;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}
int main() {
     InitRand();
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n,a;
    cin>>n>>a;
    int tmp;
    tmp=n%500;
    if(tmp<=a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

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

	int M, D;
	cin >> M >> D;

	int ans = 0;
	for (int m = 1; m <= M; ++m)
	for(int d1 = 2; d1 <= 9; ++d1)
		for(int d2 = 2; d2 <= 9 ; ++d2)
			if(d1 * 10 +d2 <= D &&d1 * d2 == m)
				ans++;
	cout << ans;
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;cin>>d;
    int c[26],last[26];
    rep(i,26)cin>>c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    vector<int> t(d);
    rep(i,d)cin>>t[i],t[i]--;
    rep(i,26)last[i]=-1;

    int S = 0,score = 0;

    rep(i,d){
      S += s[i][t[i]];
      last[t[i]] = i;
      rep(j,26)S -= c[j]*(i - last[j]);
      score += max((int)1e6 + S,0);
      cout<<S<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define fi first;
#define se second;

ll pref[300002];
map <ll,ll> x;
int main() {
    //ios_base::sync_with_stdio(0);
    //cout<<setprecision(20);
    ll n;
    cin>>n;
    ll a[300000];
    pref[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        pref[i+1]=pref[i]+a[i];
    }
    ll ans=0;
    for(int i=n;i>=0;i--){
        ans+=x[pref[i]];
        x[pref[i]]++;
        //cout<<ans<<" " ;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	
  	for (int i = 0; i < N; i++) {
    	string S;
      	cin >> S;
      
      if (S == "Y") {
      	cout << "Four" << endl;
        break;
      }
      else if (i == N-1) {
      	cout << "Three" << endl;
        break;
      }
      else {}
    
    }
 
}

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

int main() {
    int r, c;
    cin >> r >> c;
    int xs[c];
    for (int i = 0; i <= c; i++) xs[i] = 0;
    for (int i = 0; i < r; i++) {
        int sum = 0;
        for (int j = 0; j < c; j++) {
            int x;
            cin >> x;
            cout << x << ' ';
            sum += x;
            xs[j] += x;
        }
        cout << sum << endl;
        xs[c] += sum;
    }
    for (int i = 0; i < c; i++) {
        cout << xs[i] << ' ';
    }
    cout << xs[c] << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#define LL long long
#define front top
using namespace std;
const double PI = acos(-1.0);

int smax(int ary[]) {
	int m = 0;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (m < ary[i]) m = ary[i];
	return m;
}

int nmax(int ary[]) {
	int max = 0, num;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) {
			max = ary[i];
			num = i;
		}
	return max, num;
}

bool dfs(int q, int value) {
	return false;
}

int max2(int a, int b) {
	if (a < b) a = b;
	return a;
}

int min2(int a, int b) {
	if (a > b) a = b;
	return a;
}

int max3(int a, int b, int c) {
	return max2(a, max2(b, c));
}

int min3(int a, int b, int c) {
	return min2(a, min2(b, c));
}

LL a[2000000];

int main() {
	LL n, min = 3000000000000000;
	LL sum = 0, com = 0, back, ans;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n; i++)
		sum += a[i];
	back = sum;
	for (int i = 0; i < n - 1; i++) {
		com += a[i];
		back -= a[i];
		if (min > abs(back - com)) {
			min = abs(back - com);
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	int a, b, c, k;
	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);
	while (k > 0 && a >= b) {
		b *= 2;
		k--;
	}
	// printf("%d\n", k);
	while (k > 0 && b >= c) {
		c *= 2;
		k--;
	}
	if (a < b && b < c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

vector < vector <int> > V;

int h_max;
int w_max;

void solve( int h, int w )
{
	V[h][w] = 0;
	for ( int i = -1; i < 2; i++ )
	{
		for ( int j = -1; j < 2; j++ )
		{
			if ( i == 0 && j == 0 )
				continue;

			if ( h+i >= 0 && h+i < h_max )
			{
				if ( w+j >= 0 && w+j < w_max )
				{
					if ( V[h+i][w+j] == 1 )
					{
						solve( h+i, w+j );
					}
				}
			}

		}
	}
}

int main ( void )
{
	while (1)
	{
		int w, h;
		cin >> w >> h;
		if ( w == 0 && h == 0 )
			break;

		h_max = h;
		w_max = w;
		V = vector < vector <int> > ( h_max, vector <int>(w_max,0) );

		for ( int i = 0; i < h; i++ )
		{
			for ( int j = 0; j < w; j++ )
			{
				int info;
				cin >> info;
				V[i][j] = info;
			}
		}

		int kotae = 0;
		for ( int i = 0; i < h; i++ )
		{
			for ( int j = 0; j < w; j++ )
			{
				if ( V[i][j] == 1 )
				{
					kotae++;
					solve( i, j );
				}
			}
		}

		cout << kotae << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[2][110];
    rep(i, 0, 2){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }
    rep(i, 1, n){
        a[0][i] += a[0][i - 1];
    }
    repb(i, n - 2, 0){
        a[1][i] += a[1][i + 1];
    }
    int ans = 0;
    rep(i, 0, n){
        int tmp = a[0][i] + a[1][i];
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

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

const int mod = 1e9+7;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
const int maxn=1e6+10;


int main()
{
   int n; cin >> n;
   string a, b; cin >> a >> b;
   for(int i = 0; i < n; i++) {
    cout << a[i] << b[i];
   }
   cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int isprime(int x) {
    if (x == 2)
    return 1;

    if (x < 2 || x % 2 == 0)
    return 0;

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


int main()
{
    int x, box[10000],  n, k, ans = 0, m=0;

    scanf("%d", &n);
    for (k = 0; k < n; k++)
        scanf("%d", &box[k]);

    for (x = 0; x < n; x++) {
        ans = isprime(box[x]);

            if (ans == 1)
            m++;

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

Measured memory_bytes: 1828
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nc = readln.split.to!(long[]);
    auto N = nc[0];
    auto C = nc[1];
    long[] xs, vs;
    foreach (_; 0..N) {
        auto xv = readln.split.to!(long[]);
        xs ~= xv[0];
        vs ~= xv[1];
    }

    auto rs = new long[](N);
    auto ls = new long[](N);
    long m, s;
    foreach (i; 0..N) {
        s += vs[i];
        rs[i] = max(i == 0 ? 0 : rs[i-1], s - xs[i]);
    }
    m = 0; s = 0;
    foreach_reverse (i; 0..N) {
        s += vs[i];
        ls[i] = max(i == N-1 ? 0 : ls[i+1], s - C + xs[i]);
    }

    long r;
    foreach (i; 0..N) {
        r = max(r, rs[i]);
        r = max(r, ls[i]);
        if (i < N-1) r = max(r, rs[i] - xs[i] + ls[i+1]);
        if (i > 0) r = max(r, ls[i] - C + xs[i] + rs[i-1]);
    }
    writeln(r);
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int happy = 0;
    rep(i,N - 1){
        if (S[i] == S[i + 1]){
            happy++;
        }
    }
    cout << min(happy + K * 2, N - 1) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
struct Edge{
    int to;
    int id;
};

vector<Edge> g[100005];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(Edge{b,i});
        g[b].push_back(Edge{a,i});
    }
    queue<int> q;
    q.push(0);
    vector<int> color(n,-1);
    vector<int> pre(n+1,-1);
    while(!q.empty()){
        int c=q.front();q.pop();
        int tempc=1;
        for(Edge item:g[c]){
            if(color[item.id]>0) continue;
            if(tempc==pre[c]) tempc++;
            pre[item.to]=tempc;
            color[item.id]=tempc;
            tempc++;
            q.push(item.to);
        }
    }
    cout<<*max_element(color.begin(),color.end())<<endl;
    for(int i=0;i<n-1;i++){
        cout<<color[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 7424
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
ostream &operator<<(ostream &os, const vector<lint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<lint> cal(vector<lint> x){
	int rank=0;
	rep(i,63){
		if(rank>=x.size()) break;
		REP(j,rank,x.size()){
			if((x[j]&(1L<<i))) swap(x[rank],x[j]);
		}
		if(!(x[rank]&(1L<<i))) continue;
		rep(j,x.size()){
			if(j==rank) continue;
			if((x[j]&(1L<<i))) x[j]^=x[rank];
		}
		rank++;
	}
	REP(i,rank,x.size()){
		assert(x[i]==0L);
	}
	/*rep(i,rank) REP(j,i+1,rank){
		assert((x[i]&x[j])==0L);
	}*/
	//x.resize(rank);
	//return x;
	vector<lint> ret;
	rep(i,rank){
		//assert(x[i]>0L);
		ret.pb(x[i]);
	}
	return ret;
}
bool ng(lint y,vector<lint> x){
	int rank=0;
	rep(i,x.size()){
		while(!(x[i]&(1L<<rank))) rank++;
		if((y&(1L<<rank))>0L) y^=x[i];
		rank++;
	}
	//cout<<y<<endl;
	if(y>0L) return true;return false;
}
lint a[252];string s;
int ca(){
	int n;cin>>n;
	rep(i,n) cin>>a[i];
	cin>>s;
	vector<lint> x,y;
	//if(s[n-1]=='1') return 1;
	int now=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='0'){
			x.pb(a[i]);x=cal(x);
			//cout<<x<<endl;
		}
		else{
			y.pb(a[i]);y=cal(y);
			rep(j,y.size()){
				if(ng(y[j],x)) return 1;
			}
		}
	}
	return 0;
}
int main()
{
	int t;cin>>t;rep(i,t) cout<<ca()<<endl;
}


Measured memory_bytes: 3512
//code by lynmisakura.wish to be accepted
/****************************/
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
	
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/***************************/
int a[200010];
int b[200010];
int main(void){
	int n;cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = n;i >= 1;i--){
		if(i * 2 > n){
			b[i] = a[i];
		}else{
			int cnt = 0;
			int j = i * 2;
			while(j <= n){
				cnt += b[j];
				j += i;
			}
			b[i] = abs((cnt % 2) - a[i]);
		}
	}
	int m  = 0;
	for(int i = 1;i <= n;i++) if(b[i] == 1) m++;
	cout << m << endl;
	for(int i = 1;i <= n;i++) if(b[i] == 1) cout << i << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	std::string s,t;
	std::cin >> s >> t;
	std::vector<std::vector<int> > dp(s.size()+1,std::vector<int>(t.size()+1,0));
	rep(i,s.size())rep(j,t.size()) {
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
	}
	std::string lcs = "";
	int x = s.size();
	int y = t.size();
	while(true) {
		if(dp[x][y]==0) break;
		if(s[x-1]==t[y-1]) {
			lcs = s[x-1] + lcs;
			x--; y--;
		} else {
			if(dp[x-1][y]>=dp[x][y-1]) {
				x--;
			} else {
				y--;
			}
		}
	}
	print(lcs);
  return 0;
}


Measured memory_bytes: 70784
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		if(x<a)
		System.out.println("0");
		else
		System.out.println("10");
	}
}

Measured memory_bytes: 22484
from bisect import bisect_left

N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
l = 0
r = 2*10**5+5


while l+1 < r:
    mid = (l+r) // 2
    
    m = 0
    for a in A:
        idx = bisect_left(A, mid-a)
        m += N-idx
        
    if m >= M: l = mid
    else: r = mid

s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]
    
ans = 0
m = 0
for a in A:
    idx = bisect_left(A, l-a)
    m += N-idx
    
    ans += s[N]-s[idx]
    ans += a*(N-idx)
    
ans -= (m-M)*l

print(ans)

Measured memory_bytes: 14140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using vvp = vector<vector<P>>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll n, m, r;
    cin >> n >> m >> r;
    
    ll a, b, c;
    vvp e(n);
    REP(i, m) {
        cin >> a >> b >> c;
        e[a].push_back({b, c});
    }

    vll res(n, inf);
    res[r] = 0;

    min_priority_queue<P> que;
    que.push({0, r});
    ll cur, mem;
    while (!que.empty()) {
        mem = que.top().first, cur = que.top().second;
        que.pop();
        for (auto ee : e[cur]) {
            ll to = ee.first, w = ee.second;
            if (chmin(res[to], res[cur] + w)) {
                que.push({res[to], to});
            }
        }
    }
    REP(i, n) {
        if (res[i] == inf) cout << "INF" << endl;
        else cout << res[i] << endl;
    }
    return 0;
}


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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long a,b,c=0,k,d=0,i,n,j,ans,temp,p,m,ex1,ex2,ex3,ex4,x,y;
	    string s;
	    cin>>s;
	    if(s.length()==1)
	    {
	        cout<<0;
	        return 0;
	    }
	    for(i=1;i<s.length();i++)
	    {
	        if(s[i]!=s[i-1])
	        c++;
	    }
	    for(i=s.length()-2;i>=0;i--)
	    {
	        if(s[i]!=s[i+1])
	        d++;
	    }
	    cout<<min(c,d);
    }
    
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  
  ll ans = a[N/2] - a[N/2-1];
  // bool ok = false;

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4036
/*
  AtCoder Beginner Contest 095
  C - Half and Half
*/

#include<iostream>
#include<cmath>
using namespace std;

int A, B, C, X, Y;

int main() {
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

  long long sum = 0;

  if (A + B <= 2 * C) { // 個別に買う方がコスパがいい場合
    sum = A * X + B * Y;
  }
  else {                // ABピザの方がコスパがいい場合
    if (X < Y) {
      sum = 2 * C * X + B * (Y - X);
      if (sum > 2 * C * Y) sum = 2 * C * Y;
    }
    else {
      sum = 2 * C * Y + A * (X - Y);
      if (sum > 2 * C * X) sum = 2 * C * X;
    }
  }

  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;


int main(void){
  int n;
  int a_;
  vector<int> buf;
  int buf2[3] = {0,0,0};
  int ret = 0;

  for(int i = 0; i <= 100000; i++){
    buf.push_back(0);
  }

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

  for(int i = 0; i <= 100000; i++){
    // 0 -> 0, 1 -> 1, 2 -> 2, 3 -> 1, 4 -> 2,  5 -> 1
    if(buf[i] != 0){
      if(buf[i] % 2){
        buf[i] = 1;
      }else{
        buf[i] = 2;
      }
    }
    buf2[buf[i]] += 1;
  }

  //buf2 0 -> 0, 1->1, 2->0(buf2[1]+=2), 3->1 (buf2[1]+=2),
  buf2[1] += buf2[2]/2*2;
  buf2[2] -= buf2[2]/2*2;

  cout << buf2[1] << "\r\n";
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int N, K;
int const NMAX = 5005;
bool dp1[NMAX][NMAX];
bool dp2[NMAX][NMAX];
int main() {
  cin >> N >> K;
  vector<int> a(N+1);
  for (int i=1; i<=N; i++) {
    cin >> a.at(i);
  }

  rep(i, NMAX) {
    rep(j, NMAX) {
      dp1[i][j] = false;
      dp2[i][j] = false;
    }
  }

  dp1[0][0] = true;
  dp2[0][0] = true;
  for (int i=1; i<=N; i++) {
    for (int j=K; j>=0; j--) {
      if (j >= a.at(i)) {
        dp1[i][j] = dp1[i - 1][j] || dp1[i - 1][j - a.at(i)];
      } else {
        dp1[i][j] = dp1[i-1][j];
      }
    }
  }
  for (int i=1; i<=N; i++) {
    for (int j=K; j>=0; j--) {
      if (j >= a.at(N-i+1)) {
        dp2[i][j] = dp2[i - 1][j] || dp2[i - 1][j - a.at(N-i+1)];
      } else {
        dp2[i][j] = dp2[i-1][j];
      }
    }
  }

  int ans = 0;
  for (int i=1; i<=N; i++) {
    bool found = false;
    if (a.at(i) >= K) {
      continue;
    }

    int pos2 = 0;
    for (int j=K-1; j>=0; j--) {
      if (dp1[i-1][j]) {
        for (int k=max(pos2, K-j-a.at(i)); k<=K-j-1; k++) {
          if (k < 0) {
            continue;
          }
          if (dp2[N-i][k]) {
            found = true;
            break;
          }
        }
        pos2 = K-j;
      }
      if (found) {
        break;
      }
    }

    if (!found) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 49152
antennas = []
for _ in range(5):
  a = int(input())
  antennas.append(a)
k = int(input())
cannot_communicate_pair_exists = False
for i in range(len(antennas)):
  for q in range(len(antennas)):
    if i == q:
      continue
    if abs(antennas[i]-antennas[q]) > k:
      cannot_communicate_pair_exists = True
      break
  if cannot_communicate_pair_exists:
    break
if cannot_communicate_pair_exists:
  print(":(")
else:
  print("Yay!")

Measured memory_bytes: 3060
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(1, N+1):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))


Measured memory_bytes: 27528
#include <stdio.h>

int main(){
    int a, b, n, s;
    
    while(scanf("%d %d %d", &a, &b, &n) != EOF){
        s = 0;
            
        while(n--)
            s += (a = 10 * (a % b)) / b;
        
        printf("%d\n", s);
    }
    
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    int n;
    int r,g,b;
    
    cin >> r >> g >> b >> n;
    
    long long ans = 0;
    
    for (int i = 0;i <= n/r;i++){
        for (int j = 0;j <= n/g;j++){
            if (i*r+j*g <= n && (n-i*r-j*g)%b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	string ans="";
	cin >>s;
	for(int i=0;i<s.size()-8;i++){
		ans+=s[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
// #include <map>
// #include <string>

using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n; cin>>n;

    int paid=0;
    while(paid<n){
        paid+=1000;
    }
    cout<<paid-n;
    return 0;
}

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

bool is_prime[1000000+1];
void prime(int n){
	for(int i=0;i<n+1;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<n+1;i++){
		if(is_prime[i]==true){
			for(int j=i+i;j<n+1;j+=i){
				is_prime[j] = false;
			}
		}
	}
}

int main()
{
	int n,m;
	prime(1000000);
	while(cin >> n >> m){
		if(!n && !m)
			break;
		bool DP[1000000+1];
		for(int i=0;i<m+1;i++)
			DP[i] = false;
		DP[0] = true;
		int ryori;
		for(int i=0;i<n;i++){
			cin >> ryori;
			for(int j=0;j<m+1-ryori;j++)
				if(DP[j])
					DP[j+ryori] = true;
		}		
		
		for(int i=m;i>=0;i--){
			if(is_prime[i] && DP[i]){
				cout << i << endl;
				break;
			}
			else if(i==0){
				cout << "NA" << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

//DP[i][j] = placed i pieces,  of n-i left, (0 to j) are greater than last placed
ll DP[3010][3010];
ll MOD = 1e9+7;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n; string s;
	cin >> n >> s;
	
	DP[n][0] = 1;

	for(int i = n-1; i > 0; i--) {
		for(int j = 0; j <= n - i; j++) {
			if(j == 0) DP[i][j] = 0;
			else DP[i][j] = DP[i][j-1];

			if(s[i-1] == '<') {
				if(j != 0) DP[i][j] += DP[i+1][j-1];
			} else {
				DP[i][j] += DP[i+1][n-i-1];
				if(j != 0) DP[i][j] -= DP[i+1][j-1];
			}
			DP[i][j] += MOD;
			DP[i][j] %= MOD;

		}
	}
	finish(DP[1][n-1] % MOD);
}


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

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



  for(i=1;i<n;i++){
    ans[a[i]-1]++;
  }
  for(i=0;i<n;i++){
    printf("%d\n",ans[i]);
  }
}


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

const int INF = 1 << 29;

// グラフ
using Edge = pair <int, ll>;  // {重み, 行き先}
using Graph = vector<vector<Edge>>; // グラフ

// 使われうる辺集合
set<pair<int, int>> use;

vector<ll> dijkstra(const Graph &G, int s){
  vector<ll> dist((int)G.size(), INF);
  vector<vector<int>> prev((int)G.size()); // prev[v] := v から復元できる辺たち
  dist[s] = 0;
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
  que.push(make_pair(0, s));
  while(!que.empty()) {
    auto cur = que.top(); que.pop();
    ll cur_dist = cur.first;
    int v = cur.second;
    if(cur_dist > dist[v]) continue; //枝狩り
    for(auto e : G[v]) {
      if(dist[e.first] > dist[v] + e.second){
        dist[e.first] = dist[v] + e.second;
        que.push(make_pair(dist[e.first], e.first));

        //経路復元のためのもの
        prev[e.first].clear();
        prev[e.first].push_back(v);
      }else if(dist[e.first] == dist[v] + e.second){
        prev[e.first].push_back(v);
      }
    }
  }
  for (int i = 0; i < (int)G.size(); i++){
    for(auto u : prev[i]){
      use.insert(make_pair(min(u,i), max(u,i)));
    }
  }
  return dist;
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  rep(i,m){
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(Edge(b,c));
    G[b].push_back(Edge(a,c));
  }
  rep(v, n) dijkstra(G, v);
  cout << m - (int)use.size() << endl;
}

Measured memory_bytes: 384
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    L = LI()

    ans = 0
    for i, j, k in itertools.combinations(L, 3):
        if i != j and j != k and k != i:
            if i + j > k and j + k > i and k + i > j:
                ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10120
import math
num1 = int(input())
num2 = math.floor(num1 / 1.08)
num3 = math.ceil(num1 / 1.08)
end = False
if math.floor(math.floor(num1 / 1.08) * 1.08) == num1:
  print(math.floor(num1 / 1.08))
  end = True
elif math.floor(math.ceil(num1 / 1.08) * 1.08) == num1 and end == False:
  print(math.ceil(num1 / 1.08))
else:
  print(':(')

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

#無向行列
path_matrix = []

#無向行列の初期化
for _ in range(N):
    path_matrix.append([False] * N)

for _ in range(M):
  line = map(int, input().split())
  paths = [x-1 for x in line]
  path_matrix[paths[0]][paths[1]] = True
  path_matrix[paths[1]][paths[0]] = True
  
visited = [False]*N

def dfs(now, depth):
  if visited[now]:
    return 0
  if depth == N-1:
    return 1
  
  visited[now] = True
  total_paths = 0
  for i in range(N):
    if path_matrix[now][i]:
      total_paths += dfs(i, depth+1)
  
  visited[now] = False
  
  return total_paths
print(dfs(0,0))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    
    if(a < b)
    cout<<"a < b"<<endl;
    if(a > b)
    cout<<"a > b"<<endl;
    if(a ==b)
    cout<< "a == b" <<endl;
    
}


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

int main(){
  string s;
  cin >> s;  
  int start , end;
  bool f = true;
  for(int i = 0 ; i < s.size() ; i++ ){
    if(f)
      if( s[i] == 'A' ){
        start = i;
        f=false;
      }
    
    if( s[i] == 'Z' )
      end = i;
  }
  
  
  cout << end - start + 1 << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
bool used[202020];
ll n,k;
int a[202020];
vi v;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>k;
	fo(i,1,n+1)cin>>a[i];
	int i=1;
	while(!used[i]){
		used[i]=1;
		i=a[i];
		k--;
		if(k==0){
			cout<<i<<endl;
			return 0;
		}
	}
	fo(i,0,n+1)used[i]=0;
	while(!used[i]){
		used[i]=1;
		v.pb(i);
		i=a[i];
	}
	k%=(ll)v.size();
	cout<<v[k]<<endl;
	return 0;
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
#define pb push_back
//struct edge{int to,cost;};
struct edge{int from,to,cost;};
typedef pair<int,int> P;
int n,m,r,d[1010];
edge es[2010];
bool NEGATIVE_CYCLE;
void bell(int s){
	fill(d,d+n,INF);
	d[s]=0;
	for(int i=0;i<=n;i++){
		bool update=false;
		for(edge e:es){
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(i==n&&update)NEGATIVE_CYCLE=1;
	}
}
signed main(){
	cin>>n>>m>>r;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		es[i]={a,b,c};
	}
	bell(r);
	if(NEGATIVE_CYCLE)puts("NEGATIVE CYCLE");
	else{
		rep(i,n){
			if(d[i]==INF)puts("INF");
			else cout<<d[i]<<endl;
		}
	}
	return 0;
}



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

int getAns(int A[], int n){
    vector<int>dp(n+1, INT_MAX);

    dp[0] = 0;
    
    for(int i=1;i<=n;i++){
        if(i == 1) dp[i] = min(dp[i], abs(dp[i-1] + abs(A[i]-A[i-1])));
        else dp[i] = min(dp[i], min(dp[i-1] + abs(A[i]-A[i-1]), dp[i-2] + abs(A[i]-A[i-2])));
    }

    return dp[n-1];
}

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

    cout<<getAns(A, n);
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	int n, K;
	cin >> n >> K;

	ll ans = 0;
	FOR(b, K + 1, n) {
		ans += (n / b) * (b - K);
		ans += max(0, n % b - K + 1);
		if (K == 0) ans -= 1;
	}
	cout << ans << endl;
}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 256
// 貪欲
import java.util.*

fun main(args: Array<String>) {
    var sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val C = sc.nextInt()
    var order = Array(N, {
        (1..3).map { sc.nextInt() }
    })
    order.sortBy { it[0] }
    var searched: MutableSet<Int> = mutableSetOf()
    var ans = 0
    for (i in 0..N - 1) {
        if (i in searched) continue
        ans += 1
        var prev = order[i]
        for ((id, next) in order.withIndex().filter { it.index !in searched }) {
            if ((prev[2] == next[2] && next[0] >= prev[1]) || (prev[2] != next[2] && next[0].toDouble() - 0.5 >= prev[1].toDouble())) {
                searched.add(id)
                prev = next
            }
        }
    }
    println(ans)
}

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

int main() {
  int N,A;
  cin >> N >> A;
  
  int m = N % 500;
  
  if (N - A <= 0) {
    cout << "Yes" << endl;
  }
  
  else if (0 < N - A < 500 && m - A <= 0) {
    cout << "Yes" << endl;
  }
  
  else if (0 < N - A < 500 && m - A > 0) {
    cout << "No" << endl;
  }
  
  else if (500 <= N - A) {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


N, M = readmap()
cnt = [0] * N
for _ in range(M):
    a, b = readmap()
    cnt[a-1] += 1
    cnt[b-1] += 1

for i in range(N):
    if cnt[i] % 2:
        print("NO")
        quit()

print("YES")

Measured memory_bytes: 3828
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

#ifdef _MSC_VER
#define scanf scanf_s
#define KEYWAIT getchar();getchar();
#else
#define KEYWAIT
#endif

int main()
{
    std::string l1, l2, l3;

    std::cin >> l1;
    std::cin >> l2;
    std::cin >> l3;

    std::cout << l1[0] << l2[1] << l3[2] << std::endl;

    KEYWAIT

    return 0;
}


Measured memory_bytes: 768
import copy

def discomfort(dic, n):
    global expenses, c
    if expenses != None and sum(p_res) >= expenses:
        return
    if n == c:
        if n == g_n:
            c = s_n
            discomfort(l_dic, g_n)
            c = g_n
            return
        else:
            expenses = sum(p_res)
            Pirates.append(r-(sum(p_res)+p))
            return
    for v in dic[n]:
        c_l_dic = copy.deepcopy(dic)
        c_l_dic[n].remove(v)
        c_l_dic[v].remove(n)
        p_res.append(p_dic[(n,v)])
        load.append(v)
        discomfort(c_l_dic, v)
        del p_res[-1]
        del load[-1]

if __name__ == '__main__':
    t_c = int(raw_input())
    
    l_dic = {}
    p_dic = {}
    for i in range(input()):
        n1, n2, p1, p2 = map(int, raw_input().split(','))
        if not n1 in l_dic:
            l_dic[n1] = [n2]
            if not n2 in l_dic:
                l_dic[n2] = [n1]
            else:
                l_dic[n2].append(n1)
        else:
            l_dic[n1].append(n2)
            if not n2 in l_dic:
                l_dic[n2] = [n1]
            else:
                l_dic[n2].append(n1)
        p_dic[(n1,n2)] = p1
        p_dic[(n2,n1)] = p2
    
    s_n, g_n, r, p = map(int, raw_input().split(','))
    c = g_n
    Pirates = []
    p_res = []
    load = [s_n]
    expenses = None
    discomfort(l_dic, s_n)
    print sorted(Pirates)[-1]

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type mod_pow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

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

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

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

	// for prime mod
	mint inv() const
	{
		return pow(mod - 2);
	}
	mint& operator/=(const mint a)
	{
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const
	{
		mint res(*this);
		return res /= a;
	}
	
};

mint choose(int n, int k)
{
	mint x = 1, y = 1;
	for (int i = 0; i < k; i++) {
		x *= n - i;
		y *= i + 1;
	}
	return x / y;
}

struct combination
{
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1)
	{
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k)
	{
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	mint ans(2);
	ans = ans.pow(n);
	ans -= 1;
	ans -= choose(n, a);
	ans -= choose(n, b);
	cout << ans.x << endl;
}

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

int main(){
	int n;
	char a[1001],b[1001];
	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		cout<<a[i]<<b[i];
	}
	
	cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[102];
  int i,j,n;
  while(fgets(s,101,stdin)!=NULL){
    for(i=0;s[i]!=0;i++){
      if(s[i]=='@'){
	i++;
	n=s[i]-'0';
	i++;
	for(j=0;j<n;j++)printf("%c",s[i]);
      }
      else printf("%c",s[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> x(N);
  rep(i, N)cin >> x[i];
  ll ans = LLONG_MAX;
  for(ll i=0; i<N-K+1; ++i) {
    ll tmp = 0;
    if(x[i] <= 0 && x[i+K-1] <= 0) tmp = abs(x[i]);
    else if(x[i] < 0 && x[i+K-1] > 0) tmp = max(abs(x[i]),abs(x[i+K-1])) + 2*min(abs(x[i]),abs(x[i+K-1]));
    else if(x[i] >= 0 && x[i+K-1] >= 0) tmp = x[i+K-1];
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> memo; //map<key,value>
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        memo[s]++;
    }
    int maxv=0;
    map<string,int> :: iterator it;
    for(it = memo.begin();it!=memo.end();it++){
        //pair<string,int> s = *it;
        maxv = max(maxv,(*it).second);
    }

    for(it = memo.begin();it!=memo.end();it++){
        if(maxv == (*it).second){
            cout << (*it).first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string a;
    cin >> a;
    for(int i=0; i<a.size(); i++){
      if(a[i]==','){
        cout << ' ';
      }else{
        cout << a[i];
      }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main(void)
{
	int n,m; cin >> n >> m;
	cout << n * (n-1) /2 + m * (m-1) /2 << endl;

	return 0;
}


Measured memory_bytes: 256