akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(int K) {
        int n = 15;
        vector<vector<long long>> dp(n + 1, vector<long long>(10, 0));
        for (int i = 0; i < 10; ++i) {
            dp[1][i] = 1;
        }

        for (int i = 2; i <= n; ++i) {
            for (int j = 0; j < 10; ++j) {
                for (int k = -1; k < 2; ++k) {
                    int nj = j + k;
                    if (nj >= 0 && nj < 10) {
                        dp[i][j] += dp[i - 1][nj];
                    }
                }
            }
        }

        // long long cnt = 0;
        // for (int i = 0; i <= n; ++i) {
        //     for (int j = 0; j < 10; ++j) {
        //         cnt += dp[i][j];
        //     }
        // }
        // cout << cnt << endl;

        --K;
        long long res = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j < 10; ++j) {
                // cout << i << "," << j << " " << dp[i][j] << " " << K << endl;
                if (dp[i][j] > K) {
                    // cout << i << " " << j << endl;
                    int x = j;
                    res = j;
                    for (int k = i - 1; k >= 0; --k) {
                        for (int d = -1; d < 2; ++d) {
                            int nx = x + d;
                            if (nx >= 0 && nx < 10) {
                                // cout << " " << k << " " << nx << " " << dp[k][nx] << endl;
                                if (dp[k][nx] > K) {
                                    res = res * 10 + nx;
                                    x = nx;
                                    break;
                                } else {
                                    K -= dp[k][nx];
                                }
                            }
                        }
                    }
                    return res;
                    break;
                } else {
                    K -= dp[i][j];
                }
            }
        }
        
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    Solution sol;
    cout << sol.solve(K) << "\n";

    return 0;
}

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

int main(){
  long inf = 1000000007;
  long n;
  cin >> n;
  string s;
  cin >> s;
  long x[26];
  for(long i = 0;i < 26;i++){
    x[i] = 0;
  }
  for(long i = 0;i < n;i++){
    x[s.at(i) - 'a']++;
  }
  long kekka = 1;
  for(long i = 0;i < 26;i++){
    kekka = (kekka*(x[i]+1))%inf;
  }
  kekka--;
  cout << kekka << endl;
}

Measured memory_bytes: 512
N = gets.to_i
as = gets.split.map(&:to_i)
ranks = Hash.new(0)
over = 0
as.each do |a|
    if a < 3200
        ranks[a / 400] += 1
    else
        over += 1
    end
end

min = [ranks.length,  over > 0 ? 1 : 0].max
max = ranks.length + over
puts [min, max].join(' ')


Measured memory_bytes: 1788
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979

int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	double e = 30*c + 0.5*d;
	double f = d*6;
	double g = a*a + b*b - 2*a*b*cos(PI*(e-f)/180);
	printf("%.18lf",sqrt(g));
}

Measured memory_bytes: 2620
/*

Author : AllKilled
Date   : 201910277

Contest: AtCoder Beginner Contest 144.
Problem: Task B.
Result :

*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL MAXN = 1e6+7;

///--------------------------------------------///



int main()
{
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define REP(i,x)for(__typeof(x) i=0;i<x;i++)

string res;
set<string> m;
int H,W,dx,dy,min_len;
char s[200];
string MAP[11];
bool visit[20][20];
void dfs(int x,int y,int k){
  if(k==min_len){
    if(m.count(string(s)))res=min(res,string(s));
    m.insert(string(s));
  }else if(k>min_len){
    if(m.count(string(s)))res=string(s),min_len=k;
    m.insert(string(s));
  }
  if(visit[y][x])
    return;
  s[k]=MAP[y][x];  visit[y][x]=1;
  dfs((x + dx + W) % W, (y + dy + H) % H, k + 1);
  s[k]=0;  visit[y][x]=0;
}
int main() {
  while(cin>>H>>W,H){
    REP(i,H)cin>>MAP[i];
    m.clear();
    min_len=1;
    res="0";
    REP(y,H)REP(x,W){
      for(dx=-1;dx<=1;dx++){
        for(dy=-1;dy<=1;dy++){
          if(dx|dy)dfs(x,y,0);
        }
      }
    }
    cout<<res<<endl;
  }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	rep (i, 0, n)
		cin >> a[i];
	rep (i, 0, n)
		cin >> b[i];
	rep (i, 0, n)
		cin >> c[i];

	ll res = 0;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for (auto it_b = b.begin(); it_b != b.end(); it_b++) {
		auto it_a = lower_bound(a.begin(), a.end(), *it_b);
		auto it_c = upper_bound(c.begin(), c.end(), *it_b);
		ll size_a = distance(a.begin(), it_a);
		ll size_c = distance(it_c, c.end());
		res += (size_a * size_c);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int cnt(int x)
{
    int ans=1;
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            int tmp=0;
            while(x%i==0)
            {
                x/=i;
                tmp++;
            }
            ans*=(tmp+1);
        }
    }
    if(x>1) ans*=2;
    return ans;
}


int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<n;i++)
    {
        int ans=n-i;
        sum+=cnt(ans);
    }
    cout<<sum<<endl;
    return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

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

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


signed main() {
  string s,t;
  cin >> s;
  cin >> t;
  
  unordered_map<char,char> cMap1,cMap2;
  for(int i=0;i<s.length();i++){
    if(0==cMap1.count(s[i])){
      cMap1[s[i]]=t[i];
    }
    else{
      if(t[i]!=cMap1[s[i]]){
        cout << "No" << endl;
        return 0;
      }
    }
    
    if(0==cMap2.count(t[i])){
      cMap2[t[i]]=s[i];
    }
    else{
      if(s[i]!=cMap2[t[i]]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll N, K;
vector<vec> v;
vec cnt;
modint res;
vec memo;
void dfs(int pos){

    memo[pos] = 1;

    for(auto p: v[pos]){
        if(memo[p]) continue;
        res = res * modint(K-cnt[pos]);
        cnt[pos]++;
        dfs(p);
    }
}

void solve() {
    cin >> N >> K;
    v.resize(N); memo.resize(N, 0);
    cnt.resize(N, 2); cnt[0] = 1;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    res = K;
    dfs(0);

    cout << res.n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 14080
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x[1100],y[1100],d[1100];
bool v[1100];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		v[(x[i]+y[i])&1]=1;
	}
	if (v[0]&&v[1]){
		puts("-1");
		return 0;
	}
	if (v[0]) d[++m]=1;
	for (int i=30;i>=0;i--) d[++m]=1<<i;
	printf("%d\n",m);
	for (int i=1;i<m;i++) printf("%d ",d[i]);
	printf("%d\n",d[m]);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (abs(x[i])>abs(y[i])){
				if (x[i]>0) x[i]-=d[j],putchar('R');
				else x[i]+=d[j],putchar('L');
			} else {
				if (y[i]>0) y[i]-=d[j],putchar('U');
				else y[i]+=d[j],putchar('D');
			}
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
#define fr first
#define sc second
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
 
int h, w, n, ans[10][10];
vector< Pii > memo;
 
int wy, wx;
void plus_n( int y, int x, int nt){
  wy = y;
  wx = ( x + nt ) % w;
  if(!wx) wy++;
  return ;
}

int dfs( const int mas[][10], const int used, const int y, const int x){
  if( y == h){ //exit
    memcpy( ans, mas, sizeof(int)*100);
    return 1;
  }
  int ret = 0;
  if( mas[y][x] != 0){
    plus_n( y, x, 1);
    ret += dfs( mas, used, wy, wx);
  }else{
    for(int bit = 0 ; bit < n ; bit++ ){
      if( (used >> bit) & 1 ) continue; // もうやってある
 
      for(int i = 1 ; i <= memo[bit].fr ; i++ ){ //高さ決定
        if( memo[bit].fr % i != 0 ) continue; // 長方形無理
        int height = i, width = memo[bit].fr / i;
 
        if( y <= memo[bit].sc.fr && y > memo[bit].sc.fr - height &&
            x <= memo[bit].sc.sc && x > memo[bit].sc.sc - width &&
            y + height - 1 < h && x + width - 1 < w){
          int java[10][10];
          bool ok = true;
          memcpy( java, mas, sizeof(int)*100);
          for(int j = 0 ; j < height ; j++ ){
            for(int k = 0 ; k < width ; k++ ){
              if(java[j + y][k + x]) ok = false;
              java[j + y][k + x] = bit + 1;
            }
          }
          if(ok){
            plus_n( y, x, width);
            ret += dfs( java, used|(1<<bit), wy, wx);
          }
        }
      }
    }
  }
  return ret;
}
int main(){
  while(cin >> w >> h >> n , w){
    memo.resize( n);
    for(int i = 0, bf ; i < n ; i++ ){
      cin >> bf;
      cin >> memo[bf - 1].fr;
    }
    for(int i = 0, c ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> c;
        if(c)memo[c - 1].sc = Pi( i, j);
      }
    }
    int mas[10][10] = {{}};
    if(dfs( mas, 0, 0, 0) == 1){
      for(int i = 0 ; i < h ; i++ ){
        for(int j = 0 ; j < w ; j++ ){
          cout << ( j ? " " : "" ) << ans[i][j];
        }
        cout << endl;
      }
    }else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1244
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll n, r; scanf("%lld %lld", &n, &r);
		if (n == 0 && r == 0) break;
		deque<ll> q;
		stack<ll> s1,s2;
		for (ll i = n; i >= 1; i--) q.push_back(i);
		for (ll i = 0; i < r; i++) {
			ll p, c; scanf("%lld %lld", &p, &c);
			p--;
			for (ll j = 0; j < p; j++) {
				s1.push(q.front());
				q.pop_front();
			}
			for (ll j = 0; j < c; j++) {
				s2.push(q.front());
				q.pop_front();
			}
			while (!s1.empty()) {
				q.push_front(s1.top());
				s1.pop();
			}
			while (!s2.empty()) {
				q.push_front(s2.top());
				s2.pop();
			}
		}
		printf("%lld\n", q.front());
	}
	return 0;
}



Measured memory_bytes: 3172
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    s = input()
    t = input()
    res = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            res += 1
    print(res)

if __name__ == "__main__":
    resolve()

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 K, X;
  cin >> K >> X;
  if (500 * K >= X) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
/* 
 * File:   main.cpp
 * Author: freebsd
 *
 * Created on 2014/08/28, 10:07
 */

#include <cstdio>

using namespace std;

int main() {
    while (true) {
        int n = 0;
        int ice[10] = {0}, icetemp = 0;
        
        scanf("%d", &n);
        
        if(n == 0) break;
        
        for (int i = 0; i < n; i++) {
            icetemp = 0;
            scanf("%d", &icetemp);
            ice[icetemp]++;
        }
        
        for (int i = 0; i < 10; i++) {
            if(ice[i] > 0) {
                for(int j = 0; j < ice[i]; j++){
                    printf("*");
                }
            }else {
                printf("-");
            }
            printf("\n");
        }
        
    }
       
    return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
long double a, b, x;
 
void input() {
    cin >> a >> b >> x;
}
 
long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}
 
void solve() {
    input();
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++) {
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}


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

int table[11][10000];

void num(int size, int deep, int data[], int sum){
	if (size + 1 == deep){
		table[size][sum]++;
	}
	else {
		for (int i = 0; i <= 9; i++){
			if (data[i] == 0){
				data[i] = 1;
				num(size, deep + 1, data, sum+i*deep);
				data[i] = 0;
			}
		}
	}
	return;
}

int main(void)
{
	int n, s, data[10];
	for (int i = 1; i <= 10; i++){
		memset(data, 0, sizeof(data));
		num(i, 1, data, 0);
	}
	while (cin >> n >> s){
		cout << table[n][s] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 796
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const double pi=acos(-1.0);
ll mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n<=111) cout << 111 << endl;
	else if(n<=222) cout << 222 << endl;
	else if(n<=333) cout << 333 << endl;
	else if(n<=444) cout << 444 << endl;
	else if(n<=555) cout << 555 << endl;
	else if(n<=666) cout << 666 << endl;
	else if(n<=777) cout << 777 << endl;
	else if(n<=888) cout << 888 << endl;
	else cout << 999 << endl;
}

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

int main(){
  int S, a;
  int h, m, s;

  cin >> S;
  h = S / 3600;
  a = S % 3600;
  m = a / 60;
  s = a % 60;
  cout << h << ':' << m << ':' << s << endl;

  return 0;
}


Measured memory_bytes: 3080
N = int(input()) - 1

def solve():
    ans = ''
    res = N
    q = 26
    while q > 0:
        q, r = divmod(res, 26)
        res = q-1
        ans = chr(ord('a') + r) + ans
    return ans

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;



int main(){
	string s, t;
	cin>>t>>s;
	int ans = 1e9;
	for(int i = 0; i-1+s.size() < t.size(); i++){
		int cnt = 0;
		for(int j = 0; j < s.size(); j++){
			cnt += s[j] != t[i+j];
		}
		ans = min(ans, cnt);
	}
	print(ans);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int i = 0; i < (N); i++)

int main(){

    vector<string> result = {"AC","WA","TLE","RE"};
    int N;
    cin >> N;
    map<string, int> S;
    for (auto ele: result) S[ele] = 0;
    rep (i, N){
        string s;
        cin >> s;
        S[s]++;
    }

    for (auto ele: result) cout << ele << " x " << S[ele] << endl;;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

int divide(int n) {
   int res = 1;
   while ((n > 0) && ((n & 1) == 0)) {
      res *= 2; n >>= 1;
   }
   return res;
}

struct Node {
   Node* child[2];
   Node() {
      child[0] = nullptr;
      child[1] = nullptr;
   }
};

class Trie {
   private:
      Node* root;
      int H;
   public:
      Trie(int h) {
         H = h;
         root = new Node();
      }
      void insert(string str) {
         Node* cur = root;
         for (int i = 0; i < str.size(); i++) {
            int x = str[i] - '0';
            if (cur->child[x] == nullptr) {
               cur->child[x] = new Node();
            }
            cur = cur->child[x];
         }
      }
      int dfs(Node* cur, int d) {
         if (cur == nullptr) {
            return divide(H - d + 1);
         } else {
            return dfs(cur->child[0], d+1) ^ dfs(cur->child[1], d+1);
         }
      }
      int dfs() {
         return dfs(root, 0);
      }
};

signed main()
{
   int N, L; cin >> N >> L;
   V<string> s(N);
   REP(i, N) cin >> s[i];

   Trie trie(L);
   REP(i, N) {
      trie.insert(s[i]);
   }

   int ans = trie.dfs();
   cout << (ans == 0 ? "Bob" : "Alice") << endl;

   return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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 int long long

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());
  vector<int> color;
  rep(i, x) color.push_back(p[i]);
  rep(i, y) color.push_back(q[i]);
  ll ans = 0;
  rep(i, color.size())
    ans += color[i];
  sort(color.begin(), color.end());
  vector<ll> sum1(color.size()+1), sum2(c+1);
  rep(i, color.size())
    sum1[i+1] = sum1[i]+color[i];
  rep(i, c)
    sum2[i+1] = sum2[i]+r[i];
  for (int i = 1; i < sum1.size() && i < sum2.size(); i++)
    chmax(ans, sum1.back()-sum1[i]+sum2[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6256
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;

int main(){
    int N;
    vector<int> v;
    cin >> N;
    v.resize(N);
    for(int i=0; i<N; i++)
        cin >> v[i];

    for(int i=1; i<N; i++){
        for(int k=0; k<N; k++){
            cout << v[k];
            if(v[k] != v.back()) cout << ' ';
        }
        cout << endl;

        int num = v[i];
        int j = i-1;
        while(j >= 0 && v[j] > num){
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = num;
    }
    for(int k=0; k<N; k++){
        cout << v[k];
        if(v[k] != v.back()) cout << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3120
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  int ans=0;
  int t;
  for(int d=1;d<=D;d++){
    cin>>t;
    
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    last[d][t]=d;
    
    for(int i=1;i<=26;i++) ans-=C[i]*(d-last[d][i]);
    
    ans+=S[d][t];

    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3716
import Control.Monad

main::IO()
main=do
  nxc<-getLine
  let n:x:[] = map read (words nxc) ::[Int]
  ls<-forM [1..n] (\_->getLine)
  let dat = map read ls ::[Int]
  print ((div (x - (sum dat)) (minimum dat)) +n) 

Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int d = ni();
        int[] c = new int[26];
        for (int i = 0; i < 26; i++) {
            c[i] = ni();
        }
        int[][] s = new int[d][26];
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < 26; j++) {
                s[i][j] = ni();
            }
        }
        int[] t = new int[d];
        for (int i = 0; i < t.length; i++) {
            t[i] = ni()-1;
        }
        
        int score = 0;
        int[] last = new int[26];
        for (int i = 1; i <= d; i++) {
            score += s[i-1][t[i-1]];
            int mi = 0;
            last[t[i-1]] = i;
            for (int j = 0; j < 26; j++) {
                mi += c[j]*(i-last[j]);
            }
            score -= mi;
            out.println(score);
        }
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main(void){
    
   string s;
   int ans;
   cin>>s;
   if(s=="SUN"){ans = 7;}
   else if(s=="SAT"){ans = 1;}
   else if(s=="MON"){ans = 6;}
   else if(s=="TUE"){ans = 5;}
   else if(s=="WED"){ans = 4;}
   else if(s=="THU"){ans = 3;}
   else if(s=="FRI"){ans = 2;}
   cout<<ans<<endl;
   return 0;
}

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

int main(){
	int n;
	cin >> n;
	
	int ans = 1;
	while(ans <= n){
		ans *= 2;
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int sz,m,b,e;
    cin>>sz;
    vector<int >v(sz);
    for(int i=0; i<sz; i++)
        cin>>v[i];
    cin>>m;
    while(m--) {
        cin>>b>>e;
        reverse(v.begin()+b,v.begin()+e);

    }
    cout<<v[0];
    for(int i=1; i<sz; i++)
        cout<<' '<<v[i];
        cout<<endl;
    return 0;
}




Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
using Int = int64_t;
int main() {
    Int N;
    cin >> N;
    vector<Int> A(N), S(N + 1, 0);
    unordered_map<Int, Int> um;
    um[0] = 1;
    for (Int i = 0; i < N; i++) {
        cin >> A[i];
        S[i + 1] = S[i] + A[i];
        um[S[i + 1]]++;
    }
    Int ans = 0;
    for (const auto& p : um) ans += p.second * (p.second - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 11592
import math
a, b, c = map(int, input().split())
left = 0
right = (10 ** 9) ** 2 * 5

while left + 1 < right:
    mid = (left + right) // 2
    if mid * mid <= 4 * a * b:
        left = mid
    else:
        right = mid

if a + b  + right  <= c :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vi v(N);
    REP(i, N) cin >> v[i];

    vi s = v;
    sort(ALL(s), greater<>());

    REP(i, N) {
        if(v[i] == s[0]) print(s[1]);
        else print(s[0]);
    }
    
}


Measured memory_bytes: 4704
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

string toUpper(string s) {
	string t = s;
	for (int i = 0; i < s.size(); i++) {
		t[i] = toupper(s[i]);
	}
	return t;
}

int main()
{
	string target, source;

	cin >> target;
	target = toUpper(target);

	int cnt = 0;

	while (1) {
		cin >> source;
		if (source == "END_OF_TEXT")break;
		source = toUpper(source);
		if (target == source)cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        if (N % K == 0)
        {
            Console.WriteLine(0);
            return;
        }
        Console.WriteLine(1);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

typedef pair<pair<int, int>, int> P;
int n,c=0;
P p[200];
multiset<int> s;

int main(void){
    cin>>n;
    for(int i=0;i<n*2;i++){
        cin>>p[i].first.first>>p[i].first.second;
        p[i].second=i/n;
    }
    sort(p, p+n*2, greater<P>());
    /*
    for(int i=0;i<n*2;i++){
        cout<<p[i].second<<":"<<p[i].first.first<<","<<p[i].first.second<<endl;
    }
    */
    for(int i=0;i<n*2;i++){
        int y=p[i].first.second;
        if(p[i].second==0){ // R
            auto itr=s.upper_bound(y);
            if(itr!=s.end()){
                c++;
                s.erase(itr);
            }
        }else{ // B
            s.insert(y);
        }
    }

    cout<<c<<endl;

}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc166/tasks/abc166_c
//2020-05-03
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int dai_num, miti_num;
    cin >>  dai_num >> miti_num;
    int dai[100010];
    bool judge[100010];
    for(int i=0;i<100010;i++){
        judge[i]=true;
    }
    for(int i=0;i<dai_num;i++){
        cin >> dai[i];
    }
    int tmpa, tmpb;
    for(int i=0;i<miti_num;i++){
        cin >> tmpa >> tmpb;
        if(dai[tmpa-1]==dai[tmpb-1]){
            judge[tmpa-1]=false;
            judge[tmpb-1]=false;
        }else if(dai[tmpa-1]>dai[tmpb-1]){
            judge[tmpb-1]=false;
        }else{
            judge[tmpa-1]=false;
        }
    }
    int ans = 0;
    for(int i=0;i<dai_num;i++){
        if(judge[i]==true){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ans = 0

0.upto(N - 1) do |i|
  if A[i] <= (B[i] || 0)
    ans += A[i]

    np = B[i] - A[i]
    n = A[i + 1] <= np ? A[i + 1] : np
    ans += n
    A[i + 1] -= n
  else
    ans += B[i]
  end
end

puts ans


Measured memory_bytes: 15380
from typing import List


def manhattan_distance(student: List[int], check_point: List[int]) -> int:
    return abs(check_point[0] - student[0]) + abs(check_point[1] - student[1])


def answer(n: int, m: int, students: List[List[int]], check_points: List[List[int]]) -> str:
    students_destination = []
    for student in students:
        mds = {}
        for i, check_point in enumerate(check_points, start=1):
            md = manhattan_distance(student, check_point)
            if md not in mds.keys():
                mds[md] = str(i)
        students_destination.append(mds[min(mds.keys())])

    return '\n'.join(students_destination)


def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    cd = [list(map(int, input().split())) for _ in range(m)]
    print(answer(n, m, ab, cd))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10168
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int N, ind;
vector<ll> c;
vector<int> ans;
vector<vector<int>> G;

void dfs(int now) {
  ans[now] = c[ind++];
  for (int next : G[now]) {
    if (ans[next] != -1)
      continue;
    dfs(next);
  }
}

signed main() {
  cin >> N;
  vector<int> a(N - 1), b(N - 1);
  rep(i, N - 1) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  c = vector<ll>(N);
  rep(i, N) {
    cin >> c[i];
  }
  sort(all(c), greater<ll>());

  ll M = 0;
  repp(i, 1, N - 1) {
    M += c[i];
  }
  cout << M << "\n";

  G = vector<vector<int>>(N);
  rep(i, N - 1) {
    G[a[i]].pb(b[i]);
    G[b[i]].pb(a[i]);
  }

  ans = vector<int>(N, -1);
  ind = 0;

  dfs(0);
  cout << ans << "\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
} 

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   ll a[n];
   ll val = 0;
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      if(i > 1)
         val ^= a[i];
   }
   ll y = a[0] + a[1] - val;
   if(y < 0 || (y & 1))
      return cout << -1 , 0;
   y /= 2;
   if((y & val) || y > a[0])
      return cout << -1 , 0;
   for(int i = 50 ; i >= 0 ; i--){
      if(((1ll << i) & val) && y + (1ll << i) < a[0])
         y += (1ll << i);
   }
   if(y == 0)
      return cout << -1 , 0;
   cout << a[0] - y;
   return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
const int N = 15;
int main (void)
{
	int n , s[N] = {0} , h[N] = {0} , c[N] = {0} , d[N] = {0};
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++)
	{
		char a;
		int b;
		scanf(" %c %d" , &a , &b);
		
		if(a == 'S')
		{
			s[b - 1]++;
		}
		if(a == 'H')
		{
			h[b - 1]++;
		}
		if(a == 'C')
		{
			c[b - 1]++;
		}
		if(a == 'D')
		{
			d[b - 1]++;
		}
	}
	for(int i = 0 ; i < 13 ; i++)
	{
		if(s[i] == 0)
		{
			printf("S %d\n" , i+1);
		}
	}
	for(int i = 0 ; i < 13 ; i++)
	{
		if(h[i] == 0)
		{
			printf("H %d\n" , i+1);
		}
	}
	for(int i = 0 ; i < 13 ; i++)
	{
		if(c[i] == 0)
		{
			printf("C %d\n" , i+1);
		}
	}
	for(int i = 0 ; i < 13 ; i++)
	{
		if(d[i] == 0)
		{
			printf("D %d\n" , i+1);
		}
	}
	return 0;
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
                        
#define endl '\n'
#define int long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 
using namespace std;
int dp[105][100005];  
const int mod = 1e9 + 7;
int32_t main()
{
    IOS  //FRE
 
    int n, k;
    cin >> n >> k;
    if(k == 0)
        return cout << 1, 0;
    int arr[n];
    for(int i = 0; i < n; i++) 
        cin >> arr[i];
    dp[0][0] = 1;
    for(int i = 1; i < 100005; i++){
        if(i <= arr[0])
            dp[0][i] = 1;
        dp[0][i] += dp[0][i - 1];
        dp[0][i] %= mod;
    }

    for(int i = 1; i < n; i++)
        dp[i][0] = 1;

    for(int i = 1; i < n; i++){
        for(int j = 1; j < 100005; j++){
            if(j <= arr[i]){
                dp[i][j] = dp[i - 1][j];
                dp[i][j] %= mod;
            }
            else{
                dp[i][j] = dp[i - 1][j] - dp[i - 1][j - arr[i] - 1] + mod;
                dp[i][j] %= mod;
            }
        }
        for(int j = 1; j < 100005; j++){
            dp[i][j] += dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }
    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j <= k; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << (dp[n - 1][k] - dp[n - 1][k - 1] + mod) % mod;
   return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll mod=1e9+7;
ll p=1e9+7;
ll n,m;
ll KSM(ll a,ll b)
{
    ll s=1;
    while(b)
    {
        if(b&1)
            s=s*a%p;
        a=a*a%p;
        b>>=1;
    }
    return s;
}

ll c(ll n,ll m)
{
    if(m>n)
        return 0;
    int a=1,b=1;
    for(ll i=n-m+1; i<=n; i++)
        a=a*i%p;
    for(ll i=2; i<=m; i++)
        b=b*i%p;
    return a*KSM(b,p-2)%p;
}

ll lucas(ll n,ll m)
{
    int i,j;
    if(!m)
        return 1;
    else
        return (c(n%p,m%p)*lucas(n/p,m/p))%p;
}

int main()
{
    ll a,b;
    cin>>n>>a>>b;
    ll ans=KSM(2,n);
    ans-=lucas(n,a);
    ans%=mod;
    ans-=lucas(n,b);
    ans%=mod;
    ans-=1;
    ans%=mod;
    cout<<(ans+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

a_sum = [0] * (n+1)
for i in range(n):
    a_sum[i+1] = a_sum[i] + a[i]

min_ = 0
max_ = 2*10**5+1

for _ in range(50):
    tmp = (min_+max_)//2
    i,j = 0,n-1
    m_tmp = 0
    while(True):
        if(a[i] + a[j] >= tmp):
            m_tmp += n-i
            j -= 1
        else:
            i += 1

        if(i >= n)|(j < 0):
            break
    if(m_tmp >= m):
        min_ = tmp
    else:
        max_ = tmp

    if(max_-min_ == 1):
        break

tmp = min_
i,j = 0,n-1
m_tmp = 0
ans = 0
while(True):
    if(a[i] + a[j] >= tmp):
        m_tmp += n-i
        ans += a[j] * (n-i) + a_sum[-1] - a_sum[i]
        j -= 1
    else:
        i += 1

    if(i >= n)|(j < 0):
        break

ans -= min_ * (m_tmp - m)
print(ans)

Measured memory_bytes: 53752
<?php
$line=trim(fgets(STDIN));
$line=array_map('intval',explode(' ',$line));
if($line[0]<$line[1])
	echo "a < b\n";
elseif($line[0]>$line[1])
	echo "a > b\n";
else
	echo "a == b\n";

Measured memory_bytes: 6544
da = list(map(int, input().split()))
da = sorted(da)
ans = 0
ans += (da[2] - da[0]) // 2
da[0] += (da[2] - da[0]) // 2 * 2
ans += (da[2] - da[1]) // 2
da[1] += (da[2] - da[1]) // 2 * 2
da = sorted(da)
if da[0] == da[2]:
    pass
elif da[0] == da[1]:
    ans += 1
else:
    ans += 2
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){

	int k;
	char s[100]={0};

	scanf("%d",&k);
	scanf("%s",s);

	if(strlen(s) <= k){
		printf("%s",s);
	}else{
		char w[100];
		strncpy(w,s,k);
		w[k]='\0';
		printf("%s...",w);
	}

	return 0;
}



Measured memory_bytes: 1732