akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
using namespace std;

int main(){
    map<char, char> ma, mb;
    ma['2'] = 'k';
    ma['3'] = 's';
    ma['4'] = 't';
    ma['5'] = 'n';
    ma['6'] = 'h';
    ma['7'] = 'm';
    ma['8'] = 'y';
    ma['9'] = 'r';
    mb['T'] = 'a';
    mb['L'] = 'i';
    mb['U'] = 'u';
    mb['R'] = 'e';
    mb['D'] = 'o';
    char a, b;
    while(cin >> a >> b){
        if(a == '0'){
            if(b == 'T')    cout << "wa";
            if(b == 'U')    cout << "nn";
            if(b == 'D')    cout << "wo";
        }else{
            if(a != '1')    cout << ma[a];
            cout << mb[b];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
# 2019-11-19 01:10:02(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
from scipy.misc import comb # (default: exact=False)
# import numpy as np

# def nCr(n, r):
#     r = min(n, r)
#     return np.cumprod(range(n, n-r, -1)) // np.cumprod(range(r, 0, -1))

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    s = list(itertools.accumulate(a))

    
    res = s.count(0)
    for x in [x for x in collections.Counter(s).values() if x >= 2]:
        res += comb(x, 2, exact=True)

    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 51508
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-09-19 20:00:27
 * @LastEditTime: 2020-09-19 20:01:42
 * @FilePath: \VSC\C++\Practice\AC abc179 A.cpp
 */
#include <bits/stdc++.h>
using namespace std;

string s;
signed main()
{
    cin >> s;
    cout << s;
    if (s[s.size() - 1] == 's')
        puts("es");
    else
        puts("s");
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){

  int n, i;
  int a[100];
  int aa[100];
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
    aa[n - i - 1] = a[i];
  }

  for(i = 0; i < n; i++){
    printf("%d", aa[i]);
    if(n - i > 1){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

def func(a):
    b = []
    for ai in a:
        for j in reversed(range(30)):
            if (ai >> j) * 2 ** j == ai:
                b.append(j)
                break
    return b

a = LIST()
if len(set(a)) == 1 and not a[0] % 2:
    print(-1)
    exit()
b = func(a)
ans = 0
while True:
    if 0 in b:
        break
    tmp = [0, 0, 0]
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            tmp[i] += a[j] // 2
    a = tmp
    b = func(a)
    ans += 1
print(ans)

Measured memory_bytes: 59756
#import<bits/stdc++.h>
using namespace std;
long long i,k=1,m=3,n,p=2,z[100005];
char e[100005];
main()
{
scanf("%s",e);n=strlen(e);
for(;i++<100000;z[i]=p)p=p*2%1000000007;
for(i=0;++i<n;)m*=3,e[i]%2?k++:m-=z[k],m=(m+1000000007)%1000000007;
printf("%lld",m);
}

Measured memory_bytes: 1152
#include <stdio.h>
 
int main(void) {
  int H, A;
  scanf("%d %d", &H, &A);
  int ans;
  if (H%A!=0) {
    ans = H / A + 1;
  }else {
    ans = H / A;
  }
  printf("%d", ans);
    return 0;
  }

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<tuple>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

pii operator-(const pii &l, const pii &r){
	return pii(l.first - r.first, l.second - r.second);
}

int operator/(const pii &l, const pii &r){
	return l.first * r.second - l.second * r.first;
}

int sign(pii x){ return pii(0, 0) < x ? 1 : -1; }
double atan2(pii x){ return atan2(x.second, x.first); }

const int MX = 100005;
const int MM = 1000000007;

pii D[MX];
int N, M;

struct uf{
	int t[MX];
	int find(int x){ return t[x] ? t[x] = find(t[x]) : x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		return a == b ? 0 : (t[a] = b, 1);
	}
} uf;

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d%d", &D[i].first, &D[i].second);
	int O[MX];
	for(int i = 1; i <= N; i++) O[i] = i;
	vector<t3> L;
	
	sort(O+1, O+N+1, [](int l, int r){ return D[l] < D[r]; });
	for(int i = 1; i < N; i++){
		L.emplace_back(D[O[i+1]].first - D[O[i]].first, O[i], O[i+1]);
	}

	sort(O+1, O+N+1, [](int l, int r){ return D[l].second != D[r].second ? D[l].second < D[r].second : D[l].first < D[r].first; });
	for(int i = 1; i < N; i++){
		L.emplace_back(D[O[i+1]].second - D[O[i]].second, O[i], O[i+1]);
	}
	sort(L.begin(), L.end());
	ll ans = 0;
	for(t3 e : L){
		int a, b, c;
		tie(a, b, c) = e;
		if( uf.merge(b, c) ) ans += a;
	}
	printf("%lld\n", ans);
}


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

const int maxn = 1e5 + 3;
int n, a[maxn];
std::map<int, int> cnt;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
	for(int i = 0; i < n; ++i) {
		++cnt[a[i]];
		++cnt[a[i] + 1];
		++cnt[a[i] - 1];
	}
	int ans = 0;
	for(std::map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it)
		ans = std::max(ans, it->second);
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

int n, ans = INF;
vector<int> nums(3), bamboo(8);

void calc(vector<int> select){
    vector<vector<int>> new_bamboo(4, vector<int>());
    rep(idx, n){
        new_bamboo[select[idx]].emplace_back(bamboo[idx]);
    }

    int elem_ans = 0;
    repi(idx, 1, 4){
        if(new_bamboo[idx].size() == 0) return;
        elem_ans += new_bamboo[idx].size() * 10 + abs(nums[idx - 1] - accumulate(all(new_bamboo[idx]), 0));
    }

    ans = min(ans, elem_ans - 30);
}

void dfs(int depth, vector<int> select){
    if(depth == n){
        calc(select);
        return;
    }

    rep(nex, 4){
        select[depth] = nex;
        dfs(depth + 1, select);
    }
}

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

    cin >> n;
    rep(i, 3) cin >> nums[i];
    rep(i, n) cin >> bamboo[i];

    vector<int> select(8, 0);
    dfs(0, select);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,a,b;
  cin>>n>>a>>b;ll x[n];
 ll ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
  }
  for(int i=1;i<n;i++)
  {
    ans=ans+min((x[i]-x[i-1])*a, b);
  }
  cout<<ans;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> A;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    A[x]++;
  }
  int ret = 0;
  for (auto& it : A) {
    int x = it.first, cnt = it.second;
    if (cnt >= x) {
      ret += cnt - x;
    } else {
      ret += cnt;
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>


int main(void)
{
    int i,j;
    int n;
    int a[2000001];
    int buka[2000001];

    scanf("%d",&n);
    for(i=0;i<n-1;i++){
        scanf("%d",&a[i]);
        buka[a[i]-1]++;
    }

    for(i=0;i<n;i++){
        printf("%d\n",buka[i]);
    }

    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int n, a[3], cnt, ed;
int f[50][1 << 17], ans = 1;

inline int add(const int &x, const int &y) {
	return x + y < mod ? x + y : x + y - mod;
}
inline int sub(const int &x, const int &y) {
	return x - y < 0 ? x - y + mod : x - y;
}
inline int mul(const int &x, const int &y) { return (int)((ll)x * y % mod); }
int main() {
	scanf("%d%d%d%d", &n, &a[0], &a[1], &a[2]);
	for(int i = 1; i <= n; i++) ans = mul(ans, 10);
	cnt = (1 << a[0] + a[1] + a[2]) - 1;
	ed = (1 << a[0] - 1) | (1 << a[0] + a[1] - 1) | (1 << a[0] + a[1] + a[2] - 1);
	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= cnt; j++)
			for(int k = 1; k <= 10; k++) {
				int t = (j << k) + (1 << k - 1); t &= cnt;
				if((t & ed) != ed) f[i][t] = add(f[i - 1][j], f[i][t]);
			}
	for(int i = 0; i <= cnt; i++) ans = sub(ans, f[n][i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl
const double eps = 1e-6;

void solve(){
	int x; cin >> x;
	if(x >= 400 && x <= 599) cout << 8;
	else if(x >= 600 && x <= 799) cout << 7;
	else if(x >= 800 && x <= 999) cout << 6;
	else if(x >= 1000 && x <= 1199) cout << 5;
	else if(x >= 1200 && x <= 1399) cout << 4;
	else if(x >= 1400 && x <= 1599) cout << 3;
	else if(x >= 1600 && x <= 1799) cout << 2;
	else if(x >= 1800 && x <= 1999) cout << 1;
} 

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}



Measured memory_bytes: 3632
//ABC 158 D
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin >> s;
	
	int q, t, f;
	char c;
	bool flag=true;
	deque<char> dq;
	
	for (int i=0; i<s.size(); ++i)
	   dq.push_back(s[i]);
	
	cin >> q;
	while (q--){
		cin >> t;
		if (t==1){
			flag=!flag; 
		}
		else{
			cin >> f >> c; 
			if(flag){
			  if (f==1){
				dq.push_front(c);
			  }
			  else{
				dq.push_back(c);
			  }
		    }
		    else{
              if (f==1){
				dq.push_back(c);
			  }
			  else{
				dq.push_front(c);
			  }
		    }
	    }
	}
	
	if (!flag) reverse(dq.begin(), dq.end());
	
	for(int i=0; i<dq.size();++i)
	   cout << dq[i];
	
	return 0; 
}

Measured memory_bytes: 896
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const int MAX_S = 3000;
const int MOD = 998244353;

vector<int> as;

vector<int> dp;

int main(void) {
    int N, S;
    cin >> N >> S;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    dp.resize(MAX_S + 1, 0);
    dp[0] = 1;

    for (int i = 0; i < N; i++) {
        const int a = as[i];
        for (int j = MAX_S; j >= 0; j--) {
            if (j + a <= MAX_S) {
                // use a
                dp[j + a] = (dp[j + a] + dp[j]) % MOD;
            }
            // not use a
            dp[j] = (dp[j] * 2) % MOD;
        }
    }

    // for (int i = 0; i <= S; i++) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;

    cout << dp[S] << endl;

    return 0;
}


Measured memory_bytes: 3656
#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;}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct piece {
	int w, d;

	piece(int w = 0, int d = 0) : w(w), d(d) {};

	piece cut(int s) {
		piece ret;
		s %= w + d;
		if(s <= w) {
			ret.w = s;
			w = w - ret.w;
			ret.d = d;
		}
		else {
			ret.d = s - w;
			d = d - ret.d;
			ret.w = w;
		}
		return ret;
	}

	int size() { return w * d;}
	void print() { cout << w << ' ' << d << endl;}
};

vi solve(int n, int w, int d) {
	vector<piece> vp;
	vp.push_back(piece(w, d));
	rep(i, n) {
		int p, s;
		cin >> p >> s;
		p--;
		piece tp = vp[p].cut(s);
		if(tp.size() < vp[p].size()) {
			vp.push_back(tp);
			vp.push_back(vp[p]);
		}
		else {
			vp.push_back(vp[p]);
			vp.push_back(tp);
		}
		vp.erase(vp.begin() + p);
	}
	vi ret(n + 1);
	rep(i, n + 1) ret[i] = vp[i].size();
	sort(ret.begin(), ret.end());
	return ret;
}

int main() {
//	cout << fixed << setprecision(15);
	vector<vi> ans;
	while(true) {
		int n, w, d;
		cin >> n >> w >> d;
		if(n == 0 && w == 0 && d == 0) break;
		ans.push_back(solve(n, w, d));
	}
	rep(i, ans.size()) {
		rep(j, ans[i].size()) {
			cout << ans[i][j];
			if(j < ans[i].size() - 1) cout << ' ';
			else cout << endl;
		}
	}
}



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

// com[k] := nCk の値をメモ
vector<long long> com;

// a^b mod p を返す
long long modpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long res = modpow(a, b / 2, p);
  if (b % 2 == 0) res = (res * res) % p;
  else res = (((res * res) % p) * a) % p;
  return res;
}

// mod p における a の逆元 a^{p-2} mod p を返す
long long inverse(long long a, long long p) {
  return modpow(a, p-2, p);
}

// nCk (mod p) の前処理 O(k log p)
void comInit(long long n, long long k, long long p) {
  com.resize(k+1);
  com.at(0) = 1;
  long long tmp = 1;
  for (int i = 1; i <= k; i++) {
    tmp = ((tmp * (n-i+1) % p) * inverse(i, p)) % p;
    com.at(i) = tmp;
  }
}

// val を p で割った余り (>= 0) を返す
long long mod(long long val, long long p) {
  long long res = val % p;
  if (res < 0) res += p;
  return res;
}

int main() {
  const int MOD = 1000000007;
  int n, a, b; cin >> n >> a >> b;
  comInit(n, 200000, MOD);
  long long ans = modpow(2, n, MOD);
  cout << mod(ans - 1 - com.at(a) - com.at(b), MOD) << endl;
}

Measured memory_bytes: 1792
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    xs <- unfoldr (B.readInt.B.dropWhile isSpace) <$> B.getContents
    print $ solve n xs

solve :: Int -> [Int] -> Int
solve n xs = go (r - f) f r fs rs
  where
    !(f:fs, r:rs) = fmap reverse . splitAt (div n 2) $ sort xs
    go !acc !low !high (f:fs) (r:rs) = go acc' f r fs rs
      where
        !acc' = acc + (r - low) + (high - f)
    go !acc !low !high [] [r] = acc + max (r - low) (high - r)
    go !acc _ _ _ _ = acc


Measured memory_bytes: 17788
let N = stdin.ReadLine() |> int

let A =
    stdin.ReadLine().Split()
    |> Array.map int
    |> Array.countBy id
    |> dict

[| 1..N |]
|> Array.map (fun x ->
    if A.ContainsKey x then A.[x]
    else 0)
|> Array.iter stdout.WriteLine


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, m; std::cin >> n >> m;
    vvi to(n, vi(n, inf));
    vi a(m), b(m), c(m);
    rep(i, n) to[i][i] = 0;
    rep(i, m) {
        std::cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        to[a[i]][b[i]] = to[b[i]][a[i]] = c[i];
    }
    rep(k, n) rep(i, n) rep(j, n) chmin(to[i][j], to[i][k] + to[k][j]);
    int ans = 0;
    rep(k, m) {
        bool ok = false;
        rep(i, n) srep(j, i+1, n) {
            if (to[i][a[k]]+c[k]+to[b[k]][j] == to[i][j])
                ok = true;
            if (to[i][b[k]]+c[k]+to[a[k]][j] == to[i][j])
                ok = true;
        }
        if (!ok) ans++;
    }
    std::cout << ans << "\n";
}


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

int main(){
  ll n,a,b;cin >> n >> a >> b;
  ll tmp = b-a;
  if(tmp%2==0){cout << tmp/2 << endl; return 0;}
  else{
    ll ans1,ans2;
    ans1 = (n-b+1) + (n-(a+(n-b+1)))/2;
    ans2 = a + (b-a-1)/2;
    cout << min(ans1,ans2) << endl;
  }
}

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

typedef long long ll;

int n, m;
bool g[8][8];

bool check(vector<int> vec){
    for (int i = 1; i < n; i++){
        if (!g[vec[i-1]][vec[i]]) return false;
    }
    return true;
}

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x][y] = true;
        g[y][x] = true;
    }
    vector<int> v;
    for (int i = 0; i < n; i++){
        v.push_back(i);
    }

    int cnt = 0;
    do {
        if (check(v)) cnt++;
    } while (next_permutation(v.begin()+1, v.end()));

    cout << cnt << endl;
}


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

using namespace std;

#define EPS 1e-9
#define For(i,N) FOR(i,N)
#define Forr(i,a,b) FORR(i,a,b)
#define Fotr(i,a,b,c) FOTR(i,a,b,c)
#define FOR(i,N) FORR(i, 0, N)
#define FORR(i,a,b) FOTR(i, a, b, 1)
#define FOTR(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define FOREACH(i,x) for(__typeof__((x).begin())i=(x).begin();i!=(x).end();i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define BCHK(a,x) (((a)>>(x))&1)
#define BSET(a,x) ((a)|(1<<(x)))
#define BCLR(a,x) ((a)&(~(1<<(x))))
#define BTGL(a,x) ((a)^(1<<(x)))
#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
#define read() freopen("input.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
#define cpp_io() {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define BUFFSIZE 30000
#define INF 1000000000
#define MAX 300010
#define MOD 1000000007
#define pb push_back
#define mkpr make_pair
#define pii pair<int, int>
#define PI acos(-1)
#define ll long long
#define fi first
#define si second
#define all(x) x.begin(), x.end()
#define double long double

char CRTBUFF[BUFFSIZE];
#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main(){
    cpp_io();
    #ifdef LOCAL
        read();
        //write();
    #endif

    ll n, k, ans = 0, x, r;
    cin>>n>>k;

    FORR(i, 1, n+1){
        r = n/i;
        x = n/i * i;
        ans += max((i - k)*r, 0LL);
        ans += max(n-x-k+1, 0LL);
        if(k==0)ans--;
    }
    cout<<ans<<"\n";

}











Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

#define ITEM_NUM_MIN        1
#define ITEM_NUM_MAX        100
#define COMBINE_WEIGHT_MIN  1
#define COMBINE_WEIGHT_MAX  10000
#define ITEM_VALUE_MIN      1
#define ITEM_VALUE_MAX      1000
#define ITEM_WEIGHT_MIN     1
#define ITEM_WEIGHT_MAX     1000
#define SUCCSESS    0
#define FAIL        -1

using namespace std;

unsigned int CalcKnapsackProblem(vector<unsigned int> ulvecValue, vector<unsigned int> ulvecWeight, unsigned int ulCap)
{
    unsigned int ulValueNum = ulvecValue.size();            
    unsigned int aulKnapsack[ulValueNum + 1][ulCap + 1];    // 一度したことのある計算を参照するために、値を保存する配列
    
    // 0初期化することで、動的計画法で0になる計算を省く
    memset(&aulKnapsack[0][0], 0 , sizeof(aulKnapsack));
    
    // ボトムアップに値を計算し、同じ計算を繰り返さないようにする
    for(unsigned int i = 1; i <= ulValueNum; i++)
    {
        for(unsigned int j = 1; j <= ulCap; j++)
        {
            // 品物が入るかを判定する
           if (ulvecWeight[i-1] <= j)
           {
               // 入る場合は、入った場合のナップザックに入った品物の総価値と、品物が一つ少ない場合の最大価値を比べる
                aulKnapsack[i][j] = max(ulvecValue[i-1] + aulKnapsack[i-1][j-ulvecWeight[i-1]],  aulKnapsack[i-1][j]); 
           }
           else
           {
               // 入らない場合は、品物が一つ少ない場合の最大価値とする
                aulKnapsack[i][j] = aulKnapsack[i-1][j]; 
           }
        }
    }
    
    // 計算した、N個の品物で、ナップザックの容量がWのときの最大価値を返す
    return aulKnapsack[ulValueNum][ulCap];
}



/*
最初の行に品物の数nとナップザックの容量Wが空白区切りで与えられる。
続くn行にn個の整数v_i, w_iがそれぞれ１行に与えられる。
次の条件を満たすようにナップザックに品物を入れるとしたとき、
・選んだ品物の価値の合計をできるだけ高くする。
・選んだ品物の重さの総和は W を超えない。
価値の合計の最大値を1行で表示する。
return 正常値0のみ。
*/
int main(void)
{
    unsigned int ulItemNum;
    unsigned int ulCombineWeight;
    vector<unsigned int> ulvecItemValue;
    vector<unsigned int> ulvecItemWeight;
    
    ulvecItemValue.reserve(ITEM_NUM_MAX);
    ulvecItemWeight.reserve(ITEM_NUM_MAX);
    
    // 入力を受け取る
    cin >> ulItemNum;
    if((ulItemNum < ITEM_NUM_MIN) || (ulItemNum > ITEM_NUM_MAX))
    {
        return FAIL;
    }
    cin >> ulCombineWeight;
    if((ulCombineWeight <  COMBINE_WEIGHT_MIN) || (ulCombineWeight > COMBINE_WEIGHT_MAX))
    {
        return FAIL;
    }
    
    for(unsigned int i = 0; i < ulItemNum; i++)
    {
        unsigned int tmp;

        cin >> tmp;
        if((tmp <  ITEM_VALUE_MIN) || (tmp > ITEM_VALUE_MAX))
        {
            return FAIL;
        }
        ulvecItemValue.push_back(tmp);
        
        cin >> tmp;
        if((tmp < ITEM_WEIGHT_MIN) || (tmp > ITEM_WEIGHT_MAX))
        {
            return FAIL;
        }
        ulvecItemWeight.push_back(tmp);
        
    }

    // 0-1ナップザック問題を計算し、表示する。
    cout << CalcKnapsackProblem(ulvecItemValue, ulvecItemWeight, ulCombineWeight) << endl;
    
    return SUCCSESS;
}




Measured memory_bytes: 7116
fun main(args: Array<String>) {

    val (W, H, x, y) = readLine()!!.split(" ").map { Integer.parseInt(it).toDouble() }
    print((W * H) / 2.0)
    print(" ")
    if (x == 0.0 || y == 0.0) {
        print(0)
        return
    }

    if (x* 2.0 == W && y*2.0 ==H ) {
        print(1)
    } else {
        print(0)
    }
}


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

int main(void){
    int n;
    cin >> n;
    
    set<int> list;
    int cnt = 0;
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        auto it = list.find(input);
        if(it != list.end()){
            list.erase(it);
            cnt--;
        }else{
            list.insert(input);
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 4864
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n,k = map(int,input().split())
A = []
D = []
p = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(len(a)):
        p[a[j]-1]+=1
cnt = 0
for i in range(len(p)):
    if p[i] == 0:
        cnt+=1
print(cnt)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long int N;
  cin>>N;
  vector<unsigned long long int>A(N);
  unsigned long long int ans=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    ans+=A[i];
  }
  unsigned long long int count=0;
  unsigned long long int answer;
  unsigned long long int E;
  for(int i=0;i<N;i++){
    count+=A[i];
    answer=max(ans-count,count)-min(ans-count,count);
    if(i==0)E=answer;
    else E=min(E,answer);
  }
  cout<<E<<endl;
}

Measured memory_bytes: 4812
#include <cstdio>
int main() {
  int a,b;
  scanf("%d %d", &a, &b);
  if (a > b) {
    printf("a > b");
  } else if (a < b) {
    printf("a < b");
  } else {
    printf("a == b");
  }
  printf("\n");
}



Measured memory_bytes: 2732
def main():
    n, m= map(int, input().split()) 
    inlis = list()
    for i in range(n):
        a, b = list(map(int, input().split()))
        inlis.append([a,b])
    inlis.sort(key = lambda x: x[0])
    #print(inlis)

    tmp = 0
    kane = 0

    for numlis in inlis:
        a = numlis[0]
        b = numlis[1]

        if tmp + b <= m:
            tmp += b 
            kane += a * b
        
        else:
            kau = m - tmp
            tmp += kau
            kane += a * kau

        if tmp == m:
            break
    print(kane)   


if __name__ == "__main__":
    main()

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



int main(){
    int N,K,R,S,P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    int ren;
    for (int j = 0; j < K; j++)
    {
        if(T[j] == 'r') ans += P;
        if(T[j] == 's') ans += R;
        if(T[j] == 'p') ans += S;
    }
    
    for (int i = 0; i < K; i++)
    {
        ren = 0;
        for (int j = i; j < N-K; j += K)
        {
            if(T[j+K] != T[j]){
                ren = 0;
                if(T[j+K] == 'r') ans += P;
                if(T[j+K] == 's') ans += R;
                if(T[j+K] == 'p') ans += S;
            }
            else{
                ren++;
                if(ren%2 == 0){
                    if(T[j+K] == 'r') ans += P;
                    if(T[j+K] == 's') ans += R;
                    if(T[j+K] == 'p') ans += S;
                }
            }
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll res = 0;
    ll N,K; cin >> N >> K;
    if(K == 0) return res = N*N;
    for(ll b = K+1; b <= N; b++){
        ll x = K;
        ll T = b;
        for(int i = 0; b*i+K <= N; i++){
            if(T <= N){
                res += (b-K);
            }else{
                res += (N - (b*i+K) + 1);
            }
            T += b;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, m;
    cin >> n >> m;
    static int ok[100001];

    for(int i=0;i<m;i++){
        int l, r;
        cin >> l >> r;
        ok[l-1]++;
        ok[r]--;
    }
    for(int i=1;i<=n;i++) ok[i] += ok[i-1];
    int ans = 0;
    for(int i=0;i<n;i++) if(ok[i]==m) ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int dfs(int n, vector<vector<int>>& graph, int p, int s) {
    if (s == (1 << n) - 1) {
        return 1;
    }

    int r = 0;
    for (int i = 0; i < static_cast<int>(graph[p].size()); i++) {
        if ((s & (1 << graph[p][i])) == 0) {
            r += dfs(n, graph, graph[p][i], s | (1 << graph[p][i]));
        }
    }

    return r;
}

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

    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    cout << dfs(n, graph, 0, 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
 int a,b;
  cin>>a>>b;
  cout<<(a+b)%24<<endl;
}

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;

    bool ans = false;
    for(int i = k; i <= b; i += k){
        if (i >= a) ans = true;
    }
    if (ans) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct edge {
  int to, cost;
  edge(int to_, int cost_) {
    to = to_; cost = cost_;
  }
};

vector<edge> G[101];
int n, m;

int dij() {
  int d[2][101];
  for(int i=0; i<101; i++) {
    d[0][i] = d[1][i] = INF;
  }

  priority_queue<Pip, vector<Pip>, greater<Pip> > q;
  q.push(Pip(0, Pii(0, 1)));
  d[0][0] = 0;
  while( !q.empty() ) {
    Pip p = q.top(); q.pop();
    int cost = p.fr, u = p.sc.fr, t = p.sc.sc;

    if( u == n-1 ) {
      return cost;
    }

    for(int i=0; i<G[u].size(); i++) {
      int v = G[u][i].to;
      int add_cost = G[u][i].cost;
      if( cost + add_cost < d[t][v] ) {
	d[t][v] = cost + add_cost;
	q.push(Pip(d[t][v], Pii(v, t)));
      }

      if( t ) {
	for(int j=0; j<G[v].size(); j++) {
	  int k = G[v][j].to;
	  if( cost < d[t-1][k] ) {
	    d[t-1][k] = cost;
	    q.push(Pip(d[t-1][k], Pii(k, t-1)));
	  }
	}
      }
    }
  }
}

int main() {
  while( cin >> n >> m, n+m ) {
    for(int i=0; i<101; i++) {
      G[i].clear(); 
    }

    for(int i=0; i<m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--; b--;
      G[a].pb(edge(b, c));
      G[b].pb(edge(a, c));
    }

    cout << dij() << endl;
  }
}

Measured memory_bytes: 1212
n = int(input())
h = list(map(int, input().split()))

for i in range(1, n - 1):
    if h[i - 1] < h[i]:
        h[i] -= 1
    if not h[i - 1] <= h[i] <= h[i + 1]:
        print('No')
        exit()

print('Yes')

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

int main() {
  int N;
  double T, A;
  cin >> N;
  cin >> T >> A;
  double m = 0;
  int a = 0;
  vector<double> H(N);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  for(int i = 0; i < N; i++) {
    H.at(i) = abs(T - H.at(i)*0.006 - A);
  }
  for(int i = 0; i < N; i++) {
    if(i == 0) {
      m = H.at(i);
      a = 0;
    }
    else {
      m = min(H.at(i),m);
      if(H.at(i) <= m) {
        a = i;
      }
    }
  }
  
  cout << a+1 << endl;
}


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

using namespace std;

int solve(){
    char n;
    cin>>n;
    int a=n-'A';
    if(a>25) cout<<'a';
    else cout<<'A';
    
    return 0;
}

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


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
int k,q;
typedef long long ll;
ll d[5001];
ll n[5001];
ll x[5001];
ll m[5001];

int main(){
    cin >> k >> q;
    for (int i=0;i<k;i++){
        cin >> d[i];
    }
    for (int i=0;i<q;i++){
        cin >> n[i] >> x[i] >> m[i];
    }
    for (int i=0;i<q;i++){
        ll dd[5001];
        ll l,p;
        l = (n[i]-1)/k;
        p = (n[i]-1) % k;
        ll sum=0;
        ll sumb=0;
        ll cnt=0;
        ll cntb=0;
        x[i] %= m[i];
        for (int j = 0;j<p;j++){
            dd[j] = d[j] % m[i];
            sum += dd[j];
            sumb += dd[j];
            if (dd[j] == 0){
                cnt += 1;
                cntb += 1;
            }
        }
        for (ll j = p;j<k;j++){
            dd[j] = d[j] % m[i];
            x[i] %= m[i];
            sum += dd[j];
            if (dd[j] == 0){
                cnt += 1;
            }
        }
        sum = sum * l + sumb + x[i];
        cnt = cnt * l + cntb;
        ll ans=0;
        ans = n[i] -1 -sum/m[i]-cnt;
        cout << ans << endl;
    }
    
}



Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[60];

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n", sqrt(r2));
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,W;
ll v[108],w[108];
ll dp[105][100005];
//<<-----Implement Functions Here---->>//
ll solve(ll i,ll h)
{
	if(h>W)return -1e+18;
	else if(i>n-1)return 0;
	else if(dp[i][h]!=-1)return dp[i][h];
	dp[i][h] = max(v[i]+solve(i+1,h+w[i]),solve(i+1,h));
	return dp[i][h];
	
}

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>W;mset(dp,-1);
		for(ll i=0;i<n;i++)cin>>w[i]>>v[i];
		cout<<solve(0,0);
		
	}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

}

Measured memory_bytes: 85376
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  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].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card 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 partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // ????????????????????¨??????????????????????????????????????????
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string ans = "Three";
  for(int i = 0; i < n; i++){
    char s;
    cin >> s;
    if(s == 'Y'){
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main(){
	int R[MAX],n;
	cin>>n;
	for(int i=0;i<n;i++) cin >> R[i];
	int maxv=-2000000000;
	int minv=R[0];
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
			minv=min(minv,R[i]);
	}
	cout << maxv << endl;
	
	return 0;
}



Measured memory_bytes: 3860
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define GRESORT(v) sort(v.begin(),v.end(),greater<int>())
#define REVERSE(v) reverse(v.begin(),v.end())
#define overlap(v) v.erase(unique(v.begin(),v.end()),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999

//4??????
//int dy[]={0, 0, 1, -1};
//int dx[]={1, -1, 0, 0};

//8??????
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

ll mod = (ll)1e9+7;

void solve(){
    int n;
    while(cin >> n){
        cout << (n * n + n + 2) / 2 << endl;
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int red = sc.nextInt();
        int green = sc.nextInt();
        int blue = sc.nextInt();
        int k = sc.nextInt();
        while(k!=0){
            if(green<=red){
                green*=2;
            }
            else if(blue<=green)
                blue*=2;
            else
                break;
            k--;
        }
        if(green>red && blue>green){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35600
from collections import deque

n = int(input())
A = list(map(int,input().split()))
B = deque([])


for i in range(n):
    if i%2 == 0:
        B.append(A[i])
    else:
        B.appendleft(A[i])

if n%2:
    B = list(B)[::-1]
        
print(*B)

Measured memory_bytes: 32452
# 二部グラフの最大マッチングを解く
class BipartiteGraph
  def initialize(n)
    @V = n                # 頂点数
    @G = Array.new(n){[]} # グラフの隣接リスト表現
    @match = Array.new(n) # マッチングのペア
    @used = Array.new(n)  # DFS で既に調べたか
  end
  
  # u -> v の辺をグラフに追加
  def add_edge(u, v)
    @G[u] << v
    @G[v] << u
  end
  
  # 増加パスを DFS で探索
  def dfs(v)
    @used[v] = true
    @G[v].each do |u|
      w = @match[u]
      if w < 0 || !@used[w] && dfs(w)
        @match[v] = u
        @match[u] = v
        return true
      end
    end
    false
  end
  
  # 最大マッチングを求める
  def bipartite_matching
    res = 0
    @match.fill(-1)
    @V.times do |v|
      if @match[v] < 0
        @used.fill(false)
        res += 1 if dfs(v)
      end
    end
    return res
  end
end

N = gets.to_i
ab = Array.new(N) { gets.split.map(&:to_i) }.sort 
cd = Array.new(N) { gets.split.map(&:to_i) }.sort

bg = BipartiteGraph.new(N*2)
N.times do |i|
  a, b = ab[i]
  N.times do |j|
    c, d = cd[j]
    bg.add_edge(i, N+j) if a < c and b < d
  end
end
puts bg.bipartite_matching

Measured memory_bytes: 1916