akhauriyash/Code-Regression huggingface dataset:
// Template //
#include<bits/stdc++.h>
using namespace std;

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int A;
    cin >> A;
    int cnt = 0;
    if (A == 1e5) cou(90909);
    elif(A >= 1e4) cou(A - 9999 + 909);
    elif(A >= 1e3) cou(909);
    elif(A >= 1e2) cou(A - 99 + 9);
    elif(A >= 1e1) cou(9);
    else cou(A);
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	Map<Integer, Set<Integer>> map = new HashMap<Integer,Set<Integer>>();
	Map<Integer, Set<Integer>> inv = new HashMap<Integer,Set<Integer>>();

	void run() {
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> isParent = new HashSet<Integer>();
		for(int i =0 ; i < n ; i++){
			isParent.add(i+1);
		}
		
		for(int i = 0; i < n+m-1;i++){
			int a  =sc.nextInt();
			int b = sc.nextInt();
			
			map.computeIfAbsent(a, __ -> new HashSet<Integer>()).add(b);
			inv.computeIfAbsent(b, __ -> new HashSet<Integer>()).add(a);
			
			isParent.remove(b);
		}
		
		int root = isParent.toArray(new Integer[0])[0];
		
		int ans[] = new int[n];
		search(ans,root,0);
		
		for(int i =0 ; i < n ; i++){
			System.out.println(ans[i]);
		}
	}
	
	void search(int[] ans, int initnow, int initparent ){

		List<int[]> children = new LinkedList<int[]>();
		children.add(new int[]{initnow,initparent});
		
		
		for(;!children.isEmpty();){
			int[] n = children.remove(0);
						
			int now = n[0];
			int parent = n[1];
			
//			System.out.println(now+" "+parent);
			
			ans[now-1] = parent;
			
			for(int child : map.getOrDefault(now,new HashSet<Integer>())){
				if(inv.get(child).size() != 1){
					inv.get(child).remove(now);
//					System.out.println(" remove "+child+" : "+now);
				}else{
					children.add(new int[]{child,now});
				}			
			}
			
		}
		
		return ;
		
	}
}


Measured memory_bytes: 160348
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

vector<string> w{"SUN","MON","TUE","WED","THU","FRI","SAT"};

void solve(std::string S){
    // vout(w);
    ll num=0;
    for (ll i = 0; i < 7; i++) {
        if (w[i] == S){
            num=i;
            break;
        }
    }
    cout << 7 - num << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

template <typename T, typename U> void cmin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U> void cmax(T &a, U b) {
  if (a < b) a = b;
}

template <typename T, T (*op)(T, T), T (*ie)()> class SegmentTree {
private:
  int N, size, log;
  vector<T> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }

public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n, ie())) {}
  SegmentTree(const vector<T> &v) : N((int)v.size()) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<T>(2 * size, ie());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) apply(i);
  }
  void set(int p, T x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  T get(int p) { return D.at(p + size); }
  T query(int l, int r) {
    r++;
    T sml = ie(), smr = ie();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  T query_all() { return D.at(1); }
  template <bool (*f)(T)> int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    T sm = ie();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(T)> int min_left(int r) {
    return min_left(r, [](T x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    T sm = ie();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};

using mono = int;
mono op(mono a, mono b) { return max(a, b); };
mono ie() { return 0; };

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

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int MX = 3e5;
  SegmentTree<mono, op, ie> ST(MX + 1);
  for (int i = 0; i < N; i++) {
    int l = A.at(i) - K;
    cmax(l, 0);
    int r = A.at(i) + K;
    cmin(r, MX);
    ST.set(A.at(i), ST.query(l, r) + 1);
  }
  cout << ST.query_all() << "\n";
}

Measured memory_bytes: 9780
/*#include<bits/stdc++.h>
using namespace std;
const long double PI=3.14159265358979323846;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int r; cin>>r;
	cout<<fixed<<setprecision(20)<<2*r*PI<<"\n"s;
}*/

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,m; cin>>n>>m;
	int64_t sum=0;
	for(int i=0;i<m;++i){
		int64_t a; cin>>a;
		sum+=a;
	}
	cout<<(n-sum<0?-1:n-sum)<<"\n"s;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#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;



int main() {
	ll k;
	cin >> k;
	ll now = 0;
	rep(i, k*2) {
		now *= 10;
		now += 7;
		if(now%k == 0) {
			cout << i+1 << endl;
			return 0;
		} else {
			now %= k;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = int64_t;
int main() {
    i64 n;
    string s[2];
    cin >> n >> s[0];
    s[1] = s[0];
    reverse(begin(s[1]), end(s[1]));
    map<pair<string, string>, i64> mp[2];
    for (int k = 0; k < 2; ++k) {
        int d = n * k;
        for (int t = 0; t < (1 << n); ++t) {
            string r, b;
            for (int i = 0; i < n; ++i) {
                if (t & (1 << i)) {
                    r.push_back(s[k][i]);
                } else {
                    b.push_back(s[k][i]);
                }
            }
            mp[k][{ r, b }]++;
        }
    }
    i64 ans = 0;
    for (const auto& p : mp[0]) {
        // cerr << p.first.first << ' ' << p.first.second << endl;
        ans += p.second * mp[1][p.first];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define endl '\n'
#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define lson (idx<<1)
#define rson ((idx<<1) | 1)

const int mx = 2e5 + 9;

int n, q;

struct node {
    int l, r;
    int val;
    int lazy = mx;
};

struct SegTree {
    node tree[8 * mx];

    void build(int idx, int l, int r) {
        int mid = (l + r) / 2;

        tree[idx].l = l, tree[idx].r = r;
        if (l == r) {
            if (l == n) tree[idx].val = 1;
            else tree[idx].val = n;
            return;
        } 

        build(lson, l, mid);
        build(rson, mid + 1, r);

        tree[idx].val = min(tree[lson].val, tree[rson].val);
    }

    void propagate(int idx) {
        tree[idx].val = min(tree[idx].val, tree[idx].lazy);
        tree[lson].lazy = min(tree[lson].lazy, tree[idx].lazy);
        tree[rson].lazy = min(tree[rson].lazy, tree[idx].lazy);

        tree[idx].lazy = mx;
    }

    void update(int idx, int L, int R, int x) {
        int l = tree[idx].l, r = tree[idx].r;
        propagate(idx);

        if (r < L or R < l) return;
        if (L <= l and r <= R) {
            tree[idx].val = min(tree[idx].val, x);
            tree[idx].lazy = min(tree[idx].lazy, x);
            return;
        }

        update(lson, L, R, x);
        update(rson, L, R, x);

        tree[idx].val = min(tree[lson].val, tree[rson].val);
    }

    int query(int idx, int L, int R) {
        int l = tree[idx].l, r = tree[idx].r;
        propagate(idx);

        if (r < L or R < l) return mx;
        if (L <= l and r <= R) {
            return tree[idx].val;
        }

        int q1 = query(lson, L, R);
        int q2 = query(rson, L, R);

        return min(q1, q2);
    }
};

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

    SegTree R, C;
    R.build(1, 1, n);
    C.build(1, 1, n);

    ll ans = ll(n - 2) * (n - 2);
    while (q--) {
        int t, x; cin >> t >> x;
        if (t == 1) {
            int hi = R.query(1, x, x);
            ll stones = max(0, hi - 2);

            ans -= stones;
            R.update(1, x, x, 1);
            C.update(1, 1, hi, x);

        } else {
            int hi = C.query(1, x, x);
            ll stones = max(0, hi - 2);

            ans -= stones;
            C.update(1, x, x, 1);
            R.update(1, 1, hi, x);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 53616
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define ff first
#define ss second
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,R,L) for(auto i=R;i>L;i--)
#define all(x) (x).begin(),(x).end()
#define show(x) cout<<(#x)<<" = "<<(x)<<"\n";
#define show2(x,y) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<"\n";
#define show3(x,y,z) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<" & "<<(#z)<<" = "<<(z)<<"\n";
#define endln "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000000000000000

using namespace std;

map<ll,ll> mp;

int main() 
{
	fastio;
	ll n,N;
	cin>>n;
	N=n;
	
	while(n%2==0)
	{
	    n = n/2;
	    mp[2]++;
	}
	for(ll i=3;i<=sqrt(N);i+=2)
	{
	 //   show(i);
	    while(n%i==0)
	    {
	        n = n/i;
	        mp[i]++;
	    }
	}
	if(n>2)
	    mp[n]++;
	ll ans=0;
	for(auto it=mp.begin();it!=mp.end();it++)
	{
	    ll ct=1;
	    ll val = it->ss;
//	    show2(it->ff,it->ss)
	    while(val>=ct)
	    {
	        val-=ct;
	        ans+=1;
	        ct++;
	    }
	}
	cout<<ans;
}




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

int main() {
  int n;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }
  sort(y, y + n);
  int mid_l = y[(n - 1) / 2];
  int mid_r = y[(n + 1) / 2];
  for (int i = 0; i < n; i++) {
    if (x[i] <= mid_l)
      cout << mid_r << endl;
    else
      cout << mid_l << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
const int MAXN=1001;
double h[MAXN];
double T,A;
int n;
int main()
{
	scanf("%d",&n);
	scanf("%lf%lf",&T,&A);
	for(int i=1;i<=n;i++)scanf("%lf",&h[i]);
	
	int loc=1;
	double ans=abs(T-h[1]*0.006-A);
	
	for(int i=2;i<=n;i++)
	{
		if(abs(T-h[i]*0.006-A)<ans)
		{
			ans=abs(T-h[i]*0.006-A);
			loc=i;
		}
	}
	printf("%d\n",loc);
	return 0;
}


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

struct UF {
    vector<int> p;

    UF(int n) {
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        p[y] = p[x];
    }
};

int main() {
    while(true){
        int n;cin >> n;
        if(n == 0) break;
        UF uf(n);

        vector<double> x(n), y(n), z(n), r(n);
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }

        vector<pair<double, pair<int, int>>> e;

        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double dx = x[i]-x[j];
                double dy = y[i]-y[j];
                double dz = z[i]-z[j];
                e.push_back({max(0.0, sqrt(dx*dx+dy*dy+dz*dz)-r[i]-r[j]), {i, j}});
            }
        }

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

        double ans = 0;
        for(int i=0;i<(int)e.size();i++){
            int x = e[i].second.first;
            int y = e[i].second.second;
            double d = e[i].first;
            if(uf.find(x) != uf.find(y)){
                ans += d;
                uf.unite(x, y);
            }
        }

        printf("%.3lf\n", ans);
    }
    return 0;
}

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

int N, X, T;

int main(){
  cin >> N >> X >> T;
  
  int time1;
  
  if( N % X == 0 ){
    time1 = (N / X)*T;
  }else{
    time1 = ((N / X) + 1 ) * T;
  }
  
  cout << time1 << endl;
}

Measured memory_bytes: 3612
from collections import defaultdict

h,w=map(int,input().split())
c=[]
dic=defaultdict(int)
for _ in range(10): c.append(list(map(int,input().split())))
for _ in range(h):
    temp=list(map(int,input().split()))
    for i in temp: dic[i]+=1
for k in range(10):
    for i in range(10):
        for j in range(10): c[i][j]=min(c[i][j],c[i][k]+c[k][j])
ans=0
for item in dic.items():
    if item[0]>=0: ans+=item[1]*c[item[0]][1]
print(ans)

Measured memory_bytes: 9396
import java.util.Scanner;

public class Main {
	/**
	 * ???????????\????????£?????´??° a, b ?????\???????????¨??????a ??¨ b ????????§??¬?´???°??¨????°???¬?????°???????????????????????????????????°????????????????????????????????? ????????????a ??¨
	 * b ???????°???¬?????°??? 20 ???????¶??????????????????¨????????????
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			System.out.print(greatestcommondivisor(a, b) + " " );
			System.out.println(leastcommonmultiple(a, b));
		}

	}

	public static long greatestcommondivisor(long a, long b) {
		if(a > b) {
            long tmp;
            tmp = a;
            a = b;
            b = tmp;
        }

        while(a != 0) {
            long tmp = a;
            a = b%a;
            b = tmp;
        }

        return b;
	}

	public static long leastcommonmultiple(long a, long b) {
		// ?????° A , B ????????§??¬?´???°??? G ????°???¬?????°??? L ??¨????????¨
		// AB=GL???????????????????????????????????§???????????????
		long c = greatestcommondivisor(a, b);
		long d = a * b / c;
		return d;

	}

}

Measured memory_bytes: 25992
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	LL ans=0;
	REP(i,N){
		if((i+1)%3==0||(i+1)%5==0)continue;
		ans+=(i+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int c[maxn],du[maxn];
int n;
struct edge{int v,nxt;}e[maxn<<1];
int head[maxn],ecnt=0,to[maxn];
void add(int u,int v)
{
	to[u]=v,to[v]=u;
	e[++ecnt]=(edge){v,head[u]},head[u]=ecnt;
	e[++ecnt]=(edge){u,head[v]},head[v]=ecnt;
}
bool vis[maxn];
vector<int>ans;
int find(int u)
{
	for(int i=head[u];~i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(vis[v]||du[v]==1)continue;
		return v;
	}
}
vector<int>solve(int l,int r)
{
	vector<int>cnt;
	vector<int>ret;
	ret.push_back(1);
	cnt.push_back(du[l]-2);
	memset(vis,0,sizeof(vis));
	while(l!=r)vis[l]=1,l=find(l),cnt.push_back(du[l]-2);
	int id=1;
	for(auto t:cnt)
	{
		for(int i=1;i<=t;i++)ret.push_back(id+i+1);
		ret.push_back(id+1),id+=t+1;
	}
	ret.push_back(n);
	return ret;
	
}
vector<int>min(vector<int>a,vector<int>b)
{
	for(int i=0;i<a.size();i++)
	if(a[i]<b[i])return a;
	else if(a[i]>b[i])return b;
	return a;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		du[u]++,du[v]++;
	}
	for(int i=1;i<=n;i++)c[i]=du[i];
	for(int i=1;i<=n;i++)if(du[i]==1)c[i]--,c[to[i]]--;
	int mx=0;
	for(int i=1;i<=n;i++)mx=max(mx,c[i]);
	if(mx>2){printf("-1\n");return 0;}
	if(mx==0)
	{
		printf("1 ");
		for(int i=3;i<n;i++)printf("%d ",i);
		printf("2 ");
		printf("%d\n",n);
		return 0;
	}
	int u,v;
	for(int i=1;i<=n;i++)if(c[i]==1)u=i;
	for(int i=n;i>=1;i--)if(c[i]==1)v=i;
	ans=min(solve(u,v),solve(v,u));
	for(auto u:ans)printf("%d ",u);
	printf("\n");
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, s = 0;
    cin >> n;
    if(n%1000 == 0) {
        cout << 0;
        return 0;
    }
    while(n%1000 != 0) {
        n += 1;
        s += 1;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int dp[101][10001];
int main() {
	int N, W;
	cin >> N >> W;
	int v[101], w[101];
	REP(i, N) {
		cin >> v[i] >> w[i];
	}
	REP(i, W+1)dp[0][i] = 0;
	REP(i, N) {
		REP(j, W+1) {
			if (j >= w[i])dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
}



Measured memory_bytes: 7020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        System.out.println(lcm(sc.nextLong(), sc.nextLong()));
    }
    
    public static long lcm(long m, long n) {
        return m * (n / gcd(m, n));
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 21972
#include<stdio.h>
int calc(int x){
int count=1;
  while(x>=10){
	x/=10;
    count++;
  }
  return count;
}
int main(void){
int n;
  scanf("%d",&n);
  int c=0;
  for(int i=1;i<=n;i++){
	if(calc(i)%2!=0)c++;
  }
printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
int p[3];
using namespace std;
int main(){
	int a=0,b=0,c=0,d=0;
	while(~scanf("%d%d%d",p,p+1,p+2)){
		std::sort(p,p+3);
		if(p[0]+p[1]<=p[2]){
			printf("%d %d %d %d\n",a,b,c,d);
			return 0;
		}
		a++;
		if(p[0]*p[0]+p[1]*p[1]==p[2]*p[2])b++;
		if(p[0]*p[0]+p[1]*p[1]>p[2]*p[2])c++;
		if(p[0]*p[0]+p[1]*p[1]<p[2]*p[2])d++;
	}
}


Measured memory_bytes: 2768
N = int(input())

res = N
for i in range(N+1):
    cc = 0
    t = i
    while t > 0:
        cc += t % 6
        t //= 6
    t = N-i
    while t > 0:
        cc += t % 9
        t //= 9
    if res > cc:
        res = cc

print(res)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BPapersPlease
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var aList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            var evens = aList.Where(x => x % 2 == 0);
            var answers = evens.Where(x => x % 3 == 0 || x % 5 == 0);

            Console.WriteLine(evens.Count() == answers.Count() ? "APPROVED": "DENIED");
            Console.ReadLine();
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int j=0,k=1;
    a[0] = 0;
    for (int i = 1; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) b[i] = 0;

    sort(a,a+n);
    // for (int i = 0; i < n; i++) cout << a[i];

    while(1){
        // if (k == n) {
        //     j += 1;
        //     k = 1;
        // }
        if (a[k] == j+1) {
            b[j] ++;
            k ++;
        }else{
            // j += 1;
            j ++;   
        }
        if (j == n || k == n) break;
        
    }

    for (int i = 0; i < n; i++) cout << b[i] << endl;
}

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

bool checkBit(int n,int i)
{
    return n&(1<<i);
}
int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int> > v;
    vector<int> price;

    ll M = 1e12;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        price.push_back(x);
        vector<int> temp;
        for(int j=0;j<m;j++)
        {
            int x;
            cin >> x;
            temp.push_back(x);
        }
        v.push_back(temp);
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //         cout << v[i][j] << " ";
    //     cout << endl;
    // }
    // for(int i=0;i<n;i++)
    //     cout << price[i] <<  " ";
    // cout << endl;
    // cout << (1<<n) << endl;
    for(int i=1;i<(1<<n);i++)
    {
        int num = i;
        // cout << num << endl;
        vector<int> S;
        for(int j=0;j<n;j++)
        {
            // cout << num << " " << j << " " << checkBit(num,j) << endl;
            if( checkBit(num,j) ) 
            {
                
                S.push_back(j);
            }
                

        }
        if(S.size()>0)
        {
                // cout << num << endl;
                // for(int j=0;j<S.size();j++)
                //     cout << S[j] << " ";
                // cout << endl;
                vector<ll> sums;
                for(int j=0;j<m;j++)
                    sums.push_back(v[S[0]][j]);
                ll P = price[S[0]];
                // for(int j=0;j<m;j++)
                //     cout << sums[j] << " ";
                // cout << endl;
                for(int j=1;j<S.size();j++)
                {
                    P += price[S[j]];
                    for(int l=0;l<m;l++)
                    {
                        int cur = v[S[j]][l];
                        sums[l] += cur;
                        
                    }
                    
                }
                // for(int j=0;j<m;j++)
                //     cout << sums[j] << " ";
                // cout << endl;
                bool valid = true;
                for(int j=0;j<m;j++)
                {
                    if(sums[j]<k)
                    {
                        valid = false;
                        break;
                    }
                }
                // cout << P << endl;
                if(valid)
                    M = min(M,P);
                // cout << M << endl;
        }
        
    }
    if(M==1e12)
        M=-1;
    cout << M <<endl;
    
}

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

const int MAXN = 2e6 + 100 , MAXA = 2000 + 100 , MOD =1e9+7 ; 

int n , a[MAXN] , b[MAXN] , cnt[2*MAXA][2*MAXA] , dp[2*MAXA][2*MAXA] , fact[4*MAXA]; 

int pw(int a , int b)
{
	if(!b)
		return 1 ; 
	int res= pw(a , b/2) ;
	res*=res ; 
	res%=MOD ;  
	if(b%2)
		res*=a ; 
	return res%MOD ; 
}

int C(int a , int b)
{
	int res = fact[a] ;
	res = (res*pw(fact[b] , MOD-2)) %MOD ; 
	res = (res*pw(fact[a-b] , MOD-2)) %MOD ; 
	return res ; 
}

int32_t main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
	fact[0]=1 ; 
	for(int i=1 ; i<MAXA*4 ; i++)
		fact[i] = (fact[i-1]*i)%MOD ;
	cin >> n ; 
	for(int i=0 ; i<n ; i++)
	{
		cin >> a[i] >> b[i] ; 
		cnt[MAXA-a[i]][MAXA-b[i]]++ ; 
	}
	for(int i=1 ; i<2*MAXA ; i++)
		for(int j=1 ; j<2*MAXA ; j++)
		{
			dp[i][j] = dp[i-1][j] + dp[i][j-1] + cnt[i][j] ; 
			dp[i][j] %=MOD; 
		}
	int ans=0 ;
	for(int i=0 ; i<n ; i++)
	{
		ans+=(dp[MAXA+a[i]][MAXA+b[i]]);
		ans%=MOD ; 
		ans-=(C(2*a[i] + 2*b[i] , 2*a[i])) ; 
		ans+=MOD ; 
		ans%=MOD ; 
	}
	ans = (ans * pw(2 , MOD-2)) %MOD ; 
	cout << ans ; 
	
}

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

using namespace std;
const int MAXN=1e5+10;
char s[MAXN];
int pp=0,rk=0,len;
int main()
{
	scanf("%s",s);len=strlen(s);
	for(int i=0;i<len;i++)
		if(s[i]=='p') pp++;
		else rk++;
	printf("%d",(rk-pp)/2);
	return 0;
}

Measured memory_bytes: 384
/************************************************************
	> File Name: c.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 17 May 2020 08:12:59 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
signed main(void){
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double dah = 30*h + m/2;
	double dam = m*6;
	double cha = fabs(dah-dam)/180*PI;
	cout << fixed << setprecision(20) << sqrt(a*a+b*b-2*a*b*cos(cha)) << endl;
	return 0;
}


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

const long long p = 998244353;
long long fac[1000000] = {};
long long invfac[1000000] = {};

long long power(long long a, int n) {
    long long l;
    if (a == 1 || n == 0) {
        return 1;
    } else if (n == 1) {
        return a % p;
    } else if (n % 2 == 0) {
        l = power(a, n/2) % p;
        return l * l % p;
    } else {
        l = power(a, n/2) % p;
        return l * l % p * a % p;
    }
}

void makefac(int N) {
    int i;
    fac[0] = fac[1] = 1;
    invfac[0] = invfac[1] = 1;
    for (i = 2; i <= N; i++) {
        fac[i] = fac[i-1] * i % p;
        invfac[i] = power(fac[i], p-2);
    }
}

long long nCr(long long n, long long r) {
    return fac[n] * invfac[r] % p * invfac[n-r] % p;
}

int main() {
    
    int N, A, B;
    long long K;
    cin >> N >> A >> B >> K;
    
    makefac(N);
    
    long long r, b, ans = 0;
    for (r = 0; r <= N; r++) {
        if ((K - r * A) % B != 0) continue;
        b = (K - r * A) / B;
        if (b < 0 || N < b) continue;
        ans = (nCr(N, r) * nCr(N, b) % p + ans) % p;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 8448
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; itr++)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; i--)
#define reprev(itr, end) reprrev(i, 0, end)
#define all(container) container.begin(), container.end()
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807i64
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };
struct edge { ll to; ll cost; };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    for (T& x : vec) os << x << endl;
    return os;
}

// ***<ここから>****************************************************************

int main(void) {

    int N;
    cin >> N;
    vll A(N);

    rep(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }

    sort(all(A));
    int c = (N + 1) / 2 - 1;
    ll cn = A[c];

    ll ans = 0;
    rep(i, N){
        ans += abs(A[i] - cn);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int m, n;
vector<PII> vp, vp2;

void input() {
  cin >> m;
  if ( !m ) {
    return;
  }
  vp.resize( m );
  for ( int i = 0; i < m; i++ ) {
    cin >> vp[ i ].first >> vp[ i ].second;
  }
  cin >> n;
  vp2.resize( n );
  for ( int i = 0; i < n; i++ ) {
    cin >> vp2[ i ].first >> vp2[ i ].second;
  }
}


void solve() {
  set<PII> s( vp2.begin(), vp2.end() );
  for ( int i = 0; i < n; i++ ) {
    bool isans = true;
    for ( int j = 0; j < m; j++ ) {
      if ( !s.count( MP( vp[ j ].first + vp2[ i ].first - vp[ 0 ].first, vp[ j ].second + vp2[ i ].second - vp[ 0 ].second ) ) ) {
        isans = false;
        break;
      }
    }
    if ( isans ) {
      cout << vp2[ i ].first - vp[ 0 ].first << " " << vp2[ i ].second - vp[ 0 ].second << "\n";
      break;
    }
  }
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  while ( true ) {
    input();
    if ( !m ) {
      break;
    }
#ifdef WIN32
    clock_t stime = clock();
#endif
    solve();
#ifdef WIN32
    clock_t etime = clock();
    cerr << "TIME : " << ( double ) ( etime - stime ) / CLOCKS_PER_SEC << "\n";
#endif
  }
  return 0;
}

Measured memory_bytes: 1260
import java.io.*;
import java.util.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m, k;
	static long mod = 998244353;
	static Boolean[][][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static ArrayList<Integer>[] ad;
	static boolean[] vis, taken;
	static int[] occ, ans;
	static TreeSet<Long> al;
	static long[] val;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long n = sc.nextLong();
		int ans = 0;
		long x = 100;
		for (; x < n;) {
                x=x+x/100;
                ans++;
		}
		System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int main () {
  int x,y,X,Y;
  cin >> x >> y >> X >> Y;
  
  for (int i = 0; i < Y-y; i++) {
    cout << 'U';
  }
  for (int i = 0; i < X-x; i++) {
    cout << 'R';
  }
  for (int i = 0; i < Y-y; i++) {
    cout << 'D';
  }
  for (int i = 0; i < X-x; i++) {
    cout << 'L';
  }
  cout << 'L';
  for (int i = 0; i <= Y-y; i++) {
    cout << 'U';
  }
  for (int i = 0; i <= X-x; i++) {
    cout << 'R';
  }
  cout << 'D';
  cout << 'R';
  for (int i = 0; i <= Y-y; i++) {
    cout << 'D';
  }
  for (int i = 0; i <= X-x; i++) {
    cout << 'L';
  }
  cout << 'U';
  cout << endl;
}
   

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x - k + 1; i <= x + k - 1; i++) cout << i << " ";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,a,n,i,count=0;
    scanf("%d%d",&h,&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        h=h-a;
        if(h<=0)break;
    }
    if(h<=0)
    printf("Yes");
    else
        printf("No");
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;

typedef long long ll;

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


vector<ll> cost(999999,-1);
vector<ll> memo(999999,-1);
ll K,a;

ll dp(ll n){
    ll c=K,check=1e9+7;
    if(n==0) return 0;
    if(memo[n]!=-1) return memo[n];
    else if(n<K) c=n;
    for(ll i=1;i<=c;i++){
        a=dp(n-i)+abs(cost[n]-cost[n-i]);
        if(check>a)check=a;
    }
    return memo[n]=check;
}

int main(){
    int N;
    cin>>N>>K;
    rep(i,N) cin>>cost[i];
    memo[0]=0;
    cout<<dp(N-1)<<endl;
    return 0;
}


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

int main()
{
    string N;
    cin >> N;
    if (N[0] == '9') {
        cout << "Yes";
    } else if (N[1] == '9') {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

int n;
int p[MAXN], a[MAXN][2];
bool w[MAXN][MAXN], vis[MAXN];

bool find (int k)
{
    for (int i = 1; i <= n; i ++)
        if ((w[k][i]) && (!vis[i]))
        {
            vis[i] = 1;
            if ((!p[i]) || (find (p[i])))
            {
                p[i] = k;
                return true;
            }
        }
    return false;
}

int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d%d", &a[i][0], &a[i][1]);
    }
    memset (w, false, sizeof (w));
    for (int i = 1; i <= n; i ++)
    {
        int x, y;
        scanf ("%d%d", &x, &y);
        for (int j = 1; j <= n; j ++)
        {
            if ((a[j][0] < x) && (a[j][1] < y))
            {
                w[i][j] = true;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        memset (vis, false, sizeof (vis));
        if (find (i))
        {
            ans ++;
        }
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def dot(a,b):
    return a[0]*b[0] + a[1]*b[1]

def cross(a,b):
    return a[0]*b[1] - a[1]*b[0]

x0,y0,x1,y1 = [int(i) for i in input().split()] 
a = [x1-x0,y1-y0]

q = int(input())
for i in range(q):
    x2,y2 = [int(i) for i in input().split()]
    b = [x2-x0,y2-y0]
    crs = cross(a,b)
    if crs > 0 :
        print("COUNTER_CLOCKWISE")
    elif crs < 0 :
        print("CLOCKWISE")
    else :
        if dot(a,b) < 0 :
            print("ONLINE_BACK")
        elif dot(a,a) < dot(b,b) :
            print("ONLINE_FRONT")
        else :
            print("ON_SEGMENT")

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int a,b,c;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>a>>b>>c;
    if(a+b+c >= 22) cout<<"bust\n";
    else cout<<"win\n";


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

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

int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
    mint ans = 1;
    unordered_map<char, ll>mp;
    rep(i, 0, N) {
        mp[s[i]]++;
    }
    for (auto p : mp) {
        ans *= p.second + 1;
    }
    ans -= 1;
    cout << ans.x << "\n";
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int main(){
  int n,m,h[N],ma[N];
  //入力
  cin>>n>>m;
  for(int i=1;i<=n;i++) {
    cin>>h[i];
    ma[i]=0;//0に初期化
  }
  
  for(int i=0;i<m;i++) {
    int a,b;
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);//aと繋がっている展望台の標高の最大値
    ma[b]=max(ma[b],h[a]);//bと繋がっている展望台の標高の最大値
  }
  
  int ans=0;
  for(int i=0;i<=n;i++) {
    if(h[i]>ma[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4404