akhauriyash/Code-Regression huggingface dataset:
/* include */
#include <bits/stdc++.h>

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int H, W;    // input
  string ans;  // output

  int i, j;    // subscript
  int target_cnt, achieve_cnt;
  int count;

  int right, bottom;
  int left,  top;


  /* Input, Array_Proclamation */
  cin >> H >> W;
  vector< vector<char> > s    (H+2, vector<char>(W+2, '.'));
  vector< vector<bool> > board(H+1, vector<bool>(W+1, false));


  for(i=1; i<H+1; i++)
  {
    for(j=1; j<W+1; j++)
    {
      cin >> s.at(i).at(j);
    }
  }


  /* Initialize */
  target_cnt  = 0;
  achieve_cnt = 0;
  count       = 0;


  /* Calculation */
  for(i=1; i<H+1; i++)
  {
    for(j=1; j<W+1; j++)
    {
      if( s.at(i).at(j) == '#' )
      {

        // target_cnt++;
        right  = i+1;
        bottom = j+1;

        left   = i-1;
        top    = j-1;

        if(s.at(right).at(j) == '.' && s.at(left).at(j) == '.' && s.at(i).at(top) == '.' && s.at(i).at(bottom) == '.' )
        {
          count++;
        }

        
        // if( s.at(right).at(j) == '#' && s.at(i).at(bottom) == '#' )
        // {

        //   achieve_cnt += 3;

        //   if(board.at(i).at(j) == true)
        //   {
        //     achieve_cnt--;
        //   }
        //   if(board.at(right).at(j) == true)
        //   {
        //     achieve_cnt--;
        //   }
        //   if(board.at(i).at(bottom) == true)
        //   {
        //     achieve_cnt--;
        //   }

        //   board.at(i).at(j)      = true;
        //   board.at(right).at(j)  = true;
        //   board.at(i).at(bottom) = true;

        // }
        // else if( s.at(right).at(j) == '#' )
        // {
        //   achieve_cnt += 2;

        //   if(board.at(i).at(j) == true)
        //   {
        //     achieve_cnt--;
        //   }
        //   if(board.at(right).at(j) == true)
        //   {
        //     achieve_cnt--;
        //   }

        //   board.at(i).at(j)      = true;
        //   board.at(right).at(j)  = true;

        // }
        // else if( s.at(i).at(bottom) == '#' )
        // {
        //   achieve_cnt += 2;

        //   if(board.at(i).at(j) == true)
        //   {
        //     achieve_cnt--;
        //   }
        //   if(board.at(i).at(bottom) == true)
        //   {
        //     achieve_cnt--;
        //   }

        //   board.at(i).at(j)      = true;
        //   board.at(i).at(bottom) = true;

        // }

      }
    }
  }

  // if(target_cnt == achieve_cnt)
  if(count == 0)
  {
    ans = "Yes";
  }
  else
  {
    ans = "No";
  }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N, K;
    scanf("%d %d", &N, &K);
    int D[K];
    for(int i = 0; i < K; ++i){
        scanf("%d", D + i);
    }
    int n_ok = 10 - K;
    vector<int> ok_to_use;
    for(int i = 0; i < 10; ++i){
        if(!binary_search(D, D + K, i)) ok_to_use.push_back(i);
    }
    int tmp;
    for(int i = 0; i < n_ok; ++i){
        if(ok_to_use[i] >= N){
            printf("%d\n", ok_to_use[i]);
            return 0;
        }
    }
    for(int j = 0; j < n_ok; ++j){
        for(int i = 0; i < n_ok; ++i){
            tmp = 10*ok_to_use[j] + ok_to_use[i];
            if(tmp >= N){
                printf("%d\n", tmp);
                return 0;
            }
        }
    }
    for(int k = 0; k < n_ok; ++k){
        for(int j = 0; j < n_ok; ++j){
            for(int i = 0; i < n_ok; ++i){
                tmp = 100*ok_to_use[k] + 10*ok_to_use[j] + ok_to_use[i];
                if(tmp >= N){
                    printf("%d\n", tmp);
                    return 0;
                }
            }
        }
    }
    for(int l = 0; l < n_ok; ++l){
        for(int k = 0; k < n_ok; ++k){
            for(int j = 0; j < n_ok; ++j){
                for(int i = 0; i < n_ok; ++i){
                    tmp = 1000*ok_to_use[l] + 100*ok_to_use[k] + 10*ok_to_use[j] + ok_to_use[i];
                    if(tmp >= N){
                        printf("%d\n", tmp);
                        return 0;
                    }
                }
            }
        }
    }
    for(int m = 0; m < n_ok; ++m){
        for(int l = 0; l < n_ok; ++l){
            for(int k = 0; k < n_ok; ++k){
                for(int j = 0; j < n_ok; ++j){
                    for(int i = 0; i < n_ok; ++i){
                        tmp = 10000*ok_to_use[m] + 1000*ok_to_use[l] + 100*ok_to_use[k] + 10*ok_to_use[j] + ok_to_use[i];
                        if(tmp >= N){
                            printf("%d\n", tmp);
                            return 0;
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}

string s;

int main(){
	cin>>s;
	if(s=="RSR") cout<<1<<endl;
	else{
		int t=0;
		for(int i=0;i<3;i++) if(s[i]=='R') t++;
		cout<<t<<endl;
	}
}

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

int main() {
	long long n[99999],num,i,ans=0;
	cin>>num;
	for(i=0;i<num;i++){
		cin>>n[i];
	}
	sort(n,n+num);
	cout<<n[0]<<" ";
	for(i=0;i<num;i++){
		ans=ans+n[i];
	}
	cout<<n[num-1]<<" "<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3220
N,Q = map(int,input().split())
S = input()

list = [0]*(N+1)

for i in range(N):
    list[i+1] = list[i] + 1 if S[i:i+2] =='AC' else list[i]

for i in range(Q):
    l,r = map(int,input().split())
    print(list[r-1]-list[l-1])

Measured memory_bytes: 6060
#include <iostream>

int main()
{
    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;
    if (x < r || y < r || x > w - r || y > h - r)
    {
        std::cout << "No" << std::endl;
    }
    else
    {
        std::cout << "Yes" << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(),c = sc.nextLong(), d = sc.nextLong();
		long ans = b/c - a/c;
		if(a%c == 0) {
			ans++;
		}
		ans += b/d - a/d;
		if(a%d == 0) {
			ans++;
		}
		long cd = lcm(c,d);
		ans -= b/cd - a/cd;
		if(a%cd == 0) {
			ans--;
		}
		System.out.println(b - a + 1 - ans);
	}

	static long gcd(long a, long b) {
		if(a%b == 0)return b;
		else return gcd(b, a%b);
	}

	static long lcm(long a, long b) {
		return a * b / gcd(a,b);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32828
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

int main(){
    int n;
    while(cin>>n && n){
        vector<int> sq;
        for(int i=1;i<=n/2;i++){
            sq.push_back((i*i)%n);
        }
        sort(all(sq));
        sq.erase(unique(all(sq)),sq.end());
        int ans[5000]={};
        rep(i,sq.size()){
            rep(j,sq.size()){
                int t=sq[i],u=sq[j];
                int x=min(abs(t-u),n-abs(t-u));
                ans[x]++;
            }
        }
        for(int i=1;i<=n/2;i++){
            cout<<ans[i]<<endl;
        }
    }
}

Measured memory_bytes: 1296
main = do 
    n <- readLn :: IO Int
    {-}
    let day = case n of 
        25 -> "Christmas"
        24 -> "Christmas Eve"
        23 -> "Christmas Eve Eve"
        22 -> "Christmas Eve Eve Eve"
    putStrLn str
    -}
    putStrLn $ getAns n 

getAns :: Int -> String
getAns n 
    | n==22 = "Christmas Eve Eve Eve"
    | n==23 = "Christmas Eve Eve"
    | n==24 = "Christmas Eve"
    | n==25 = "Christmas"


    -- なぜ上のcase文が通らない

Measured memory_bytes: 508
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut aseq = vec![0; n];
    let mut cnts = HashMap::<i32, usize>::new();
    for i in 0..n {
        aseq[i] = read::<i32>();
        *cnts.entry(aseq[i]).or_insert(0) += 1;
    }
    let mut ans = 0;
    for &v in cnts.keys() {
        let mut sum = cnts[&v];
        if let Some(&cnt) = cnts.get(&(v - 1)) {
            sum += cnt
        }
        if let Some(&cnt) = cnts.get(&(v + 1)) {
            sum += cnt
        }
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
void main() {
  auto n = ri;
  n %= 10;
  if (n == 0) writeln("pon");
  if (n == 1) writeln("pon");
  if (n == 2) writeln("hon");
  if (n == 3) writeln("bon");
  if (n == 4) writeln("hon");
  if (n == 5) writeln("hon");
  if (n == 6) writeln("pon");
  if (n == 7) writeln("hon");
  if (n == 8) writeln("pon");
  if (n == 9) writeln("hon");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
  return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
  return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
  auto res = new T[][](height, width);
  foreach(i; 0..height) {
    res[i] = readAs!(T[]);
  }
  return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
  auto res = new T[][](height, width);
  foreach(i; 0..height) {
    auto s = rs;
    foreach(j; 0..width) res[i][j] = s[j].to!T;
  }
  return res;
}

int ri() {
  return readAs!int;
}

long rl() {
  return readAs!long;
}

double rd() {
  return readAs!double;
}

string rs() {
  return readln.chomp;
}

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

using namespace std;

int main()
{
    int n,i=0,temp=0;
    scanf("%d",&n);
    unsigned long a[n],x[2];
    unsigned long long area;
    for(i;i<n;i++)
    {
        scanf("%lu",&a[i]);
    }
    sort(a,a+n,greater<unsigned long>());
    i=0;
    for(i;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            x[temp]=a[i];
            temp++;
            i++;
        }

        if(temp==2)
            break;
    }
    if(temp==2)
    {
        area=x[0]*x[1];
        printf("%llu" , area);
    }
    else
        printf("0");




}


Measured memory_bytes: 1024
#include<stdio.h> 

int main()
{     
	int a[100],i,b;    
	 scanf("%d",&b);    
	 for(i=0;i<b;i++)
	{         
		scanf("%d",&a[i]);     
	}    
	 for(i=b-1;i>=0;i--)
	{         
	if(i!=b-1)
	 printf(" ");        
	 printf("%d",a[i]);    
	 }     
	printf("\n");  
		 return 0;
 }

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    long double ans=0,n,k;
    cin>>n>>k;
    for(long double i=1;i<=n;i++){
        long double a,now;
        now=1.0;
        a=i;
        while(a<k){
            a*=2;
            now/=2;
        }
        ans+=now;
    }
    ans/=n;
    printf("%.13Lf",ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import itertools

N=input()
xy=[ map(int, sys.stdin.readline().split()) for _ in range(N)]

P=list(itertools.permutations(range(N)))
pattern_num=len(P)


total=0

for L in P:
    l=0    #長さ
    for i,n in enumerate(L):
        if i==0:
            pass
        else:
            x2=xy[n][0]
            y2=xy[n][1]
            x1=xy[prev_n][0]
            y1=xy[prev_n][1]
            l+=( (x2-x1)**2+(y2-y1)**2 )**0.5
        prev_n=n
    total+=l

print total/pattern_num

Measured memory_bytes: 38172
import math
import sys
input = sys.stdin.readline().rstrip

a, b, C = map(float, input().split())
C = math.radians(C)

S = a * b * math.sin(C) / 2
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
h = b * math.sin(C)

print(S)
print(L)
print(h)



Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double x_h, y_h, x_m, y_m;
	double theta_h, theta_m;

	double ans;

	theta_m = (double)M * (360.0 / 60.0);		//deg
	theta_h = (double)(H + M/60.0) * (360.0 / 12.0);
	
	x_h = (double)A * sin(theta_h * PI / 180.0);
	x_m = (double)B * sin(theta_m * PI / 180.0);
	y_h = (double)A * cos(theta_h * PI / 180.0);
	y_m = (double)B * cos(theta_m * PI / 180.0);

	ans = sqrt((x_h - x_m) * (x_h - x_m) + (y_h - y_m) * (y_h - y_m));

	printf("%20.20f\n", ans);

	return 0;
}


Measured memory_bytes: 4152
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#define MAXN 5010
#define MOD 1000000007
int n;
std::vector<int> next[MAXN];
int d[MAXN], size[MAXN], f[MAXN][MAXN][2], g[MAXN][MAXN][2], h[MAXN][2];
inline void up(int &x, int y) {
	if ((x += y) >= MOD) x -= MOD;
}
void dfs(int x, int fa) {
	f[x][1][0] = size[x] = 1;
	for (int y : next[x]) {
		if (y == fa) continue;
		dfs(y, x);
		for (int i = 1; i <= size[x] + size[y]; i++) g[x][i][0] = g[x][i][1] = 0;
		for (int i = 1; i <= size[x]; i++) {
			for (int j = 1; j <= size[y]; j++) {
				up(g[x][i][0], 1LL * f[x][i][1] * f[y][j][0] % MOD * d[j] % MOD);
				up(g[x][i][0], 1LL * f[x][i][0] * f[y][j][1] % MOD * d[j] % MOD);
				up(g[x][i][1], 1LL * f[x][i][0] * f[y][j][0] % MOD * d[j] % MOD);
				up(g[x][i][1], 1LL * f[x][i][1] * f[y][j][1] % MOD * d[j] % MOD);
				up(g[x][i + j][0], 1LL * f[x][i][0] * f[y][j][0] % MOD);
				up(g[x][i + j][0], 1LL * f[x][i][1] * f[y][j][1] % MOD);
				up(g[x][i + j][1], 1LL * f[x][i][0] * f[y][j][1] % MOD);
				up(g[x][i + j][1], 1LL * f[x][i][1] * f[y][j][0] % MOD);
			}
		}
		for (int i = 1; i <= size[x] + size[y]; i++) f[x][i][0] = g[x][i][0], f[x][i][1] = g[x][i][1];
		size[x] += size[y];
	}
}
int ans = 0;
int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), next[u].push_back(v), next[v].push_back(u);
	d[0] = 1;
	d[1] = 0;
	for (int i = 2; i <= n; i++) d[i] = 1LL * d[i - 2] * (i - 1) % MOD;
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		up(ans, 1LL * f[1][i][0] * d[i] % MOD);
		up(ans, MOD - (1LL * f[1][i][1] * d[i] % MOD));
	}
	printf("%d\n", ans);
	return 0;
}

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
int n;
int a[100500];
int mn = 899999, mx;

map<int, int> cnt;

int main(){/*
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);*/

cin >> n;
for(int i=1;i<=n;i++){
    cin >> a[i];
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);

    cnt[a[i]]++;
}
if(mn + 2 == mx){
    cout << "No";
    return 0;
}
if(mn == mx){
    if(mn ==  n - 1){
        cout << "Yes";
    }
    else{
        if(mx <= n / 2){
            cout << "Yes";
        }
        else cout << "No";
    }
    return 0;
}
if(cnt[mn] < mx && 2 * (mx - cnt[mn]) <= cnt[mx]){
    cout << "Yes";
}
else cout << "No";

return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int n, m, v, p, a[N], b[N], k;
bool check(int ind){
	int x = a[ind] + m;
	int vv = v - 1, pp = p;
	k = 0;
	for(int i = 0; i < n; i++){
		if(i == ind)
			continue;	
		if(a[i] > x)
			pp--, vv--;				
		else
			b[k++] = x - a[i];
	}
	if(pp <= 0)
		return 0;
	if(vv <= 0)	
		return 1;	
	if(vv - pp + 1 <= 0)
		return 1;
	vv -= pp - 1;
	ll sum = 0;
	sort(b, b + k);
	for(int i = pp - 1; i < k; i++)
		sum += min(m, b[i]);
	if(sum < 1ll * vv * m)
		return 0;
	return 1;
}

int main()
{
	scanf("%d%d%d%d", &n, &m, &v, &p);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	int l = 0, r = n - 1;
	while(l <= r){
		int m = (l + r) >> 1;
		if(!check(m))
			l = m + 1;
		else
			r = m - 1;
	}
	printf("%d", n - l);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool pair_sort1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool pair_sort2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool pair_sort3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool pair_sort4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

int main() {
	int n;
	ll k;
	cin >> n >> k;
	ll count = 0;
	vector<pair<int, int>>ab(n);
	int ans = 0;
	rep(i, n) {
		cin >> ab[i].first >> ab[i].second;
	}
	sort(all(ab), pair_sort1);
	rep(i, n) {
		count += ab[i].second;
		if (count >= k) {
			ans = ab[i].first;
			break;
		}
	}
	cout << ans << endl;
}

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

int n, q;
vector<int> G[200010]; 
int d[200010];

void dfs(int v, int p, int sum){
    d[v] += sum;
    for(auto i : G[v]){
        if(i == p) continue;
        dfs(i, v, d[v]);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    while(q--){
        int p, x;
        cin >> p >> x;
        p--;
        d[p] += x;
    }
    dfs(0, -1, 0);
    rep(i, 0, n){
        if(i) cout << " ";
        cout << d[i];
    }
    cout << endl;
}

Measured memory_bytes: 24320
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

long long power(long long _n,long long _k, long long _mod)
{
	long long r=1;
	while(_k) {
		if(_k&1) {
			r = ((r * _n) % _mod);
		}
		_n = ((_n * _n) % _mod);
		_k>>=1;
	}
	return (r % _mod);
}

inline int add(int _a, int _b)
{
	_a += _b;
	if(_a >= MOD)
	{
		_a -= MOD;
	}
	return _a;
}

inline int mul(int _a, int _b)
{
	return (long long) _a * _b % MOD;
}

int N, A, B, C, D;
int dp[1003][1003];
int dp2[1003][1003];
int comb[2003][2003];

void pre()
{
	for(int i = 0; i < 2003; i++)
	{
		comb[i][0] = 1;
		for(int j = 1; j <= i; j++)
		{
			comb[i][j] = add(comb[i - 1][j], comb[i - 1][j - 1]);
		}
	}
}

int getWays(int groups, int groupSize)
{
	if(groups == 0)
		return 1;

	int &ret = dp2[groups][groupSize];
	if(ret != -1)
		return ret;
	ret = mul(comb[groups * groupSize][groupSize], power(groups, MOD - 2, MOD));
	ret = mul(getWays(groups - 1, groupSize), ret);
	return ret;
}

int rec(int people, int groupSize)
{
	if(groupSize > B)
	{
		if(people == 0)	return 1;
		return 0;
	}

	int &ret = dp[people][groupSize];
	if(ret != -1)
		return ret;
	// cerr << people << " " << groupSize << "\n";
	ret = rec(people, groupSize + 1);

	for(int i = C; i <= D; i++)
	{
		int peopleIncluded = i * groupSize;
		if(peopleIncluded > people)
			break;
		int thisAns = rec(people - peopleIncluded, groupSize + 1);
		thisAns = mul(thisAns, comb[people][peopleIncluded]);
		thisAns = mul(thisAns, getWays(i, groupSize));
		ret = add(ret, thisAns);
	}

	return ret;
}


int main()
{
	int i, j;

	pre();
	mem(dp, -1);
	mem(dp2, -1);

	fl(i,0,1001)
	{
		fl(j,0,1001)
		{
			if(i * j < 1003)
				getWays(i, j);
		}
	}

	si(N);	si(A);	si(B);	si(C);	si(D);

	printf("%d\n", rec(N, A));

	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  int ans = 0;
  rep(i, s.size()/2) {
    ans+=s[i]!=s[s.size()-i-1];
  } cout << ans;
}


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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int power(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(power(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int divide(int a, int b) {
  return mul(a, power(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

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

  int n;
  cin >> n;
  vector<int> cnt(62);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    for (int j = 0; j < 62; ++j) {
      if (((a >> j) & 1) == 0) {
        ans = add(ans, mul(power(2, j), cnt[j]));
      } else {
        ans = add(ans, mul(power(2, j), i - cnt[j]));
      }
    }
    for (int j = 0; j < 62; ++j) {
      cnt[j] += ((a >> j) & 1);
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+1;
int r[N];
int c[N];
int n,m,k;
int rr[N];
int cc[N];
struct node{
	int x,y;
	node(int _x,int _y){
		x=_x,y=_y;
	}
	bool operator <(const node &a)const{
		if(a.x!=x)
		return a.x<x;
		else return a.y<y;
	};
};
map<node,int> st;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	while(k--){
		int x,y;
		scanf("%d%d",&x,&y);
		r[x]++;
		c[y]++;
		node s=node(x,y);
		st[s]=1;
	}
	int maxn=0;
	int sum=0;
	int tot=0;
	for(int i=0;i<N;i++){
		if(r[i]==maxn){
			rr[++tot]=i;
		}else if(r[i]>maxn){
			tot=0;
			rr[++tot]=i;
			maxn=r[i];
		}
	}
	sum+=maxn;
	maxn=0;
	int to=0;
	for(int i=0;i<N;i++){
		if(c[i]==maxn){
			cc[++to]=i;
		}else if(c[i]>maxn){
			to=0;
			cc[++to]=i;
			maxn=c[i];
		}
	}
	sum+=maxn;
	int f=0;
	for(int i=1;i<=tot;i++){
		for(int j=1;j<=to;j++){
			node sk=node(rr[i],cc[j]);
			if(!st[sk]){
			f=1;
			break;
			}
		}
		if(f)break;
	}
	if(f)
	cout<<sum<<endl;
	else
	cout<<sum-1<<endl;
}

Measured memory_bytes: 27040
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>sa;
	a=0;
	for(i=0;i<sa.size()/2;i++){
		if(sa[i]!=sa[sa.size()-i-1])a++;
	}
	cout<<a<<endl;
}

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

using namespace std;

int main()
{
    long long int N,H;cin >> N>>H;
    long long int A[N];
    vector<long long> B;
    for(long long int a = 0;a < N;a++){
        long long b;
        cin >> A[a]>>b;
        B.push_back(b);
    }
    long long int ippon = 0;
    for(long long int a = 0;a < N;a++){
        ippon = max(ippon,A[a]);
    }
    long long int s = 0;
    sort(B.begin(),B.end());
    for(long long int a = B.size()-1;a >= 0;a--){
        //cout<<B.at(a)<<" "<<ippon<<endl;
        if(B.at(a) > ippon){
            H-=B[a];
            s++;
            if(H<=0)break;
        }
    }
    long long int ans = s;
    //cout<<s<<endl;
    if(H > 0){
    if(H%ippon == 0){
        cout<<(H/ippon) + ans<<endl;
    }else{
        cout<<(H/ippon)+1 + ans<<endl;
    }
    }else{
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n;
    cin>>n;
    string s[n];
    for(i=0;i<n;i++) cin>>s[i];
    int AC,WA,TLE,RE;
    AC=WA=TLE=RE=0;
    for(i=0;i<n;i++){
    	if(s[i]=="AC") AC++;
    	if(s[i]=="WA") WA++;
    	if(s[i]=="TLE") TLE++;
    	if(s[i]=="RE") RE++;
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
	return 0;
}

Measured memory_bytes: 6764
k,n = map(int,input().split())
a = list(map(int,input().split()))

dist = []
for i in range(n):
    if i == n-1:
        dist.append(abs((k-a[n-1])+a[0]))
    else:
        dist.append(abs(a[i+1]-a[i]))

dist.sort()

min_dist = 0
for i in range(n-1):
    min_dist += dist[i]

print(min_dist)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		SortedSet<String> ss = new TreeSet<String>();
		for (int i=0;i<n;i++) {
			for (int j=i;j<n && j<i+5; j++) {
				ss.add(s.substring(i, j+1));
			}
		}
		
		int k = sc.nextInt();
		System.out.println(ss.toArray()[k-1]);
	}

}


Measured memory_bytes: 25172
n = int(input())
data = list(map(int, input().split()))
data.sort()
#全て正の時の処理
if data[0] > 0:
    print(sum(data) - data[0] * 2)
    k = data[0]
    for i in range(1,n - 1):
        print("{} {}".format(k, data[i]))
        k -= data[i]
    print("{} {}".format(data[-1], k))
#すべて負の場合の処理
elif data[-1] <= 0:
    print(-sum(data) + (data[-1] * 2))
    k = data[-1]
    for i in range(n - 1):
        print("{} {}".format(k, data[i]))
        k -= data[i]
#それ以外
else: 
    print(sum(list(map(lambda x:abs(x), data))))
    max_data = data[-1]
    min_data = data[0]
    i = 1
    while data[i] <= 0:
        print("{} {}".format(max_data,data[i]))
        max_data -= data[i]
        i += 1
    while i < n - 1:
        print("{} {}".format(min_data, data[i]))
        min_data -= data[i]
        i += 1
    print("{} {}".format(max_data, min_data))


    




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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	string s,u;
	t = 1;
	while(t--) {
	 cin >> s;
	 u = s;
	 reverse(s.begin( ), s.end( ));
	 if(s == u)
	  cout << "Yes" << endl;
	 else
	  cout << "No" << endl;
	}
	return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<double> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }

  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1.0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i + 1; j++) {
      dp[i + 1][j + 1] += dp[i][j] * P[i];
      dp[i + 1][j] += dp[i][j] * (1 - P[i]);
    }
  }

  double res = 0.0;
  for (int i = (N + 1) / 2; i < N + 1; i++) {
    res += dp[N][i];
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll X, K;
    cin >> X >> K;
    vector<ll> r(K+1);
    r[0] = 0;
    REP(i, K) cin >> r[i+1];
    vector<ll> a(K+1), b(K+1), c(K+1);
   	a[0] = 0;
   	b[0] = 0;
   	c[0] = X;

   	REP(i, K){
   		ll delta = r[i+1] - r[i];
   		if(i%2==0){
   			a[i+1] = max(a[i]-delta, 0ll);
   			b[i+1] = min(b[i]+max(delta-a[i], 0ll), c[i]);
   			c[i+1] = c[i];
   		}else{
   			a[i+1] = min(a[i]+delta, X);
   			b[i+1] = b[i];
   			c[i+1] = max(c[i]-max(delta-(X-(a[i]+c[i]-b[i])), 0ll), b[i]);
   		}
   	}

   	/*
   	cout << a << endl;
   	cout << b << endl;
   	cout << c << endl;
	*/

    ll Q;
    cin >> Q;
    while(Q--){
    	ll t, p;
    	cin >> t >> p;
    	int idx = upper_bound(r.begin(), r.end(), t) - r.begin();
    	idx--;
    	ll res = 0;
    	if(p<=b[idx]) res = a[idx];
    	else if(p>=c[idx]) res = a[idx] + c[idx] - b[idx];
    	else res = a[idx] + p - b[idx];
    	ll delta = t - r[idx];
    	if(idx%2==0) res = max(res-delta, 0ll);
    	else res = min(res+delta, X);
    	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    if(a>b){
	printf("a > b\n");
    }
     if(a<b){
	printf("a < b\n");
    }
    if(a==b){
	printf("a == b\n");
    }
    return (0);
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
int mem[100010];

int dp(int x) {
	if(mem[x] != -1) return mem[x];
	set <int> s;
	for(int i = 1; i <= x; i++) {
		int ans = 0;
		for(int j = 1; j < i; j++) {
			ans ^= dp(x - j);
		}
		s.insert(ans);
	}
	int res = 0;
	while(s.count(res)) {
		++res;
	}
	return mem[x] = res;
}

long long fn(long long x) {
	long long ans = 1;
	while(x % 2 == 0) {
		ans <<= 1;
		x >>= 1;
	}
	return ans;
}

struct node {
	node *a[2];
	bool leaf;
	int height;
	node () {
		for(int i = 0; i < 2; i++) {
			a[i] = NULL;
		}
		leaf = false;
		height = 0;
	}
} *root;

void insert(string s) {
	node* cur = root;
	int dis = 0;
	for(int i = 0; i < s.size(); i++) {
		int c = s[i] - '0';
		if(cur -> a[c] == NULL) {
			cur -> a[c] = new node();
		}
		cur = cur -> a[c];
		cur -> height = ++dis;
	}
	cur -> leaf = true;
}

vector <int> v;

void dfs(node* cur) {
	int cnt = 0;
	for(int i = 0; i < 2; i++) {
		if(cur -> a[i]) {
			++cnt;
			dfs(cur -> a[i]);
		}
	}
	if(cnt == 1) {
		v.push_back(cur -> height);
	}		
}




int main(int argc, char const *argv[])
{
	root = new node();
	int n;
	long long L;
	cin >> n >> L;
	for(int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		insert(s);
	}
	dfs(root);

	long long ans = 0;
	for(auto i : v) {
		ans ^= fn(L - i);
	}
	if(ans) {
		cout << "Alice" << endl;
	} else {
		cout << "Bob" << endl;
	}
	return 0;
}








Measured memory_bytes: 5628
a,b=map(int,input().split())
import fractions
n=fractions.gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
#print(factorization(n))
if factorization(n)==[[1,1]]:
  print(1)
else:
  print(len(factorization(n))+1)

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)

using namespace std;
using ll = long long;

void solve(ll x) {
  ll ans = x / (6 + 5) * 2;
  x %= (6 + 5);
  if (x > 0) {
    x -= 6;
    ans++;
  }
  if (x > 0) {
    x -= 5;
    ans++;
  }
  cout << ans << endl;
}

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

  ll x;
  cin >> x;

  solve(x);

  return 0;
}


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

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

    vector<int> cnt(M, 0);
    int k = 0;
    int a = 0;
    for(int i = 0; i < N; i++){
        cin >> k;
        for(int i = 0; i < k; i++){
            cin >> a;
            cnt[a-1]++;
        }
    }

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	int c;
	int t;
	cin >> a >> b >> c;
	if(a > b){
		t = a;
		a = b;
		b = t;
	} 
	if(b > c){
		t = b;
		b = c;
		c = t;
	}
    if (a > b){
		t = a;
		a = b;
		b = t;
	}
	cout << a;
	cout << " ";
	cout << b;
	cout << " ";
	cout << c;
	cout <<"\n";
		return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int INF = 200000005;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 16;
int x[maxn][maxn], y[maxn][maxn], a[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  
  int ans = 0;
  for (int i = 1; i < 1 << n; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        for (int k = 0; k < a[j]; k++) {
          if (((i >> x[j][k]) & 1) != y[j][k]) {
            ok = false;
          }
        }
      }
    }
    if (ok) ans = max(ans, (int)bitset<32>(i).count());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,*a=map(int,open(0).read().split())
    a.sort(reverse=1)
    while len(a)>1:
        tmp=a.pop()
        a[-1]=(a[-1]+tmp)/2
    print(*a)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5608
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    int T, X;
    double answer;

    cin >> T >> X;
    
    answer = (double) T / X;

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  if(a==b&&b!=c){
    printf("Yes\n");
  }else if(b==c&&c!=a){
    printf("Yes\n");
  }else if(c==a&&a!=b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	string t;
	cin >> t;
	int n = s.size();
	int k = t.size();
	if (n < k) {
		cout << "UNRESTORABLE" << endl;
		return;
	}

	for (int i = n - 1; i >= 0; i--) {
		bool b = true;
		for (int j = 0; j < k; j++) {
			if (s[i - j] == '?' || s[i - j] == t[k - 1 - j]) continue;
			b = false;
		}
		if (b) {
			string ans = "";
			for (int j = 0; j < i - k + 1; j++) {
				if (s[j] == '?') ans += 'a';
				else ans += s[j];
			}
			ans += t;
			for (int j = i + 1; j < n; j++) {
				if (s[j] == '?') ans += 'a';
				else ans += s[j];
			}
			cout << ans << endl;
			return;
		}
	}
	cout << "UNRESTORABLE" << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // 

    // freopen("output.out", "w", stdout);

    string s;
    cin >> s;

    cout << (s.back() == 's' ? s + "es" : s+'s');

    return 0;
}

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

int main() {
    int n, m;
    cin >>n >>m;
    vector<int> t(n);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >>a >>b;
        t.at(a-1)++;
        t.at(b-1)++;
    }
    for (int i = 0; i < n; i++) {
        cout << t.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, g;
	int[] a, b, n;

	void run(){
		for(;;){
			m=sc.nextInt();
			if(m==0){
				break;
			}
			a=new int[m];
			b=new int[m];
			for(int i=0; i<m; i++){
				a[i]=sc.nextInt();
				b[i]=sc.nextInt();
			}
			g=sc.nextInt();
			n=new int[g];
			for(int i=0; i<g; i++){
				n[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[] dp=new int[1001];
		int[] dp2=new int[1001];
		dp[0]=1;
		for(int j=0; j<m; j++){
			System.arraycopy(dp, 0, dp2, 0, 1001);
			for(int i=0; i<b[j]; i++){
				for(int k=1000-a[j]*(i+1); k>=0; k--){
					dp[k+a[j]*(i+1)]+=dp2[k];
				}
			}
		}
		for(int i=0; i<g; i++){
			println(""+dp[n[i]]);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
    while(getline(cin, s)){
        if(s == "END OF INPUT")return 0;
        int cnt = 1;
        for(int i = 1;i <(int)s.size();i++){
            if(('a' <= s[i] && s[i] <= 'z') || ('A' <= s[i] && s[i] <= 'Z')){
                cnt++;
            }else{
                cout << cnt;
                cnt = 0;
            }
        }
        if(cnt)cout << cnt;
        cout << endl;
    }
}


Measured memory_bytes: 2980
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  unsigned N;
  std::cin >> N;
  std::vector<std::vector<bool>> a(N, std::vector<bool>(N));
  std::vector<std::pair<unsigned, unsigned>> cnt_vec(N);
  std::vector<bool> row(N, false);
  std::vector<bool> colum(N, false);
  bool no_zero = false;
  for (unsigned i = 0; i < N; ++i) {
    unsigned cnt = 0u;
    for (unsigned j = 0; j < N; ++j) {
      char tmp;
      std::cin >> tmp;
      a[i][j] = tmp == '#';
      if (a[i][j]) ++cnt;
      if (a[i][j]) {
        row[j] = true;
        colum[i] = true;
        no_zero = true;
      }
    }
    cnt_vec[i] = std::make_pair(cnt, i);
  }
  if (!no_zero) {
    std::cout << -1;
    return 0;
  }
  std::sort(cnt_vec.begin(),
            cnt_vec.end(),
            [](std::pair<unsigned, unsigned> i, std::pair<unsigned, unsigned> j) {
              return i.first > j.first;
            }
  );
  unsigned ans = INT32_MAX;
  for (unsigned i = 0; i < N; ++i) {
    if (row[cnt_vec[i].second]) {
      ans = std::min(ans, N - cnt_vec[i].first);
      break;
    } else if (colum[cnt_vec[i].second]) {
      ans = std::min(ans, N - cnt_vec[i].first + 1);
    }
  }
  for (unsigned i = 0; i < N; ++i) {
    for (unsigned j = 0; j < N; ++j) {
      if (!a[j][i]) {
        ++ans;
        break;
      }
    }
  }
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()


int main() {
    int64_t N, time = 0;
    cin >> N;
    vector<pair<int,int>> BA(N);
    for (int i = 0; i < N; i++) {
        cin >> BA.at(i).second >> BA.at(i).first;
    }
    sort(ALL(BA));
    for (int i = 0; i < N; i++) {
        if (BA.at(i).first < time + BA.at(i).second) {
            cout << "No" << endl;
            return 0; 
        }
        else {
            time += BA.at(i).second;
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  int p0,p1,p2;
  int count=0;

  cin >> n;
  cin >> p0 >> p1;
  for(int i=0; i<n-2; i++) {
    cin >> p2;
    if(p0<p1 && p1<p2) count++;
    if(p0>p1 && p1>p2) count++;
    p0=p1; p1=p2;
  }
  cout << count << endl;
}


Measured memory_bytes: 256