akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll get_result(ll h, ll w, const vector<string>& s, vector<vector<ll>>& dps) {
	if (dps[h][w] != -1) {
		return dps[h][w];
	}

	ll res = 0;


}

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

	ll H, W;
	cin >> H >> W;
	
	vector<string> s(H);
	
	for (ll i = 0; i < H; ++i) {
		cin >> s[i];
	}

	vector<vector<ll>> dps(H + 1, vector<ll>(W + 1, 1LL << 60));
	dps[1][1] = 0;
	for (ll i = 0; i < H; ++i) {
		for (ll j = 0; j < W; ++j) {
			if (i == 0 && j == 0) {
				continue;
			}
			dps[i + 1][j + 1] = min(
				dps[i][j + 1] + ((s[i][j] == '#') && (i > 0) && (s[i - 1][j] == '.') ? 1 : 0),
				dps[i + 1][j] + ((s[i][j] == '#') && (j > 0) && (s[i][j - 1] == '.') ? 1 : 0)
			);
		}
	}

	cout << dps[H][W] + (s[0][0] == '#' ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    cout << a * 2 - 1 << endl;
  }else if(a < b) cout << b * 2 - 1 << endl;
  else cout << a * 2 << endl;
}

Measured memory_bytes: 256
(defun inc (x)
  (1+ x))

(defun solve(n a b)
    (dotimes (i n)
      (format t "~A~%" (+ (count (1+ i) a) (count (1+ i) b))))) 

(defun main ()
  (let* ((n (read))
         (m (read))
         (a (make-array m))
         (b (make-array m)))
    (progn
      (dotimes (i m)
        (setf (aref a i) (read))
        (setf (aref b i) (read)))
      (solve n a b))))

(main)


Measured memory_bytes: 24400
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> aa(a), bb(b);
    priority_queue<ll, vector<ll>, greater<ll>> pa, pb, pc;
    rep(i, a){
        cin >> aa.at(i);
    }
    rep(i, b){
        cin >> bb.at(i);
    }

    sort(aa.rbegin(), aa.rend());
    sort(bb.rbegin(), bb.rend());

    rep(i, x){
        pa.push(aa.at(i));
    }

    rep(i, y){
        pb.push(bb.at(i));
    }

    rep(i, c){
        ll tmpc;
        cin >> tmpc;
        pc.push(tmpc);
    }

    ll sum = 0;

    while(!pc.empty()){
        ll ta = pa.top();
        ll tb = pb.top();
        ll tc = pc.top();
        dump(tb);

        if(ta<tc && tb<tc){
            if(ta>tb){
                pb.pop();
                pb.push(tc);                
                pc.pop();
                continue;
            }
            else{
                pa.pop();
                pa.push(tc);                
                pc.pop();
                continue;
            }
        }
        else if(ta<tc){
            pa.pop();
            pa.push(tc);                
            pc.pop();
            continue;
        }
        else if(tb<tc){
            pb.pop();
            pb.push(tc);                
            pc.pop();
            continue;
        }
        pc.pop();
    } 

    rep(i, x){
        sum += pa.top();
        pa.pop();
    }

    rep(i, y){
        sum += pb.top();
        pb.pop();
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

template<typename Monoid> struct Segment_Tree{
    //二項演算
    Monoid ope(Monoid a, Monoid b) {return min(a, b);}
    //単位元
    Monoid unit;
    int n;
    vector<Monoid> seg;
    //要素数N(0-indexed)のxを単位元とするセグメント木を構築
    Segment_Tree(int N, Monoid x){
        unit = x;
        n = 1;
        while(n < N) n <<= 1;
        seg.assign(2*n, unit);
    }
    //i番目の要素をxに変更
    void change(int i, Monoid x){
        i += n;
        seg[i] = x;
        while(i > 0){
            i /= 2;
            seg[i] = ope(seg[2*i], seg[2*i+1]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    Monoid query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return unit;
        elif(a <= l && r <= b) return seg[i];
        else{
            Monoid vl = query(a, b, 2*i, l, (l+r)/2);
            Monoid vr = query(a, b, 2*i+1, (l+r)/2, r);
            return ope(vl, vr);
        }
    }
    //i番目の要素を取得
    Monoid at(int i){
        return seg[n+i]; 
    }
    //初期化する
    void clear(){
        fill(seg.begin(), seg.end(), unit);
    }
};

const int MAX_N = 1e5;
//seg2[i]:=A[2*i],seg1[i]=A[2*i+1]
Segment_Tree<pii> seg2(MAX_N, pii(inf, inf)), seg1(MAX_N, pii(inf, inf));

//[l,r)での辞書順最小のペアのインデックスを返す
pii min_pair(pii sec){
    int l = sec.first, r = sec.second;
    int L, R;
    pii a, b;
    if(l%2 == 0){
        a = seg2.query(l/2, r/2);
        L = a.second;
        b = seg1.query(L/2, r/2);
        R = b.second;
    }
    else{
        a = seg1.query(l/2, r/2);
        L = a.second;
        b = seg2.query((L+1)/2, (r+1)/2);
        R = b.second;
    }
    return pii(L, R);
}

int p[2*MAX_N];
using P = pair<int, pii>;
priority_queue<P, vector<P>, greater<P> > que;

void push_que(int l, int r){
    if(l < r) que.push(P(p[min_pair(pii(l, r)).first], pii(l, r)));
}

int main(){
    int N;
    cin >> N;
    rep(i, N){
        cin >> p[i];
        if(i%2 == 0) seg2.change(i/2, pii(p[i], i));
        else seg1.change(i/2, pii(p[i], i));
    }
    vector<int> ans;
    push_que(0, N);
    while(!que.empty()){
        int l = que.top().second.first, r = que.top().second.second;
        pii x = min_pair(que.top().second);
        que.pop();
        int L = x.first, R = x.second;
        ans.pb(p[L]), ans.pb(p[R]);
        push_que(l, L);
        push_que(L+1, R);
        push_que(R+1, r);
    }
    for(auto &e: ans) cout << e << ' ';
    cout << endl;
}

Measured memory_bytes: 7848
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        ll ret = ((n*(n+1))/2 + (n*(n+1)*(2*n+1))/6)/2;
        forr(i,0,n-1) {
            readll(u); readll(v);
            if (u>v) {swap(u,v);}
            ret -= u*(n-v+1);
        }
        cout << ret << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef pair<double, double> P;

const int MAXN = 50;
const double EPS = 1e-8;
int N;
P arr[MAXN];

P operator+(const P& a, const P& b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

P operator-(const P& a, const P& b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

P operator/(const P& a, double b) {
    return make_pair(a.first / b, a.second / b);
}

P operator*(const P& a, double b) {
    return make_pair(a.first * b, a.second * b);
}

double len(const P& a) {
    return sqrt(a.first * a.first + a.second * a.second);
}

bool check(double r) {
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            P a = arr[i], b = arr[j];
            P mid = (a + b) / 2;
            P h = (a - b);
            if (len(h) > 2 * r + EPS)
                continue;
            swap(h.first, h.second);
            h.second = -h.second;
            double x2 = h.first * h.first, y2 = h.second * h.second;
            h = h / len(h) * sqrt(r * r - x2 / 4 - y2 / 4);
            P c[2] = {mid + h, mid - h};
            for (int k = 0; k <= 1; k++) {
                bool flag = true;
                for (int l = 0; l < N; l++) {
                    if (len(arr[l] - c[k]) > r + EPS) {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                    return true;
            }
        }
    }
    return false;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i].first >> arr[i].second;

    double l = 0, r = 800;
    while (r - l > 1e-7) {
        double mid = (r + l) / 2;
        // cout << "check r = " << mid << endl;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << setiosflags(ios::fixed) << setprecision(8) << r << endl;
}

Measured memory_bytes: 256
n=gets.to_i
as=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)
cs=gets.split.map(&:to_i)

# bcs
bcs=[]
n.times do |i|
  if cs[i] == false
    cs[i] == nil
  end
  bcs.push([bs[i],cs[i]])
end

abcs=[]

as.each do |a|
  abcs.push([a,bcs[a-1]])
end

sum=0
rem=[21,[0,0]]
abcs.each do |x|
  sum+=x[1][0]
  sum+=rem[1][1] if x[0]-rem[0]==1
  rem=x
end

p sum


Measured memory_bytes: 1788
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll x,y;cin>>x>>y;
  if(x%y==0)cout<<-1<<endl;
  else cout<<x*(y-1)<<endl;
}

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

int main(){
  double r;
  double a, c;
  cin >> r;
  a = r * r * M_PI;
  c = 2 * r * M_PI;
  printf("%.6lf %.6lf", a, c);
  return 0;
}



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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;


int main(){
	int N,L;cin>>N>>L;
	int suml=0;

	REP(i,N)suml+=L+i;

	if(L>0){
		cout << (suml-L) << endl;
	}
	else{
		int s = L,e = L+N-1;
		if(s <= 0 && 0<=e)cout << suml << endl;
		else{
			cout << (suml-(L+N-1)) << endl;
		}
	}



	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll f(ll b, ll n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}
int main() {
    ll n, s, minn = LLONG_MAX;
    cin>>n>>s;
    if (n == s) minn = s + 1;
    else 
	{
        for (ll i = 2; i *i <= n; i++)
            if (f(i,n) == s && minn > i)
                minn = i;
        for (ll i = 1; i * i <= n; i++)
		{
            ll b = (n - s) / i + 1;
            if(b > 1)
                if (f(b,n) == s && minn > b)
                    minn = b;
        }
        if (minn == LLONG_MAX)
            minn = -1;
    }
    cout<<minn<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 11:04:32 2019

@author: shinjisu
"""


# arc 071 dubious document
def getInt(): return int(input())


def zeros(n): return [0]*n


def db(x):
    global debug
    if debug:
        print(x)


debug = False
n = getInt()
Str = zeros(n)
for i in range(n):
    Str[i] = [c for c in input()]
    Str[i].sort()
    Str[i] = ''.join(Str[i])
db((Str, n))
idx = zeros(n)
widx = zeros(n)
dub = ''
for i in range(len(Str[0])):
    allFound = True
    for j in range(1, n):  # プレテスト
        widx[j] = Str[j].find(Str[0][i], idx[j])
        if widx[j] == -1:
            allFound = False
    if allFound:
        dub = dub + Str[0][i]
        db(dub)
        for j in range(1, n):
            idx[j] = widx[j]+1
print(dub)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  int n;
  cin >> n;
  ll ans = 1;
  ll mod = 1000000007;
  for (int i = 1; i <= n; i++) {
    ans *= i; 
    ans %= mod;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Harmony
            var line = ReadLine();
            int a = line[0];
            int b = line[1];

            if ((a + b) % 2 == 0)
            {
                Console.WriteLine((a + b) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++)
				if ((h == 0 || h == H - 1) || (w == 0 || w == W - 1))
					cout << '#';
				else
					cout << '.';
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
	ll n;
	cin>>n;
	ll ch[10010];
	ll so[1000010]={};
	so[1]=1;
	for(ll i=2;i<1000010;i++){
		if(so[i]!=0){
			continue;
		}
		for(ll j=1;j*i<1000010;j++){
			so[j*i]=i;
		}
	}
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll in[1000010]={};
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		map<ll,ll>cnt;
		while(so[now]!=now){
			ll next=so[now];
			ll sum=0;
			while(now%next==0){
				sum++;
				now/=next;
			}
			cnt[next]=sum;
		}
		cnt[now]++;
		for(auto itr=cnt.begin();itr!=cnt.end();itr++){
			ll num=itr->first;
			ll val=itr->second;
			in[num]=max(in[num],val);
		}
	}
	ll lcm=1;
	for(ll i=2;i<1000010;i++){
		ll now=in[i];
		if(now==0){
			continue;
		}
		ll now2=modpow(i, now, 1000000007);
		lcm*=now2;
		lcm%=inf;
		//cout << lcm<<endl;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		ll cnt=lcm*modinv(now,inf)%inf;
		ans+=cnt;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 19304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
 
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
 
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
using namespace std;
 
typedef pair<int,int> pii;
 
int main(){

  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);

  vector<int> a;
  REP(i,n){
    int t;
    scanf("%d", &t);
    a.pb(t);
  }

  int ans[100][100] = {};
  int count = 0;
  REP(i,n){
    REP(j,a[i]){
      ans[count / w][count % w] = i + 1;
      count++;
    }
  }

  REP(i,h){
    if(i % 2 == 0){
      REP(j,w){
        if(j != w -1){
          printf("%d ", ans[i][j]);
        }else{
          printf("%d\n", ans[i][j]);
        }
      }
    }else{
      REPR(j, w - 1){
        if(j != 0){
          printf("%d ", ans[i][j]);
        }else{
          printf("%d\n", ans[i][j]);
        }
      }
    }
  }
  return 0;
}



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


#define li          int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[3];

int main() {
    li sum=0;
    rep(i,3){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<(sum>21?"bust":"win")<<endl;


    return 0;
}


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

int n, a[100009], b[100009], c[100009];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) b[i] = b[i - 1] + abs(a[i] - a[i - 1]);
	for (int i = n; i >= 1; i--) c[i] = c[i + 1] + abs(a[i] - a[i + 1]);
	for (int i = 1; i <= n; i++) {
		cout << abs(a[i - 1] - a[i + 1]) + b[i - 1] + c[i + 1] << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N+1);
    REP(i,1,N+1) cin >> A[i];

    ll k = 1, cnt = 0;
    REP(i,0,N+1) {
        k = A[k];
        ++cnt;
        if(k == 2) break;
    }
    if(cnt == N+1) PR(-1);
    else PR(cnt);


    return 0;
}

/*



*/

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  ll tot = 0;
  int mc = 0;
  rep(i, n){
    int in;
    cin >> in;
    if(in < 0) mc++;
    a.at(i) = abs(in);
    tot += a.at(i);
  }
  if(mc % 2 == 1){
    sort(ALL(a));
    tot -= a.front()*2;
  }
  cout << tot << endl;
  return 0;
}

Measured memory_bytes: 3784
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}


int main()
{
	int n;
	cin >> n;
	vector<int> a(10^5);
	a.resize(n+1);
	fill(a.begin(), a.end(), 0);
	FOR(i, 1, n+1) {
		cin >> a[i];
	}
	int i = 1;
	int count = 1;
	while (count <= n) {
		if (a[i] == 2) {
			cout << count << endl;
			return 0;
		}
		else {
			count++;
			i = a[i];
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),x=sc.nextInt(),ans=0,min=1000;
		int[] m = new int[n];
		for(int i=0; i<n; i++) {
			int g = sc.nextInt();
			x -= g;
			if(min > g) min = g;
			ans++;
		}
		System.out.println(x/min+ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define MAX_N 60
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
pii students[MAX_N];
pii checkP[MAX_N];
ll getlog(ll a){
    ll k = 0;
    while (a){
        k++;
        a/=10;
    }
    return k;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,m;
    cin >> n;
    ll best = 1e9;
    for (ll i  = 1;i * i <= n;i++){
        if (n % i) continue;
        ll c = max(getlog(i),getlog(n / i));
        if (c < best) best = c;
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";

const receive = () => require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/);

const main = input => {
  const A = Number(input[0]);
  const B = Number(input[1]);
  const ans = A * B - (A + B - 1)
  console.log(ans);
};

main(receive());

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	static bool is_prime[1000000] = {};
	eratos(1000000, is_prime);
	for (int a, d, n; cin >> a >> d >> n && (a || d || n);) {
		int cnt = 0;
		for (int i = 0;; i++) {
			if (is_prime[a + i*d])cnt++;
			if (cnt == n) {
				cout << a + i*d << endl;
				break;
			}
		}
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, k, m, t, a[114514], b[114514], r;

int main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i] >> b[i];
	// まずkの最上ビットを使わないって条件をつけると最上ビット未満のビットが全部立ったもの以下の数字は全部買える
	// 2番目の最上ビットを使わないって条件ならそれ未満のビットが全部立ったもの以下の数字を全部買える
	// kそのもので一回調べる必要があって、後はこれの繰り返し(たかだか30回)で一番価値が高いものが答え
	rep(i,n) if ((a[i]|k) == k) t += b[i];
	r = t;
	repr(i,30) {
		if (k>>i & 1) {
			m = k ^ (1<<i);
			m |= (1<<i) - 1;
			t = 0;
			rep(j,n) if ((a[j]|m)==m) t += b[j];
			chmax(r, t);
		}
	}
	cout << r << ln;
}

Measured memory_bytes: 1792
def main():
  import sys
  from scipy.sparse.csgraph import floyd_warshall
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=floyd_warshall(floyd_warshall(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(map(str,[int(d[i])for i in zip(*[iter(t[m*3+1:])]*2)])))
main()

Measured memory_bytes: 36208
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=105;

int n,m,xE,yE,ans;
char maz[N][N];
int sum[N][N];
int f[2][N][N][N];

#define upd(a,b) a=max(a,b)
#define between(a,b,c) ((a)<=(b) && (b)<=(c))

int Calc(int u,int d,int l,int r){
	if(u>d || l>r) return 0;
	return sum[d][r]-sum[u-1][r]-sum[d][l-1]+sum[u-1][l-1];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",maz[i]+1);
		for(int j=1;j<=m;j++){
			if(maz[i][j]=='E') xE=i,yE=j;
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(maz[i][j]=='o');
		}
	}
	f[0][0][0][0]=0;
	for(int u=0;xE-u>=1;u++){
		int I=u&1,J=!I;
		for(int d=0;d+xE<=n;d++)
			for(int l=0;yE-l>=1;l++)
				for(int r=0;yE+r<=m;r++){
					int Ru=d,Rd=n+1-u,Rl=r,Rr=m+1-l;
					int Yu=xE-u,Yd=xE+d,Yl=yE-l,Yr=yE+r;
					//printf("%d %d %d %d - %d %d %d %d: \n",Ru,Rd,Rl,Rr,Yu,Yd,Yl,Yr);
					//Move Down
					if(Yd+1<=n){
						/*
						if(between(Ru+1,Yd+1,Rd-1))
							printf("  > down: %d + (%d %d %d %d)=%d\n",f[I][d][l][r],Yd+1,Yd+1,max(Rl+1,Yl),min(Rr-1,Yr),Calc(Yd+1,Yd+1,max(Rl+1,Yl),min(Rr-1,Yr)));
						else
							printf("  > down: %d + 0\n",f[I][d][l][r]);
						*/
						upd(f[I][d+1][l][r],f[I][d][l][r]+(between(Ru+1,Yd+1,Rd-1)? Calc(Yd+1,Yd+1,max(Rl+1,Yl),min(Rr-1,Yr)):0));
					}
					//Move Up
					if(Yu-1>=1){
						/*
						if(between(Ru+1,Yu-1,Rd-1))
							printf("  > up: %d + (%d %d %d %d)=%d\n",f[I][d][l][r],Yu-1,Yu-1,max(Rl+1,Yl),min(Rr-1,Yr),Calc(Yu-1,Yu-1,max(Rl+1,Yl),min(Rr-1,Yr)));
						else
							printf("  > up: %d + 0\n",f[I][d][l][r]);
						*/
						upd(f[J][d][l][r],f[I][d][l][r]+(between(Ru+1,Yu-1,Rd-1)? Calc(Yu-1,Yu-1,max(Rl+1,Yl),min(Rr-1,Yr)):0));
					}
					//Move Left
					if(Yl-1>=1){
						/*
						if(between(Rl+1,Yl-1,Rr-1))
							printf("  > left: %d + (%d %d %d %d)=%d\n",f[I][d][l][r],max(Ru+1,Yu),min(Rd-1,Yd),Yl-1,Yl-1,Calc(max(Ru+1,Yu),min(Rd-1,Yd),Yl-1,Yl-1));
						else
							printf("  > left: %d + 0\n",f[I][d][l][r]);
						*/
						upd(f[I][d][l+1][r],f[I][d][l][r]+(between(Rl+1,Yl-1,Rr-1)? Calc(max(Ru+1,Yu),min(Rd-1,Yd),Yl-1,Yl-1):0));
					}
					//Move Right
					if(Yr+1<=m){
						/*
						if(between(Rl+1,Yr+1,Rr-1))
							printf("  > right: %d + (%d %d %d %d)=%d\n",f[I][d][l][r],max(Ru+1,Yu),min(Rd-1,Yd),Yr+1,Yr+1,Calc(max(Ru+1,Yu),min(Rd-1,Yd),Yr+1,Yr+1));
						else
							printf("  > right: %d + 0\n",f[I][d][l][r]);
						*/
						upd(f[I][d][l][r+1],f[I][d][l][r]+(between(Rl+1,Yr+1,Rr-1)? Calc(max(Ru+1,Yu),min(Rd-1,Yd),Yr+1,Yr+1):0));
					}
					upd(ans,f[I][d][l][r]);
				}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9696
#!/usr/bin/env python3
n, k = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
f = sorted(map(int, input().split()))


def check(x):
    res = 0
    for i in range(n):
        res += (max(0, a[i] * f[i] - x) + f[i] - 1) // f[i]
    return res


ok = 10**12
ng = -1
while ok - ng > 1:
    m = (ok + ng) // 2
    res = check(m)
    if res <= k:
        ok = m
    else:
        ng = m

print(ok)


Measured memory_bytes: 121676
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 100
#define INF (1<<29)
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int main(){
  int n;
  int d[MAX][MAX];

  fill(d[0],d[MAX],INF);

  cin >> n;
  rep(i,n){
    int u,k;
    cin >> u >> k;
    rep(j,k){
      int v,c;
      cin >> v >> c;
      d[u][v] = c;
    }
  }

  d[0][0] = 0;
  rep(k,n){
    rep(i,n){
      rep(j,n){
	d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
      }
    }
  }

  rep(i,n){
    cout << i << " " << d[0][i] << endl;
  }

  return 0;
}

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

int main() {
	int n;
	cin>>n;
	vector<int> arr (n,0);
	for(int i=1;i<=n;i++)
	{
	    int count=0;
	    for(int x=1;x<=i/2;x++)
	    {
	        int sum1=x*x;
	        if(sum1>i)
	            break;
	        for(int y=1;y<=i/2;y++)
	        {
	            int sum2=sum1+y*y+x*y;
	            if(sum2>i)
	                break;
	            for(int z=1;z<=i/2;z++)
	            {
	                int sum3=sum2+z*z+z*x+z*y;
	                if(sum3==i)
	                {
	                    count++;
	                }
	                else if(sum3>i)
	                    break;
	            }
	        }
	    }
	    arr[i-1]=count;
	}
	for(int i=0;i<n;i++)
	    cout<<arr[i]<<endl;
	   return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 gcd(i64 a,i64 b){
  if(b == 0) return a;
  return gcd(b,a % b);
}

int main(){
  int N;
  cin >> N;
  i64 X;
  cin >> X;
  vector<int> x(N);
  rep(i,0,N - 1) cin >> x[i];
  x.push_back(X);
  i64 ans = x[1] - x[0];
  rep(i,1,N){
    ans = gcd(ans , abs(x[i] - x[i - 1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstring>
#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 <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

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

const int N = (int) 1e6 + 7;
const int MOD = (int) 1e9 + 7;

int n;
vector<int> g[N];

int sum[N];
int par[N];

void dfs(int v, int parent = 0) {
  sum[v] = 1;
  par[v] = parent;
  for (auto to : g[v]) {
    if (to == parent) continue;
    dfs(to, v);
    sum[v] += sum[to];
  }
}

int main() {
  #ifdef LOCAL
  freopen("in.txt", "r", stdin);
  #endif

  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].pb(v);
    g[v].pb(u);
  }
  dfs(1);
  vector<int> path;
  for (int i = n; i; i = par[i])
    path.pb(i);
  reverse(path.begin(), path.end());
  int l = 0, r = (int) path.size() - 1;
  int a = n - sum[path[1]] - 1, b = sum[n] - 1;
  for (int turn = 0; true; turn ^= 1) {
    //cout << a << ' ' << b << " (" << l << ", " << r << ")\n";
    if (l + 1 < r) {
      if (turn == 0) {
        l++;
        a += sum[path[l]] - sum[path[l + 1]] - 1;
      } else {
        r--;
        b += sum[path[r]] - sum[path[r + 1]] - 1;
      }
    } else {
      if (turn == 0) {
        if (a) a--;
        else {
          cout << "Snuke";
          break;
        }
      } else {
        if (b) b--;
        else {
          cout << "Fennec";
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 39804
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n;
        n = scan.nextInt();
        String[] s1 = new String[n];
        String[] s2 = new String[n]; 
        int[] p = new int[n];
        for(int i = 0;i < n;i++){
            s1[i] = scan.next();
            s2[i] = s1[i];
            p[i] = scan.nextInt();
        }
        Arrays.sort(s1);
        int[] point = new int[n];
        for(int i = 0;i < n;i++){
            point[i] = 0;
        }
        for(int i = 0;i < n;i++){
            int pointp = 0;
            int name = 0;
            for(int j = 0;j < n;j++){
                if(s1[i].equals(s2[j])){
                    if(pointp <= p[j] && point[j] == 0){
                        pointp = p[j];
                        name = j;
                    }
                }
            }
            point[name] = 1;
            System.out.println(name+1);
        }
    }   

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

int main(){/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	map<string, ll> m;
    ll n, ma = 0;
    string s;
    cin>>n;
    while(n--){
        cin>>s;
        ++m[s];
        ma = max(ma, m[s]);
    }
    map<string, ll>::iterator itr;
    for(itr = m.begin(); itr != m.end(); itr++){
        if(itr->second == ma){
            cout<<itr->first<<"\n";
        }
        
    }
}

Measured memory_bytes: 23808
import itertools
n=int(input())
xy=[[int(i) for i in input().split()] for _ in range(n)]
l=list(itertools.permutations(range(n)))
sum = 0
for lis in l:
    for i in range(n-1):
        sum += ((xy[lis[i]][0] - xy[lis[i+1]][0])**2 + (xy[lis[i]][1] - xy[lis[i+1]][1])**2)**(1/2)
print(sum/len(l))

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

int main() {
  int N, M, D;
  cin >> N >> M >> D;

  vector<vector<char> > field(N + 1);
  for (int i = 0; i < N; i++) {
    field[i].resize(M + 1);
    for (int j = 0; j < M; j++) {
      cin >> field[i][j];
    }
    field[i][M] = '#';
  }
  field[N].resize(M + 1, '#');

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int len = 0;
    for (int j = 0; j <= M; j++) {
      if (field[i][j] == '#') {
	cnt += max(len - D + 1, 0);
	len = 0;
	continue;
      }
      len++;
    }
  }

  for (int j = 0; j < M; j++) {
    int len = 0;
    for (int i = 0; i <= N; i++) {
      if (field[i][j] == '#') {
	cnt += max(len - D + 1, 0);
	len = 0;
	continue;
      }
      len++;
    }
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3128
<?php
    $n = intval(fgets(STDIN));
    $input = fgets(STDIN);
    list($t, $a) = explode(' ', $input);
    $input = fgets(STDIN);
    $hs = explode(' ', $input);

    $min=PHP_INT_MAX;
    $place = null;
    foreach($hs as $i => $h) {
        $temp = $t - $h * 0.006;
        $diff = abs($temp - $a);
        if($diff < $min) {
            $min = $diff;
            $place = $i + 1;
        }
    }

    echo $place;

Measured memory_bytes: 4604
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[1000000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n >> m;
	vector<P> ab(m);
	vector<ll> bri(n);
	ll res = 0;
	rep(i, m) {
		cin >> ab[i].second >> ab[i].first;
	}
	sort(ab.begin(), ab.end());
	int br = -1;
	rep(i, m) {
		if (br > ab[i].second)continue;
		else {
			res++;
			br = ab[i].first;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 2688
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int N;
    private int A;
    private int B;
    private long[] v;
 
    private long count;
 
    private void solve(Scanner sc) {
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        v = new long[N];
        for (int i = 0; i < N; ++i) {
            v[i] = sc.nextLong();
        }
        Arrays.sort(v);
        for (int i = 0; i < N / 2; ++i) {
            long t = v[i];
            v[i] = v[N - i - 1];
            v[N - i - 1] = t;
        }
 
        double avg = avg(v, 0, A - 1);
        long count;
        if (v[0] != v[A - 1]) {
            int x = 0;
            for (int i = 0; i < N; ++i) {
                if (v[A - 1] == v[i]) {
                    ++x;
                }
            }
            int y = 0;
            for (int i = 0; i < A; ++i) {
                if (v[A - 1] == v[i]) {
                    ++y;
                }
            }
            count = C(x, y).longValue();
        } else {
            int x = 0;
            for (int i = 0; i < N; ++i) {
                if (v[0] == v[i]) {
                    ++x;
                }
            }
            count = 0;
            for (int i = A; i <= B; ++i) {
                count += C(x, i).longValue();
            }
        }
 
        _out.printf("%.6f%n", avg);
        _out.println(count);
    }
    private double avg(long[] ary, int from, int to) {
        long sum = 0;
        for (int i = from; i <= to; ++i) {
            sum += ary[i];
        }
        return 1d * sum / (to - from + 1);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double h = x / (a * a);
    double tant = 0;
    if (h < b / 2)
    {
        tant = (a * b * b) / (2 * x);
    }
    else
    {
        tant = 2 * (b - h) / a;
    }
    double ans = atan(tant);
    ans *= 180.0 / 3.14159265;
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 512