akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int countOne(int bit) {
    if (bit == 0) {
        return 0;
    }
    int count = 0;

    while (bit != 0) {
        if (bit % 2 == 1) {
            count++;
        }
        bit = bit / 2;
    }
    return count;
}

int main()
{
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> l(N, 0);
    for (int i = 0;i < N;i++) {
        cin >> l[i];
    }
    //N本それぞれ3通りのため3進数でどうにかするのかと思ったが、2bit全探索を3回重ねて
    //探索する模様。
    int min = 1000000000;
    for (int bit1 = 1;bit1 < (1 << N);bit1++) {
        for (int bit2 = 1;bit2 < (1 << N);bit2++) {
            for (int bit3 = 1;bit3 < (1 << N);bit3++) {
                //重なっていたらその時点で抜ける。全部網羅している必要はない。
                if ((bit1 & bit2) > 0 || (bit2 & bit3) > 0 || (bit3 & bit1) > 0) {
                    continue;
                }
                else {
                    int countMP = 0;
                    //Aに使うMPは、bit1で指定されている竹の長さの合計とAの差の絶対値プラス,bit1で
                    //指定されている(竹の個数-1)*10である。
                    int tmp = 0;
                    for (int i = 0;i < N;i++) {
                        if (bit1 & (1 << i)) {
                            tmp += l[i];
                        }
                    }
                    countMP += (countOne(bit1)-1)*10+abs(tmp-A);
                    tmp = 0;
                    for (int i = 0;i < N;i++) {
                        if (bit2 & (1 << i)) {
                            tmp += l[i];
                        }
                    }
                    countMP += (countOne(bit2) - 1) * 10 + abs(tmp - B);
                    tmp = 0;
                    for (int i = 0;i < N;i++) {
                        if (bit3 & (1 << i)) {
                            tmp += l[i];
                        }
                    }
                    countMP += (countOne(bit3) - 1) * 10 + abs(tmp - C);
                    //cout << min << endl;
                    min = fmin(min, countMP);
                }
            }
        }
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N, M; cin >> N >> M;
    vector<int> b(N), p(M);
    rep(i,0,N) cin >> b[i];
    rep(i,0,M) cin >> p[i];

    int ans = INF;
    rep(k,0,2) {
        int col = k, cnt = 0, idx = 0;
        vector<int> v;
        rep(i,0,N) {
            v.push_back(col);
            if(++cnt == p[idx]) cnt = 0, idx++, col ^= 1;
        }

        vector<int> c = b;
        int cost = 0;
        rep(i,0,N) {
            if(c[i] != v[i]) {
                rep(j,i+1,N) {
                    if(c[j] == v[i]) {
                        cost += j - i;
                        swap(c[i], c[j]);
                        break;
                    }
                }
                if(c[i] != v[i]) cost = INF;
            }
        }
        chmin(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3152
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End
const int nax=2e5+10;
vector<int> adj[nax];
multiset<int> cnt[nax],naya;
int mini[nax],n,ar[nax],ans[nax];
void dfs(int ver,int par){
	int pos = lower_bound(mini,mini+n+1,ar[ver])-mini;
	naya.insert(-pos);
	ans[ver] = -(*naya.begin());
	cnt[pos].insert(ar[ver]);
	mini[pos] = min(mini[pos],ar[ver]);
	
	for(int i:adj[ver]){
		if(i!=par){
			dfs(i,ver);
		}
	}
	
	cnt[pos].erase(cnt[pos].lower_bound(ar[ver]));
	naya.erase(naya.lower_bound(-pos));
	if(cnt[pos].empty()) mini[pos] = INT_MAX;
	else mini[pos] = (*cnt[pos].begin());
	
}


void solve(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>ar[i];
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	for(int i=1;i<=n+1;i++)ans[i]=0,mini[i]=INT_MAX;
	dfs(1,0);
	
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<"\n";
	}
	
	//cout<<INT_MAX<<endl;
	
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 63640
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int k; cin >> k;
  string s; cin >> s;
  if (k >= s.size()) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;


int main() {
  int A, B;

  cin >> A >> B;

  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if(A > B) {
      ans += A;
      A--;
    } else {
      ans += B;
      B--;
    }
  }


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

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

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

    int tmp;
    if (N % 2 == 0)
    {
        tmp = N / 2;
    }
    else
    {
        tmp = N / 2 + 1;
    }

    if (tmp >= K)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int A, B;

	scanf("%d %d", &A, &B);

	if(A <= 12 && A >= 6){
		B = B / 2;
	}else if(A <= 5){
		B = 0;
	}

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

	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<vector<int> > v(n);
		for(int i=0; i< n; i++){
			for(int j=0; j < 5; j++){
				int m; cin >> m; v[i].push_back(m);
			}
		}
		int ret = 0;

		while(true){
			bool p = false;
			for(int i=0; i < n; i++){
				for(int j=0; j< 3; j++){
					if(v[i][j] == -1) continue;
					int count = 0;
					while(v[i][j] == v[i][j+count] && j+count < 5) count++;
					if(3 <= count){
						p = true; ret += v[i][j]*count;
						rep(k, count) v[i][j+k] = -1;
					}
				}
			}
			if(!p) break;
			else {
				for(int i=n-1; 1 <= i; i--){
					for(int j=0; j< 5; j++){
						if(v[i][j] == -1){
							for(int k =0; 0 <= i-k; k++) if(v[i-k][j] != -1){
								v[i][j] = v[i-k][j]; v[i-k][j] = -1; break;
							}
						}
					}
				}
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int b = tx - sx;
	int a = ty - sy;
	REP(i,a){
		cout << "U";
	}
	REP(i,b){
		cout << "R";
	}
	REP(i,a){
		cout << "D";
	}
	REP(i,b){
		cout << "L";
	}
	cout << "L";
	REP(i,a+1){
		cout << "U";
	}
	REP(i,b+1){
		cout << "R";
	}
	cout << "DR";
	REP(i,a+1){
		cout << "D";
	}
	REP(i,b+1){
		cout << "L";
	}
	cout << "U";
    return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto C = new long[](N - 1);
    auto S = new long[](N - 1);
    auto F = new long[](N - 1);
    foreach (i; 0 .. N - 1)
        scan(C[i], S[i], F[i]);
    // writeln(C);
    foreach (i; 0 .. N - 1)
    {
        long t = S[i];
        t += C[i];
        foreach (j; i + 1 .. N - 1)
        {
            // write(t, " ");
            if (t < S[j])
                t = S[j];
            if (t % F[j] != 0)
                t += F[j] - (t % F[j]);
            t += C[j];
        }
        writeln(t);
    }
    writeln(0);
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
#define N 100010
#define M 200010
vector< vector<pii> > adj(4*M, vector<pii>());
int cnt = 0;
int n, m;
map<pii, int> mp;
vector< set<int> > station(4*M);
vi d(4*M, inf);

int get_id(int p, int c) {
	pii pr = make_pair(p, c);
	if (mp[pr]) {
		//cout << mp[pr] << endl;
		return mp[pr];
	}
	else {
		mp[pr] = ++cnt;
		//cout << mp[pr] << endl;
		return mp[pr];
	}
}

void dijkstra(int s) {
	priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > pq;
	int i;
	vi color(4 * M, WHITE);

	d[s] = 0;
	pq.push(make_pair(0, s));
	color[s] = GRAY;

	while (!pq.empty()) {
		pair<int, int> f = pq.top();
		pq.pop();
		int u = f.second;
		color[u] = BLACK;
		if (d[u]<f.first) {
			continue;
		}
		for (i = 0; i < adj[u].size(); i++) {
			int v = adj[u][i].second;
			if (color[v] == BLACK) {
				continue;
			}
			if (d[v]>d[u] + adj[u][i].first) {
				d[v] = d[u] + adj[u][i].first;
				pq.push(make_pair(d[v], v));
				color[v] = GRAY;
			}
		}
	}
}


int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		int p, q, c;
		scanf("%d%d%d", &p, &q, &c);
		p--; q--;
		int u = get_id(p, c), v = get_id(q, c);
		adj[u].push_back(make_pair(0, v));
		adj[v].push_back(make_pair(0, u));
		station[p].insert(c);
		station[q].insert(c);
	}
	for (i = 0; i < n; i++) {
		for (auto itr = station[i].begin(); itr != station[i].end(); itr++) {
			int u = get_id(i, *itr);
			int v = get_id(i, -1);
			adj[u].push_back(make_pair(0, v));
			adj[v].push_back(make_pair(1, u));
		}
	}
	int s = get_id(0, -1), g = get_id(n - 1, -1);
	dijkstra(s);
	if (d[g] == inf) {
		printf("-1\n");
		return 0;
	}
	else {
		printf("%d\n", d[g]);
		return 0;
	}
}

Measured memory_bytes: 131964
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
int x,y,z,A[100100],B[100100],C[100100],tot,vis[100100];
LL sum=0;
priority_queue<pii > pq1,pq2,pq3;
int main()
{
    scanf("%d%d%d",&x,&y,&z);
    tot=x+y+z;
    for(int i=1;i<=tot;i++)
    {
        scanf("%d%d%d",&A[i],&B[i],&C[i]);
        sum+=A[i];
    }
    for(int i=1;i<=tot;i++)
    {
        pq1.push(make_pair(B[i]-A[i],i));
    }
    for(int i=1;i<=y;i++)
    {
        pii now=pq1.top();pq1.pop();
        vis[now.second]=1;
        sum+=now.first;
    }
    while(!pq1.empty())pq1.pop();
    for(int i=1;i<=tot;i++)
    {
        if(!vis[i])
        {
            pq2.push(make_pair(C[i]-A[i],i));
            pq3.push(make_pair(B[i]-A[i],i));
        }else
        {
            pq1.push(make_pair(C[i]-B[i],i));
        }
    }
    for(int i=1;i<=z;i++)
    {
        while(vis[pq2.top().second])pq2.pop();
        while(vis[pq3.top().second])pq3.pop();
        pii now1=pq1.top(),now2=pq2.top(),now3=pq3.top();
        if(now2.first>=now1.first+now3.first)
        {
            vis[now2.second]=1;
            sum+=now2.first;
            pq2.pop();
        }else
        {
            vis[now1.second]=vis[now3.second]=1;
            sum+=now1.first+now3.first;
            pq1.pop();
            pq1.push(make_pair(C[now3.second]-B[now3.second],now3.second));
            pq3.pop();
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 4980
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

static const string stations = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

int main(){

  int n;
  while(~scanf("%d",&n)){
    if(n==0) break;

    int back_dist[101];
    for(int i=0;i<n;i++){
      scanf("%d",back_dist+i);
    }
    string str;
    cin >> str;

    int back_idx = 0;
    for(int i=0;i<str.size();i++){
      int pos = lower_bound(stations.begin(),stations.end(),str[i]) - stations.begin();
      str[i] = stations[(pos - back_dist[back_idx] + stations.size()) % stations.size()];
      back_idx++;
      back_idx %= n;
    }

    cout << str << endl;
  }
}

Measured memory_bytes: 1244
#include<stdio.h>

int main(){
  int counter=0;
  char s[101];
  scanf("%s",s);
  while (s[counter]!='\0'){ counter++;}

  int min=100;
  for (int i = 0; i < counter; i++)
  {
    int j=0,max=0;
    while (j<counter)
    {
      int between=0;
      while (s[i]!=s[j]&&j<counter){ between++; j++;}
      if (max<between){ max=between;}
      j++;
    }
    if (min>max){ min=max; }
  }
  
  printf("%d",min);
  
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int n;
vector<int> G[100010], ans;
map<P, int> mp;

void solve(int now, int pre, int used)
{
    int col = 1;
    rep(i, G[now].size())
    {
        int nxt = G[now][i];
        if (nxt == pre)
            continue;
        if (col == used)
            col++;
        int num = mp[P(now, nxt)];
        ans[num] = col;
        solve(nxt, now, col);
        col++;
    }
}

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

    cin >> n;
    ans.resize(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        mp[P(a, b)] = mp[P(b, a)] = i;
    }
    solve(0, -1, -1);
    int k = 0;
    rep(i, n - 1) k = max(k, ans[i]);
    cout << k << endl;
    rep(i, n - 1) cout << ans[i] << endl;
}

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

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; }
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    from fractions import gcd
    def lcm(c,d):
        return c//gcd(c,d)*d
    mod=10**9+7
    n=int(input())
    a=[int(i) for i in input().split()]
    l=a[0]
    for i in range(1,n):
        l=lcm(l,a[i])
    ans=0
    for i in range(n):
        ans+=l//a[i]
    print(ans%mod)
main()


Measured memory_bytes: 6100
#include<cstdio>
#include<algorithm>
#define MAXN 300000
using namespace std;

int n,loc;
struct E{
	int next,to;
}edge[MAXN<<1];
int head[MAXN],edge_num;
int vis[MAXN],path[MAXN];
int size[MAXN];

void addedge(int x,int y){
	edge[++edge_num].next=head[x];
	edge[edge_num].to=y;
	head[x]=edge_num;
}

void INIT(){
	scanf("%d",&n);
	int i;
	for(i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,b);
		addedge(b,a);
	}
}

void DFS(int x,int depth){
	path[depth]=x;vis[x]=1;
	size[x]=1;
	if(x==n){
		loc=path[depth/2+1];
	}
	int i;
	for(i=head[x];i;i=edge[i].next){
		if(vis[edge[i].to])
			continue;
		DFS(edge[i].to,depth+1);
		size[x]+=size[edge[i].to];
	}
}

void solve(){
	DFS(1,0);
	int sz_f=size[1]-size[loc],sz_s=size[loc];
	if(sz_f>sz_s)
		printf("Fennec\n");
	else
		printf("Snuke\n");
}

void DEBUG(){
	int i;
	printf("Size：");
	for(i=1;i<=n;i++)
		printf("%d ",size[i]);
}

int main(){
	INIT();
	solve();
	//DEBUG();
	return 0;
}


Measured memory_bytes: 10240
import math
def intersectionCC0(x1, y1, r1, r2):
    r = x1**2 + y1**2
    t = (r + r1**2 - r2**2) / (2*r)
    dd = r1**2/r - t**2
    if - (10**-8) < dd < 0: dd = 0
    if dd < 0: return []
    x, y = t * x1, t * y1
    if dd == 0: return [(x, y)]
    sq = math.sqrt(dd)
    dx, dy = y1 * sq, -x1 * sq
    return [(x+dx, y+dy), (x-dx, y-dy)]

def intersectionCC(x1, y1, x2, y2, r1, r2):
    return [(x1+x, y1+y) for x, y in intersectionCC0(x2-x1, y2-y1, r1, r2)]

def chk(t):
    L = [a for a in L0]
    for i, (x1, y1, c1) in enumerate(X):
        for x2, y2, c2 in X[:i]:
            L += intersectionCC(x1, y1, x2, y2, t/c1, t/c2)
    for x0, y0 in L:
        cnt = 0
        for x, y, c in X:
            if math.sqrt((x-x0) ** 2 + (y-y0) ** 2) * c <= t + 10**-8:
                cnt += 1
        if cnt >= K: return 1
    return 0

N, K = map(int, input().split())
X = []
L0 = []
for _ in range(N):
    x, y, c = map(int, input().split())
    X.append((x, y, c))
    L0.append((x, y))

l, r = 0, 150000
while (r-l) * (1<<20) > max(1, l):
    m = (l+r) / 2
    if chk(m):
        r = m
    else:
        l = m
    
print((l+r)/2)

Measured memory_bytes: 51036
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC128B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var rest = new SortedList<string, int>();

            for (int i = 1; i <= N; i++)
            {
                var temp = Console.ReadLine().Split(' ').ToArray();
                var city = temp[0];
                var score = 100 - int.Parse(temp[1]);

                var dict = city.PadRight(10, '_') + String.Format("{0:000}", score);
                //Console.WriteLine(dict);
                rest.Add(dict, i);
            }

            foreach (string r in rest.Keys.OrderBy(x => x))
            {
                Console.WriteLine(rest[r]);
            }
        }
    }
}


Measured memory_bytes: 11740
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back

vector<vector<int> > G(100010);
int n,m;
vector<int> dp(100010);

int rec(int v){
    if(dp[v] != -1) return dp[v];
    int res = 0;
    for(auto &nv : G[v]){
        res = max(res,rec(nv)+1);
    }
    return  dp[v]=res;
}

int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int x,y; cin >> x >> y;
        x--; y--;
        G[x].pb(y);
    }
    for(int i=0;i<n;i++) dp[i] = -1;

    int res=-1;
    for(int v=0;v<n;v++){
        res = max(res,rec(v));
    }
    cout << res << endl;
}

Measured memory_bytes: 11072
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N); //int a[N]と同じだけどこっちのがいいらしい
  for(int i = 0;i<N;i++){
    cin >> a.at(i); //A[i]と同じだけど以下略
  }
  sort(a.begin(), a.end()); //配列変数vecをソートする（要素を小さい順に並び替える）
  reverse(a.begin(), a.end());//配列変数vecの要素の並びを逆にする
  int A = 0,B = 0;
  for(int i = 0; i<N;i++){
      if(i%2==0){
          A += a.at(i);
      }
      else{
          B += a.at(i);
      }
  }
  cout << A-B <<endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if a**2 * b / 2 < x:
    print(90-math.degrees(math.atan2(a**3, 2*(a**2 * b - x))))
else:
    print(90-math.degrees(math.atan2(2*x, a * b**2)))

Measured memory_bytes: 3060
import java.util.*;

class Main{

    int n, m, sz;
    char[] kakko;
    int[] a, bkt, add;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        kakko = sc.next().toCharArray();

        sz = Math.max(1, (int)Math.sqrt(n) - 1);
        a = new int[n];
        bkt = new int[n/sz+10];
        add = new int[n/sz+10];
        TreeSet<Integer> set = new TreeSet<Integer>();

        for(int i=0; i<n; i++){
            if(i==0) a[i] = 1;
            else{
                if(kakko[i]=='(') a[i] = a[i-1] + 1;
                else{
                    a[i] = a[i-1] - 1;
                    set.add(i);
                }
            }
            bkt[i/sz] = Math.min(a[i], bkt[i/sz]);
        }

        for(int i=0; i<m; i++){
            int q = sc.nextInt()-1;
            int idx = 0;
            if(kakko[q]=='('){
                kakko[q] = ')';
                set.add(q);
                add(q, n, -2);
                //idx = set.higher(new Integer(-1));
                idx = set.pollFirst();
                kakko[idx] = '(';
                set.remove(idx);
                add(idx, n, 2);
            }else{
                kakko[q] = '(';
                set.remove(q);
                add(q, n, 2);
                idx = search(q);
                kakko[idx] = ')';
                add(idx, n, -2);
                set.add(idx);
            }
            //System.out.println(Arrays.toString(kakko));
            System.out.println(idx+1);
        }
    }

    void add(int start, int last, int num){
        int from = start - start%sz;
        int to = from + sz;
        for(int i=start/sz; i<=last/sz; i++){
            if(start<=from && to<=last){
                add[i] += num;
            }else{
                for(int j=from; j<to; j++){
                    if(start<=j && j<last){
                        a[j] += num;
                    }
                }
                int min = Integer.MAX_VALUE;
                for(int j=from; j<to && j<a.length; j++){
                    min = Math.min(min, a[j]);
                }
                bkt[i] = min;
            }
            from = to;
            to += sz;
        }
    }

    int search(int f){        
        int from = f - f%sz;
        int to = from + sz;
            
        for(int i=f/sz; i>=0; i--){
            if(bkt[i]+add[i]<=1){
                for(int j=Math.min(f-1, to-1); j>=from; j--){
                    if(a[j]+add[i]==1) return j+1;
                }
            }
            to = from;
            from -= sz;
        }
        return 0;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 113292
#想定解法
N, A = map(int, input().split())
X = sorted(list(map(int, input().split())))
xm = max(X)
xm = max(xm, A)
for i in range(N):
  X[i] -= A 
#print(X, xm)
dp = [[0] * (2 * N * xm + 1) for i in range(N + 1)]
dp[0][N * xm] = 1

for i in range(1, N + 1):
  for j in range(2 * N * xm + 1):
    if 0 <= j - X[i - 1] <= 2 * N * xm:
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]]
    else:
      dp[i][j] = dp[i - 1][j]

print(dp[N][N * xm] - 1)


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



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

	int A[110];
	for (int i = 0; i < N; i++) {
		cin >> A[i];

		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0) {	
			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N, M; cin >> N >> M;
  vector<int> data(M);
  for(int i=0; i<M; i++){
    cin >> data.at(i);
  }
  
  int day = 0;
  for(int i=0; i<M; i++){
    day += data.at(i);
  }
  
  if(N - day >= 0) cout << N - day << endl;
  else cout << "-1" << endl;
  
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll n,k;
  cin>>n>>k;
  ll x[n];
  rep(i,n) cin>>x[i];
  ll ans = MOD;
  for(int i = 0; i <= n - k; i++) {
    ll l = x[i];
    ll r = x[i + k- 1];
    ll tmin;
    if(l * r >= 0) {
      tmin = max(abs(l), abs(r));
    } else {
      tmin = max(abs(l), abs(r)) + min(abs(l), abs(r)) * 2;
    }
    ans = min(tmin, ans);
  }
  cout << ans << endl;
  


  return 0;
}


Measured memory_bytes: 1024
#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>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a;cin >>a;
    cout << EDSum(a) << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
const int H=1e9 +7;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
        int h,w;
        cin>>h>>w;
        vector<vector<char>> v(h,vector<char>(w));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>v[i][j];}}
        vector<vector<int>> dp(h,vector<int>(w));
        if(v[0][0]=='.')dp[0][0]=1;
        else {
            cout<<0<<endl;
            return 0;
        }
        for(int i=1;i<h;i++){
            if(v[i][0]=='.' && dp[i-1][0]==1)dp[i][0]=1;
        }
        for(int i=1;i<w;i++){
            if(v[0][i]=='.' && dp[0][i-1]==1)dp[0][i]=1;
        }
        for(int i=1;i<h;i++){
            for(int j=1;j<w;j++){
                if(v[i][j]=='#')dp[i][j]=0;
                else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%H;
            }
        }
        cout<<dp[h-1][w-1]<<endl;
        //for(auto i:dp){
            //for (int j:i)cout<<j<<" ";
            //cout<<endl;
        //}
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {     
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> cnt;
	int sum = 0;
	for (int i = 0; i < n; ++i) cin >> a[i], cnt[a[i]]++, sum += a[i];
	int Q;
	cin >> Q;
	while (Q--) {
	 	int b, c;
		cin >> b >> c;
		sum -= cnt[b] * b;
		sum -= cnt[c] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		sum += cnt[c] * c;
		cout << sum << '\n';		
	}      
}                                                    


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,1));
	queue<pair<int,int>> q;
	unordered_set<int> flag;
	REP(i,H){
		REP(j,W){
			char c = in<char>();
			if(c=='#'){
				M[i][j] = 0;
				q.emplace(j+i*W,0);
			}
		}
	}

	int maxD=0;
	while(!q.empty()){
		auto p = q.front();
		maxD = max(maxD,p.second);
		q.pop();
		int u = p.first%W,v = p.first/W;
		if(u>0 && M[v][u-1]){
			int w = u-1+v*W;
			auto res = flag.emplace(w);
			if(res.second){
				q.emplace(w,p.second+1);
			}
		}
		if(u<W-1 && M[v][u+1]){
			int w = u+1+v*W;
			auto res = flag.emplace(w);
			if(res.second){
				q.emplace(w,p.second+1);
			}
		}
		if(v>0 && M[v-1][u]){
			int w = u+(v-1)*W;
			auto res = flag.emplace(w);
			if(res.second){
				q.emplace(w,p.second+1);
			}
		}
		if(v<H-1 && M[v+1][u]){
			int w = u+(v+1)*W;
			auto res = flag.emplace(w);
			if(res.second){
				q.emplace(w,p.second+1);
			}
		}
	}

	cout << maxD << endl;
	return 0;
}


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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 100 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}
int n, m, x;
map<int, int> mp;
ll mem[N];
ll dp(int i) {
	if (i == n)
		return 1;
	ll &ret = mem[i];
	if (ret != -1)
		return ret;
	ll a = 0, b = 0;
	if (!mp[i + 1]) {
		a = dp(i + 1);
	}
	if (!mp[i + 2])
		b = dp(i + 2);
	ret = (a + b) % MOD;
	return ret;

}

int main() {
//	READ();
	OUTPUT();
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> x;
		mp[x] = 1;
	}
	clr(mem, -1);
	cout << (dp(0) % MOD);

	return 0;

}


Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 35620
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[10];
int main()
{
	for (int i = 0; i < 4; i++) {
		int N;
		cin >> N;
		cnt[N]++;
	}
	if (cnt[1] == 1 && cnt[4] == 1 && cnt[7] == 1 && cnt[9] == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

int main(){
  long long X,K,D;
  cin >> X >> K >> D;
  bool a=false;
  if(X>0){
    long long A=X/D;
    if(K<A){
      X-=K*D;
      cout << abs(X) << endl;
      a=true;
    }
    X-=A*D;
    K-=A;
    if(abs(X-D)<abs(X) && K>0){
      X-=D;
      K--;
    }
  }
  else if(X<0){
    long long A=abs(X)/D;
    if(K<A){
      X+=K*D;
      cout << abs(X) << endl;
      a=true;
    }
    X+=A*D;
    K-=A;
    if(abs(X+D)<abs(X) && K>0){
      X+=D;
      K--;
    }
  }
  if(!a){
    if(K%2==0){
      cout << abs(X) << endl;
    }
    else if(abs(X-D)<abs(X+D)){
      cout << abs(X-D) << endl;
    }
    else{
      cout << abs(X+D) << endl;
    }
  }
}
  
  

Measured memory_bytes: 3620
#include <stdio.h>
long long a [100010];
int main ()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%lld",&a[i]);
    int zero =0;
    for(int i=0; i<n; i++)if(a[i]==0) zero ++;
    if(zero >0)
    {

        printf("0\n");
        return 0;
    }
    long long prod =1;
    for(int i=0; i<n; i++)
    {
        if(a[i ] <=1000000000000000000/ prod )
        {

            prod *=a[i];
        }
        else
        {
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",prod );
}

Measured memory_bytes: 2488
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var sp = mutableListOf<Triple<String,Int,Int>>()

    for (i in 1 .. n){
        var tmp = readLine()!!.split(" ")
        sp.add(Triple(tmp[0], tmp[1].toInt(), i))
    }


    for (i in sp.sortedBy { -it.second }.sortedBy { it.first }) println(i.third)
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> s;
  for(int i=0;i<n;i++) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 256
// ABC64-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

    int n;
    cin>>n;
    deque<char> info;
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='(') a++;
        else{
            if(0<a) a--;
        }
        info.push_back(s[i]);
    }
    for(int i=n-1;0<=i;i--){
        if(s[i]==')') b++;
        else{
            if(0<b) b--;
        }
    }
    for(int i=0;i<a;i++){
        info.push_back(')');
    }
    for(int i=0;i<b;i++){
        info.push_front('(');
    }
    for(int i=0;i<info.size();i++){
        cout<<info[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    cout << s << endl;
    return 0;
}

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


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

typedef const vector<int>& vec;

double calc_manhattan_dist(int n, vec x, vec y);
double calc_euclid_dist(int n, vec x, vec y);
double calc_p3_dist(int n, vec x, vec y);
double calc_chebyshev_dist(int n, vec x, vec y);

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

    vector<int> x(dimens), y(dimens);
    for (auto i = 0; i < dimens; i++) {
        cin >> x.at(i);
    }
    for (auto i = 0; i < dimens; i++) {
        cin >> y.at(i);
    }

    double manhattan_dist = calc_manhattan_dist(dimens, x, y);
    double euclid_dist = calc_euclid_dist(dimens, x, y);
    double p3_dist = calc_p3_dist(dimens, x, y);
    double chebyshev_dist = calc_chebyshev_dist(dimens, x, y);

    cout << std::fixed
         << manhattan_dist << endl
         << euclid_dist <<  endl
         << p3_dist <<  endl
         << chebyshev_dist << endl;

    return 0;
}

double calc_manhattan_dist(int n, vec x, vec y)
{
    double dist = 0;
    for (auto i = 0; i < n; i++) {
        dist += abs(x.at(i) - y.at(i));
    }

    return dist;
}

double calc_euclid_dist(int n, vec x, vec y)
{
    int i;

    double dist_sq = 0;
    for (i = 0; i < n; i++) {
        dist_sq += pow(x.at(i) - y.at(i), 2);
    }
    double dist = sqrt(dist_sq);

    return dist;
}

double calc_p3_dist(int n, vec x, vec y)
{
    int i;

    double dist_cb = 0;
    for (i = 0; i < n; i++) {
        dist_cb += pow(abs(x.at(i) - y.at(i)), 3);
    }
    double dist = cbrt(dist_cb);

    return dist;
}

double calc_chebyshev_dist(int n, vec x, vec y)
{
    int i;

    double max = abs(x.at(0) - y.at(0));
    for (i = 1; i < n; i++) {
        int dist_i = abs(x.at(i) - y.at(i));
        if (dist_i > max) {
            max = dist_i;
        }
    }

    return max;
}

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

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool less(const P& left,const P& right){
        if(left.ans != right.ans) return left.ans > right.ans;
        else if(left.sum != right.sum) return left.sum < right.sum;
        else return left.team < right.team;
    }
};

int main(){
    int t,p,r,tid,pid,tim;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> tim >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+tim;
                        data[i].ans += 1;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].pro[pid] += 1;
                        break;
                    }
                }
            }
        }
        sort(data.begin(),data.end(),P::less);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}

Measured memory_bytes: 1284
a,b,c=map(int,input().split())
k=int(input())
while k>0:
    if a<b:
        break
    b*=2
    k-=1
while k>0:
    if b<c:
        break
    c*=2
    k-=1
if a<b<c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9052
n=int(input())
res=[]
city=[]
for i in range(n):
    s,p=map(str,input().split())
    p=int(p)
    res.append([s,p,i+1])
R=sorted(res,key=lambda x : x[1],reverse=True)
Res=sorted(R,key=lambda x : x[0])

for j in Res:
    print(j[2])

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int main(){
	int m,n;//町,道
	int d[10][10];
	while(cin>>n,n){
		fill_n((int*)d,10*10,INF);
		m=0;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a>>b>>c;
			m=max(m,max(a,b)+1);
			d[a][b]=d[b][a]=c;
		}
		for(int i=0;i<m;i++){
			d[i][i]=0;
		}
		for(int k=0;k<m;k++)
			for(int i=0;i<m;i++)
				for(int j=0;j<m;j++)
					d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int a=0,b=INF;
		for(int i=0;i<m;i++){
			int sum=0;
			for(int j=0;j<m;j++)sum += d[i][j];
			if(sum<b){
				a=i;
				b=sum;
			}
		}
		cout<<a<<' '<<b<<endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }

xy_t P[110];

double area(xy_t a, xy_t b, xy_t c)
{
    double z = (abs(a) + abs(b) + abs(c)) / 2;

    return sqrt(z * (z - abs(a)) * (z - abs(b)) * (z - abs(c)));
}

int main()
{
    int N = 0;
    double x, y;
    while (scanf("%lf,%lf", &x, &y) != EOF)
    {
        P[N++] = xy_t(x, y);
    }

    double sum = 0.0;
    for (int i = 0; i + 2 < N; i++)
    {
        xy_t a = P[0], b = P[i + 1], c = P[i + 2];
        sum += area(a - b, b - c, c - a);
    }
    printf("%.6f\n", abs(sum));
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=40003;
const ll INF=1LL<<63;
typedef vector<vector<int>> mat;

ll cnt=0;

ll DFS(mat &S,int rem,int s){
    int N=S.size();
    
    if(rem==0){
        for(int i=0;i<N;i++){
            int win=0,lose=0;
            for(int j=0;j<N;j++){
                if(S[i][j]==1) win++;
                else if(S[i][j]==0) lose++;
            }
            if(win!=N/2||lose!=N/2) return 0;
        }
        return 1;
    }
    
    for(int i=max(0,s-1);i<N;i++){
        int win=0,lose=0;
        for(int j=0;j<N;j++){
            if(S[i][j]==1) win++;
            else if(S[i][j]==0) lose++;
        }
        if(win>N/2||lose>N/2) return 0;
    }
    
    ll res=0;
    
    for(int i=s;i<N;i++,s++){
        for(int j=i+1;j<N;j++){
            
            if(S[i][j]==-1){
                
                S[i][j]=1;
                S[j][i]=0;
                
                res+=DFS(S,rem-1,s);
                
                S[i][j]=0;
                S[j][i]=1;
                
                res+=DFS(S,rem-1,s);
                
                S[i][j]=-1;
                S[j][i]=-1;
                
                return res;
            }
        }
    }
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //cout<<5<<endl;
    
    while(1){
        int N,M;cin>>N>>M;
        if(N==0) break;
        mat S(N,vector<int>(N,-1));
        
        for(int i=0;i<M;i++){
            int a,b;cin>>a>>b;
            a--;b--;
            S[a][b]=1;
            S[b][a]=0;
        }
        
        cout<<DFS(S,(N)*(N-1)/2-M,0)<<endl;
    }
}




Measured memory_bytes: 3140
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int K[200001];
int zentai, N;
ll kotae[200001];
int C[200001];
int E[400001], ne[400001], he[200001];
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
char dn[2400000], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void dfs(int p, int mae) {
	int k = K[C[p]] + zentai;
	int k0 = k;
	for (int to = he[p]; to; to = ne[to]) {
		if (mae != E[to]) {
			dfs(E[to], p);
			int sa = K[C[p]] + zentai - k;
			kotae[C[p]] -= ll(sa) * (sa + 1) >> 1;
			k += sa;
		}
	}
	zentai++;
	K[C[p]] = k0 - zentai;
}


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


	N = getint();
	rep1(i, N) C[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();

		E[k] =b;
		ne[k] = he[a];
		he[a] = k++;
		E[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	dfs(1, -1);
	ll n = ll(N) * (N + 1) / 2;
	rep1(i, N) {
		int sa = K[i] + zentai;
		putint(n + kotae[i] - (ll(sa) * (sa + 1) >> 1));
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 26216