akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  ll D,G;
  cin>>D>>G;
  VL P(D),C(D);
  rep(i,D) cin>>P[i]>>C[i];
  ll ans=1001001001;
  rep(i,1<<D){
    VI B(D);
    rep(j,D) if((i>>j)&1) B[j]++;
    ll tmp=0;
    ll sum=0;
    ll M=-1;
    rep(j,D){
      if(B[j]){
        tmp+=P[j];
        sum+=P[j]*(j+1)*100+C[j];
      }else M=j;
    }
    if(sum>G){
      ans=min(ans,tmp);
      continue;
    }
    if(M!=-1){
      tmp+=(G-sum+M*100)/((M+1)*100);
      if((G-sum+M*100)/((M+1)*100)>=P[M]) continue;
      sum+=(G-sum+M*100)/((M+1)*100)*((M+1)*100);
    }
    if(sum>=G) ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int h,w;
  cin>>h>>w;
  Graph A(h,vector<int>(w,0));
  rep(i,h) rep(j,w) cin>>A[i][j];
  
  Graph ans(1000000);
  int count=0;
  rep(i,h) rep(j,w){
    if(i==h-1 && A[i][j]%2==1){
      if(j!=w-1){
        A[i][j]--;
        A[i][j+1]++;
        ans[count].push_back(i);
        ans[count].push_back(j);
        ans[count].push_back(i);
        ans[count].push_back(j+1);
        count++;
        //cout<<i<<j<<"a"<<endl;
      }
    }
    else if(A[i][j]%2==1){
      if(j!=w-1 && A[i][j+1]%2==1){
        A[i][j]--;
        A[i][j+1]++;
        ans[count].push_back(i);
        ans[count].push_back(j);
        ans[count].push_back(i);
        ans[count].push_back(j+1);
        count++;
        //cout<<i<<j<<"b"<<endl;
      }
      else{
        A[i][j]--;
        A[i+1][j]++;
        ans[count].push_back(i);
        ans[count].push_back(j);
        ans[count].push_back(i+1);
        ans[count].push_back(j);
        count++;
        //cout<<i<<j<<"c"<<endl;
      }
    }
  }
  
  cout<<count<<endl;
  rep(i,count) rep(j,4){
    if(j!=3) cout<<ans[i][j]+1<<" ";
    else cout<<ans[i][j]+1<<endl;
  }
}

Measured memory_bytes: 30464
#include <stdio.h>
main(){
   
  int a,b,c,x,y,z;
   
  scanf("%d%d%d",&a,&b,&c);
   
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
   
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
   
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
   
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}




 

Measured memory_bytes: 596
// AOJ 282: Programming Contest
// 2019.9.28 bal4u

#include <stdio.h>

#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX 100002
typedef struct { int x, t, qid; char f; } T; // 得点、映された長さ、キューでの位置、新規登録か
T team[MAX];


#define QSIZE 1000000
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key; int idx; } QUE;
QUE que[QSIZE+5]; int qsize;

//void idx_update(int idx, int pos);
#define idx_update(idx, pos) (team[idx].qid = pos)

void max_heapify(int i)
{
	int l, r, max;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].key > que[i].key
		|| (que[l].key == que[i].key && que[l].id < que[i].id))) max = l;
	else max = i;
	if (r < qsize && (que[r].key > que[max].key ||
		(que[r].key == que[max].key && que[r].id < que[max].id))) max = r;
	if (max != i) {
		idx_update(que[i].idx, max);
		idx_update(que[max].idx, i);
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

void deq(void) {
	que[0] = que[--qsize];
	idx_update(que[qsize].idx, 0);
	max_heapify(0);
}

void qup(int i) {
	int max;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		idx_update(que[i].idx, max);
		idx_update(que[max].idx, i);
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}
	
void enq(int id, int x, int idx) {
	int i = qsize++;
	que[i].id = id, que[i].key = x, que[i].idx = idx;
	idx_update(idx, i);
	qup(i);
}

void pri_update(int qid, int x) {
	QUE t = que[qid]; que[qid].key = x;
	if (x < t.key) max_heapify(qid);
	else           qup(qid);
}

int main()
{
	int i, N, R, L, d, t, x;
	int pre_t, pre_d, ans;

	N = in(), R = in(), L = in();
	pre_t = 0, pre_d = 1;
	
	team[1].x = 0, team[1].t = 0, team[1].qid = qsize, team[1].f = 1;  // 最初のチームが有利
	enq(1, 0, 1);
	
	while (R--) {
		d = in(), t = in(), x = in();
		if (x == 0) continue;
		team[d].x += x;
		
		if (team[d].f == 0) team[d].f = 1, enq(d, team[d].x, d);
		else pri_update(team[d].qid, team[d].x);

		team[pre_d].t += t - pre_t;
		pre_t = t, pre_d = que[0].id;
	}
	team[pre_d].t += L - pre_t;

	ans = t = 0; for (d = 1; d <= N; d++) if (team[d].t > t) t = team[d].t, ans = d;
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 4488
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::collections::HashMap;
#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let mut ans = 0;
    for i in 1..n {
        let prime = trial_division(n - i);
        let mut count = 1;
        for (_, value) in prime.iter() {
            count *= value + 1;
        }
        ans += count;
    }
    println!("{}", ans);
}

fn trial_division(mut n: usize) -> HashMap<usize, usize> {
    let mut primes = HashMap::new();
    let mut i = 2;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            if primes.contains_key(&i) {
                let x = primes.get_mut(&i).unwrap();
                *x += 1;
            } else {
                primes.insert(i, 1);
            }
        }
        i += 1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    if n > 1 {
        if primes.contains_key(&n) {
            let x = primes.get_mut(&n).unwrap();
            *x += 1;
        } else {
            primes.insert(n, 1);
        }
    }
    primes
}


Measured memory_bytes: 2212
#include <cstdio>
# define likely(x)      __builtin_expect(!!(x), 1)
# define unlikely(x)    __builtin_expect(!!(x), 0)
void reader(int *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void reader(long long *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int n, b[100009]; long long a[100009];
int main() {
	reader(&n);
	for (int i = 0; i < n; i++) {
		reader(&a[i]);
		reader(&b[i]);
	}
	long long ret = 0;
	for (int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if (d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

template <class T>
struct SegmentTree{
	std::vector<T> v;
	T def;
	int n;
	SegmentTree(int n_, T default_value): def(default_value){
		n = 1;
		while(n<n_) n <<= 1;
		v.assign(2*n-1, def);
	}
	template<class I>
	SegmentTree(I first, I last, T default_value): SegmentTree(last-first, default_value){
		copy(first, last, v.begin()+n-1);
		for(int i=n-2; i>=0; i--)
			v[i] = merge(v[2*i+1], v[2*i+2]);
	}
	SegmentTree(std::vector<T> initial_data, T default_value):
	SegmentTree(initial_data.begin(), initial_data.end(), default_value){}
	void update(int idx, T val){
		idx += n-1;
		v[idx] = val;
		while(idx > 0){
			idx = (idx-1)/2;
			v[idx] = merge(v[2*idx+1], v[2*idx+2]);
		}
	}
	T q(int a, int b, int k, int l, int r){
		if(a<=l&&r<=b) return v[k];
		if(b<=l||r<=a) return def;
		return merge(q(a, b, 2*k+1, l, (l+r)/2), q(a, b, 2*k+2, (l+r)/2, r));
	}
	T query(int a, int b){
		return q(a, b, 0, 0, n);
	}
	T merge(T left, T right);
};

// Example

template <>
int SegmentTree<int>::merge(int a, int b){
	return std::max(a, b);
}

int _main(){
	using namespace std;
	vector<int> a = {4,2,2,1,5,9,10};
	SegmentTree<int> st(a.begin(), a.end(), 1<<20);
	assert((st.query(0, 4)==1));
	for(int i=0; i<10; i++){
		assert((st.query(i, i+1)==i<a.size()?a[i]:1<<20));
	}

	return 0;
}
typedef vector<vector<int>> Gr;

void dfs(int u, int p, Gr &graph, SegmentTree<int> &st, vector<int> &a, vector<int> &ans){
	int backup = st.query(a[u], a[u]+1);
	int x = st.query(0, a[u]);
	st.update(a[u], x+1);
	ans[u] = st.query(0, st.n);
	for(int v: graph[u]){
		if(v==p) continue;
		dfs(v, u, graph, st, a, ans);
	}
	st.update(a[u], backup);
}


int main() {
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	vector<vector<int>> graph(N);
	for(int i=0; i<N-1; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	vector<int> as(A);
	sort(as.begin(), as.end());
	auto e = unique(as.begin(), as.end());
	for(int i=0; i<N; i++){
		A[i] = lower_bound(as.begin(), e, A[i])-as.begin()+1;
		dbg(i, A[i]);
	}

	SegmentTree<int> st(200010, 0);

	vector<int> ans(N);
	dfs(0, -1, graph, st, A, ans);

	for(int i=0; i<N; i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 47124
main :: IO ()
main = do
  [n, a, b] <- (map read . words) <$> getLine :: IO [Int]
  print $ sum $ filter (\i -> let ds = digitSum i 0 in a <= ds && ds <= b) [1..n]

digitSum n carry
  | n < 10 = carry + n
  | otherwise = digitSum (n `div` 10) (carry + n `mod` 10)


Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Policy;

class Program
{
	static void Main()
	{
		Console.ReadLine();
		var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));

		long max1 = 0;
		long max1Count = 0;
		long max2 = 0;
		var nums = new HashSet<long>();

		foreach (var l in a) {
			if (nums.Contains(l)) {
				if (l == max1) {
					++max1Count;
				} else if (l > max1) {
					max2 = max1;
					max1 = l;
					max1Count = 2;
				} else if (l > max2) {
					max2 = l;
				}
			} else {
				nums.Add(l);
			}
		}

		if (max1Count >= 4) {
			Console.WriteLine(max1 * max1);
		} else if (max1 != 0 && max2 != 0) {
			Console.WriteLine(max1 * max2);
		} else {
			Console.WriteLine(0);
		}

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


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

int main() {
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(a+b>=k){
    cout<<0<<" "<<a+b-k<<endl;
  }
  else{
    cout<<0<<" "<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll i=0;
	vii v;
	while(i<n){
		ll cnt=0,j=i;
		while(j<n && a[j]==a[i]){
			cnt++;
			j++;
		}
		v.pb({a[i],cnt});
		i=j; 
	}
	ll m=v.size();
	mi ind;
	for(ll i=0;i<m;i++) ind[v[i].first] = i+1;
	
	vector<bool> ans(m+1,true);
	ll cnt=0,maxx=v[m-1].first;
	for(ll i=0;i<m;i++){
		ll val = v[i].first;
		for(ll j=2*val;j<=maxx;j+=val){
			ans[ind[j]]=false;
		}
		if(ans[i+1]==true && v[i].second==1) cnt++;
	}
	cout<<cnt;

	return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    string s;
    cin>>s;

    rep(i,s.size()){
        if(s[i]=='?')s[i]='D';
    }

    cout<<s<<endl;

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n, pw;
	while (cin >> n >> pw, n)
	{
		vector<ld> vw(n), pf(n), vf(n), th(n);
		REP(i, n) cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
		ld lb = 0, ub = 100;
		REP(bs, 1000)
		{
			ld l = (lb * 2 + ub) / 3.0, r = (lb + ub * 2) / 3.0;
			ld resl = l*pw, resr = r*pw;
			REP(i, n)
			{
				ld vl = th[i] - vw[i] * l; 
				ld vr = th[i] - vw[i] * r;
				if (vl > 0) resl += vl / vf[i] * pf[i];
				if (vr > 0) resr += vr / vf[i] * pf[i];
			}
			if (resl < resr) ub = r;
			else lb = l;
		}
		ld ans = lb * pw;
		REP(i, n)
		{
			ld val = th[i] - vw[i] * lb;
			if (val > 0) ans += val / vf[i] * pf[i];
		}
		cout << D10 << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9240
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>


#ifndef _USEFUL_MACROS_
#define _USEFUL_MACROS_
#define INF 99999999
#define N_PRIME 1000000007
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x) do{}while(false)
#endif
#endif 

using namespace std;

int main(void){
    int64_t a,b,c;
    
    cin >> a >> b >> c;
    
    cout << min((a%2)*b*c,min((b%2)*a*c,(c%2)*a*b)) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int n, h, w;
int a[10010];
int c[110][110];

int main() {
    cin >> h >> w >> n;
    rep(i, n) cin >> a[i];

    int y = 0, x = 0;
    rep(i, n) {
        while (a[i]--) {
            c[y][x] = i + 1;
            if (x % 2 == 0) { // 下方向に塗る
                if (y == h-1) x++;
                else y++;
            } else { // 上方向に塗る
                if (y == 0) x++;
                else y--;
            }
        }
    }

    rep(i, h) {
        rep(j, w-1) printf("%d ", c[i][j]);
        printf("%d\n", c[i][w-1]);
    }
}


Measured memory_bytes: 3668
#include<iostream>
using namespace std;
#define int long long
#define mod 1000000007
int na[114514], ma[114514];
signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> na[i];
	for (int i = 0; i < m; i++)cin >> ma[i];
	int sx = 0, sy = 0;
	for (int i = 1; i <= n; i++) {
		sx += ((i-1)*na[i-1] - (n - i)*na[i-1]);
		sx %= mod;
	}
	for (int i = 1; i <= m; i++) {
		sy += ((i-1)*ma[i - 1] - (m - i)*ma[i - 1]);
		sy %= mod;
	}
	cout << sx*sy%mod << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int s;
    cin>>s;
    int a[4];
    a[0]=s%10;
    a[1]=s/10%10;
    a[2]=s/100%10;
    a[3]=s/1000;
    for(int i=0;i<=3;i++){
    	for(int j=0;j<=3;j++){
    		if(a[i]==a[j]&&(i-j==1||j-i==1)){
    			cout<<"Bad"<<endl;
				return 0; 
    		}
    	}
    }
    cout<<"Good";
	return 0; 
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
L = list(tuple(map(int, input().split())) for _ in range(Q))

ans = 0
A = []


def dfs():
    global A, ans
    if len(A) == N:
        res = sum(t[3] for t in L if A[t[1]-1] - A[t[0]-1] == t[2])
        ans = max(ans, res)
    else:
        for a in range(A[-1] if A else 1, M + 1):
            A.append(a)
            dfs()
            A.pop()


dfs()
print(ans)


Measured memory_bytes: 9160
#include<stdio.h>
int main(){
    int a, b;
    int p;
    while(1){
        scanf("%d %c %d", &a, &p,&b);
        if(p=='+'){
            printf("%d\n", a+b);
        }else if(p=='-'){
            printf("%d\n", a-b);
        }else if(p=='*'){
            printf("%d\n", a*b);
        }else if(p=='/'){
            printf("%d\n", a/b);
         }else {
             break;
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl vx(n),vy(n);
	rep(i,n)cin>>vx[i]>>vy[i];
	rep(i,n){
		vd r;
		rep(j,n){
			if(i==j)continue;
			r.push_back(atan2(vx[i]-vx[j],vy[i]-vy[j]));
		}
		sort(all(r));
		r.push_back(r[0]+2*PI);
		double mn=0;
		rep(i,n-1)chmax(mn,r[i+1]-r[i]-PI);
		fcout(6)<<mn/(2*PI)<<endl;
	}
}


Measured memory_bytes: 512
def solve(A, B, C, S):
    N = len(S)
    abc = [A, B, C]
    path = []
    for si in range(N - 1):
        i, j = S[si]
        if abc[i] == abc[j] == 0:
            print('No')
            return
        if abc[i] == 0:
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -= 1
            continue
        elif abc[j] == 0:
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -= 1
            continue

        i2, j2 = S[si + 1]
        if not (abc[j] - 1 == 0 and abc[3 - i - j] == 0 and {i2, j2} == {3-i-j, j}):
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -= 1
            continue
        if not (abc[i] - 1 == 0 and abc[3 - i - j] == 0 and {i2, j2} == {3-i-j, i}):
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -= 1
            continue

        if abc[i] <= abc[j]:
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -=1
        else:
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -=1

    i, j = S[N - 1]
    if abc[i] == abc[j] == 0:
        print('No')
        return
    if abc[i] == 0:
        path.append('ABC'[i])
    else:
        path.append('ABC'[j])

    print('Yes')
    for c in path:
        print(c)


N, A, B, C = map(int, input().split())
S = []
for _ in range(N):
    s = input()
    S.append({'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}[s])
solve(A, B, C, S)

Measured memory_bytes: 10836
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m) = readListOfInt() 
    val ab = mutableListOf<Pair<Long, Int>>()
    for(i in 0 until n) {
        val (a, b) = readListOfInt()
        ab.add(Pair(a.toLong(), b))
    }
    val sortedAb = ab.sortedBy { it.first }.toMutableList()
    var cost = 0L
    var boughtNum = 0
    var idx = 0
    while(boughtNum < m) {
        val cab = sortedAb[idx]
        if(cab.second > 0) {
            cost += cab.first
            sortedAb[idx] = Pair(cab.first, cab.second-1)
            boughtNum++
        } else {
            idx++
        }
    }
    println(cost)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 81048
//
// Created by Hideaki Imamura on 2020-03-19.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 1000000007;

ll X, Y;
ll fact[4001000];
ll invfact[4001000];

inline ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b) {
    return take_mod(a + b);
}

inline ll sub(ll a, ll b) {
    return take_mod(a - b);
}

inline ll mul(ll a, ll b) {
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n) {
    ll res = 1LL;
    while (n > 0) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x) {
    return mod_pow(x, mod - 2);
}

// nは上限
void make_fact(ll n) {
    fact[0] = 1;
    ll res = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = res;
        res = mul(res, i + 1);
    }
}

// nは上限
void make_invfact(ll n) {
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for (int i = n - 1; i >= 1; i--) {
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k) {
    return mul(fact[n], invfact[n - k]);
}

ll comb(ll n, ll k) {
    return mul(mul(fact[n], invfact[n - k]), invfact[k]);
}

int main() {
    cin >> X >> Y;
    make_fact(4000000);
    make_invfact(4000000);

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
    } else {
        ll _n = (X + Y) / 3 - X + Y;
        ll _m = (X + Y) / 3 + X - Y;
        if (_n < 0 || _m < 0 || _n % 2 || _m % 2) {
            cout << 0 << endl;
        } else {
            ll n = _n / 2;
            ll m = _m / 2;
            cout << comb(add(n, m), n) << endl;
        }
    }

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

vector<pair<char, int>> runlength(string s) {
    int n = s.size();
    vector<pair<char, int> > res;
    char pre = s[0];
    int cnt = 1;
    for(int i = 1; i < n; i++){
        if(pre != s[i]){
            res.push_back({ pre, cnt });
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }
    res.push_back({pre, cnt});
    return res;
}

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

    V<P<char, int> > v = runlength(s);

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

    return 0;
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int A,B,C,i=0;
  cin>>A>>B>>C;
  if(A%2==0&&B%2==0&&C%2==0&&A==B&&C==B) cout<<"-1"<<endl;
  else{
  for(;A%2==0&&B%2==0&&C%2==0;i++){
    int a=A,b=B,c=C;
    A=(b+c)/2;
    B=(a+c)/2;
    C=(b+a)/2; 
  }
  cout<<i<<endl;
  
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

int main(void)
{
	int person[50]; //候補者の手持ち石の数
	int n,p,maxp; //n=候補者の数 p,maxp=石の数の合計
	int i,j;
	
	for(;;)
	{
		scanf("%d %d",&n,&p);
		maxp=p;
		if(n==0 && p==0) break;
		j=0;
		
		for(i=0; i<n; i++)
		{
			person[i]=0; //初期枚数
		}
		
		for(;;)
		{
			if(p!=0)
			{
				p--;
				person[j]++;
			}
			else if(person[j]==0)
			{
			}
			else
			{
				p+=person[j];
				person[j]=0;
			}
			
			if(p==0 && person[j]==maxp)
			{
				break;
			}
			j++;
			if(j==n) j=0;

		}
		printf("%d\n",j);
	}
}

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


int main() {
    ll n; cin>>n;
    vector<ll> a(n);
    ll max=1000000000000000000;
    ll ans=1;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)==0){
            puts("0");
            return 0;
        }
    }
    rep(i,n){
        if(a.at(i)>max/ans){
            cout<<-1<<endl;
            return 0;
        }
        else{
            ans*=a.at(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
int N;
  in(N);
  double ans = 0;
  rep(i,N){
double a;
    string s;
    in(a>>s);
    if(s=="BTC") ans += a*380000.0;
    else ans += a;
  }
  out(ans);
}

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

ll divisor=1e9+7;
int main(){
	int s,w;
	cin>>s>>w;
	if(s>w){
		puts("safe");
	}else{
		puts("unsafe");
	}
}

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;


class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int oddCount = 0;

        for (int i = 1; i <= N; i++) {
            if (i % 2 == 1)
                oddCount++;
        }

        System.out.println((double) oddCount / N);


    }
}




Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


vector<ll> prime_factorization(ll n){
    vector<ll> ret;
    
    for(ll div=2;div<=1+sqrt(n);div++){
        while(n%div==0){
            ret.pb(div);
            n/=div;
        }
    }
    if(n!=1)ret.pb(n);
    return ret;
}

const ll MOD = 1e9+7;

int main(){
    int n;
    cin>>n;
    
    vector<int> v(1001,0);
    
    for(int i=2;i<=n;i++){
        vector<ll> res = prime_factorization(i);
        for(auto e:res){
            v[e]++;
        }
    }
    
    ll ans = 1;
    rep(i,1001){
        if(v[i]!=0){
            (ans*=v[i]+1)%=MOD;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    // to, dist
    vector<vector<pair<int, int>>> graph(n);
    for (int i = 0; i < m; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        graph[l].push_back(make_pair(r, d));
        graph[r].push_back(make_pair(l, -d));
    }
    vector<int> x(n, -inf);
    for (int i = 0; i < n; ++i) {
        if (x[i] != -inf)
            continue;

        x[i] = 0;
        queue<int> que;
        que.push(i);
        while (!que.empty()) {
            int from = que.front();
            que.pop();

            for (const auto &to : graph[from]) {
                if (x[to.first] == -inf) {
                    x[to.first] = x[from] + to.second;
                    que.push(to.first);
                } else if (x[to.first] != x[from] + to.second) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 9344
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	if ((K - M) % 2) {
		cout << "Borys\n";
	}
	else {
		cout << "Alice\n";
	}
	return 0;
}

Measured memory_bytes: 768
/**
 *  author: MahfuzAhmed
 *  created: 26.08.2019
**/

#include <iostream>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int a; cin >> a;
    string s; cin >> s;
    
    if(a < 3200)
        cout << "red\n";
    else
        cout << s << "\n";
    
    
    return 0;
}


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

int main()
{
	int n[4];
	string str;

	while (cin >> str, str != "0000"){
		for (int i = 0; i < 4; i++){
			n[i] = str[i] - '0';
		}

		if (n[0] == n[1] && n[0] == n[2] && n[0] == n[3]){
			cout << "NA" << endl;
		}
		else {
			int c = 0;
			while (n[0] != 6 || n[1] != 1 || n[2] != 7 || n[3] != 4){
				
				char l[4], s[4];
				for (int i = 0; i < 4; i++){
					l[i] = s[i] = n[i];
				}

				sort(l, l + 4);
				reverse(l, l + 4);
				sort(s, s + 4);

				for (int i = 3; 0 <= i; i--){
					n[i] = l[i] - s[i];
					if (n[i] < 0){
						n[i] += 10;
						l[i - 1]--;
					}
				}
				c++;
			}
			cout << c << endl;
		}
	}
	return (0);
}

Measured memory_bytes: 1212
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int X[100010];
    rep(i, M) cin >> X[i];
    sort(X, X + M);
    int ans = 0;
    vector<int> v;
    rep(i, M-  1) v.push_back(X[i + 1] - X[i]);
    sort(v.begin(), v.end());
    rep(i, M - N) {
        ans += v[i];
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1276
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }

int n, m;
vector<vector<int>> VC;

void dfs(vector<int> vec){
    if(vec.size()==n){
        VC.push_back(vec);
        return;
    }
    for(int i=vec.back(); i<=m; i++){
        vec.push_back(i);
        dfs(vec);
        vec.pop_back();
    }
}

int main() {   
    int q; cin >> n >> m >> q;    
    vector<int> a(q), b(q), c(q), d(q);
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    
    vector<int> vec{1};
    dfs(vec);

    ll res = 0;
    for(vector<int> A: VC){
        ll sum = 0;
        rep(i, q){
            int num = A[b[i]] - A[a[i]];
            if(num == c[i]) sum += d[i];
        }
        chmax(res, sum);
    }
    cout << res << ln;
}

Measured memory_bytes: 6776
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
 
using namespace std;
typedef long long int ll;


int main(){

    double N , K;
    cin >> N >> K;

    double ans = 0;
    for(ll i = 1; i <= N; i++){
        ll count = 0;
        for(ll j = i; j < K; j *= 2){
            count++;
        }
        //cout << pow(1/2, count) << endl;
        ans += pow(0.5, count);

    }

    ans *= 1 / N;
    printf("%.12f\n", ans);

} 

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x = max({ a,b,c });
	int y = x * 3 - (a + b + c);
	if (y % 2 == 0) {
		cout << y / 2 << endl;
	}
	else {
		y = (x + 1) * 3 - (a + b + c);
		cout << y / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
ans = 10**9
b = [i for i in range(-100,101)]
for i in range(len(b)):
    ansa = 0
    for j in range(N):
        ansa += (b[i]-a[j])**2
    ans = min(ans,ansa)
print(ans)

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	string t=s;
	reverse (t.begin(),t.end());
	cout<<(s==t?"Yes":"No")<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N = 200010;
LL a[N];
bool cmp(LL a,LL b){
	return a>b;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
	}
	sort(a+1,a+n+1,cmp);
	LL ans=a[1];
	for(int i=3;i<=n;i++){
		ans+=a[(i+1)/2];
	}
	cout<<ans<<endl;
	return 0;
}

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

struct edge {int to, cost; };

const int MAX_N=100005;
const ll INF=1e17;
int n;
vector<edge> G[MAX_N];
ll d[MAX_N];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d+n, INF);
  d[s]=0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p=que.top();
    que.pop();
    int v=p.second;
    if (d[v]<p.first) continue;
    rep(i, G[v].size()) {
      edge e=G[v][i];
      if (d[e.to]>d[v]+e.cost) {
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin>>n;
  rep(i, n-1) {
    int a,b,c; cin>>a>>b>>c;
    a--, b--;
    G[a].push_back(edge{b, c});
    G[b].push_back(edge{a, c});
  }
  int q,k; cin>>q>>k;
  k--;
  vector<int> x(q),y(q);
  rep(i, q) {
    cin>>x[i]>>y[i];
    x[i]--, y[i]--;
  }
  dijkstra(k);
  rep(i, q) printf("%lld\n", d[x[i]]+d[y[i]]);
  return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max({a, b, c}) << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val input1 = readLine
  val N = input1.split(" ")(0).toInt
  val M = input1.split(" ")(1).toInt  
  
  var array: Array[Int] = Array.empty
  
  val input2 = readLine
  for(count1 <- 1 to N){
    var input3 = input2.split(" ")(count1 -1).toInt
    array = array :+ input3
  }
    
  var sorted = array.sorted.reverse
  
  if(sorted(M-1) < array.sum / (4.0*M)) println("No")
  else if(sorted(M-1) >= array.sum / (4.0*M)) println("Yes")
}

Measured memory_bytes: 25552
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

const int INF = 1e6;

int main(){
    long long n, a, b;  cin >> n >> a >> b;
    long long ans=0;
    vector<int> x(n);
    for (int i=0; i<n; i++){
        cin >> x[i];
    }

    for (int i=0; i<n-1; i++){
        if (a*(x[i+1]-x[i]) < b){
            ans += a*(x[i+1]-x[i]);
        }
        else {
            ans += b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Tree {
   Tree(Int n)
      : ps(n, -1) {}
   std::vector<Int> ps;
   Int root(Int x) {
      if( ps[x] == -1 ) return x;
      return ps[x] = root(ps[x]);
   }
   void connect(Int parent, Int child) {
      parent = root(parent), child = root(child);
      if( parent == child ) return;
      ps[root(child)] = root(parent);
   }
};

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ws(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ws[i];
   std::vector<RQ<std::pair<Int,Int>>> qs(v);
   std::vector<Int> os(v);
   rep(i, e) {
      Int s = ss[i], t = ts[i], w = ws[i];
      qs[t].emplace(w, s);
   }
   std::vector<Int> xs(v);
   xs[r] = 2;
   Tree tree(v);
   auto f = [&]() -> Int {
      Int res = 0;
      std::vector<Int> pws(v), pis(v);
      rep(i, v) {
         Int a = tree.root(i);
         assert( xs[a] == 0 or xs[a] == 2 );
         guard( xs[a] == 0 );
         std::vector<Int> ys;
         while( xs[a] != 2 ) {
            ys.emplace_back(a);
            xs[a] = 1;
            if( qs[a].empty() ) return -1;
            Int w, p;
            do {
               std::tie(w, p) = qs[a].top(); qs[a].pop();
               w += os[a];
               p = tree.root(p);
            } while( p == tree.root(a) );
            pws[a] = w;
            pis[a] = p;
            res += w;
            if( xs[p] != 1 ) {
               a = p;
            }
            else {
               Int nr = a;
               for(Int b = pis[a]; b != a; b=pis[b]) {
                  if( qs[nr].size() < qs[b].size() ) nr = b;
               }
               os[nr] -= pws[nr];
               for(Int b = pis[nr]; b != nr; b=pis[b]) {
                  tree.connect(nr, b);
                  while( not qs[b].empty() ) {
                     Int w2, p2; std::tie(w2, p2) = qs[b].top(); qs[b].pop();
                     Int nw = w2 + os[b] - pws[b] - os[nr];
                     qs[nr].emplace(nw, p2);
                  }
               }
               a = nr;
            }
         }
         for(Int y : ys) xs[y] = 2;
      }
      return res;
   };
   printf("%ld\n", f());
}



Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
long long N=0,M=0,ans=0,sum=0;


int main()
{
  string moji;
  cin>>moji;
  if(moji=="A"){
      cout<<"T";
  }else if(moji=="T"){
      cout<<"A";
  }else if(moji=="G"){
      cout<<"C";
  }else if(moji=="C"){
      cout<<"G";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int H, R;
	cin >> H;
	cin >> R;
	int ans = H + R;
    if (ans > 0)cout << "1" << endl;
	else if (ans < 0)cout << "-1" << endl;
	else cout << "0" << endl;
	return 0;
}



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

int main () {
	int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
	int x, y; 
	cin >> x >> y ;
	cout << (a[x] == a[y] ? " Yes " : " No ") << endl;
}



Measured memory_bytes: 3592
#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 setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int A[3][3];
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    bool a[3][3];
    rep(i, 3) rep(j, 3) a[i][j] = false;
    int N;
    cin >> N;
    rep(i, N){
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3){
            if(A[i][j] == b) a[i][j] = true;
        }
    }
    bool res = false;
    rep(i, 3){
        if(a[i][0] && a[i][1] && a[i][2]) res = true;
    }
    rep(i, 3){
        if(a[0][i] && a[1][i] && a[2][i]) res = true;
    }
    if(a[0][0] && a[1][1] && a[2][2]) res = true;
    if(a[2][0] && a[1][1] && a[0][2]) res = true;
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long int

#define md 1000000007

ll ppow(ll b, int p){
    ll ret=1;
    for(;p;p/=2){
        if(p&1) ret=(ret*b)%md;
        b=(b*b)%md;
    }
    return ret;
}

int main(){
    int n;
    scanf("%d",&n);
    
    ll sm=0;
    ll sms=0;
    ll val;
    for(int i=0;i<n;i++){
        scanf("%lld",&val);
        sm+=val;
        sms=(sms+val*val)%md;
    }

    sm%=md;
    ll ans=(sm*sm-sms)%md;
    ans=(ans*ppow(2,md-2))%md;
    if(ans<0) ans+=md;

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


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0032
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            List<int> Nums = new List<int>();

            Nums.Add(N);

            int index = 1;
            while (true)
            {
                if (Nums[index - 1] % 2 == 0)
                {
                    Nums.Add(Nums[index - 1] / 2);
                }
                else
                {
                    Nums.Add(3 * Nums[index - 1] + 1);
                }

                index++;

                if (Nums.Count() != Nums.Distinct().Count())
                {
                    break;
                }

            }

            Console.WriteLine(index);

        }
    }
}

Measured memory_bytes: 28324