akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int result = a - (b * 2);
        if (result <= 0) {
            result = 0;
        }

        System.out.println(result);
    }
}

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



void solve(long long N, long long K, std::vector<long long> p){
    
    sort(p.begin(),p.end());
    ll ans = 0;
    for(ll i=0; i<K; i++) {
        ans += p[i];
    }
    cout << ans << endl;
    
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
int main() 
{
	int x[3000],y[3000],n,a;
	n = 0;
	while (1) 
	{
		scanf("%d %d", &x[n],&y[n]);
		if ((x[n] == 0) && (y[n] == 0)) break;
		if (x[n] > y[n])
		{
			a = y[n];
			y[n] = x[n];
			x[n] = a;
		}
			n = n + 1;
			
	}
	n = 0;
	while (1)
	{
		if ((x[n] == 0) && (y[n] == 0)) break;
		printf("%d %d\n", x[n], y[n]);
		n = n + 1;
	}
	return 0;
}

Measured memory_bytes: 1052
while 1:
    H, W = map(int, input().split())
    if H == W == 0: break
    for h in range(1, H+1):
        for w in range(1, W+1):
            if h % 2 == 0 and w % 2 == 0: # 偶数行・偶数列
                print("#", end="")
            elif h % 2 == 0 and w % 2 == 1: # 偶数行・奇数列
                print(".", end="")
            elif h % 2 == 1 and w % 2 == 0:
                print(".", end="")
            elif h % 2 == 1 and w % 2 == 1:
                print("#", end="")
        print()
    print()


Measured memory_bytes: 7004
import math

N = int(input())

dic = {}
for n in range(2, N + 1):
    p = 2
    while 1 < n and p <= math.sqrt(n):
        if n % p == 0:
            while n % p == 0:
                n //= p
                dic[p] = dic.get(p, 0) + 1
        p += 1

    if n > 1:
        if n not in dic:
            dic[n] = 1
        else:
            dic[n] += 1

ret = 1
for v in dic.values():
    ret *= v + 1

print(ret % (10 ** 9 + 7))

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

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

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

    int ans = 1;
    int tmp = p[0];
    rep2(i,1,N){
        tmp = min(tmp,p[i]);
        if(tmp == p[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
struct st{int l, r, x, v;};
int n, bs, lt, rt, fr, to, a[200005], tr[2][1<<18];
priority_queue<st> pq;
bool operator < (st p, st q) {return p.v>q.v;}

int f(int p, int q, int r) {
	int t, mn=1e9, mi;
	p = bs + p/2;
	q = bs + q/2;
	while(p<q) {
		if(p%2==1) {
			t = tr[r][p];
			if(a[t]<mn) mn=a[t], mi=t;
			p++;
		}
		if(q%2==0) {
			t = tr[r][q];
			if(a[t]<mn) mn=a[t], mi=t;
			q--;
		}
		p/=2, q/=2;
	}
	if(p==q) {
		t = tr[r][p];
		if(a[t]<mn) mn=a[t], mi=t;
	}
	return mi;
}

int main() {
	int i, k;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", a+i);
	for(bs=1; bs<n/2; bs*=2);
	for(i=0; i<n/2; i++) tr[0][bs+i] = i*2, tr[1][bs+i] = i*2+1;
	for(i=bs-1; i; i--) {
		lt = tr[0][i*2], rt = tr[0][i*2+1];
		tr[0][i] = a[lt] < a[rt] ? lt : rt;
		lt = tr[1][i*2], rt = tr[1][i*2+1];
		tr[1][i] = a[lt] < a[rt] ? lt : rt;
	}
	k = f(0, n-2, 0);
	pq.push({0, n-1, k, a[k]});
	while(!pq.empty()) {
		st t = pq.top(); pq.pop();
		fr=t.l, to=t.r, lt=t.x;
		rt = f(lt+1, to, (lt+1)%2);
		printf("%d %d ", t.v, a[rt]);
		if(fr<lt) {
			k = f(fr, lt-2, fr%2);
			pq.push({fr, lt-1, k, a[k]});
		}
		if(rt-lt>1) {
			k = f(lt+1, rt-2, (lt+1)%2);
			pq.push({lt+1, rt-1, k, a[k]});
		}
		if(rt<to) {
			k = f(rt+1, to-1, (rt+1)%2);
			pq.push({rt+1, to, k, a[k]});
		}
	}
	return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

template<class Type,class Type_k,class Type_m>
Type pow_mod(Type n,Type_k k,Type_m m){//n^k(mod m). long long推奨.
	if(k==0) return 1;
	else if(k%2) return n*pow_mod(n,k-1,m)%m;
	else{
		Type tmp=pow_mod(n,k/2,m);
		return tmp*tmp%m;
	}
}

int main(){
	int n;
	cin>>n;
	
	vi cnt(n,0);
	REP(i,n){
		int a;
		cin>>a;
		cnt[a]++;
	}
	
	bool jud=true;
	if(n%2){
		REP(i,n){
			if(i==0){
				if(cnt[i]!=1) jud=false;
			}else if(i%2){
				if(cnt[i]!=0) jud=false;
			}else{
				if(cnt[i]!=2) jud=false;
			}
			
			if(!jud) break;
		}
	}else{
		REP(i,n){
			if(i%2){
				if(cnt[i]!=2) jud=false;
			}else{
				if(cnt[i]!=0) jud=false;
			}
			
			if(!jud) break;
		}
	}
	
	if(jud) cout<<pow_mod(2LL,(llong)n/2,(llong)MOD)<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 640
def main():
	a,b = map(int,input().split())
	h = list(map(int,input().split()))
	av = 0
	i = 1
	while av == 0:
		if b ==0:
			print(a)
			break
		elif a not in h:
			print(a)
			break
		plus = a+i
		minus = a-i
		if minus not in h:
			print(minus)
			av = 1
		elif plus not in h:
			print(plus)
			av = 1
		else:
			i += 1


if __name__ == '__main__':
	main()

Measured memory_bytes: 61996
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]<<" ";
	for(i=0;2*a[i]<a[n-1];){i++;}
	int c=2*a[i]-a[n-1],b=a[n-1]-2*a[i-1];
	if(c<b) cout<<a[i];
	else cout<<a[i-1];
	return 0;
}


Measured memory_bytes: 640
{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List
import           Control.Monad

data Query = AB | AC | BC deriving (Show, Eq, Read)
data Decision = A | B | C deriving (Show, Eq)

main :: IO ()
main = do
  [n, a, b, c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  ss           <- replicateM n (readLn @Query)
  pr $ go [] (a, b, c) ss

go ans _ [] = Just (reverse ans)
go ans abc (q:qs) = case get abc q of
  (0, 0, d, e) -> Nothing
  (x, 0, d, e) -> go (e:ans) (set abc q (x-1) 1) qs
  (0, y, d, e) -> go (d:ans) (set abc q 1 (y-1)) qs
  (x, y, d, e) -> case compare x y of
    GT -> go (e:ans) (set abc q (x-1) 1) qs
    LT -> go (d:ans) (set abc q 1 (y-1)) qs
    EQ -> case qs of
      [] -> go (d:ans) (set abc q (x+1) (y-1)) qs
      (r:_) -> case comp q r of
        N -> go (d:ans) (set abc q (x+1) (y-1)) qs
        L -> go (d:ans) (set abc q (x+1) (y-1)) qs
        R -> go (e:ans) (set abc q (x-1) (y+1)) qs

get (a, b, c) AB = (a, b, A, B)
get (a, b, c) AC = (a, c, A, C)
get (a, b, c) BC = (b, c, B, C)

set (a, b, c) AB x y = (x, y, c)
set (a, b, c) AC x y = (x, b, y)
set (a, b, c) BC x y = (a, x, y)

data Tri = L | R | N

comp AB AB = N
comp AB AC = L
comp AB BC = R
comp AC AB = L
comp AC AC = N
comp AC BC = R
comp BC AB = L
comp BC AC = R
comp BC BC = N

pr (Just ans) = do
  putStrLn "Yes"
  mapM_ print ans
pr Nothing = putStrLn "No"


Measured memory_bytes: 13576
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	char a;
	int counter[4] = {0};
	int MIN = 1000;
	char KUPC[4] = {'K', 'U', 'P', 'C'};
	while (cin >> a) {
		for (int i = 0; i < 4; i++) {
			if (a == KUPC[i]) {
				counter[i]++;
				break;
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		MIN = min(MIN, counter[i]);
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
struct dat { double x, y, arg; };

class SCC {
private:
	int n;
	vvi G;
	vvi rG;
	vi visited;
	stack<int> order;
public:
	vvi ret;
	SCC(vvi A) {
		G = A;
		n = G.size();
		rG.resize(n);
		Loop(i, n) {
			Loop(j, G[i].size()) {
				rG[G[i][j]].push_back(i);
			}
		}
		visited.resize(n);
		fill(visited.begin(), visited.end(), 0);
		mainf();
	}
	void dfs(int a) {
		visited[a] = 1;
		Loop(j, G[a].size()) {
			if (visited[G[a][j]]) continue;
			dfs(G[a][j]);
		}
		order.push(a);
	}
	void rdfs(int a) {
		visited[a] = 1;
		Loop(j, rG[a].size()) {
			if (visited[rG[a][j]]) continue;
			rdfs(rG[a][j]);
		}
		ret.back().push_back(a);
	}
	void mainf() {
		Loop(i, n) {
			if (visited[i]) continue;
			dfs(i);
		}
		fill(visited.begin(), visited.end(), 0);
		while (order.size()) {
			int focus = order.top(); order.pop();
			if (visited[focus]) continue;
			ret.push_back({});
			rdfs(focus);
		}
	}
};

class Union_Find_Tree {
private:
	vi p, r;
	int find(int x) {
		if (p[x] == x) return x;
		else return p[x] = find(p[x]);
	}
public:
	Union_Find_Tree(int N) {
		p.resize(N);
		r.resize(N);
		Loop(i, N) {
			p[i] = i;
			r[i] = 0;
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (r[x] < r[y]) p[x] = y;
		else {
			p[y] = x;
			if (r[x] == r[y]) r[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int main() {
	int n, m; cin >> n >> m;
	vvi G(n);
	Loop(i, m) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
	}
	SCC scc(G);
	Union_Find_Tree uf(n);
	Loop(i, scc.ret.size()) {
		Loop(j, scc.ret[i].size()) {
			uf.unite(scc.ret[i][j], scc.ret[i][0]);
		}
	}
	int q; cin >> q;
	Loop(i, q) {
		int s, t;
		cin >> s >> t;
		cout << uf.same(s, t) << endl;
	}
	return 0;
}

Measured memory_bytes: 5452
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let _t: i64 = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut mx = vec![0; n + 1];
    for i in (1..n + 1).rev() {
        mx[i - 1] = std::cmp::max(mx[i], a[i - 1]);
    }

    let mut p = vec![0; n + 1];
    for i in 0..n {
        p[i] = std::cmp::max(0, mx[i + 1] - a[i]);
    }
    p.sort_by_key(|p| -p);

    let mut ans = 0;
    let cur = p[0];
    let mut i = 0;
    while i < n && p[i] == cur {
        ans += 1;
        i += 1;
    }

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


Measured memory_bytes: 6396
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(v) begin(v), end(v)

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

vector<bool> bfs(int s, int r, const vector<vector<int>> &G) {
	const int n = G.size();

	queue<int> que;
	que.push(s);

	vector<int> dist(n, -1);
	dist[s] = 0;

	vector<bool> reach(n, false);
	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		if(dist[v] == r) break;

		for(const auto &to : G[v]) {
			if(dist[to] == -1) {
				dist[to] = dist[v] + 1;
				que.push(to);
				reach[to] = true;
			}
		}
	}

	return reach;
}

int dijkstra(int s, int t, const vector<int> &cost, const vector<vector<bool>> &mat) {
	constexpr int INF = (1 << 29);
	const int n = mat.size();

	vector<bool> used(n, false);
	vector<int> dist(n, INF);
	dist[s] = 0;

	while(true) {
		int v = -1;
		rep(u, n) {
			if(!used[u] && (v == -1 || dist[v] > dist[u])) {
				v = u;
			}
		}

		if(v == t) return dist[v];
		used[v] = true;

		rep(u, n) {
			if(mat[v][u]) chmin(dist[u], dist[v] + cost[v]);
		}
	}
}

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

	int n, m;
	cin >> n >> m;

	vector<int> c(n), r(n);
	rep(i, n) {
		cin >> c[i] >> r[i];
	}

	vector<vector<int>> G(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	vector<vector<bool>> mat;
	mat.reserve(n);
	rep(i, n) {
		mat.emplace_back(bfs(i, r[i], G));
	}

	cout << dijkstra(0, n - 1, c, mat) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, l;
	cin >> n >> l;

    int ans=n*(l-1)+n*(n+1)/2;
    if(l*(l+n-1)>0){
        if(l<0) ans -= l+n-1;
        else ans -= l;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read


def main():
    N, K, *AF = map(int, read().split())
    A = AF[:N]
    F = AF[N:]

    A.sort()
    F.sort(reverse=True)
    C = [a * f for a, f in zip(A, F)]

    def is_ok(cost):
        k = 0
        for i in range(N):
            if C[i] > cost:
                k += (C[i] - cost + F[i] - 1) // F[i]
        return k <= K

    ok = pow(10, 12)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 138712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int n;
    cin >> n;
    set<string> st;
    rep(i, n){
        string s;
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19204
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){

int a,b;
  cin>>a>>b;
  int C=gcm(a,b);
//１からCまでの素数＋1個数
int ret=1;
for(int i = 2;i <= sqrt(C);i++) {
       if(C % i == 0) {
            ret++;
            while(C % i == 0) {
                C = C / i;
            }
}
}
if(C!=1){
ret++;
}
  cout<<ret;
  }

Measured memory_bytes: 256
import java.util.*;

 // Compiler version JDK 11.0.2

  public class Main
 {
   public static void main(String args[])
   { 
     Scanner sc= new Scanner(System.in);
     String s= sc.next();
     s=s.toUpperCase();
     if(s.equals("ABC"))
    System.out.println("ARC");
    else
    System.out.println("ABC");
   }
 }


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 096 D / Link: http://abc096.contest.atcoder.jp/tasks/abc096_d  ----- */
vector<long long > make_prime(long long  N) {
	vector<long long >a;
	vector<bool> prime(N + 1);
	FOR(i, 0, N + 1) {
		prime[i] = 1;
	}prime[0] = prime[1] = 0;

	for (LL i = 2; i <= N; i++) {
		if (prime[i]) {
			a.push_back((long long)i);
			for (LL j = i * 2; j <= N; j += i)
				prime[j] = 0;
		}
	}
	return a;
}

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

	LL N; 
	cin >> N;
	auto primes = make_prime(55555);
	LL cnt = 0;
	VL ans;
	for (auto it : primes) {
		if (it % 10 == 1)cnt++,ans.push_back(it);
	}
	DD(de(cnt));
	FOR(i, 0, N) {
		cout << ans[i] << " \n"[i == N - 1];
	}

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N, num[5001];
vi adj[5001];

void AD(int& a, int b) { a = (a+b)%MOD; }
int sub(int a, int b) { return (a-b+MOD)%MOD; }
void SUB(int& a, int b) { a = sub(a,b); }
int mul(int a, int b) { return (ll)a*b%MOD; }

vi comb(vi a, vi b) {
    vi res(sz(a)+sz(b)-1);
    F0R(i,sz(a)) F0R(j,sz(b)) AD(res[i+j],mul(a[i],b[j]));
    return res;
}

vi solve(int x, int p) {
    vi tmp = {0,1};
    for (int i: adj[x]) if (i != p) tmp = comb(tmp,solve(i,x));
    if (sz(tmp) % 2 == 1) for (int i = 2; i < sz(tmp); i += 2) SUB(tmp[0],mul(num[i],tmp[i]));
    /*cout << x << "\n";
    for (int i: tmp) cout << i << " ";
    cout << "\n\n";*/
    return tmp;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N-1) {
        int a,b; cin >> a >> b;
        adj[a].pb(b), adj[b].pb(a);
    }
    num[2] = 1;
    for (int i = 4; i <= 5000; i += 2) num[i] = mul(i-1,num[i-2]);
    
    cout << sub(0,solve(1,0)[0]);
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<int> A(N);
    REP(i,N) {
        cin >> A[i];
        A[i] *= -1;
    }

    vector<int> a;
    REP(i,N){
        if(A[i]==0){
            a.push_back(0);
        } else {
            auto it = upper_bound(all(a),A[i])-a.begin();
            if(it < a.size()) a[it] = A[i];
            else a.push_back(A[i]);
        }        
   }

    pl(a.size())

    return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    if(n == 1 ){

        printf("Yes\n");
        printf("2\n");
        printf("1 1\n");
        printf("1 1\n");

        ret();
    }

    auto get_k = [&] {
        rep(k, n + 1) {
            ll a = (k * k) - k;
            if (2 * n == a) {
                return k;
            }
        }
        return -1ll;
    };

    ll k = get_k();
    if (k == -1) {
        cout << "No" << endl;
        ret();
    }
    cout << "Yes" << endl;

    vector<set<ll>> ans(k);

    int next = 1;
    for (ll i = 0; i < k; i++) {
        for (ll j = i + 1; j < k; j++) {
            ans[i].insert(next);
            ans[j].insert(next);
            next++;
        }
    }

    cout << k << endl;

    rep(i, k) {
        cout << k - 1;
        for (ll l : ans[i]) cout << ' ' << l;
        cout << endl;
    }
}





Measured memory_bytes: 10752
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () {
    long long w = 0, h = 0, x = 0, y = 0;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10);
    double ans = (double)w / 2.0 * h;
    cout << ans << " ";
    if (h%2 == 0 && w%2 == 0) {
        if (h/2 == y && w/2 == x) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
l=[None]*M
for i in range(M):
    P,Y=map(int,input().split())
    l[i]=(P,Y,i)
l.sort()
a=[None]*M
s=0
t=1
for i in l:
    if i[0]==s:
        t+=1
    else:
        t=1
        s=i[0]
    a[i[2]]="{:06d}".format(i[0]) + "{:06d}".format(t)
print(*a,sep="\n")

Measured memory_bytes: 30564
#include <iostream>
#include <string>
#include <stdint.h>
#include <algorithm>
#include <cmath>

int main()
{
	int A, B;

	std::cin >> A >> B;

	float la, ma;
	la = A / 0.08f;
	ma = (A + 1) / 0.08f;

	float lb, mb;
	lb = B / 0.10f;
	mb = (B + 1) / 0.10f;

	if (la >= lb && la < mb)
	{
		std::cout << ceil(la) << std::endl;
	}
	else if (lb >= la && lb < ma)
	{
		std::cout << ceil(lb) << std::endl;
	}
	else
	{
		std::cout << -1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7

n,k = map(int, input().split())
a = list(map(int, input().split()))

DP = [0]*(k+1)
DP[0] = 1

for ai in a:
    nxt = [0]*(k+1)
    # iから前ai個の和になる
    # もらうDPにして和を保持すればO(N)
    s = 0
    for i in range(k+1):
        s += DP[i]
        if i>ai:
            s -= DP[i-ai-1]
        s %= mod
        nxt[i] = s
    DP = nxt
print(DP[-1])

Measured memory_bytes: 108508
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int H = stdIn.nextInt();
        int N = stdIn.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = stdIn.nextInt();
        }
        stdIn.close();

        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i];
        }

        if (sum >= H) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 50756
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[110000];

long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include <stdio.h>

main() {
  int a, b, c, d, e, f ;
 scanf("%d %d %d", &a, &b, &c);
 if( a > b ) {
  d = a;
  a = b;
  b = d;
 }

 if( b > c ) {
   e = b;
   b = c;
   c = e;
 }
 if( a > b ) {
  f = a;
  a = b;
  b = f;
 }
 printf("%d %d %d\n", a, b, c);
 return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H;
    cin >> N >> H;
    ll a[100010], b[100010];
    rep(i,0,N){
        cin >> a[i] >> b[i];
    }
    sort(b, b+N, greater<int>());
    sort(a, a+N, greater<int>());
    int h = H;
    int pb = 0;
    ll ans = 0;
    while(h > 0){
        if(a[0] <= b[pb] && pb < N){
            ans++;
            h -= b[pb];
            pb++;
        }else{
            ll val = h / a[0];
            if(h % a[0] != 0) val++;
            ans += val;
            break;
        }

    }
    print(ans);



}


Measured memory_bytes: 1792
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while 1:
  if(tr<0 ):
    break
  if(tp>=x):
    pp=100000000000
  else:
    pp=p[tp]
  if(tq>=y):
    qq=100000000000
  else:
    qq=q[tq]

  if(pp>r[tr] and qq>r[tr]):
    break
  if(pp<qq ):
    res+=r[tr]-pp
    tp+=1
  else:
    res+=r[tr]-qq
    tq+=1
  tr-=1
print(res)
    



Measured memory_bytes: 22720
import java.nio.*;
import java.util.*;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) throws Exception {
    int n = sc.nextInt();
    int q = sc.nextInt();

    Queue queue = new Queue(n);

    String s;
    int t;
    for (int i = 0; i < n; i++) {
      s = sc.next();
      t = sc.nextInt();

      queue.enQueue(s, t);
    }

    int sum = 0;
    while (!queue.isEmpty()) {
      P p = queue.deQueue();
      if (p.t > q) {
        sum += q;
        queue.enQueue(p.s, p.t - q);
      } else {
        sum += p.t;
        System.out.println(p.s + " " + sum);
      }
    }

    sc.close();
  }
}

class P {
  public String s;
  public int t;

  public P(String s, int t) {
    this.s = s;
    this.t = t;
  }
}

class Queue {
  private int head = 0;
  private int tail = 0;
  private P[] p;

  public Queue(int n) {
    this.p = new P[n + 1];
  }

  public boolean isEmpty() {
    return this.head == this.tail;
  }

  public boolean isFull() {
    return this.head == (this.tail + 1) % this.p.length;
  }

  public void enQueue(String s, int t) throws Exception {
    if (this.isFull()) {
      throw new Exception();
    }

    this.p[this.tail] = new P(s, t);

    if (this.tail + 1 == this.p.length) {
      this.tail = 0;
    } else {
      this.tail++;
    }
  }

  public P deQueue() throws Exception {
    if (this.isEmpty()) {
      throw new Exception();
    }

    P p = this.p[this.head];

    if (this.head + 1 == this.p.length) {
      this.head = 0;
    } else {
      this.head++;
    }

    return p;
  }
}


Measured memory_bytes: 75048
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,k = na()
h = na()

A = [0]+[float("inf")]*(n-1)

for i in range(1,n):
  for j in range(max(0, i-k), i):
    A[i] = min(A[i],A[j]+abs(h[i]-h[j]))

print(A[-1])

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

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

	int n;cin >> n;
	for(int i = 0; i < n; i++){
		int l[3] = {};
		for(int j = 0; j < 3; j++){
			cin >> l[j];
		}
		bool flag = false;
		for(int j = 0; j < 3; j++){
			//printf("%d %d %d",l[j]*l[j],l[(j+1)%3]*l[(j+1)%3],l[(j+2)%3]*l[(j+2)%3]);
			if(l[j]*l[j] + l[(j+1)%3]*l[(j+1)%3] == l[(j+2)%3]*l[(j+2)%3]){
				flag = true;
				break;
			}
		}
		cout << (flag?"YES":"NO") << endl;
	}

	return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
vector<ll> z_algorithmll(const vector<ll> &s)
{
  vector<ll> prefix(s.size());
  for (int i = 1, j = 0; i < s.size(); i++)
  {
    if (i + prefix[i - j] < j + prefix[j])
    {
      prefix[i] = prefix[i - j];
    }
    else
    {
      int k = max(0LL, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k])
        ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int)s.size();
  return prefix;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> b(n);
rep(i, n){
  cin >> b[i];
}
vector<vector<ll>> v,vv;
rep(j,30){
  vector<ll> a1;
  vector<ll> a2;
  vector<ll> bb;
  rep(i,n){
    if(a[i]>>j & 1LL){a1.push_back(1);a2.push_back(0);}
    else {a1.push_back(0);a2.push_back(1);}
    if(b[i]>>j & 1LL)bb.push_back(1);
    else bb.push_back(0);
  }
  auto r=bb; r.push_back(-1);
  r.insert(r.end(), a1.begin(), a1.end());
  r.insert(r.end(), a1.begin(), a1.end());
  v.push_back(z_algorithmll(r));
  r=bb; r.push_back(-1);
  r.insert(r.end(), a2.begin(), a2.end());
  r.insert(r.end(), a2.begin(), a2.end());
  vv.push_back(z_algorithmll(r));
}
rep(i,n){
  bool ok=1;
  ll ans=0;
  rep(j,30){
    if(v[j][i+n+1]!=n&&vv[j][i+n+1]!=n){
      ok=0;
      break;
    }
    if(vv[j][i+n+1]==n)ans+=1LL<<j;
  }
  if(ok)cout << i << ' ' << ans <<endl;
}
return 0;
}

Measured memory_bytes: 305652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll H,W;
string s[400];
ll S[400][400];
bool b[400][400];
bool tmp[400][400];
ll ans;
ll vx[4]={1,0,-1,0};
ll vy[4]={0,1,0,-1};

bool ok(ll y,ll x){
  return 0<=y&&y<H&&0<=x&&x<W;
}

LP dfs(ll y,ll x){
  LP res;
  if((x+y)%2) res=LP(1,0);
  else res=LP(0,1);
  b[y][x]=1;
  rep(i,4){
    ll ny=y+vy[i];
    ll nx=x+vx[i];
    if(ok(ny,nx) && !b[ny][nx]){
      LP np = dfs(ny,nx);
      res.fr+=np.fr;
      res.sc+=np.sc;
    }
  }
  return res;
}

ll calc(){
  ll res = 0;
  rep(i,H) rep(j,W){
    if(!b[i][j]){
      LP x = dfs(i,j);
      res += x.fr*x.sc;
    }
  }
  return res;
}


int main()
{
  cin>>H>>W;
  rep(i,H){
    cin>>s[i];
    rep(j,W){
      if(s[i][j]=='.') S[i][j]=1;
      b[i][j]=(S[i][j]+i+j)%2;
      tmp[i][j]=(b[i][j]+1)%2;
    }
  }
  // rep(i,H){
  //   rep(j,W){
  //     cout<<b[i][j];
  //   }
  //   cout<<endl;
  // }
  ans = calc();
  rep(i,H) rep(j,W) b[i][j]=tmp[i][j];
  ans += calc();
  cout<<ans<<endl;
}


Measured memory_bytes: 9472
h,w,k = map(int,input().split())
c_list = []
for i in range(h):
  c_list.append(list(str(input())))
h_TF_list = []
w_TF_list = []
for i in range(2**h):
  p_m_list = [False for i in range(h)]
  for j in range(h):
    if ((i >>j) & 1):
      p_m_list[j] = True
  h_TF_list.append(p_m_list)
for i in range(2**w):
  p_m_list = [False for i in range(w)]
  for j in range(w):
    if ((i >>j) & 1):
      p_m_list[j] = True
  w_TF_list.append(p_m_list)
count = 0
for h_list in h_TF_list:
  for w_list in w_TF_list:
    p = 0
    for i in range(h):
      for j in range(w):
        if c_list[i][j] == "#" and h_list[i] == True and w_list[j] == True:
          p += 1
    if p == k:
      count += 1
print(count)
        

Measured memory_bytes: 9072
#include<iostream>
using namespace std;
int main(){
    int a[6];
    for(int i=0; i<6; i++)  cin>>a[i];
    string str;
    cin>>str;
    for(int i=0; i<str.length(); i++){
        if(str[i]=='W'){
            //1 4 6 3       0 3 5 2 
            int memo=a[0];
            a[0]=a[2];
            a[2]=a[5];
            a[5]=a[3];
            a[3]=memo;
        }
        else if(str[i]=='E'){
            int memo=a[0];
            a[0]=a[3];
            a[3]=a[5];
            a[5]=a[2];
            a[2]=memo;
        }
        else if(str[i]=='S'){
            int memo=a[0];
            a[0]=a[4];
            a[4]=a[5];
            a[5]=a[1];
            a[1]=memo;
        }
        else{
            int memo=a[0];
            a[0]=a[1];
            a[1]=a[5];
            a[5]=a[4];
            a[4]=memo;
        }
    }
    cout<<a[0]<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 
int main() {
    ll n; cin >> n;
    if (n < 2 || (n & 1) != 0) {
        cout << 0 << endl;
        return 0;
    }
    n >>= 1;
    ll ans = 0;
    for (ll i = 5; i <= n; i *= 5) {
        ans += n / i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
int seq[MAXN+5],cnt[MAXN+5],N,M;
int A[MAXN+5];
int main()
{
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++)
		scanf("%d",&seq[i]),cnt[seq[i]]++;
	for(int i=1;i<=N;i++)
		for(int j=max(1,i-cnt[i]+1);j<=i;j++)
			A[j]++;
	int ans=0;
	for(int i=1;i<=N;i++)
		if(A[i]==0)
			ans++;
	int X,Y;
	for(int i=1;i<=M;i++)
	{
		scanf("%d %d",&X,&Y);
		if(seq[X]-cnt[seq[X]]+1>=1)
		{
			A[seq[X]-cnt[seq[X]]+1]--;
			if(A[seq[X]-cnt[seq[X]]+1]==0)
				ans++;
		}
		cnt[seq[X]]--;
		seq[X]=Y;
		cnt[seq[X]]++;
		if(seq[X]-cnt[seq[X]]+1>=1)
		{
			if(A[seq[X]-cnt[seq[X]]+1]==0)
				ans--;
			A[seq[X]-cnt[seq[X]]+1]++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int cnt;
void merge(int A[],int n,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++) L[i]=A[left+i];
  for(int i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=R[n2]=SENTINEL;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int main(){
  int A[MAX],n,i;
  cnt=0;
  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}
	      
	      
    



Measured memory_bytes: 6992
while True:
    try:
        a,b,c = map(int, raw_input().split())
        s = a+b
        count = 0
        for i in range(1,11):
            if i != a and i != b and i != c:
                if s + i <= 20:
                    count += 1 
        print "YES" if count > 3 else "NO"
    except:
        break

Measured memory_bytes: 4204
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

ll a[100005];
ll b[100005];

map<pair<ll,ll>,ll>mp;
map<pair<ll,ll>,int>mp2;

ll ans[10];

int main(){

	ll H,W;

	int N;

	scanf("%lld %lld %d",&H,&W,&N);

	int i,j,k,m;

	for(i=0;i<N;i++){
		scanf("%lld %lld",&a[i],&b[i]);
		mp[make_pair(a[i],b[i])]=1ll;
	}

	ll dx[3][3]={
		{0ll,1ll,2ll},
		{-1ll,0ll,1ll},
		{-2ll,-1ll,0ll}
	};
	ll dy[3][3]={
		{0ll,1ll,2ll},
		{-1ll,0ll,1ll},
		{-2ll,-1ll,0ll}
	};

	ll dx2[9]={0ll,-1ll,-2ll,0ll,-1ll,-2ll,0ll,-1ll,-2ll};
	ll dy2[9]={0ll,0ll,0ll,-1ll,-1ll,-1ll,-2ll,-2ll,-2ll};

	for(i=0;i<N;i++){
		for(j=0;j<9;j++){
			ll cnt=0ll;
			if(mp2[make_pair(a[i]+dy2[j],b[i]+dx2[j])]==0){
				int flag=0;
					for(k=0;k<3;k++){
						for(m=0;m<3;m++){
							if(a[i]+dy[j/3][k]<=0 ||a[i]+dy[j/3][k]>=H+1 ||b[i]+dx[j%3][m]<=0 ||b[i]+dx[j%3][m]>=W+1){flag=1;}
							cnt+=mp[make_pair(a[i]+dy[j/3][k],b[i]+dx[j%3][m])];
						}
					}
					if(flag==0){
					ans[cnt]+=1ll;
					mp2[make_pair(a[i]+dy2[j],b[i]+dx2[j])]=1;
					}
			}
		}
	}
	ll sum=0ll;
	for(i=1;i<10;i++){
		sum+=ans[i];
	}

	printf("%lld\n",((H-2ll)*(W-2ll))-sum);
	for(i=1;i<10;i++){
		printf("%lld\n",ans[i]);
	}

	return 0;
}

Measured memory_bytes: 214316
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

bool comp(vll a,vll b){
    return a[1]<b[1];
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vvll AB(N,vll(2));
    for(int i=0;i<N;i++) cin>>AB[i][0]>>AB[i][1];
    
    sort(AB.begin(),AB.end(),comp);
    
    ll sum=0;
    for(int i=0;i<N;i++){
        sum+=AB[i][0];
        if(sum>AB[i][1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>

int main(void){
  int H,W,i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H == 0 && W == 0){
      break;
    }
    for(i = 1; i <= W; i++){
      printf("#");
    }
    printf("\n");
    for(j = 2; j <= H - 1; j++){
      printf("#");
      for(i = 2; i <= W - 1; i++){
        printf(".");
      }
      printf("#\n");
    }
    for(i = 1; i <= W; i++){
      printf("#");
    }
    printf("\n\n");
  }
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> pa;

int ary[110];
int main(){
	int N,M,hog;
	bool fir;
	priority_queue<pa > que;
	while(true){
		cin>>N>>M;
		if(N==0&&M==0) break;
		fill(ary,ary+110,0);
		for(int i=1;i<=N;i++){
			for(int j=1;j<=M;j++){
				cin>>hog;
				if(hog)ary[j]++;
			}
		}
		for(int i=1;i<=M;i++){
			que.push(pa(ary[i],-i));
		}
		fir=true;
		while(!que.empty()){
			if(!fir)cout<<" ";fir=false;
			cout<<-que.top().second;
			que.pop();
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int X;
    cin >> X;
    int ans = 1;
    for (int i = 2; i * i <= X; i++) {
        int tmp = i;
        while (tmp * i <= X) {
            tmp *= i;
            ans = max(ans, tmp);
        }
    }
    cout << ans << '\n';

}


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

typedef long long ll;

ll X;
ll Y;

int main()
{
	cin >> X >> Y;

	ll div = Y / X;

	int cou = 0;
	ll now = 1;
	while(div >= now)
	{
		cou++;
		now *= 2;
	}
	cout << cou << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

#define ll           long long int 
#define endl         '\n'

static const int maxn = 2e5 + 5;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	int n;
	cin >> n;
	map <string, bool> mp;
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		mp[s];
	}	
	cout << mp.size() << endl;
}

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

int main()
{
  int a, b,an = 0;
  cin >> a >> b;
  while(a > 0){
    a = a - b;
    an++;
  }
  cout << an << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

const int N = 2e5 + 5, mo = 1e9 + 7, inf = 1e9;
int n, X, Y;
ll ans, fac[N], ivf[N], inv[N];
vector <int> co[N];
pair <int, int> tmp;
vector <pair <int, int> > rec;
set <pair <int, int> > S;

void prep () {
	fac[0] = 1, ivf[0] = 1;
	fac[1] = ivf[1] = inv[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mo;
		inv[i] = mo - 1ll * mo / i * inv[mo % i] % mo;
		ivf[i] = ivf[i - 1] * inv[i] % mo;
	}
}
int main (){
	cin >> n >> X >> Y, ans = 1, prep();
	for (int i = 1, x, y; i <= n; ++i) {
		scanf("%d%d", &x, &y), co[x].push_back(y);
		S.insert(make_pair(y, x));
	}
	int tot = 0;
	for (int i = 1; i <= n; ++i) {
		if (!(int)co[i].size())
			continue;
		sort(co[i].begin(), co[i].end());
		int M = co[i][0], C = 0;
		for ( ; !S.empty(); ) {
			tmp = *S.begin();
			if (tmp.se == i)
				rec.push_back(tmp), S.erase(tmp);
			else
				break;
		}
		if (!S.empty() && tmp.fi + M <= Y) {
			C = 1;
			for (int j = 1; j < co[i].size(); ++j)
				C += (co[i][j] + M <= X || co[i][j] + tmp.fi <= Y);
			tot += C;
			ans = ans * ivf[C] % mo;
		}
		for (auto x : rec)
			S.insert(x);
		rec.clear();
	}
	ans = ans * fac[tot] % mo;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23544