akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

string A;
ll N;

void solve()
{
    ll hist[26] = {};
    for(char c : A) {
        ++hist[c-'a'];
    }

    ll ans = 1 + N*(N-1)/2;
    REP(i, 26) {
        ll k = hist[i];
        ans -= k*(k-1)/2;
    }

    cout << ans << "\n";
}

int main()
{
    cin >> A;
    N = A.size();

    solve();

    return 0;
}


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

int main() {
	int n,i;
	cin >> n;
	int a[n];
	for(i=n-1;i>-1;i--){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		if(i==n-1){
		cout << a[i] << endl;
		}
		else cout << a[i] << " ";
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	string a; cin >> a;

	bool ok = a.substr(0,n/2) == a.substr(n/2);
	cout << (ok ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, k] <- readIntegers
  print $ solve n k

-- NがKで割り切れれば0になる
-- 4 7
-- 3 7
-- 4 7

-- 18 8
-- 10 8
-- 2 8
-- 6 8
-- 2 8

-- NをKで割った余りと、それをKから引いたもののうちの小さい方

solve n k = if modk < (k - modk) then modk else (k - modk)
  where
    modk = n `mod` k

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 380
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	long long h, w, n;
	cin >> h >> w >> n;
	map<pair<int, int>, int> field;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		for(int aa = a-1; aa < a+2; aa++){
			for(int bb = b-1; bb < b+2; bb++){
				if(aa > 1 && aa < h && bb > 1 && bb < w){
					field[pair<int, int>(aa, bb)]++;
				}
			}
		}
	}
	int ans[10];
	for(int i = 0; i < 10; i++){
		ans[i] = 0;
	}
	
	for(map<pair<int, int>, int>::iterator it = field.begin(); it != field.end(); it++){
		ans[it->second]++;
	}
	
	unsigned long long m = (h - 2) * (w - 2);

	for(int i = 0; i < 10; i++){
		m -= ans[i];
	}
	
	cout << m << endl;
	for(int i = 1; i < 10; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 56448
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
   int a,b;
   for(;;){
       cin >> a >> b;
       if(a == 0 && b == 0) break;
       if(a > b) swap(a , b);
       cout << a << " " << b << endl;;
   }
    
    
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n+5);

  mint ans = 0;
  rep(ri,2) {
    rep(i,n) {
      mint now = c(i,k-1);
      if (ri == 1) now = -now;
      ans += now*a[i];
    }
    reverse(a.begin(), a.end());
  }

  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 2176
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, b;
	while(cin >> a >> b) {
		if(a >= 13) {
			cout << b << endl;
		} else if(a >= 6 and a <= 12) {
			cout << b / 2 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
a = rl()
for i in range(5):
    if a[i]==0:
        print(i+1)
        break

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

fn main() {
    let mut state =[[[0i32; 11]; 4]; 5];

    let scan = std::io::stdin();

    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let v: Vec<&str> = line.split_whitespace().collect();

    let _n: usize = v[0].parse().unwrap_or(0);

    for line in scan.lock().lines() {
        let uline = line.unwrap();
        let vec: Vec<&str> = uline.split_whitespace().collect();
        let b: usize = vec[0].parse().unwrap_or(0);
        let f: usize = vec[1].parse().unwrap_or(0);
        let r: usize = vec[2].parse().unwrap_or(0);
        let v: i32   = vec[3].parse().unwrap_or(0);
        state[b-1][f-1][r-1] += v;
    }
    for k in 0..4 {
        for j in 0..3 {
            for i in 0..10 {
                print!(" {}",state[k][j][i]);
            }
            println!("");
        }
        if k != 3 {
            println!("####################");
        }
    }
}


Measured memory_bytes: 5032
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		System.out.println(sc.next()
				.replace("eraser", "")
				.replace("erase", "")
				.replace("dreamer", "")
				.replace("dream", "")
				.equals("") ? "YES" :"NO");
	}
}

Measured memory_bytes: 29836
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
int N, M, P;

int main() {
    while(cin >> N >> M >> P, N||M||P){
        int sum=0, temp=0;
        for(int i=0; i<N; ++i){
            int a; cin >> a; 
            if(i==M-1) temp = a;
            sum += a;
        }
        if(temp!=0){  
            cout << sum*(100-P)/temp << endl;
        }else{
            cout << 0 << endl;
        }
    }    
    
    return 0;
}


Measured memory_bytes: 3064
// 2009Í[næ\I C : Champernowne Constant

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

// numÌãÊ©çposÔÚÌð\¦·é
int getNum(int num, int pos){
	ostringstream oss; oss << num;
	return oss.str()[pos]-'0';
}

int main(){
	int N, K;
	while(cin >> N >> K){
		if(!(N||K)) break;
		N--;
		long long mul = 9;
		int i=0;
		// mul : iÌÌÂ
		for(i=1; ;i++){
			if(N < i*mul) break;
			// iÌÌªð­
			N -= i*mul;
			mul *= 10;
		}
		long long cur = 1;
		// iÌÌ½ÔÚ©çoÍ·é©
		int pos = N/i;
		// ½ÚðoÍ·é©
		int div = N%i;
		int count = 0;
		// iÌÌ¤¿Å¬ÌàÌ
		for(int j=1;j<i;j++) cur *= 10;
		while(count<K){	
			cout << getNum(cur+pos, div);
			if(div == i-1) { div = 0; pos++; }
			else           { div++;          }
			// oÍ·éÌªÏíéê
			if(cur+pos == 10*cur){
				cur *= 10; pos = 0; i++;
			}
			count++;
		}
		cout << endl;
	}
}

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

int main()
{
  int n;
  int side[3];
  cin >> n;

  for (int i = 1; i <= n; i++){

    for (int j = 0; j <= 2; j++){
      cin >> side[j];
    }
    for (int j = 0; j < 2; j++){
      if (side[j] >= side[j + 1]){
        int s = side[j + 1];
        side[j + 1] = side[j];
        side[j] = s;
      }
    }
    if ((side[2] * side[2]) == ((side[0] * side[0]) + (side[1] * side[1]))){
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  
  return 0;
}

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

int main() {

    unsigned int X;
    int happy;

scanf("%d", &X);

happy = 0;

if (X < 0 || X > 1000000000) {
    printf("%d is invalid value!", X);
    exit(1);
}

while (X / 500 >= 1) {
    happy += 1000;
    X -= 500;
}

while (X / 5 >= 1) {
    happy += 5;
    X -= 5;
}

printf("%d\n", happy);

return 0;

}

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

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

const int MAXLEN=15;

char s[MAXLEN+1]; int slen;

bool solve() {
	int have=0; REP(i,slen) if(s[i]=='o') ++have;
	int rem=MAXLEN-slen;
	return have+rem>=8;
}

void run() {
	scanf("%s",s); slen=strlen(s);
	printf("%s\n",solve()?"YES":"NO");
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Edge {
  int f;
  int t;
  ll p;
  Edge(int f, int t, ll p) : f(f),t(t),p(p) {}
};
vector<Edge> g[100000];
int visited[100000];
ll dist[100000];
ll base[100];

void add(ll w) {
  for (int i=59; i>=0; --i) {
    if (w>>i&1) {
      if (base[i]) {
        w ^= base[i];
      } else {
        base[i] = w;
        return;
      }
    }
  }
}

void dfs(int now, ll w) {
  if (visited[now] == 2) return;
  if (visited[now] == 1) {
    // loop
    // cout << now << " " << w << " " << dist[now] << " "  << (dist[now]^w) << endl;
    add(dist[now] ^ w);
    return;
  }
  visited[now] = 1;
  dist[now] = w;
  FOR(it, g[now]) {
    dfs(it->t,w^it->p);
  }
  visited[now] = 2;
}

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  REP(i,m) {
    int f,t;
    ll p;
    cin >> f >> t >> p;
    g[f].push_back(Edge(f,t,p));
    g[t].push_back(Edge(t,f,p));
  }
  memset(visited,0,sizeof(visited));
  memset(base,0,sizeof(base));
  dfs(0,0);
  while(q--) {
    int a, b;
    cin >> a >> b;
    ll w = dist[a]^dist[b];
    for (int i=59; i>=0; --i) {
      if (!(w>>i&1)) {
        w ^= base[i];
      }
    }
    cout << w << endl;
  }
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;

int n, color[3], a[int(1e5+10)]; 
int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,3) color[i] = 0;

	ll ans = 1;
	rep(i,n) {
		ll cnt = 0;
		int id = -1;
		if (a[i] == color[0]) {cnt++; id = 0;}
		if (a[i] == color[1]) {cnt++; id = 1;}
		if (a[i] == color[2]) {cnt++; id = 2;}
		ans *= cnt; 
		color[id]++;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

struct UnionFind{
  int num;

  vector<int> rs,ps; //rsは子どもの数

  UnionFind(){}

  //iotaはコンテナに0の要素を入れるために使う
  UnionFind(int n):num(n),rs(n,1),ps(n,0){iota(ps.begin(),ps.end(),0);}

  
  int find(int x){
    return (x==ps[x]?x:ps[x]=find(ps[x]));
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(rs[x]<rs[y]) swap(x,y);
    rs[x]+=rs[y];
    ps[y]=x;
    num--;
  }

  int size(int x){
    return rs[find(x)];
  }

  int count() const{
    return num;
  }
};


int main(){
    int N,M,K;
    cin>>N>>M>>K;
    vector<vector<int>> connect(N);
    UnionFind U(N);
    for(int i=0; i<M; i++){
      int a,b;
      cin>>a>>b;
      a--,b--;
      connect[a].push_back(b);
      connect[b].push_back(a);
      U.unite(a,b);
    }

    for(int i=0; i<K; i++){
      int c,d;
      cin>>c>>d;
      c--,d--;
      if(!U.same(c,d)) continue;
      connect[c].push_back(d);
      connect[d].push_back(c);
    }


    for(int i=0; i<N; i++){
      int ans = U.size(i) - 1 - connect[i].size();
      cout<<ans<<" ";
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 8320
xn = list(map(int,input().split()))
P = list(map(int,input().split()))

x = xn[0]
n = xn[1]

kMax = int(n/2)
bl = False
for k in range(kMax+1):
     if (x - k) not in P:
         ans = x - k
         bl = True
         break
     elif (x + k) not in P:
         ans = x + k
         bl = True
         break

if not bl:
    ans = x - (kMax + 1)     

print(ans)    

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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;
};

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

  int n;
  cin >> n;
  deque<ll> dq(n);
  rep(i, 0, n) {
    cin >> dq[i];
  }

  vector<vector<vector<ll>>> dp(2, vector<vector<ll>> (3005, vector<ll> (3005, 0ll)));
  rep(i, 0, n) {
    dp[0][i][i+1] = dq[i];
    dp[1][i][i+1] = -dq[i];
  }

  rep(diff, 2, n+1) {
    rep(l, 0, n+1-diff) {
      int r = l + diff;

      rep(p, 0, 2) {
        int op;
        if (p == 0) {
          op = 1;
        } else {
          op = 0;
        }

        if (p == 0) {
          dp[p][l][r] = max(dq[l] + dp[op][l+1][r], dq[r-1] + dp[op][l][r-1]);
        } else {
          dp[p][l][r] = min(-dq[l] + dp[op][l+1][r], -dq[r-1] + dp[op][l][r-1]);
        }
      }
    }
  }

  cout << dp[0][0][n] << endl;

  return 0;
};


Measured memory_bytes: 212224
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/



signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22)cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		double v;
		try {
			while ((line = br.readLine()) != null) {
				line.trim();
				v = Double.parseDouble(line);
				double t = v / 9.8;
				double y = 4.9 * Math.pow(t, 2);
				
				int N = (int)Math.ceil(y / 5) + 1;
				
				System.out.println(N);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

vector<long long> solve(vector<long long>T) {
	vector<long long> ans; long long sum = 0; ans.push_back(0); ans.push_back(0);

	for (int i = T.size() - 2; i >= 0; i--) {
		long long E = 0, B = T[i + 1]; while (T[i] > B) { E++; B *= 4; }

		for (int j = 0; j < E; j++) {
			for (int k = i + 1; k < T.size(); k++) {
				if (T[k - 1] <= T[k]) break;
				if (T[k] * 4 >= (1LL << 32)) { sum += (long long)(T.size() - k); break; }
				T[k] *= 4; sum++;
			}
		}
		ans.push_back(sum);
	}
	return ans;
}

long long N, A[1 << 18], L[1 << 18];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<long long>V; for (int i = 0; i < N; i++) V.push_back(A[i]);

	vector<long long> J1 = solve(V); for (int i = 0; i <= N; i++) L[i] += J1[N - i] * 2;
	reverse(V.begin(), V.end());
	vector<long long> J2 = solve(V); for (int i = 0; i <= N; i++) L[i] += (J2[i] * 2 + i);

	long long maxn = (1LL << 60);
	for (int i = 0; i <= N; i++) maxn = min(maxn, L[i]);
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 12116
fn main(){
  let mut a = String::new();
  let mut b = String::new();
  let mut s = String::new();
  
  std::io::stdin().read_line(&mut a).ok();
  std::io::stdin().read_line(&mut b).ok();
  
  let a = a.chars().collect::<Vec<char>>();
  let b = b.chars().collect::<Vec<char>>();
  
  for i in 0 .. a.len() + b.len() {
    if i % 2 == 0 {
      s.push(a[i / 2]);
    } else {
      s.push(b[i / 2]);
    }
  }
  println!("{}",&s);
}

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

int count(int x,int c){
    if(x>=500){
        return count(x-500,c+1);
    }
    if(x>=100){
        return count(x-100,c+1);
    }
    if(x>=50){
        return count(x-50,c+1);
    }
    if(x>=10){
        return count(x-10,c+1);
    }
    if(x>=5){
        return count(x-5,c+1);
    }
    if(x==0){
        return c;
    }
    else{
        return count(x-1,c+1);
    }
}
int main(void){
    int x;
    while(true){
        cin >> x;
        if(x==0){
            break;
        }
        cout << count(1000-x,0)<< endl;
    }
}





Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int t=1,sum=0;char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		sum=sum*10+ch-'0',ch=getchar();
	return t*sum;
}
const int Max=2e3+10,mod=1e9+7;
int f[Max][Max],sum[Max],fac[Max],inv[Max],n,m;
void up(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
int C(int i,int j) 
{ 
	if(i<0||j<0||i<j) return 0;
	return 1LL*fac[i]*inv[j]%mod*inv[i-j]%mod; 
}
int main()
{
	int i,j;
	n=read(); m=read();
	f[0][0]=1;
	for(i=1;i<m;i++)
	{
		sum[0]=f[i-1][0];
		for(j=1;j<i;j++)
			sum[j]=(sum[j-1]+f[i-1][j])%mod;
		for(j=0;j<i;j++)
		{
			f[i][j]=sum[j];
			if(j>=i)
				up(f[i][j],mod-sum[j-i]);
		}
	}
	fac[0]=inv[0]=inv[1]=1;
	for(i=2;i<=n;i++)
		inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(i=1;i<=n;i++)
		inv[i]=1LL*inv[i-1]*inv[i]%mod,
		fac[i]=1LL*fac[i-1]*i%mod;
	sum[0]=f[m-1][0];
	for(i=1;i<=n;i++)
		sum[i]=(sum[i-1]+f[m-1][i])%mod;
	int ans=0;
	for(i=2;i<=n;i++)
	{
		if(i-2<n-m-1)
			continue;
		up(ans,1LL*C(i-2,n-m-1)*sum[n-i]%mod);
	}
	if(m==n) 
		ans=sum[n];
	for(i=m+1;i<n;i++)
		ans=2LL*ans%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14976
N,M = list(map(int,input().split()))
req = [list(map(int,input().split())) for i in range(M)]

req.sort(key=lambda x:x[1])

left = 0
cnt = 0
for i in range(M):
  if left <= req[i][0]:
    cnt += 1
    left = req[i][1]
    
print(cnt)

Measured memory_bytes: 29080
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> pii;
#define fi first
#define se second
#define ml(a,b) make_pair(a,b)
const int _ = 200002 , __ = _<<1;
struct edges
{
	int to[__],ne[__],he[_],ecnt;
	edges(){memset(he,0,sizeof(he)),ecnt=1;}
	void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
	void addde(int a,int b){adde(a,b),adde(b,a);}
}e1,e2;
int n,m1,m2,ans[_],bel[_],csz[_],ccnt;
void bfs(int s,edges &e,int col)
{
	csz[col]=0;
	register int i,a,b;
	queue<int> q;
	q.push(s);
	while(!q.empty())
	{
		a=q.front(),q.pop();
		if(bel[a])continue;
		bel[a]=col,csz[col]++;
		for(i=e.he[a];i;i=e.ne[i])
		{
			b=e.to[i];
			if(bel[b])continue;
			q.push(b);
		}
	}
}
map<pii,int> cnt;
int main()
{
	register int i,a,b;
	register pii x;
	scanf("%d%d%d",&n,&m1,&m2);
	for(i=1;i<=m1;i++)scanf("%d%d",&a,&b),e1.addde(a,b);
	for(i=1;i<=m2;i++)scanf("%d%d",&a,&b),e2.addde(a,b);
	ccnt=0,memset(bel,0,sizeof(bel));
	for(i=1;i<=n;i++)if(!bel[i])bfs(i,e1,++ccnt);
	for(i=1;i<=n;i++)ans[i]=bel[i];
	ccnt=0,memset(bel,0,sizeof(bel));
	for(i=1;i<=n;i++)if(!bel[i])bfs(i,e2,++ccnt);
	cnt.clear();
	for(i=1;i<=n;i++)
	{
		x=ml(ans[i],bel[i]);
		if(cnt.count(x))cnt[x]++;
		else cnt[x]=1;
	}
	for(i=1;i<=n;i++)printf("%d ",cnt[ml(ans[i],bel[i])]);
	puts("");
	return 0;
}


Measured memory_bytes: 21328
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vi a(N);
	int max_a = -100, min_a = 100;
	REP(i, N) {
		cin >> a[i];
		max_a = max(max_a, a[i]);
		min_a = min(min_a, a[i]);
	}

	int ans = INF;
	FOR(i, min_a, max_a + 1) {
		int tmp = 0;
		REP(j, N) {
			tmp += (a[j]-i)*(a[j]-i);
		}
		ans = min(ans, tmp);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int N = 2e4+10;
int to[N],cap[N],nxt[N],head[N],q[N<<5],v[N],path[N];
int n,x,y,c,l,r,i,tot=1,S,T;
LL cost[N], d[N], ans, inf=1e14;

void add(int x,int y,int z,int w){
	to[++tot]=y,cap[tot]=z,cost[tot]=w,nxt[tot]=head[x],head[x]=tot;
	to[++tot]=x,cap[tot]=0,cost[tot]=-w,nxt[tot]=head[y],head[y]=tot;
}

bool spfa(){
	rep(i,S,T)d[i]=inf;
	memset(v,0,sizeof(v));
	q[l=r=1]=S,d[S]=0,v[S]=1;
	while(l<=r){
		x=q[l++],v[x]=0;
		for(i=head[x];i;i=nxt[i])
			if(cap[i]&&d[y=to[i]]>d[x]+cost[i]){
				d[y]=d[x]+cost[i],path[y]=i;
				if(!v[y]) q[++r]=y,v[y]=1;
			}
	}
	return d[T]!=inf;
}

void update(){
	for(y=T;y!=S;y=x){
		i=path[y],x=to[i^1];
		--cap[i],++cap[i^1];
	}
	ans+=d[T];
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	S=0,T=n*2+5;
	rep(i,1,n){
		cin>>x>>y>>c;
		add(S,i,c,0);
		add(i,n+1,inf,-x-y);
		add(i,n+2,inf,-x+y);
		add(i,n+3,inf,x-y);
		add(i,n+4,inf,x+y);
	}
	rep(i,1,n){
		cin>>x>>y>>c;
		add(n+4+i,T,c,0);
		add(n+1,n+4+i,inf,x+y);
		add(n+2,n+4+i,inf,x-y);
		add(n+3,n+4+i,inf,-x+y);
		add(n+4,n+4+i,inf,-x-y);
	}
	while(spfa())update();
	cout<<(-ans)<<endl;
	return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[] a=new int[s[1]+1];
		var dp=new long[s[0]+1];
		for(int i = 0;i<s[1];i++) {
			a[i]=sc.I;
		}
		dp[0]=1;
		for(int i = 1,j=0;i<=s[0];i++) {
			if(i==a[j]){j++;continue;}
			dp[i]=dp[i-1]+(i!=1?dp[i-2]:0);
			dp[i]%=mod;
		}
		Console.WriteLine("{0}",dp[s[0]]);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 16224
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+5;

int a[maxn];

int main()
{
    int n;
    cin>>n;
    int ans=0;
    int l;
    cin>>l;
    for(int i=1;i<=n;++i)
    {
        ans+=l+i-1;
    }
    int aa=1;
    for(int i=1;i<=n;++i)
    {
        if(abs(l+aa-1)>abs(l+i-1))
            aa=i;
    }
    cout<<ans-(l+aa-1);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i) ++)
#define MAXINF 1e18L
#define MININF -1e18L

typedef long long ll;

vector<pair<ll, ll>> pf;

int sign(ll x){
    if(x < 0){
        return -1;
    }
    if(x > 0){
        return 1;
    }
    return 0;
}

int main(){
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> ss;
    vector<ll> ts;
    vector<ll> xs;
    rep(i, A){
        ll tmp;
        cin >> tmp;
        ss.push_back(tmp);
    }
    rep(i, B){
        ll tmp;
        cin >> tmp;
        ts.push_back(tmp);
    }
    rep(i, Q){
        ll tmp;
        cin >> tmp;
        xs.push_back(tmp);
    }

    ss.push_back(MAXINF);
    ss.push_back(MININF);
    ts.push_back(MAXINF);
    ts.push_back(MININF);

    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());


    rep(i, Q){
        ll x = xs[i];
        auto r1 = lower_bound(ss.begin(), ss.end(), x);
        auto r2 = lower_bound(ts.begin(), ts.end(), x);
        vector<ll> slr;
        slr.push_back(*r1);
        slr.push_back(*(r1 - 1));

        vector<ll> tlr;
        tlr.push_back(*r2);
        tlr.push_back(*(r2 - 1));

        ll ans = MAXINF;

        for(ll s : slr){
            for(ll t : tlr){
                ll delta_s = s - x;
                ll delta_t = t - x;
                if(sign(delta_s) * sign(delta_t) <= 0){
                    ans = min(ans, 2 * abs(delta_s - delta_t) - max(abs(delta_s), abs(delta_t)));
                }else{
                    ans = min(ans, max(abs(delta_s), abs(delta_t)));
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  x1 = 0
  for i, a in enumerate(alist):
    if i % 2 == 0:
      x1 += a
    else:
      x1 -= a
  ans = [x1]
  for a in alist:
    ans.append((a-ans[-1]//2)*2)
  print(*ans[:-1])


if __name__ == '__main__':
  main()


Measured memory_bytes: 14300
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<i64> = (0..n).map(|_| sc.cin()).collect();
    let mut ans = 0;
    let mut last = -100;
    let mut ac = 0;
    for &x in xs.iter() {
        if last >= x {
            ac += 1;
            ans = max!(ans, ac);
        } else {
            ac = 0;
        }
        last = x;
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

int main(){
    string s, t;
    cin>>s >>t;
    s+=s;
    for(int i=0;i<s.size()-t.size()+1;i++){
        if(s.substr(i, t.size())==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3220
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int count = 0;
		while(sc.hasNext()) {
			String a = sc.next();
			String b = new StringBuffer(a).reverse().toString();
			if(a.equals(b)) {
				count++;
			}
			
			
		}
		out.println(count);
		out.flush();
	}

}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 16864
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

struct Info{
	Info(int arg_color,ll arg_value){
		color = arg_color;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return value < arg.value;
	}

	int color;
	ll value;
};

int rest[NUM+1];

int main(){

	ll M;
	int N,C;
	scanf("%d %lld %d",&N,&M,&C);

	ll sum = 0;

	for(int i =1; i <= C; i++){
		scanf("%d",&rest[i]);
		sum += rest[i];
	}

	int color;
	ll value;

	priority_queue<Info> Q;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %lld",&color,&value);
		Q.push(Info(color,value));
	}

	ll ans = 0;

	ll count = 0;

	while(Q.empty() == false && count < min(M,sum)){
		if(rest[Q.top().color] == 0){
			Q.pop();
			continue;
		}

		ans += Q.top().value;
		rest[Q.top().color]--;
		Q.pop();
		count++;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 5236
#include<stdio.h>

int cnt=0,N,A[1000005],i,G[1000005],m=0;
void f(int g)
{
	int i,j,v;
	for(i=g;i<N;i++)
	{
		v=A[i];
		for(j=i-g;j>=0&&A[j]>v;j-=g)
		{
			A[j+g]=A[j];
			cnt++;
		}
		A[j+g]=v;
	}
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",A+i);
	for(m=0,G[0]=1;G[m]<=N;G[++m]=G[m-1]*3+1);
	printf("%d\n",m);
	for(i=0;i<m;i++)
	{
		printf("%d%c",G[m-i-1],i==m-1?'\n':' ');
		f(G[m-i-1]);
	}
	printf("%d\n",cnt);
	for(i=0;i<N;i++)printf("%d\n",A[i]);
	return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <vector>
#include <string>
#include<map>
using namespace std;

bool check3and4(string S) {
    if (S.at(2) == S.at(3)) {
        return true;
    }
    else {
        return false;
    }
}
bool check5and6(string S) {
    if (S.at(4) == S.at(5)) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
    string S;
    string coffee = "coffee";
    cin >> S;

    if (check3and4(S) and check5and6(S)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



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

int main() {
  int h, w;
  while (cin >> h >> w, (h | w) != 0) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1) {
          cout << "#";
        } else if (j == 0 || j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I) 
const ll INF=1e9+7; 
const ll N = 101; 
  
 
class dijkstra{ 
//0indexed 
public: 
	int v,startv; 
	vector<int> d; 
	vector<vector<pair<int,int> > >e; 

void initsize(int n0){ 
	d.resize(n0); 
	for(int i=0;i<n0;i++)d[i]=INT_MAX; 
	vector<pair<int,int> > ep; 
	for(int i=0;i<n0;i++)e.push_back(ep); 
	v=n0; 
}  
 
void initstart(int s){ 
	startv=s;
	d[s]=0;
}
 
void make_edge(int x,int y,int cost){ 
	e[x].push_back(make_pair(y,cost)); 
	e[y].push_back(make_pair(x,cost)); 
}
 
void make_edgedir(int x,int y,int cost){ 
	e[x].push_back(make_pair(y,cost)); 
}
 
void calcdistance(){ 
	// <-cost,x> 
	//cost startv->x 
	priority_queue<pair<int,int> > q; 
	pair<int,int> p; 
	vector<bool> did; 
	for(int i=0;i<v;i++)did.push_back(false); 
	did[startv]=true; 
	for(int i=0;i<e[startv].size();i++){ 
		p.first=-e[startv][i].second; 
		p.second=e[startv][i].first; 
		q.push(p); 
	}
 
	while(q.size()!=0){ 
		pair<int,int> p; 
		p=q.top(); 
		q.pop(); 
		int x,costsx; 
		x=p.second; 
		costsx=-p.first; 
		if(did[x]==true)continue; 
		did[x]=true; 
		d[x]=costsx; 
 
		for(int i=0;i<e[x].size();i++){ 
			p.first=-(d[x]+e[x][i].second); 
			p.second=e[x][i].first; 
			if(did[p.second]==false)q.push(p); 
		}
	}
}
};

int main(){ 
	dijkstra di;
	int n;
	cin>>n;
	di.initsize(n);
	di.initstart(0);
	FOR(i,0,n){
		int u,k;
		cin>>u>>k;
		FOR(j,0,k){
			int x,co;
			cin>>x>>co;
			di.make_edgedir(u,x,co);
		}
	}
	di.calcdistance();
	FOR(i,0,n){
		cout<<i<<" "<<di.d[i]<<endl;
	}
	return 0; 
}


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

int n,d[200010],sz[200010],dp[200010],minv,pos;
map<int,int> mp;
vector<pair<int,int> > res;
vector<int> v[200010];

inline void dfs(int u,int pr)
{
	for(int i=0;i<v[u].size();i++) if(v[u][i]!=pr){
		dfs(v[u][i],u);
		dp[u]+=dp[v[u][i]]+sz[v[u][i]];
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){cin>>d[i];mp[d[i]]=i;}
	minv=INF;
	for(int i=1;i<=n;i++){
		if(d[i]<minv){
			minv=d[i];
			pos=i;
		}
	}
	for(int i=1;i<=n;i++){sz[i]=1;}
  	map<int,int>::iterator it=mp.end();
  	it--;
	for(;it!=mp.begin();it--){
		int num=it->first,loc=it->second;
		if(loc==pos) continue;
		if(sz[loc]*2>=n){
			cout<<-1<<endl;
			return 0;
		}
		int cur=num-n+2*sz[loc];
		if(!mp.count(cur)){
			cout<<-1<<endl;
			return 0;
		}
		int par=mp[cur];
		res.push_back(make_pair(par,loc));
		sz[par]+=sz[loc];
	}
	for(int i=0;i<res.size();i++){
		v[res[i].first].push_back(res[i].second);
		v[res[i].second].push_back(res[i].first);
	}
	for(int i=1;i<=n;i++) dp[i]=0;
	dfs(pos,-1);
	if(dp[pos]!=minv){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<res.size();i++){
		cout<<res[i].first<<" "<<res[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 23028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

double a, b, x;
int main() {
  cin >> a >> b >> x;
  double th;
  if (x < a * a * b / 2.0) {
    th = atan2(b, 2.0 * x / (a * b));
  } else {
    th = atan2(2.0 * (b - x / (a * a)), a);
  }
  double ans = th / (4 * atan(1)) * 180.0;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

enum int modulo = 1_000_000_007;

void main() {
  int n;
  readf (" %d", &n);
  auto c = uninitializedArray!(int[]) (n);
  foreach (i; 0 .. n) {
    readf (" %d", &c[i]);
  }

  int m = 0;
  foreach (i; 1 .. n) {
    if (c[i] != c[m]) {
      c[++m] = c[i];
    }
  }
  n = m + 1;
  debug stderr.writeln (c[0 .. n]);

  m = c.reduce!"max(a,b)";
  auto pos = uninitializedArray!(int[]) (m+1);
  pos[] = -1;
  auto next = new int[n];
  foreach_reverse (i; 0 .. n) {
    next[i] = pos[c[i]];
    pos[c[i]] = i;
  }
  debug stderr.writeln (next);
  auto d = uninitializedArray!(int[]) (n+1);
  d[n] = 1;
  foreach_reverse (i; 0 .. n) {
    d[i] = d[i+1];
    if (next[i] >= 0) {
      debug stderr.writefln ("i = %d, next[i] = %d", i, next[i]);
      d[i] += d[next[i]];
      if (d[i] >= modulo) d[i] -= modulo;
    }
  }
  debug stderr.writeln (d);
  writeln (d[0]);
}



Measured memory_bytes: 4220
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string.h>
#define endl "\n"
using namespace std;

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

    int i, j;
    int arr[26] = {0};
    vector <int> minV(26, 100000000);
    for(i = 0; i < n; i ++)
    {
    	string s;
    	cin >> s;
    	memset(arr, 0, sizeof(arr));
    	for(j = 0; j < s.length(); j ++)
    	{
    		arr[s[j] - 'a'] ++;
    	}

    	for(j = 0; j < 26; j ++)
    	{
    		minV[j] = min(minV[j], arr[j]);
    	}
    }

    for(j = 0; j < 26; j ++)
    {
    	while(minV[j] > 0)
    	{
    		minV[j] --;
    		char ch = j + 'a';
    		cout << ch;
    	}
    }
}

Measured memory_bytes: 256