akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

struct edge{
	int u,v;
	ll c;
	edge(int u, int v, ll c):u(u),v(v),c(c){};
	bool operator<(edge& rhs){
		return (c < rhs.c);
	}
};

int n,ufr[225816],ufp[225816];
ll a[225816];
P segtree[816225];
vector<P> v;
vector<edge> g;

P query(int a, int b, int i=0, int l=0, int r=n){
	if(r<=a || b<=l){
		return P(INFLL,-1);
	}else if(a<=l && r<=b){
		return segtree[i];
	}else{
		return min(query(a,b,i*2+1,l,(l+r)/2),query(a,b,i*2+2,(l+r)/2,r));
	}
}

void update(int k, P x, int i=0, int l=0, int r=n){
	if(!(l<=k && k<r)){
		return;
	}else if(r-l>1){
		update(k,x,i*2+1,l,(l+r)/2);
		update(k,x,i*2+2,(l+r)/2,r);
		segtree[i] = min(segtree[i*2+1],segtree[i*2+2]);
	}else{
		segtree[i] = x;
	}
}

void ufinit(){
	int i;
	for(i=0; i<n; ++i){
		ufr[i] = 1;
		ufp[i] = i;
	}
}

int ufind(int x){
	if(ufp[x] == x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

bool unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return false;
	}
	if(ufr[x] < ufr[y]){
		swap(x,y);
	}
	ufr[x] += ufr[y];
	ufp[y] = x;
	return true;
}

int main(void){
	int p,m,i;
	ll d,ans=0ll;
	P tmp;
	cin >> n >> d;
	for(i=0; i<n; ++i){
		cin >> a[i];
		v.push_back(P(a[i],i));
	}
	sort(v.begin(),v.end());
	fill(segtree,segtree+816225,P(INFLL,-1));
	for(i=0; i<n; ++i){
		p = v[i].second;
		tmp = query(0,p);
		if(tmp.first < INFLL){
			g.push_back(edge(p,tmp.second,a[p]+d*p+tmp.first));
		}
		update(p,P(a[p]-d*p,p));
	}
	fill(segtree,segtree+816225,P(INFLL,-1));
	for(i=0; i<n; ++i){
		p = v[i].second;
		tmp = query(p,n);
		if(tmp.first < INFLL){
			g.push_back(edge(p,tmp.second,a[p]-d*p+tmp.first));
		}
		update(p,P(a[p]+d*p,p));
	}
	sort(g.begin(),g.end());
	m = g.l_ength();
	ufinit();
	for(i=0; i<m; ++i){
		if(unionf(g[i].u,g[i].v)){
			ans += g[i].c;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 28868
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_H&lang=ja
# 全列挙する関数
def allp(aa):
    now = [(0, 0)]
    for v, w in aa:
        nxt = [(w + w0, v + v0) for w0, v0 in now]
        now += nxt
    # wでソート
    now.sort(key=lambda x: (x[0], -x[1]))
    # wが昇順ならvも昇順でないと、無駄な組み合わせがあるということなので
    # それを除いて、wとvを別々に返す
    pv = -1
    ww = []
    vv = []
    for w, v in now:
        if v <= pv: continue
        ww.append(w)
        vv.append(v)
        pv = v
    return vv, ww

def main():
    n, wn = MI()
    vw = [LI() for _ in range(n)]
    # 半分全列挙する
    vv1, ww1 = allp(vw[:n // 2])
    vv2, ww2 = allp(vw[n // 2:])
    # 前半は1つずつ動かして、後半はできるだけ動かさない
    # wの和が制限を越えたら後半は動かす
    ans = 0
    j = len(vv2) - 1
    for v1, w1 in zip(vv1, ww1):
        while w1 + ww2[j] > wn:
            if j == 0:
                print(ans)
                exit()
            else:
                j -= 1
        if v1 + vv2[j] > ans: ans = v1 + vv2[j]
    print(ans)

main()



Measured memory_bytes: 291452
N,M = map(int,input().split())
l = list(map(int,input().split()))
l = list(sorted(l))

d = []
for i in range(M-1):
    d.append(abs(l[i+1]-l[i]))
d = list(sorted(d))
while N != 1 and len(d) !=0:
    del d[len(d)-1]
    N -= 1
sum = 0
if len(d) >= 1:
    for i in range(len(d)):
        sum += d[i]
print(sum)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  vector<vector<int>> U(H, vector<int>(W, 0));
  vector<vector<int>> D(H, vector<int>(W, 0));
  vector<vector<int>> L(H, vector<int>(W, 0));
  vector<vector<int>> R(H, vector<int>(W, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      U[i][j] = i == 0 ? 1 : U[i - 1][j] + 1;
      L[i][j] = j == 0 ? 1 : L[i][j - 1] + 1;
    }
  }
  for (int i = H - 1; i > -1; i--) {
    for (int j = W - 1; j > -1; j--) {
      if (S[i][j] == '#') continue;
      D[i][j] = i == H - 1 ? 1 : D[i + 1][j] + 1;
      R[i][j] = j == W - 1 ? 1 : R[i][j + 1] + 1;
    }
  }
  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      res = max(res, U[i][j] + L[i][j] + D[i][j] + R[i][j] - 3);
    }
  }
  cout << res << '\n';
  return 0;
}


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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int R = 0, B = 0;
  for (char ch: s) {
    if (ch == 'R') R++;
    else B++;
  }
  if (R > B) cout << "Yes" << endl;
  else cout << "No" << endl;
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	while (true) {
		int N;
		cin >> N;
		if(N == 0) break;
		string c;
		cin >> c;
		int maisu[10];
		for(int i = 0; i < N; i++) {
			maisu[i] = 0;
		}
		int ba = 0;
		int turn = 0;
		for(int i = 0; i < c.size(); i++) {
			if(c[i] == 'M') {
				maisu[turn]++;
			}
			else if(c[i] == 'S') {
				maisu[turn]++;
				ba += maisu[turn];
				maisu[turn] = 0;
			}
			else {
				maisu[turn]++;
				maisu[turn] += ba;
				ba = 0;
			}
			turn++;
			turn %= N;
		}
		sort(maisu, maisu+N);
		for(int i = 0; i < N; i++) {
			cout << maisu[i] << " ";
		}
		cout << ba << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
//after contest WA

#include <stdio.h>
#include <stdbool.h>

#define N 200000

int parent[N];
int c[N]={0};
bool visit[N]={false};
void init(int n) {
  for (int i=0; i<n; i++) parent[i] = -1;
}
int root(int a) {
  if (parent[a] < 0) return a;
  else return root(parent[a]);
}
void unite(int a, int b) {
  int pb = parent[b];
  parent[b] = a;
  if (pb==-1) return ;
  unite(b, pb);
}
int total(int a) {
  if (parent[a]==-1) return c[a];
  if (visit[a]) return c[a];
  c[a] += total(parent[a]);
  visit[a] = true;
  return c[a];
}

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  init(n);
  int a, b, p, x;
  for (int i=0; i<n-1; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (root(b)==0) unite(b, a);
    else unite(a, b);
  }
  for (int i=0; i<q; i++) {
    scanf("%d%d", &p, &x);
    c[p-1]+=x;
  }
  for (int i=0; i<n; i++) {
    printf("%d ", total(i));
  }
  printf("\n");
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<pair<int, int>> points;
  REP(i, N) {
    int x, y; cin >> x >> y;
    points.emplace_back(x, y);
  }

  vector<int> count(N, 0);
  const int n_trial = 1e6;
  const double PI = acos(-1);
  const double delta = 2 * PI / n_trial;
  for (double i = 0; i < 2 * PI; i += delta) {
    double x = 1e11 * cos(i), y = 1e11 * sin(i);
    //cout << x << ' ' << y << endl;
    int idx = 0;
    double dist = 1e12;
    REP(i, N) {
      double a, b; tie(a, b) = points[i];
      double cand = hypot(x - a, y - b);
      if (cand < dist) {
        dist = cand;
        idx = i;
      }
    }
    count[idx]++;
  }
  //REP(i, N) cout << count[i] << (i == N - 1 ? '\n' : ' ');
  cout << setprecision(20);
  for (int c : count) cout << 1.0 * c / n_trial << endl;
  return 0;
}


Measured memory_bytes: 384
//by Judge
#include<cstdio>
#include<iostream>
#define Rg register
#define fp(i,a,b) for(Rg int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(Rg int i=(a),I=(b)-1;i>I;--i)
using namespace std;
const int mod=998244353;
const int M=1e6+3;
#ifndef Judge
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
char buf[1<<21],*p1=buf,*p2=buf;
inline int mul(int x,int y){return 1ll*x*y%mod;}
inline bool cmax(int& a,int b){return a<b?a=b,1:0;}
inline void Pls(int& x,int y){if((x+=y)>=mod)x-=mod;}
inline int read(){ int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f;
} int n,m,ans,inv[M],f[M];
int main(){ n=read(); Rg int x;
	fp(i,1,n) x=read(),Pls(f[x],x),cmax(m,x),Pls(ans,mod-x);
	fp(i,1,m) fp(j,2,m/i) Pls(f[i],f[i*j]);
	f[1]=mul(f[1],f[1]),inv[1]=1;
	fp(i,2,m) f[i]=mul(f[i],f[i]),inv[i]=mul(inv[mod%i],mod-mod/i);
	fd(i,m,1) fp(j,2,m/i) Pls(f[i],mod-f[i*j]);
	fp(i,1,m) if(f[i]) Pls(ans,mul(f[i],inv[i]));
	return !printf("%d\n",mul(ans,inv[2]));
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
typedef uint64_t ULL;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
using namespace std;
ULL GCD(ULL x,ULL y){return y==0?x:GCD(y,x%y);}
int main()
{
  ULL A,B,greatest,index=2;
  vector<ULL> p;
  set<ULL> q;
  cin>>A>>B;
  greatest=GCD(A,B);
  while(greatest>=index*index)
  {
    if(greatest%index==0){q.insert(index);while(greatest%index==0){greatest/=index;}}
    else if(index==2)index++;
    else index+=2;
  }
  q.insert(greatest);
  q.insert(1);
  cout<<q.size()<<endl;
}

Measured memory_bytes: 256
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)..., (os << '\n', 0)}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__)
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Run() {
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	Cout(a,b,c);	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	cin.exceptions(cin.failbit);
	cerr << fixed << setprecision(10);
	assert(freopen("./io/test.in", "r", stdin));
	// assert(freopen("./io/test.out", "w", stdout));
#endif

	Run();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=1e5+10;

ll n,k;
ll ar[N];
ll dp[N];

ll func(ll i)
{
    if(i>=n){return(INT_MAX);}
    if(i==n-1){return(0);}
    if(dp[i]==-1)
    {
        ll ans=INT_MAX;
        for(ll j=0;j<k;++j)
        {
            ans=min(ans,func(i+j+1)+abs(ar[i]-ar[i+j+1]));
        }
        dp[i]=ans;
    }
    return(dp[i]);
}

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

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

	cin>>n>>k;
	for(ll i=0;i<n;++i)
    {
        cin>>ar[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<func(0);

	return(0);
}


Measured memory_bytes: 6528
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: i64,
    );
    println!("{}", n.pow(3));
}


Measured memory_bytes: 4352
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#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;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
cin>>k;
cout<<n-k+1;





return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<long long>num(N);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  
  sort(num.begin(),num.end());
  
  bool ans = true;
  
  for(int i=1;i<N;i++){
    if(num[i] == num[i - 1]) ans = false;
  }

  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

// 配列を引数とする
bool check(int n, int d[], int k){
    bool flag = true;
    // int d_size = sizeof(d)/sizeof(d[0]);
    for(int i=0; i<k; ++i){
        // 桁の大きさを取得
        int dig = to_string(n).length();
        for(int j=0; j<dig; ++j){
            double temp = pow(10, j);
            int int_temp = temp;
            if((n/int_temp)%10 == d[i]){
                flag = false;
                break;
            }
        }
    }
    return flag;
}

int main()
{    
    int n;
    cin >> n;
    // n = 1000;
    
    int k;
    cin >> k;
    // k = 8;

    int d[k];
    for(int i=0; i<n; ++i) cin >> d[i];
    // d[0] = 1, d[1] = 3, d[2] = 4, d[3] = 5, d[4] = 6, d[5] = 7, d[6] = 8, d[7] = 9;

    int ans;
    for(int i=0; i+n<=100000; ++i){
        if(check(n + i, d, k)){
            ans = n+i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);
const int INF = 1000000000;

bool check(vector<int>& y, vector<int> &C,
           vector<vector<int>> &A, int X, int &minC) {

//    bool abc = (y[0] == 1);
//    for (size_t i=1; i<y.size(); i++)
//        abc &= (y[i] == 1);
//    if (abc)
//        bool debug = true;

    for (size_t j=0; j<A[0].size(); j++) {
        int sum = 0;
        for (size_t i=0; i<A.size(); i++) {
            sum += A[i][j] * y[i];
        }
        if (sum < X) {
            return false;
        }
    }
    int cost = 0;
    for (size_t i=0; i<y.size(); i++) {
        // cout << y[i] << ' ';
        cost += y[i] * C[i];
    }
   // cout << endl;
    if (cost < minC) {
        minC = cost;
        //cout << minC << endl;
    }
    return true;
}

bool solve(int i, vector<int>& y, vector<int> &C,
           vector<vector<int>> &A, int X, int &minC) {

    if (static_cast<size_t>(i) == y.size())
        return check(y, C, A, X, minC);

    y[i] = 0;
    bool left = solve(i+1, y, C, A, X, minC);
    y[i] = 1;
    bool right = solve(i+1, y, C, A, X, minC);

    return left | right;
}

int main() {

    int N, M, X;
    cin >> N >> M >> X;

    vector<int> C(N, 0);
    vector<vector<int>> A(N, vector<int>(M, 0));
    vector<int> y(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int minC = INF;
    bool result = solve(0, y, C, A, X, minC);

    if (result)
        cout << minC << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>

using namespace std;

void node(int i, int h[]) {
	cout << "node " << i << ": key = "<<  h[i] << ", ";
}
void parent(int i, int n, int h[]) {
	int p = i / 2;
	if (p > 0) {
		cout << "parent key = " << h[p] << ", ";

	}
}
void left(int i, int n,int h[]) {
	int l = 2 * i;
	if (l <= n) {
		cout << "left key = " << h[l] << ", ";
	}
}
void right(int i, int n, int h[]) {
	int r = 2 * i + 1;
	if (r <= n) {
		cout << "right key = " << h[r] << ", ";
	}
}

int main() {
	int N;
	int H[1000];

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> H[i];
	}

	for (int i = 1; i <= N;i++) {
		node(i, H);
		parent(i, N, H);
		left(i, N, H);
		right(i, N, H);
		cout << endl;
	}

	return 0;

}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>

using namespace std;
int main(){
  int n;
  int cnt = 0;
  cin >> n;
  vector <int> p(n);

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

  for(int i = 0 ; i < n-2 ; i++){
    if(p[i+1] != max(max(p[i],p[i+1]),p[i+2])  && p[i+1] != min(min(p[i],p[i+1]),p[i+2])){
      cnt++;
    }
  }

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

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i,a in enumerate(A):
    if (i + 1) % 2 == 1 and a % 2 == 1:
        ans += 1
print(ans)

Measured memory_bytes: 9468
// https://atcoder.jp/contests/abc096/tasks/abc096_b

#include "algorithm"
#include "cmath"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;

template <class T>
inline bool chmax(T& a, T b);
template <class T>
inline bool chmin(T& a, T b);

void solve() {
  vector<ll> v(3);
  rep(i, 0, v.size()) cin >> v[i];

  int k;
  cin >> k;

  sort(v.begin(), v.end());
  v[2] <<= k;

  ll res = 0;
  rep(i, 0, v.size()) res += v[i];

  cout << res << endl;
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif

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

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


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


int main()
{
    ll A,B;
    cin >> A >> B;
    ll cnt=0;
    while(1){
        if(cnt==0 && B!=1){
            B-=A;
            cnt++;
        }else if(cnt!=0){
            B-=(A-1);
            cnt++;
        }
        if(B<=0){
            break;
        }
        if(B==1 && cnt==0){
            break;
        }
    }
    cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    ll A[X], B[Y], C[Z];
    rep(i, 0, X) cin >> A[i];
    rep(i, 0, Y) cin >> B[i];
    rep(i, 0, Z) cin >> C[i];

    vector<ll> v, rsl;
    rep(i, 0, X) rep(j, 0, Y) v.push_back(A[i] + B[j]);
    vsort(v);
    reverse(v.begin(), v.end());
    sort(C, C + Z);
    reverse(C, C + Z);
    X = X * Y;
    chmin(X, 3000ll);
    chmin(Z, 3000ll);
    rep(i, 0, X) rep(j, 0, Z) {
        rsl.push_back(v[i] + C[j]);
    }

    vsort(rsl);
    reverse(rsl.begin(), rsl.end());
    rep(i, 0, K) cout << rsl[i] << endl;

}


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

int main()
{
		int i, j, n=0, ans=0;
		string W, T[10000], temp;
		cin >> W;
		while (1) {
				cin >> T[n];
				if (T[n]=="END_OF_TEXT") break;
				for (i=0; i<T[n].size(); i++) {
						T[n][i] = tolower(T[n][i]);
						if (isalpha(T[n][i])==false) {
								T[n][i] = '\0';
						}
				}
				n++;
		}

		for (i=0; i<n; i++) if (T[i]==W) ans+=1;
		cout << ans << "\n";
}

Measured memory_bytes: 3196
#include <iostream>
int main() {
    int W,a,b;
    int a_max,a_min,b_max,b_min,ans = 0;
    scanf("%d%d%d",&W,&a,&b);
    if(W<1 || a<1 || b<1){
        return  -1;
    }
    a_max = a+W;
    a_min = a;
    b_max = b+W;
    b_min = b;
    if(2 <= b_max && b_max < a_min){
        ans = a_min - b_max;
    } else if(2 <= a_max && a_max < b_min){
        ans = b_min - a_max;
    } else {
        ans = 0;
    }
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N 12345
using namespace std;
int n,m;
char s[N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            scanf("%s",s);
            if(s[0]=='s'&&s[1]=='n'&&
			s[2]=='u'&&s[3]=='k'&&s[4]=='e')
                printf("%c%d\n",'A'+j-1,i);
        }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    long long a,b;
    a = X / D;
    b = X % D;
    if(K <= a){
        cout << X - K * D << endl;
        return 0;
    }
    K -= a;
    X = b;
    long long ans;
    if(K % 2 == 0){
        ans = X;
    }
    else{
        ans = abs(X - D);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3132
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    string s;
    cin>>s;
    ll count=s.size()/2;
    for(int i=0;i<s.size();i++){
        if(s[i]=='p'){count--;}
    }
    cout<<count<<endl;
    
    
    
    
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  pr(abs(a[2] - a[1]) + abs(a[1] - a[0]));
  return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    private int[][][] numOfppl = new int[4][3][10];

    public void  initRoom() {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    numOfppl[i][j][k] = 0;
                }
            }
        }
    }

    public void addPpl(int b, int f, int r, int v) {
        numOfppl[b][f][r] += v;
    }

    public void printRoom() {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + numOfppl[i][j][k]);
                }
                System.out.print("\n");
            }
            if (i != 3) System.out.println("####################");
        }

    }
    public static void main(String[] args) {
        Main app = new Main();
        Scanner scan = new Scanner(System.in);
        int num = Integer.parseInt(scan.next());

        app.initRoom();
        for (int i = 0; i < num; i++) {
            int b = Integer.parseInt(scan.next()) - 1;
            int f = Integer.parseInt(scan.next()) - 1;
            int r = Integer.parseInt(scan.next()) - 1;
            int v = Integer.parseInt(scan.next());
            app.addPpl(b, f, r, v);
        }
        app.printRoom();
    }
}



Measured memory_bytes: 29076
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N], B[N];
    int sum = 0;
    int ans = 0;
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    sum += A[0];
    REP(i, N) sum += B[i];
    ans = sum;
    if(N >= 2){
        REP(i, N - 1){
            sum -= B[i];
            sum += A[i + 1];
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<vector<int>> hapiness(N,vector<int>(3));
    
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            cin>>hapiness[i][j];
        }
    }

    vector<vector<int>> dp(100000+10,vector<int>(3));

    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(k == j) continue;
                dp[i+1][k] = max(dp[i][j]+hapiness[i][k],dp[i+1][k]);
            }
        }
    }

    int ans = 0;

    for(int i=0; i<3; i++){
        ans = max(dp[N][i],ans);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

ll L, R;

int main() {
    cin >> L >> R;
    ll ans = 2018;
    for (ll i = L; i <= min(L + 2018, R - 1); i++) {
        for (ll j = i + 1; j <= min(i + 2018, R); j++) {
            ll tmp = (i * j) % 2019;
            if (tmp < ans) ans = tmp;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

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

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int H, W;
  string S[50];

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];

    for(int j = 0; j < W; j++) {
      if(S[i][j] == '.') S[i][j] = '0';
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i][j] == '#') {
        for(int k = -1; k <= 1; k++) {
          for(int l = -1; l <= 1; l++) {
            int ny = i + k, nx = j + l;
            if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;


            if(!isdigit(S[ny][nx])) continue;
            S[ny][nx]++;
          }
        }
      }
    }
  }

  rep(i, H) cout << S[i] << endl;
}


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

int main(){

    ll int n,w;
    cin>>n>>w;
    ll int sum_value = 0;
    vector<pair<ll int,ll int>> values(n);
    for(ll int i =  0;i<n;i++){
        cin>>values[i].first>>values[i].second;
        sum_value+=values[i].second;
    }
    ll int ans = 0;
    pair<bool,ll int> dp[n+1][sum_value+1];
    for(ll int i = 0;i<=n;i++){
        dp[i][0].first = true;
        dp[i][0].second = 0;
    }
    for(ll int i = 1;i<=sum_value;i++){
        dp[0][i].first = false;
        dp[0][i].second = 0;
    }
    for(ll int i = 1;i<=n;i++){
        for(ll int j = 1;j<=sum_value;j++){

            if(j<values[i-1].second){
                dp[i][j] = dp[i-1][j];
            }
            else{
                if(dp[i-1][j-values[i-1].second].first==true){
                    if(values[i-1].first+dp[i-1][j-values[i-1].second].second <=w){
                        dp[i][j].first = true;
                        dp[i][j].second = values[i-1].first+dp[i-1][j-values[i-1].second].second;
                        if(dp[i-1][j].first==true){
                            dp[i][j].second = min(dp[i][j].second,dp[i-1][j].second);
                        }

                        ans = max(ans,j);
                    }
                }

            }
            if(dp[i][j].first==false && dp[i-1][j].first ==true){
                dp[i][j] = dp[i-1][j];
            }


        }
    }
    /*for(int i = 0;i<=n;i++){
        for(int j = 0;j<=sum_value;j++){
            cout<<"("<<dp[i][j].first<<","<<dp[i][j].second<<") ";
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;
}






Measured memory_bytes: 158080
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
nList = list(map(int, input().split()))
if not X in nList:
  print(X)
  exit()

ntmp = X-1
ptmp = X+1
while 0 <= ntmp or ptmp <= 100:
  if not ntmp in nList:
    print(ntmp)
    exit()
  if not ptmp in nList:
    print(ptmp)
    exit()
  ntmp -= 1
  ptmp += 1

Measured memory_bytes: 9220
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let d: usize = s.next().unwrap().parse().unwrap();
	let g: u64 = s.next().unwrap().parse().unwrap();
	let pb: Vec<_> = (0..d).map(|_| (s.next().unwrap().parse::<u64>().unwrap(), s.next().unwrap().parse::<u64>().unwrap())).collect();
	let ans = (0..1 << d).fold(std::u64::MAX, |r, i|{
		let mut n = 0;
		let mut p = 0;
		for j in 0..d {
			if (i >> j) & 1 != 0 {
				p += 100 * (j as u64 + 1) * pb[j].0 + pb[j].1;
				n += pb[j].0;
			}
		}
		for j in (0..d).rev() {
			if p >= g { break; }
			if (i >> j) & 1 == 0 {
				let a = std::cmp::min((g - p) / (100 * (j as u64 + 1)), pb[j].0 - 1);
				p += 100 * (j as u64 + 1) * a;
				n += a;
			}
		}
		if p >= g { std::cmp::min(n, r) } else { r }
	});

	println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,x;
set<int>a;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        a.insert(x);
    }
    if(a.size()==n){
        puts("YES");
    }
    else{
        puts("NO");
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 10;
int a[maxn];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
	sort(a, a + n);
	ll res = 0;
	for(int i = 0; i < n - k; i ++) res += a[i];
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
using namespace std;
int main() {
  char moji[200];
  int ans = 0;
  int m_len;
  cin >> moji;
  m_len = strlen(moji);
  for (int i = 0; i < m_len / 2; ++i) {
    if (moji[i] != moji[m_len - i - 1]) {
      ans++;
    }

  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int N;
  int R;

  scanf("%d %d", &N, &R);

  if (N < 10) {
    printf("%d\n", R + (100 * (10 - N)));
  }
  else {
    // 内部レーティング
    printf("%d\n", R);
  }

  return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int b, e;
    cin >> b >> e;
    reverse(a.begin() + b, a.begin() + e);
  }
  for (int j = 0; j < n; j++){
    cout << a[j];
    if (j < n - 1){
      cout << ' ';
    }
  }
  cout << endl;
}


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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string S;
int N;
const string words[4] = {"dreamer", "eraser", "dream", "erase"};
int main(){
  cin >> S;
  string text = "";
  bool ok = true;
  N = S.size();
  for (int i = N - 1; i >= 0; i--){
    text += S[i];
    if (text.size() > words[0].size()){
      ok = false;
      break;
    }    
    string tmp = text;
    reverse(tmp.begin(), tmp.end());
    bool replace = false;
    for (int j = 0; j < 4; j++){
      if (tmp == words[j]){
	replace = true;
	break;
      }
    }
    if (replace){
      text = "";
    }
  }
				    
  
  if (text.empty() and ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<p> ab, cd;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    ab.push_back(p(a, b));
  }
  for(int i = 0; i < n; i++){
    int c, d;
    cin >> c >> d;
    cd.push_back(p(c, d));
  }
  sort(cd.begin(), cd.end());
  int used[205] = {};
  int sum = 0;
  for(int i = 0; i < n; i++){
    vector<p> v;
    for(int j = 0; j < n; j++){
      if(used[j]) continue;
      if(ab[j].first < cd[i].first && ab[j].second < cd[i].second){
        v.push_back(p(ab[j].second, j));
      }
    }
    if(v.size() >= 1){
      sort(v.begin(), v.end());
      sum++;
      used[v[v.size()-1].second] = 1;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
num_ac = 0
num_wa = 0
num_tle = 0
num_re = 0

for i in range(n):
    s = input()
    if s == "AC":
        num_ac += 1
    elif s == "WA":
        num_wa += 1
    elif s == "TLE":
        num_tle += 1
    elif s == "RE":
        num_re += 1


print("AC x {}".format(num_ac))
print("WA x {}".format(num_wa))
print("TLE x {}".format(num_tle))
print("RE x {}".format(num_re))


Measured memory_bytes: 9200
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	Scanner sc;
	
	void solve(){
		sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			boolean[] list = new boolean[11];
			Arrays.fill(list, true);
			int sum = 0;
			
			for(int i=0; i<3; ++i){
				int v = ni();
				if(i+1 < 3){
					sum += v;
				}
				list[v] = false;
			}
			
			int n=0;
			for(int i=1; i<=10; ++i){
				if(list[i] && sum+i<=20){
					++n;
				}
			}
			
			System.out.println(3<n ? "YES" : "NO");
		}
		
		sc.close();
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	public static void main(String[] args){
		new Main().solve();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll n;

int main(){
  cin >> n;
  if(n%2==0) cout << n <<endl;
  else cout << 2*n <<endl;
}


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

constexpr LL MOD = 998244353;

int cnt[N];
int d[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> d[i];
        cnt[d[i]]++;
    }

    if (d[1] != 0) cout << 0, exit(0);

    LL res = 1;
    for (int i = 2; i <= n; i++) {
        if (d[i] == 0) {
            res = 0;
            break;
        }
        (res *= cnt[d[i] - 1]) %= MOD;
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int x[n];
int y[n];
for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
}
long double ans=0;
int dict[n];
for(int i=0;i<n;i++){
    dict[i]=i+1;
}
do{
    for(int i=0;i<n-1;i++){
        long long tmp_x=x[dict[i+1]-1]-x[dict[i]-1];
        long long tmp_y=y[dict[i+1]-1]-y[dict[i]-1];
        ans+=sqrt(tmp_x*tmp_x+tmp_y*tmp_y);
    }
}while(next_permutation(dict,dict+n));
long long avg=1;
for(int i=1;i<=n;i++)avg*=i;
cout << fixed << setprecision(15) << ans/avg << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;
const int mod=1000000007;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
     ll n,m;
     cin >>n>>m;
     char a[n][m];
     for(int i=0;i<n;i++){
     	for(int j=0;j<m;j++){
     		cin >> a[i][j];
		 }
	 }
	 
	 ll dp[n+1][m+1];
	 for(int i=0;i<=n;i++){
	 	for(int j=0;j<=m;j++){
	 		dp[i][j]=0;
		 }
	 }
	 dp[1][1]=1;
	 for(int i=1;i<=n;i++){
	 	for(int j=1;j<=m;j++){
	 		if(a[i-1][j-1]=='.'){
		       if(i==1&&j==1){
		       	dp[i][j]=1;
			   }	 
			   else
	 			dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
		 }
	 }
	 /*for(int i=0;i<=n;i++){
	 	for(int j=0;j<=m;j++){
	 	cout <<dp[i][j]<<" ";
	 }
	 cout<<"\n";}*/
	 cout <<dp[n][m]<<"\n"; 
}


Measured memory_bytes: 9088
#[test]
fn test_solve() {
    assert_eq!(solve("3 3\n.#.\n..#\n#..\n"), "10\n");
    assert_eq!(solve("2 4\n....\n....\n"), "0\n");
    assert_eq!(solve("4 3\n###\n###\n...\n###\n"), "6\n");
    assert_eq!(solve("3 3 ### ### ###"), "0\n");
    assert_eq!(solve("3 3 #.# .#. #.#"), "20\n");
    assert_eq!(solve("3 3 ### #.# ###"), "4\n");
}
fn solve(s: &str) -> String {
    let mut sc = Scanner::from_str(s);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let g: Vec<Vec<_>> = (0..h).map(|_| sc.get().chars().collect()).collect();

    let mut seen = vec![vec![false; w]; h];
    let mut ret: usize = 0;
    for i in 0..h {
        for j in 0..w {
            if !seen[i][j] {
                seen[i][j] = true;
                let mut sa = 0;
                let mut sb = 0;
                let mut q = vec![(i, j)];
                while let Some((i, j)) = q.pop() {
                    let c = g[i][j];
                    if c == '#' {
                        sa += 1;
                    } else {
                        sb += 1;
                    }
                    let mut chk = |i: usize, j: usize| {
                        if !seen[i][j] && g[i][j] != c {
                            seen[i][j] = true;
                            q.push((i, j))
                        }
                    };
                    if i > 0 {
                        chk(i - 1, j)
                    }
                    if i < h - 1 {
                        chk(i + 1, j)
                    }
                    if j > 0 {
                        chk(i, j - 1)
                    }
                    if j < w - 1 {
                        chk(i, j + 1)
                    }
                }
                ret += sa * sb;
            }
        }
    }
    format!("{}\n", ret)
}

fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

int main(){
  int d,t,s;
  scanf("%d%d%d",&d,&t,&s);
  int res=(d%s)?d/s+1:d/s;
  if(res>t)
  printf("No");
  else
  printf("Yes");
}
  

Measured memory_bytes: 3820
#!/usr/bin/env python3
import itertools
N = int(input())
Name = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}


for i in range(N):
    S = input()
    if S[0] in Name: Name[S[0]] += 1

l = []
for k, v in Name.items():
    l.append(v)

ret = 0

for x in itertools.combinations(l, 3):
    ret += x[0]*x[1]*x[2]

print(ret)


Measured memory_bytes: 9208
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL)
    {
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if(y == NIL) root = z;
    else
    {
        if(z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u)
{
    if(u == NIL) return ;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if(u == NIL) return ;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, x;
    string com;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        cin >> com;
        if(com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26744
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int main(){
  int time[100000];

  int n;
  while(cin>>n,n!=0){
      memset(time,0,sizeof(time));
      for(int i = 0;i<n;i++){
	int h,m,s;
	scanf("%d:%d:%d",&h,&m,&s);
	time[h * (60*60) + m * 60 + s]++;
	scanf("%d:%d:%d",&h,&m,&s);
	time[h * (60*60) + m * 60 + s]--;
      }
      for(int i = 1;i<=24*60*60;i++){
	time[i] += time[i-1];
      }
      cout<<*max_element(time,time+24*60*60)<<endl;
  }

  return 0;
}

Measured memory_bytes: 3488