akhauriyash/Code-Regression huggingface dataset:
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n")
#define sp printf(" ")

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) ((x)*(x))
#define CUBE(x) (SQR(x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	string S, no;
	cin >> S;
	set<char> dat, cmp;
	for (char i = 'a'; i <= 'z'; ++i){
		cmp.insert(i);
		no.pb(i);
	}
	reverse(ALL(no));
	for (auto& it : S){
		dat.insert(it);
		if (cmp.find(it) != cmp.end()){
			cmp.erase(it);
		}
	}
	if (dat.size() == S.size() && S != no){
		if (dat.size() < 26){
			cout << S << *cmp.begin() << endl;
		} else {
			for (int i = 24; i >= 0; --i){
				if (S[i+1] > S[i]){
					set<char> ans;
					for (char j = 'a'; j <= 'z'; ++j){
						ans.insert(j);
					}
					for (int j = 0; j < i; ++j){
						cout << S[j];
						ans.erase(S[j]);						
					}
					for (auto& it : ans){
						if (it > S[i]){
							cout << it << endl;
							return 0;
						}
					}
				}
			}
		}
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int tmp = r * 100 + g *  10 + b;
    if(tmp % 4 == 0)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t mod=1e9+7;

map< int64_t, int64_t > prime_factor(int64_t n) {
  map< int64_t, int64_t > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n]++;
  return ret;
}
const int MAX = 200005;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    int64_t n,m;
    cin >> n >> m;
    COMinit();
    int64_t ans=1;
    for(auto u:prime_factor(m)){
        ans*=COM(n+u.second-1,u.second);
        ans%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;

struct edge{
    int v, d, c;
    edge(){}
    edge(int v, int d, int c) : v(v),d(d),c(c){}
};

int N, M;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> P;//距?， ?点
int d[10665];

vector<edge> G[10665];

void dijkstra(int s){
    priority_queue<P, vector<P>,greater<P> > que;
    memset(d, INF, sizeof(d));
    d[s] = 0;
    que.push(P(0,s));
    while(!que.empty())
    {
        P p = que.top();
        que.pop();
        int q = p.second;
        if(d[q] < p.first) continue;
        for(int i = 0; i < G[q].size(); i++)
        {
            edge e = G[q][i];
            if(d[e.v] > d[q] + e.d)
            {
                d[e.v] = d[q] + e.d;
                que.push(P(d[e.v], e.v));
            }
        }
    }
}


int main()
{
    while(cin >> N >> M)
    {
        if(!N) break;
        for(int i = 0; i < N; i++)
		{
			G[i].clear();
		}
        for(int i = 0; i < M; i++)
        {
            int u,t,c,d;
            cin >> u >> t >> d >> c;
            u--;t--;
            G[u].push_back(edge(t,d,c));
            G[t].push_back(edge(u,d,c));
        }
        dijkstra(0);
        int ans=0;
        for(int k = 1; k < N; k++)
        {
            int mincost = INF;
            for(int j = 0; j < G[k].size(); j++)
            {
                if(d[G[k][j].v]+G[k][j].d == d[k]
                 && G[k][j].c < mincost)
                    mincost = G[k][j].c;
            }
            ans += mincost;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5060
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    int sum = 0;
    std::string S;
    std::cin >> n >> S;
    for(int i = 0; i < n; i++){
        if(S[i] == '1') sum++;
    }

    // 例外処理
    if(sum == 0){
        for(int i = 0; i < n; i++){
            std::cout << 1 << std::endl;
        }
        return 0;
    }
    if(sum == 1){
        std::vector<int> count_p1(n);
        count_p1[0] = 1; // 1 % 2
        for(int i = 1; i < n; i++){
            count_p1[i] = (count_p1[i - 1] * 2) % 2;
        }
        int r_p1 = 0;
        for(int i = 0; i < n; i++){
            if(S[i] == '1'){
                r_p1 += count_p1[n - 1 - i];
                r_p1 %= 2;
            }
        }
        for(int i = 0; i < n; i++){
            int r = 0;
            if(S[i] == '1'){
                std::cout << 0 << std::endl;
                continue;
            }else{
                r = r_p1;
                r += count_p1[n - 1 - i];
                r %= 2;
            }

            int cnt = 1;
            while(r > 0){
                // popcountの計算
                int x = r;
                int popcount = 0;
                while(x > 0){
                    if(x % 2 == 1) popcount++;
                    x /= 2;
                }

                r %= popcount;
                cnt++;
            }

            std::cout << cnt << std::endl;
        }
        
        return 0;
    }

    // 2^iの剰余
    std::vector<int> count_p1(n), count_m1(n);
    count_p1[0] = 1 % (sum + 1);
    count_m1[0] = 1 % (sum - 1);
    for(int i = 1; i < n; i++){
        count_p1[i] = (count_p1[i - 1] * 2) % (sum + 1);
        count_m1[i] = (count_m1[i - 1] * 2) % (sum - 1);
    }

    // Xに対して事前の剰余計算
    int r_p1 = 0, r_m1 = 0;
    for(int i = 0; i < n; i++){
        if(S[i] == '1'){
            r_p1 += count_p1[n - 1 - i];
            r_m1 += count_m1[n - 1 - i];
            r_p1 %= sum + 1;
            r_m1 %= sum - 1;
        }
    }

    // 後は愚直に
    for(int i = 0; i < n; i++){
        int r = 0;
        if(S[i] == '1'){
            // sum - 1の剰余で, 2^(n - 1- i)桁目が消える
            r = r_m1;
            r -= count_m1[n - 1 - i];
            while(r < 0){
                r += sum - 1;
            }
        }else{
            r = r_p1;
            r += count_p1[n - 1 - i];
            r %= sum + 1;
        }

        int cnt = 1;
        while(r > 0){
            // popcountの計算
            int x = r;
            int popcount = 0;
            while(x > 0){
                if(x % 2 == 1) popcount++;
                x /= 2;
            }

            r %= popcount;
            cnt++;
        }

        std::cout << cnt << std::endl;
    }
    return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 10007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

ll n, A;

bool cal(ll x, ll mu, ll T){
	ll res = 1;
	Rep(i, mu){
		res *= x;
		if(res > T) return false;
	}
	return true;
}

ll cal(ll n, ll mu){
	ll l = 1, r = 1000005, mid;
	while(l < r){
		mid = (l + r) >> 1;
		if(cal(mid, mu, n)) l = mid + 1;
		else r = mid;
	}
	return l - 1;
}

int main()
{
//	gen();
//	freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> A;
    ll res = n;

    for(int i = 2; (i - 1) * A <= n && i <= 45; i++){
    	ll ret = (i - 1) * A;
    	ll x = cal(n, i);
//    	cout << i << " " << x << endl;
    	if(x < 2) x = 2;
    	ret += x * i;
    	ll T = 1;
    	Rep(j, i) T *= x;
    	while(T < n) {
    		ret++;
    		T = T * (x + 1) / x;
    	}
//    	cout << ret << endl;
    	res = min(res, ret);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int count(int x) {
    int cnt = 0;
    for (; x; x /= 10, ++cnt) {}
    return cnt;
}

int main() {
    int n = read(), cnt = 0;
    for (int i = 1; i <= n; ++i) {
        cnt += count(i) & 1;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> A(N);
    int p = 0, m = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] >= 0) p++;
        else m++;
    }
    sort(A.begin(), A.end());
    if (p == 0) {
        m--;
        p++;
    }
    if (m == 0) {
        m++;
        p--;
    }
    long long ans = 0;
    for (int i = 0; i < m; i++) {
        ans += -A[i];
    }
    for (int i = m; i < N; i++) {
        ans += A[i];
    }
    cout << ans << endl;
    long long x = A[0];
    for (int i = 0; i < p-1; i++) {
        cout << x << " " << A[m+i] << endl;
        x = x-A[m+i];
    }
    cout << A[N-1] << " " << x << endl;
    x = A[N-1]-x;
    for (int i = 1; i < m; i++) {
        cout << x << " " << A[i] << endl;
        x = x-A[i];
    }
}

Measured memory_bytes: 2304
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int count;
boolean[] p=new boolean[50001];
for(int i=0;i<=50000;i++){
p[i]=true;
}
p[0]=false;
p[1]=false;
for(int i=2;i<=Math.sqrt(50000)+1;i++){
if(p[i]){
for(int j=i+i;j<=50000;j+=i){
p[j]=false;
}
}
}
while(!(line=br.readLine()).equals("0")){
count=0;
int n=Integer.parseInt(line);
for(int i=2;i<=n/2;i++){
if(p[i]&&p[n-i]){
count++;
}
}
System.out.println(count);
}
}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  string s(b, '0'+a);
  string t(a, '0'+b);
  cout << min(s,t) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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 int INF = 1e9;

const int MAX_N = 100005;
ll A[MAX_N];

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    ll r;
    while((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    ll N, M;
    cin >> N >> M;
    rep(i,N) cin >> A[i];
    rep(i,N) if(A[i]%2 != 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,N) A[i] /= 2;
    ll p = 1;
    rep(i,N) {
        ll a = A[i];
        ll _p = 1;
        while(a%2 == 0) {
            a /= 2;
            _p *= 2;
        }
        chmax(p, _p);
    }
    rep(i,N) if(A[i]%p != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll T = A[0];
    rep(i,N) {
        T = T * A[i] / gcd(T, A[i]);
        if(T > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll l = -1;
    ll r = M+1;
    ll c = (l + r) / 2;
    while(r - l > 1) {
        if(T * (2 * c + 1) <= M) l = c;
        else r = c;
        c = (l + r) / 2;
    }
    cout << l+1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,m,d;
    ans=0;
    cin >>m>>d;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            if(!(j>=20&&(j%10)>=2))continue;
            if(i==(j/10)*(j%10))ans++;
        }
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (N+1)
ans = 0
for i in range(N):
  cnt[A[i]] +=1
for i in range(N+1):
  ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(N):
  print(ans - cnt[A[i]] + 1)

Measured memory_bytes: 26140
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] input = br.readLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);			
			if ((H == 0) && (W == 0)){
				break;
			}
			for (int i = 1; i <= H; i++){
				for (int j = 1; j <= W; j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
		
	}
}

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

int main(){

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

    int res = 0;
    for(int i=0; i<n; i++){
        if(v[i] > c[i]){
            res = res + v[i] - c[i];
        }
    }

    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e12
#define mod 1000000007

ll N,A;

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

  cin>>N>>A;
  ll res=N;
  repl(C,1,42){
    ll lb=1,ub=INF;
    while(ub-lb>1){
      ll r=(lb+ub)/2;
      ll tmp=1;
      rep(i,C){
        if(tmp>INF/r) tmp=INF;
        else tmp*=r;
      }
      if(tmp>=N) ub=r;
      else lb=r;
    }
    ll r=ub;
    rep(i,C+1){
      ll tmp=1;
      rep(j,i)tmp*=r-1;
      rep(j,C-i)tmp*=r;
      if(tmp>=N) minch(res,A*(C-1)+i*(r-1)+(C-i)*r);
    }
  }
  cout<<res<<endl;

  return 0;
}


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

vector<int> adj[100005];
long long int dp[100005][2];

long long int mod=1e9+7;

long long int solve( int root, int prev, int col){
   
   //coloring the root with black color
  // cout<<"the values "<< root<<" "<<prev<<" "<<col<<endl;
   if(dp[root][col]!=-1)
   	return dp[root][col];
   dp[root][col]=1;
   if( col==0){
     for(int v:adj[root]){
     	if(v!=prev){
          solve(v,root, 1);
          dp[root][col]*=dp[v][1];
          dp[root][col]%=mod;
     	}
     }  
   } 
   else{
     
     for(int v:adj[root]){
     	if(v!=prev){
     	  solve(v,root,0);
     	  solve(v,root, 1);	
          dp[root][col]*=((dp[v][0]+dp[v][1])%mod);
          dp[root][col]%=mod;
     	}
     } 
   }
   return dp[root][col]%mod;
  
}


int main(){

int n;
cin>>n;
int u,v;
for(int i=0;i<n-1;i++){
	cin>>u;
	cin>>v;
	adj[u].push_back(v);
	adj[v].push_back(u);
}
for(int i=1;i<=n;i++){
   for(int j=0;j<2;j++)
   	dp[i][j]=-1;
}

cout<<((solve(1,-1,0)+ solve(1,-1,1))%mod)<<endl;
}

Measured memory_bytes: 14208
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
};

struct Node T[MAX];
int n, D[MAX],H[MAX];

void setDepth(int u, int d){
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;
    if(T[u].left != NIL)
        h1 = setHeight(T[u].left) +1;
    if(T[u].right != NIL)
     h2 = setHeight(T[u].right) +1;
    return H[u] = (h1 > h2 ? h1: h2);
}

//接点uの兄弟を返す
int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    
     if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
     return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg=0;
    if(T[u].left!= NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    
    if(T[u].parent == NIL){
        printf("root\n");
    }else if(T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}
int main(){
    int v,l,m, r ,root=0;
    scanf("%d",&n);
    
    for(int i=0; i<n; i++)  T[i].parent=NIL;
        
        for ( int i = 0; i < n; i++ ) {
            scanf("%d %d %d", &v, &l, &r);
             T[v].left = l;
             T[v].right = r;
             if ( l != NIL ) T[l].parent = v;
             if ( r != NIL ) T[r].parent = v;
             }

for(int i=0; i<n; i++){
    if(T[i].parent == NIL) root=i;
        }
setDepth(root,0);
setHeight(root);

for(int i=0; i<n; i++) print(i);
return 0;
}


Measured memory_bytes: 2044
w=list(input())
W=list(set(w))
a=[]
for i in range(len(W)):
    a.append(w.count(W[i]))
b=[]
for i in range(len(a)):
    if a[i]%2==0:
        b.append('yes')
    else:
        b.append('no')
if 'no' in b:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61884
#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>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */


int main() {
    vector<ll>v;
    queue<ll>q;
    ll req = 1e5;
    for(int i=1;i<10;i++)q.push(i);
    while (!q.empty())
    {
        ll t = q.front();
        q.pop();
        v.EB(t);
        if(v.size()>=req)break;
        ll last = t%10;
        ll st = t*10+max(0LL,last-1);
        ll en = t*10+min(9LL,last+1);
        for(ll i=st;i<=en;i++){
            q.push(i);
        }
    }
    ll k;
    scanf("%lld",&k);
    k--;
    cout<<v[k]<<"\n";
}



Measured memory_bytes: 2548
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9 + 7
result = 0
count = [0] * 2001

# リスト内での繰り返し
for a in A:
    count[a-1] += 1
    result += K * sum(count[a:])
    result %= mod

kn = 0
# 前のループに存在する自分より大きい数
count = [i for i in count if i != 0]
total = sum(count) % mod

for i in count:
    total -= i
    kn += total * i
    kn %= mod

result += kn * K*(K-1)//2
result %= 10**9 + 7

print(result)


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define INF (1<<30)-1
int main(){
  int s[6]={2,3,5,10,12,15};
  int n[6]={380,550,850,1520,1870,2244};
  int m;
  while(cin>>m){
    if(m==0) break;
    m /= 100;
    int dp[m+1];
    for(int i=0;i<=m;i++) dp[i] = INF;
    dp[0] = 0;
    for(int i=5;i>=0;i--){
      for(int j=0;j<=m;j++){
	if(j+s[i]<=m&&dp[j]!=INF) dp[j+s[i]] = min(dp[j+s[i]],dp[j]+n[i]);
      }
    }
    cout << dp[m] << endl;
  }
  return 0;
} 

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define vel vector<int>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main(){
	int n; cin >> n;
	vel t(n);
	rep(i, n) { cin >> t[i]; }
	sor(t);
	vel x;
	int ma = t[n - 1];
	for (int i = 1; i <= ma; i++) {
		if (ma%i == 0) {
			x.push_back(i);
		}
	}
	int ans = 0;
	rep(i, n) {
		int mn = ma;
		for (auto a : x) {
			if (t[i] <= a) {
				mmin(mn, a - t[i]);
			}
		}
		ans += mn;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3852
import sys
n = int(input())
c = list(map(int, input().split()))
c = [x-1 for x in c]
# print(c)
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = tuple(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


size = [1 for i in range(n)]
stack = [[] for color in range(n)]
in_time = [-1 for i in range(n)]
out_time = [-1 for i in range(n)]
timer = 0
total = n*(n+1)//2
ans = [total for color in range(n)]
# print(ans)


def dfs(parent, root):
    global timer
    in_time[root] = timer
    timer += 1

    for child in adj[root]:
        if parent == child:
            continue
        dfs(root, child)
        size[root] += size[child]

        color = c[root]
        cnt = size[child]
        s = stack[c[root]]
        while s:
            x = s[-1]
            if in_time[x] > in_time[root] and out_time[x] != -1:
                cnt -= size[x]
                s.pop()
            else:
                break
        ans[color] -= cnt*(cnt+1)//2

    out_time[root] = timer
    timer += 1

    stack[c[root]].append(root)


sys.setrecursionlimit(10**6)

dfs(0, 0)
# print(size)
for color in range(n):
    cnt = n
    while len(stack[color]) > 0:
        x = stack[color][-1]
        cnt -= size[x]
        stack[color].pop()
    # print("node:", -1, "color:", color, "cnt:", cnt)
    ans[color] -= cnt*(cnt+1)//2
    print(ans[color])


Measured memory_bytes: 402896
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int N;
void rec(string now, char cnow){
  int n = now.size();
  if(n==N){
    cout<<now<<endl;
    return ;
  }
  for(char c='a' ; c<=cnow+1 ; c++){
    rec(now+c, max(c, cnow));
  }
}
int main(){
  cin>>N;
  rec("", 'a'-1);
  return 0;
}


Measured memory_bytes: 1536
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    boolean answer=true;
    int d1=a-c;
    int d2=a-b;
    int d3=b-c;
    if(d1<0)
    d1 = -d1;
    if(d2<0)
    d2 = -d2;
    if(d3<0)
    d3 = -d3;


    if(d1<=d||(d2<=d&&d3<=d))
    System.out.print("Yes");
    else
    System.out.print("No");
  }
}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

using namespace std;


int main()
{	
	
	ll N;
	scanf("%lld", &N);
	ll A[N];
	ll B[N];
	ll C[N-1];
	ll sum;
	sum=0;
	for(ll i=0;i<N;i++){
		scanf("%lld", &A[i]);
	}
	for(ll i=0;i<N;i++){
		scanf("%lld", &B[i]);
		sum+=B[i];
	}
	for(ll i=0;i<N-1;i++){
		scanf("%lld", &C[i]);
	}
	
	for(ll i=0;i<N-1;i++){
		if(A[i]+1==A[i+1])
		{
			sum+=C[A[i]-1];
		}
	}
	
	printf("%lld", sum);
}


Measured memory_bytes: 128
#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(){
	int n;
	ll ans=0LL;
	cin >>n;
	V a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a),greater<ll>());
	auto ter=a.begin();
	for(int i=1;i<n;i++){
		ans+=*ter;
		if(i%2==1){
			ter++;
		}
	}
	cout<<ans<<endl;
}
/*
2 2 1 3 
*/

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

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

  double x, ans;
  string y;
  for (int i = 0; i < n; i ++) {
    cin >> x >> y;
    if (y == "BTC") ans += x * 380000;
    else ans += x;
  }

  cout << setprecision(15) << ans << endl;
}


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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0 && a[i] % 2 == 1) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()

const long long MOD = 1000000007;


int main(){
    ll l, r;
    cin >> l >> r;

    ll m = 2020;
    for(ll i = l; i <= r; i++){
        for(ll j = i+1; j <= r; j++){
            m = min(m, (i*j%2019));
            if(m == 0){
                cout << m << endl;
                return 0;
            }
        }
    }
    cout << m << endl;

    return 0;
}


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

main(){
  int val,num;
  int Sval=0,Snum=0;//SvalÍÌzSnumÍÌÂ
  int n=0;//o[½£ÁÆÌ
  while(scanf("%d,%d",&val,&num) != EOF){
    
    Sval+=val*num;
    Snum+=num;
    n++;
    
  }
  
  
  cout << Sval << endl<<(int)(Snum/(double)n+0.5)<< endl;

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>


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

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


int main(){
    ll x1,y1,x2,y2,dx,dy,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    dx=x2-x1;
    dy=y2-y1;
    x3=x2-dy;
    y3=y2+dx;
    x4=x3-dx;
    y4=y3-dy;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int s=gi();
        Map<Integer, Integer> m = new HashMap<Integer, Integer>();
        m.put(s,1);
        int i=1;
        while(true) {
        	i++;
        	if (s%2 ==0) {
        		s=s/2;
        	} else {
        		s=3*s+1;
        	}
        	if(m.containsKey(s)) {
        		break;
        	}
        	m.put(s,1);
        	
        }
	    System.out.println(i);

//        if (min==Integer.MAX_VALUE) {
//        	System.out.println("TLE");
//        }else {
//        	System.out.println(min);
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35708
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	string s;
	cin>>s;
	cout<<(s[2]==s[3] && s[4]==s[5]?"Yes":"No")<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 256
a=input()
b=a[2]
c=a[4]
a=a[0]
if(a==b and a == c):
  print("No")
elif(a != b and b == c):
  print("Yes")
elif(a != b and a == c):
  print("Yes")
elif(a!=c and a == b):
  print("Yes")
else:
  print("No")

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

int main() {
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
        s+="es";
        cout<<s<<endl;
    }else
    {
        s+='s';
        cout<<s<<endl;
    }
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 6005
#define INF (1e9)
using namespace std;
typedef long long ll;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});  
}

int dfs(int v,int t,int f,int cnt=INF){
  if(v == t)return f;
  if(!cnt)return 0;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap),cnt-1);
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

void flow_rev(int s,int t,int f){
  while(f){
    memset(used,0,sizeof(used));
    f-=dfs(s,t,f,2);
  }
}

ll n,k,x[MAX_V],y[MAX_V],s,t;

bool check_dis(int A,int B){
  return (x[A]-x[B])*(x[A]-x[B])+(y[A]-y[B])*(y[A]-y[B])<4;
}

void make_graph(){
    
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(i!=j&&y[i]%2&&!(y[j]%2)&&check_dis(i,j))add_edge(i,j,INF);

  s=n, t=n+1;
  for(int i=0;i<n;i++)
    if(y[i]%2)add_edge(s,i,1);
    else add_edge(i,t,1);
  
}

vector<int> ans;

void solve(){
  int F=max_flow(s,t);
  
  if(n-F<k){
    cout<<-1<<endl;
    return;
  }

  for(int i=0;i<n;i++){
    
    if(y[i]%2){
      int idx;
      for(int j=0;j<G[s].size();j++)
	if(G[s][j].to==i)idx=j,G[s][j].cap+=INF;
      
      int add_F=max_flow(s,t);
      if(n-(F+add_F)>=k)ans.push_back(i+1),F+=add_F;
      else{
	edge &e=G[s][idx];
	e.cap-=INF-add_F;
	G[e.to][e.rev].cap-=add_F;
	
	flow_rev(t,i,add_F);
      }
      
    }else{
      int idx;
      for(int j=0;j<G[i].size();j++)
	if(G[i][j].to==t)idx=j,G[i][j].cap+=INF;
      
      int add_F=max_flow(s,t);
      if(n-(F+add_F)>=k)ans.push_back(i+1),F+=add_F;
      else{
	edge &e=G[i][idx];
	e.cap-=INF-add_F;
	G[e.to][e.rev].cap-=add_F;
	
	flow_rev(i,s,add_F);
      }
      
    }
    
  }
  for(int i=0;i<k;i++)cout<<ans[i]<<endl;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  
  make_graph();

  solve();
  
  return 0;
}

Measured memory_bytes: 4216
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var w = Console.ReadLine();
        var dic = new Dictionary<char, int>();
        foreach (var item in w)
        {
            if (!dic.ContainsKey(item))
                dic.Add(item,1);
            else
                dic[item]++;
        }
        foreach (var item in dic)
        {
            if (item.Value % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
        Console.ReadLine();
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    public const int Mod1e9 = 1000000007;
    

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



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

using namespace std;

int main(){
    priority_queue<long long>que;
	long long n,m,x,dcount,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x;
		que.push(x);
	}
	while(m--){
		dcount=que.top()/2;
		que.push(dcount);
		que.pop();
	}
	while(n--){
		sum+=que.top();
		que.pop();
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1400
N,P = map(int,input().split())
X = P
Factoring = []

if(N == 1):
 ans = X
 print(ans)
else:
 #素因数分解
 p = 2
 ans = 1

 while(p*p <= P):
  count = 0
  while(X%p == 0):
    X = X//p
    count += 1
  if(count != 0):
   Factoring.append([p,count])
   ans = ans*(p**(count//N))
  p += 1
  
 if(len(Factoring) == 0):
  ans = 1
 print(ans)
    

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

using ll = long long;
const int N = 2e5+10;
const int MOD = 998244353;

int n, link[N];
struct data{
  int x, d;
}a[N];
ll dp[N];

int t[N << 2];
void upd(int u, int L, int R, int i, int x) {
  if(L == R) {
    t[u] = x;
    return;
  } int mid = L + R >> 1, lc = u << 1, rc = lc | 1;
  if(i <= mid) upd(lc, L, mid, i, x);
  else upd(rc, mid + 1, R, i, x);
  t[u] = max(t[lc], t[rc]);
}

int get(int u, int L, int R, int l, int r) {
  if(r < L || R < l) return 0;
  if(l <= L && R <= r) return t[u];
  int mid = L + R >> 1, lc = u << 1, rc = lc | 1;
  return max(get(lc, L, mid, l, r), get(rc, mid + 1, R, l, r));
}

int main () {
  scanf("%d", &n);
  for(int i = 0; i < n; i++) 
    scanf("%d %d", &a[i].x, &a[i].d);
  sort(a, a + n, [&](data x, data y) {
    return x.x < y.x;
  });

  link[n - 1] = n;
  upd(1, 0, n - 1, n - 1, n);

  for(int i = n - 2; i >= 0; i--) {
    if(a[i].x + a[i].d <= a[i + 1].x) {
      link[i] = i + 1;
      upd(1, 0, n - 1, i, i + 1);
      continue;
    }

    int lo = i + 1, hi = n - 1, idx = n;
    while(lo <= hi) {
      int mid = lo + hi >> 1;
      if(a[i].x + a[i].d > a[mid].x)
        lo = mid + 1;
      else hi = mid - 1, idx = mid;
    } idx--;
    link[i] = get(1, 0, n - 1, i + 1, idx);
    upd(1, 0, n - 1, i, link[i]);
  }

  dp[n] = 1;
  for(int i = n - 1; i >= 0; i--) {
    dp[i] = dp[i + 1] + dp[link[i]];
    if(dp[i] >= MOD) dp[i] -= MOD;
  }
  printf("%lld\n", dp[0]);
  return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  string str;
  cin>>str;
  for(int i = str.size()-1 ; i >= 0 ; --i)
    cout<<str[i];
  cout<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=200010;
int a[N];
int n, m;
int main(){
	int t;
	// while(){
		scanf("%d",&n);
		for(int i=0; i<n; ++i){
			scanf("%d",a+i);
		}
		sort(a, a+n);
		reverse(a, a+n);
		ll ans=a[0];
		int p=n-2;
		for(int i=1; i<n&&p>0; ++i){
			--p;
			ans+=a[i];
			if(p>0){
				--p;
				ans+=a[i];
			}
		}
		cout<<ans<<endl;
	// }
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef vector<int> VI;

queue<string> q;

int main() {
	int n; scanf("%d",&n);
	rep(i,1,10) q.push(to_string(i));
	int cnt=0;
	while (233) {
		string u=q.front();
		q.pop();
		if (++cnt==n) {printf("%s\n",u.c_str());return 0;}
		char ch=u.back();
		if (ch!='0') q.push(u+(char)(ch-1));
		q.push(u+ch);
		if (ch!='9') q.push(u+(char)(ch+1));
	}
	return 0;
}

Measured memory_bytes: 13696