akhauriyash/Code-Regression huggingface dataset:
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 2e5 + 10;

int n, q;
ll st[4 * N];
int ans[N];

void testCase();
void update(int tv, int tl, int tr, int ql, int qr, ll val);
void go(int tv, int tl, int tr);

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	cin >> n >> q;
	vector < pair < pii, int > > ranges(n);
	for (auto &r: ranges) {
		cin >> r.first.first >> r.first.second >> r.second;
	}
	vector < int > v(q);
	for (auto &el: v) {
		cin >> el;
	}
	fill(st, st + 4 * N, LINF);
	for (auto &rg: ranges) {
		int l = rg.first.first;
		int r = rg.first.second;
		if (l <= r) {
			l -= rg.second;
			r -= rg.second;
			auto lo = lower_bound(all(v), l) - v.begin();
			auto hi = lower_bound(all(v), r) - v.begin();
			--hi;
			trace(l, r, rg.second, lo, hi);
			if (lo <= hi) {
				update(1, 0, q - 1, lo, hi, rg.second);
			}
		}
	}
	go(1, 0, q - 1);
	for (int i = 0; i < q; ++i) {
		cout << ans[i] << "\n";
	}
}

void update(int tv, int tl, int tr, int ql, int qr, ll val) {
	if (ql > tr || qr < tl) {
		return;
	} else if (ql <= tl && tr <= qr) {
		st[tv] = min(st[tv], val);
	} else {
		int tm = tl + tr >> 1, left = 2 * tv, right = left + 1;
		update(left, tl, tm, ql, qr, val);
		update(right, tm + 1, tr, ql, qr, val);
	}
}

void go(int tv, int tl, int tr) {
	if (tl == tr) {
		if (st[tv] == LINF) {
			ans[tl] = -1;
		} else {
			ans[tl] = st[tv];
		}
	} else {
		int tm = tl + tr >> 1, left = 2 * tv, right = left + 1;
		st[left] = min(st[left], st[tv]);
		st[right] = min(st[right], st[tv]);
		go(left, tl, tm);
		go(right, tm + 1, tr);
	}
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	map<int,int> mp;
	rep(i,N){
		int x;
		cin>>x;
		mp[x]++;
	}
	int ans = 0;
	for(auto it:mp){
		int x = it.fs;
		int n = it.sc;
		if(x<=n) ans += n-x;
		else ans += n;
	}
	cout<<ans<<endl;
}


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

int main() {
 	int N;
  	int A[110];
  	
  	cin >> N;
  	for (int i=0; i<N; i++) cin >> A[i];
  	
  	int j = 0;
  	int max = -1;
  	while (true) {
    	for (int k=N-1; k>j; k--) {
          	int gap;
        	if (A[j] > A[k]) gap = A[j] - A[k];
          	else gap = A[k] - A[j];
          	
          	if (gap > max) max = gap;
        }
      	j++;
      	if (j == N-1) break;
    }
  	cout << max << endl;
}

Measured memory_bytes: 384
/*******************************************************************************/
//
//??????r???????????¢?????¨?????¨?????????????±???????????????°??????
//
//Input  :??????????????°r(??????)
//Output :??¢?????¨?????¨?????????????????????????????§????????£??????????????????
//		  ????????????????°???°?????°??¨??????0.00001 ??\???????????????????????§?????????
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B&lang=jp
/*******************************************************************************/

#include<stdio.h>

#define MAX 10000
#define MIN 0
#define PI 3.141592653589

int main()
{
	double r;	/* ?????? */
	
	if( scanf("%lf", &r)==1 )
	{
		if((r>MIN) && (r<MAX))
		{
			printf("%.6lf %.6lf\n", r*r*PI, 2*r*PI);
		}
		else
		{
			/* ERROR */
			return -1;
		}
	}
	else
	{
		/* ERROR */
		return -1;
	}
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n; i++)
    cin >> d.at(i);
  
  int base = 101;
  for (int i = 0; i < n + 1; i++) {
    int max = 0;
    for (int j = 0; j < n; j++) {
      if (d.at(j) < base && d.at(j) > max)
        max = d.at(j);
    }
    if (max == 0) {
      cout << i << endl;
      break;
    } else {
      base = max;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7

ansN=1
ansM=1

if N-1==M or N==M-1 or N==M:
    for i in range(2,N+1):
        ansN*=(i%mod)
        ansN%=mod
    for g in range(2,M+1):
        ansM*=(g%mod)
        ansM%=mod
    if N==M:
        print((ansM*ansN*2)%mod)
    else:
        print((ansM*ansN)%mod)
else:
    print(0)

Measured memory_bytes: 3064
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.children = []
        self.size = 1
    
class UF:
    def __init__(self, size):
        self.n = size
        self.parents = [i for i in range(self.n+1)]
        self.sizes = [1] * (self.n+1)
        self.nodes = [None]
        for i in range(1, self.n+1):
            self.nodes.append(Node(i))
        

    def get_parent(self, x):
        while x.parent != None:
            x = x.parent
        return x

    def union(self, x, y):
        x = self.nodes[x]
        y = self.nodes[y]
        xp = self.get_parent(x)
        yp = self.get_parent(y)
        if xp == yp and xp is not None and yp is not None:
            return
        if xp.size >= yp.size:
            xp.children.append(yp)
            xp.size += yp.size
            self.sink(xp, yp)
        else:
            yp.children.append(xp)
            yp.size += xp.size
            self.sink(yp, xp)

    def sink(self, xp, yp):
        yp.parent = xp
        self.parents[yp.key] = xp.key
        yp.size = xp.size
        for child in yp.children:
            self.sink(xp, child)
            
from collections import defaultdict
n, k, l = map(int, raw_input().split())
uf1 = UF(n)
for i in range(k):
    p, q = map(int, raw_input().split())
    uf1.union(p, q)
uf2 = UF(n)
for i in range(l):
    r, s = map(int, raw_input().split())
    uf2.union(r, s)
p1 = uf1.parents
p2 = uf2.parents
dic = defaultdict(int)
for i in range(1, n+1):
    key = (p1[i], p2[i])
    dic[key] += 1
res_arr = []
for i in range(1, n+1):
    if uf1.nodes[i].size == 1 or uf2.nodes[i].size == 1:
        res_arr.append(1)
    else:
        key = (p1[i], p2[i])
        res_arr.append(dic[key])
print " ".join(map(str, res_arr))


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

int  main()
{
	int n;
	cin >> n;
	set<int> st;
	rep(i, n)
	{
		int a; cin >> a;
		if (!st.count(a))
			st.insert(a);
		else
			st.erase(a);
	}
	cout << st.size() << endl;
	return (0);
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a,b;cin >> a>>b;
    cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3160
import sys

for line in sys.stdin:
  try:
    value = float(line)
    if value <= 48.00:
      print("light fly")
    elif value <= 51.00:
      print("fly")
    elif value <= 54.00:
      print("bantam")
    elif value <= 57.00:
      print("feather")
    elif value <= 60.00:
      print("light")
    elif value <= 64.00:
      print("light welter")
    elif value <= 69.00:
      print("welter")
    elif value <= 75.00:
      print("light middle")
    elif value <= 81.00:
      print("middle")
    elif value <= 91.00:
      print("light heavy")
    else:
      print("heavy")
  except:
    break

Measured memory_bytes: 5580
s = input()
q = int(input())
q_datas = [input().split() for _ in range(q)]

direction = 1  # 操作を始める前の向きを1、逆を-1とする
output_string = s
string1 = ''
string2 = ''

change_direction_count = 0
for query in q_datas :
    if query[0] == '1':
        direction *= -1
        change_direction_count += 1
    else:
        if query[1] == '1' and direction == 1:
            string1 = query[2] + string1
        elif  query[1] == '1' and direction == -1:
            string2 = string2 + query[2]
        elif  query[1] == '2' and direction == 1:
            string2 = string2 + query[2]
        else: # query[1] == '2' and direction == -1
            string1 = query[2] + string1

if change_direction_count % 2 == 0:
    print(string1 + s + string2)
else:
    print(string2[::-1] + s[::-1] + string1[::-1])

Measured memory_bytes: 40548
import numpy as np
import copy

cubes = list(input())
cubes = np.array(list(map(int, cubes)))

zeroNum = 0
oneNum = 0
for i in range(0, len(cubes)):
    if cubes[i] == 0:
        zeroNum += 1
    else :
        oneNum += 1

print(min(zeroNum, oneNum) * 2)

Measured memory_bytes: 24072
def main():
    n, k, q = map(int, input().split())
    a = [int(input()) for _ in range(q)]
    point = [k - q] * n
    for i in a:
        point[i -1] += 1
    for i in point:
        if i > 0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;

int father[N]; 
int people[N]; 
int rak[N]; 
 
int find(int x) 
{
  if (x != father[x])
    father[x] = find(father[x]);
 
  return father[x];
}
 

void Union(int x, int y) 
{
  x = find(x);
  y = find(y);
 
  if (rak[x] > rak[y])
    {
      father[y] = x;
      if (x != y)
	people[x] += people[y];
    }
  else
    {
      father[x] = y;
      if (x != y)
	people[y] += people[x];
 
      if (rak[x] == rak[y])
	rak[y] += 1;
    }
}
int n,m,k,num[N];
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>m>>k;
  for(int i = 1;i <= n;i++){
    father[i] = i;
    people[i] = 1;
    rak[i] = 0;
  }
  int u,v;
  while(m--){
    cin>>u>>v;
    num[u]++;num[v]++;
    Union(u,v);
  }
  while(k--){
    cin>>u>>v;
    if(find(u) == find(v)) num[u]++,num[v]++;
  }
  for(int i = 1;i <= n;i++) cout<<people[find(i)]-num[i]-1<<" ";
  cout<<endl;
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli a, b, c, x, y;
  while (cin >> a >> b >> c >> x >> y) {
    lli mn = 1LL << 60;
    for (int i = 0; i <= 1e8; ++i) {
      lli C = i * 2;
      lli A = max(0LL, x - C / 2);
      lli B = max(0LL, y - C / 2);
      mn = min(mn, A * a + B * b + C * c);
    }
    cout << mn << endl;
  }
  
  return 0;
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

const int nax = 2e5+5;
int n,k,c; string s;
int dpl[nax],dpr[nax];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    cin>>n>>k>>c>>s;
    dpl[0] = 0; dpr[n+1] = 0;
    FOR(i, 1, n+1) {
        if(s[i-1] == 'x') dpl[i] = dpl[i-1];
        else dpl[i] = max(dpl[i-1], ((i - c - 1 >= 0) ? dpl[i - c - 1] : 0) + 1);
    }
    RFOR(i, n, 1) {
        if(s[i-1] == 'x') dpr[i] = dpr[i + 1];
        else dpr[i] = max(dpr[i + 1], ((i + c + 1 <= n) ? dpr[i + c + 1] : 0) + 1);
    }
    
    // FOR(i, 0, n + 2) {
    //     cout<<i<<" "<<dpl[i]<<" "<<dpr[i]<<endl;
    // }

    FOR(i, 1, n + 1) {
        if(s[i-1] == 'x') continue;
        if(dpl[i-1] + dpr[i+1] + 1 == k) cout<<i<<endl;
    }
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int nax=2e5+5;
ll dp[nax];
int main()
{
    int n;

    cin>>n;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    ll a[n];
     for(int i=0;i<n;i++) cin>>a[i];
    // max possible beauty having h[i] as last element
    int base=1;
    while(base<=n)
    {
        base*=2;
    }
    vector<ll > tree(2*base);

  
    for(int i=0;i<n;i++)
    {
        // for(int j=0;j<h[i];j++)
        // {
        //     dp[h[i]]=max(dp[h[i]],dp[j]+a[i]);
        // }
        //find max from 0 to h[i]-1
        int node=base+h[i]-1;
        ll ans=tree[node];
        while(node>=1)
        {
            if(node%2)
            {
                ans=max(ans,tree[node-1]);
            }
            node/=2;
        }
        dp[h[i]]=max(dp[h[i]],ans+a[i]);
        int x=base+h[i];
        while(x>=1)
        {
            tree[x]=max(dp[h[i]],tree[x]);
            x/=2;
        }


    }
    ll ans=INT_MIN;
    for(int i=0;i<n;i++)
    {
        ans=max(ans,dp[h[i]]);

    }
    cout<<ans;
}

Measured memory_bytes: 8320
import java.util.*;

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

	while(sc.hasNext()){
	    int[] a = new int[4];
	    int[] b = new int[4];
	    for(int i=0; i<a.length; i++){
		a[i] = sc.nextInt();
	    }
	    for(int i=0; i<b.length; i++){
		b[i] = sc.nextInt();
	    }
	    int hit = 0;
	    int blow = 0;
	    for(int i=0; i<a.length; i++){
		if(a[i]==b[i]){hit++; b[i] = -1;}
	    }

	    for(int i=0; i<a.length; i++){
		for(int j=0; j<b.length; j++){
		    if(a[i]==b[j]){blow++;}
		}
	    }

	    System.out.println(hit+" "+blow);
	}
    }
}

Measured memory_bytes: 12000
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

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

    String s = in.readString();

    if (s.equals("ABC")) System.out.println("ARC");
    else System.out.println("ABC");
  }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1) throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0) return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c)) c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 32432
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i = 1; i*i <= N; i++){
    if(N % i == 0){
      if((N/i - 1) > i) ans += N/i - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b &&b==c||a!=b&&b!=c&&c!=a) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes"<<endl;
    }
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

struct Mystruct {
  int x, y, h;

  Mystruct(int input_a, int input_b, int input_c) {
    x = input_a;
    y = input_b;
    h = input_c;
  }
  bool operator<(const Mystruct& another) const {
    if (h == another.h) {
      return x < another.x;
    }
    return h < another.h;
  };
};

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

  vector<Mystruct> v;
  REP(i, n) {
    int x, y, h;
    cin >> x >> y >> h;
    v.push_back(Mystruct(x, y, h));
  }

  SORT(v);
  REVERSE(v);

  FOR(cx, 0, 100) {
    FOR(cy, 0, 100) {
      int tmp_h = -1;
      bool flag = true;
      REP(i, n) {
        Mystruct data = v[i];
        int dist = abs(data.x - cx) + abs(data.y - cy);
        if (tmp_h == -1) {
          tmp_h = data.h + dist;
          // cout << data.h << " " << dist << " " << tmp_h << endl;
        } else {
          if (data.h == 0) {
            if (tmp_h - dist > 0) {
              flag = false;
              // cout << "break at " << data.x << " " << data.y << " " << data.h
              //  << endl;
            }
          } else if (tmp_h != data.h + dist) {
            flag = false;
            // cout << tmp_h << "break at " << data.x << " " << data.y << " "
            //  << data.h << endl;
          }
        }
        if (!flag) break;
      }
      if (flag) {
        cout << cx << " " << cy << " " << tmp_h << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {

            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var x = input[0];
            var y = input[1];
            Console.WriteLine(x + y / 2);
    }
}



Measured memory_bytes: 13396
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const double PI = acos(-1);

int main() {
	IOS;
	int a, b, c, d; cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			return 0;
		}
	}
}

Measured memory_bytes: 3628
program example
	implicit none

	integer L
    real(8) x,y
    
    read(*,*) L
    
    if(mod(L,3)==0) then
    	write(*,*) (dble(L)/3)**3
    else
    	x=(dble(L)/3.0d0)
        y=dble(L)-(2.0d0*x)
        
        write(*,*) (x**2)*y
    end if
    
end program example

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

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

	int cnt=0;
	for (int i = 0; i < n-1; ++i){
		if(a[i]==a[i+1]){
			a[i+1]=0;
			cnt++;
		}
	}

	cout<<cnt<<endl;

}


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

int main() {
    string N;
    cin >> N;
    if (N[1] == N[2] &&  (N[0] == N[1] || N[2] == N[3]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int X;
    cin>>X;
    int N=X;
    int a=0;
    while(X>0) {
        a+=X%10;
        X/=10;
    }
    if(N%a==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    ll n, m, ans = 0;
    scanf("%lld%lld", &n, &m);
    vector< pair<ll, ll> > d(n);
    for (int i = 0; i < n; ++i) scanf("%lld%lld", &d.at(i).first, &d.at(i).second);
    sort(d.begin(), d.end(), [](pair<ll, ll> i, pair<ll, ll> j) { return i.first < j.first; });
    for (int i = 0; i < n; ++i) {
        ans += d.at(i).first * min(m, d.at(i).second);
        m = max(0LL, m - d.at(i).second);
    }
    printf("%lld\n", ans);
    return 0;
}


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

counter = [0]*(N+1)
integers = 0
for a in A:
    if counter[a] == 0:
        integers += 1
    counter[a] += 1
counter = sorted(counter)
ans = 0
for c in counter:
    if c > 0:
        ans += c
        integers -= 1
    if integers <= K:
        break
print(ans)

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

using namespace std;

typedef long long llint;
typedef pair <int, int> pi;

const int MAXN = 100005;

int n, m, q;
int a[MAXN], bio[MAXN], cnt[MAXN], nxt[MAXN];
vector <int> v, r;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i];
    }
    for (int i = q-1; i >= 0; i--) {
        if (!bio[a[i]]) v.push_back(a[i]);
        bio[a[i]] = 1;
    }
    for (int i = 1; i <= m; i++) if (bio[i] == 0) v.push_back(i);
    for (int i = 1; i < m; i++) nxt[v[i - 1]] = v[i];
    cnt[v[0]] = n;
    for (int i = q-1; i >= 0; i--) {
        if (cnt[a[i]] == 0) continue;
        cnt[a[i]]--;
        cnt[nxt[a[i]]]++;
    }
    memset(bio, 0, sizeof bio);
    for (int i = 0; i < m; i++) {
        if (cnt[v[i]] != 0) break;
        bio[v[i]] = 1;
        r.push_back(v[i]);
    }
    for (int i = 1; i <= m; i++) if (bio[i] == 0) r.push_back(i);
    bool ok = 1;
    for (int i = 0; i < m; i++) ok &= v[i] == r[i];
    if (ok) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 5792
A,B,C,K =  map( int ,input().split())
sum = 0
if A < K:
    sum+=A*1
    if A+B<K:
        sum+=B*0
        if A+B+C==K:
            sum-=C
        else:
            sum-=K-A-B
elif A==K:
    sum+=A*1
else:
    sum+=K*1
print(sum)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  sort(all(A));
  reverse(all(A));

  if(N==2){
    cout<<A[0]<<endl;
    return 0;
  }else if(N==3){
    cout<<A[0]+A[1]<<endl;
    return 0;
  }

  ll ans=A[0];
  int num=1;
  for(int i=1;i<N;i++){
    if(num+2<=N-1){
      ans+=A[i]*2;
      num+=2;
    }else if(num+1<=N-1){
      ans+=A[i];
      num++;
    }else break;
  }
  cout<<ans<<endl;

  return 0;
}


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

map<ll, char> m;
string s, t;
ll a, b;

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

	cin >> a >> b >> s >> t;
	ll g = 1LL*a*b/__gcd(a, b);
	for (int i = 0; i < a; ++i)
		m[i*(g/a)] = s[i];
	for (int i = 0; i < b; ++i) {
		if (m.count(i*g/b) > 0) {
			if (m[i*g/b] != t[i]) {
				cout << "-1\n";
				return 0;
			}
		}
	}
	cout << g << endl;
}

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

using namespace std;

int main(){

  string pass;
  
  for(int i=0;i<1000;++i){

	bool judge = true;
	
	cin>>pass;

	for(int j=0;j<pass.size()-1;++j){
	  
	  if(!(pass[j]=='A' && (pass[j+1]=='B' || pass[j+1]=='D'))
		 && !(pass[j]=='B' && (pass[j+1]=='A' || pass[j+1]=='C' || pass[j+1]=='E'))
		 && !(pass[j]=='C' && (pass[j+1]=='B' || pass[j+1]=='F'))
		 && !(pass[j]=='D' && (pass[j+1]=='A' || pass[j+1]=='E' || pass[j+1]=='G'))
		 && !(pass[j]=='E' && (pass[j+1]=='B' || pass[j+1]=='D' || pass[j+1]=='F' || pass[j+1]=='H'))
		 && !(pass[j]=='F' && (pass[j+1]=='C' || pass[j+1]=='E' || pass[j+1]=='I'))
		 && !(pass[j]=='G' && (pass[j+1]=='D' || pass[j+1]=='H'))
		 && !(pass[j]=='H' && (pass[j+1]=='G' || pass[j+1]=='E' || pass[j+1]=='I'))
		 && !(pass[j]=='I' && (pass[j+1]=='F' || pass[j+1]=='H'))){
		judge=false;
		break;
	  }
	  
	}
	
	if(judge==true)
	  cout<<pass<<endl;
	
  }
  
  return 0;
  
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 2e5 + 10;
int n, m, res = 1, fa[N], sz[N];
int find (int x) {
	return fa[x] == x ? x : (fa[x] = find (fa[x]));
}
signed main() {
	read (n), read (m);
	for (int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
	for (int i = 1, x, y; i <= m; ++i) {
		read (x), read (y);
		int fx = find (x), fy = find (y);
		if (fx != fy) fa[fx] = fy, sz[fy] += sz[fx], res = max (res, sz[fy]);
	}
	return printf ("%d\n", res), 0;
}

Measured memory_bytes: 5284
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include <cmath>

int main() {
	ll h;
	cin >> h;
	int n(0);
	while (h != 1) {
		h = h / 2;
		++n;
	}
	ll sum(0);
	rep(i, n+1) {
		sum += pow(2,i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
import numpy as np
aa = np.zeros((h, w),dtype='int32')
for i in range(h):
    aa[i] = np.array([int(c=='#') for c in input()])
cnt = 0
for i in range(2**w):
    col = np.array([int(i&(2**j)>0) for j in range(w)])
    tmp = aa.dot(col)
    for p in range(2**h):
        row = np.array([int(p&(2**l)>0) for l in range(h)])
        if np.sum(tmp*row) == k:
            cnt += 1
print(cnt)

Measured memory_bytes: 26988
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void) {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int E,F;

    E=min(A,B);
    F=min(C,D);

    cout<<E+F<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string sa, sb; cin >> sa >> sb;
	int start; ll ans;
	if( sa[0] == sb[0] ){
		start = 1;
		ans = 3;
	} else {
		start = 2;
		ans = 6;
	}
	for( int i = start; i < n; ++i ){
		if( sa[i] == sb[i] && sa[i-1] == sb[i-1] ){
			ans *= 2;
		} else if( sa[i] == sb[i] && sa[i-1] != sb[i-1] ){
			ans *= 1;
		} else if( sa[i] != sb[i] && sa[i-1] == sb[i-1] ){
			ans *= 2;
			i += 1;
		} else if( sa[i] != sb[i] && sa[i-1] != sb[i-1] ){
			ans *= 3;
			i += 1;
		}
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
ll z=0,o=0,n,p;
ll candy[51]; 
ll d2(ll x){
	if(x==0){
		return 1;
	}
	if(x==1){
		return 2;
	}
	else{
		if(x%2==0){
			ll a=d2(x/2)*d2(x/2);
			return a;
		}
		else {
			ll a=d2((x-1)/2)*d2((x-1)/2)*2;
			return a;
		}
	}
}
ll co(ll a){
	ll pro=1;
	a=o-a;
	if(a==0){
		return 1;
	}
	else{
		for(ll i=1;i<=a;i++){
			pro*=(o-i+1);
			pro/=i;
		}
	} 
	return pro;
}
ll all_one(){
	ll sum=0;
	for(ll i=0;i<=o;i+=2){
		ll b=co(i);
		sum+=b;
	}
	if(sum==0){
		return 1;
	}
	return sum;
}
ll all_one2(){
	ll sum=0;
	for(ll i=1;i<=o;i+=2){
		ll b=co(i);
		sum+=b;
	}
	return sum;
}
ll all_zero(){
	ll sum=d2(z);
	if(sum==0){
		return 1;
	}
	else return sum;
}
int main()
{
	ll ans=0;
	cin>>n>>p;
	for(ll i=0;i<n;i++){
		cin>>candy[i];
		candy[i]=candy[i]%2;
		if(candy[i]==0)z++;
		else o++;
	}
	ll ze=all_zero();
	ll on=all_one();
	ll one=all_one2();
	//cout<<ze<<" "<<on<<" "<<one<<" ";
	if(p==0){
		cout<<ze*on;
	}
	else cout<<ze*one;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 1000000;

int n;
char s[MAXN+1];
int a[MAXN];

int modchoose(int n, int k, int mod) {
	int ret = 1;
	while (n > 0 || k > 0) {
		int nn = n%mod, kk = k%mod; n /= mod, k /= mod;
		if (kk > nn) return 0;
		//ret *= choose(nn, kk);
	}
	return ret;
}

int solve() {
	bool any1 = false; REP(i, n) if (a[i] == 1) any1 = true;
	if (!any1) REP(i, n) a[i] /= 2;
	int res = 0;
	REP(i, n) if (a[i] == 1) res ^= modchoose(n - 1, i, 2);
	if (!any1) res *= 2;
	return res;
}

void run() {
	scanf("%d", &n);
	scanf("%s", s); assert(strlen(s) == n); REP(i, n) a[i] = s[i] - '1';
	printf("%d\n", solve());
}


int main() {
	run();
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint x, y;
    cin >> x >> y;
    unordered_set<lint> g1 = {1, 3, 5, 7, 8, 10, 12};
    unordered_set<lint> g2 = {4, 6, 9, 11};
    string res;
    if (x == 2 || y == 2) res = "No";
    else if (g1.find(x) != g1.end() && g1.find(y) != g1.end()) res = "Yes";
    else if (g2.find(x) != g2.end() && g2.find(y) != g2.end()) res = "Yes";
    else res = "No";
    cout << res << "\n";
}

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

using namespace std;
typedef tuple<int, string, int> psi;
// typedef pair<string, int> psi;

int main (void) {
    int n;
    cin >> n;
    psi p[n];
    rep(i, n) {
        string s;
        int pi;
        cin >> s >> pi;
        p[i] = psi(i+1, s, pi);
    }

    sort(p, &p[n], [](const auto& x, const auto& y) {return get<2>(x) > get<2>(y);});
    stable_sort(p, &p[n], [](const auto& x, const auto& y) {return get<1>(x) < get<1>(y);});
    rep(i, n) {
        cout << get<0>(p[i]) << endl;
    }


    return 0;
}



Measured memory_bytes: 256
import numpy as np
a = []
b = []
time_tmp = 0
ans = True
N = int(input())
for i in range(N):
    atmp, btmp = (int(x) for x in input().split())
    a.append(atmp)
    b.append(btmp)
b_sort = np.argsort(b)
for i in range(N):
    work_num = b_sort[i]
    time_tmp += a[work_num]
    if time_tmp > b[work_num]:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 29712
# Aizu Problem 0257: Railway Ticket

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


status = tuple([int(_) for _ in input().split()])
print("Open" if status in [(1, 1, 0), (0, 0, 1)] else "Close")

Measured memory_bytes: 7840
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
	long long x[4];
	long long  a,b,c;
	scanf("%lld %lld %lld", &a, &b, &c);
	x[1] = a;
	x[2] = b;
	x[3] = c;
	sort(x + 1 , x + 4);
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{
		printf("0\n");
	}
	else
	{
		printf("%lld\n",x[1] * x[2]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define f first
#define s second
#define inf 1000000007

string S,T;

int main() {
    cin >> S ;
    cin >> T;
    string ans = "0";
    rep(i,S.size()){
        string temp = S;
        ll check = 0;
        repi(j,i,i+T.size()){
            if (temp[j] == T[j-i]) {
                check ++;
                continue;
            }
            else if (temp[j] == '?'){
                temp[j] = T[j-i];
                check ++;
            }
        }
        if (check == T.size()){
        string xans = temp;
        // cout << xans << endl;
        rep(k,xans.size()){
            if (xans[k] == '?'){
                xans[k] = 'a';
            }
        }
        if (ans == "0") ans = xans;
        else ans = min(ans,xans);
        }
    }
    if (ans == "0") cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
   
    return 0;
}


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

int main()
{
	int k;
	string s;
	cin >> k >> s;
	if(s.size() > k)
	{
		for (int i = 0; i < k; ++i)
		{
			cout << s[i];
		}
		cout << "..." << endl;
	}
	else
	{
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;



int main() {
	int n, m; cin >> n >> m;
	cout << (n == m ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  string s, t;
  cin >> s >> t;

  int ans = INF;
  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int same = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i+j] == t[j]) same++;
    }
    ans = min(ans, (int)t.size() - same);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c + 9 * max(a, max(b, c)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}
const int N = 507, M = 2e5, Q = 1e5;
int n, m, qs;
vector<int> t[N];

void input() {
  memset(t, 0, sizeof(t));
  scanf("%d %d %d", &n, &m, &qs);
  forn(i, 0, m) {
    int l, r;
    scanf(" %d %d", &l, &r);
    t[l].push_back(r);
  }
  forn(i, 1, N) {
    sort(all(t[i]));
  }
}

void solve() {
  int p, q;
  forn(i, 0, qs) {
    scanf(" %d %d", &p, &q);
    int ans = 0;
    for (int j = p; j <= q; j++) {
      ans += (upper_bound(t[j].begin(), t[j].end(), q) - t[j].begin());
    }
    printf("%d\n", ans);
  }
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Measured memory_bytes: 2176
N, K, Q = map(int, input().split())
points = [0 for _ in range(N)]
for i in range(Q):
  a = int(input()) - 1
  points[a] += 1
  
for j in range(N):
  if K - Q + points[j] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

struct Graph {
    struct Edge { int from; int to; lint cost; };
    struct Node {
        Node() : par(-1), done(false), dist(INF) {}
        int index;
        int par;
        bool done;
        lint dist;
        vector<Edge> edge;
    };

    int n;
    vector<Node> nodes;
    vector<Edge> edges;
    const static lint INF = 1e18;

    Graph(int n) : n(n) {
        nodes.resize(n);
        for(int i=0; i<n; i++)  nodes[i].index = i;
    }

    void add_edge(int from, int to, lint cost) {
        nodes[from].edge.push_back(Edge{from, to, cost});
        edges.push_back(Edge{from, to, cost});
    }

    void bfs(int s) {
        queue<int> que;
        nodes[s].dist = 0;
        que.push(s);

        while(!que.empty()) {
            int index = que.front(); que.pop();
            for(auto& e : nodes[index].edge) {
                if(nodes[e.to].dist != INF)  continue;
                nodes[e.to].dist = nodes[index].dist + 1;
                nodes[e.to].par = index;
                que.push(e.to);
            }
        }
    }

    lint shortest_dist(int to) { return nodes[to].dist; }
};

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

  Graph g(N);
  for(lint i=0; i<M; i++) {
    lint a, b;
    cin >> a >> b;
    a--, b--;
    g.add_edge(a, b, 1);
    g.add_edge(b, a, 1);
  }

  g.bfs(0);
  cout << (g.shortest_dist(N-1) == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 29560