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

int main(void)
{
    long long int N;

    std::cin >> N;

    std::string ans;
#if 0
    for (int i = 1; i < 12; ++i)
    {
        if (N <= pow(26, i))
        {
            N = N - 1;
            for (int j = 0; j < i; ++j)
            {
                ans = ans + char('a' + N % 26);
                N = N / 26;
            }
            break;
        }
        else
        {
            N = N - pow(26, i);
        }
    }
#endif

    while (N > 0)
    {
        N = N - 1;
        ans = ans + char('a' + N % 26);
        N = N / 26;
    }
    std::reverse(ans.begin(), ans.end());
    std::cout
        << ans << "\n";
}


Measured memory_bytes: 3076
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second
#define pb push_back
using namespace std;
using ll=long long;
const ll maxn=2e5+5,inf = 1e18+18;
ll n,k,x,a[maxn],ps[maxn],l,r;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	x=300;
	x=min(x,k);
	while(x--){
		for(int i=0;i<=n+1;i++)ps[i]=0;
		for(int i=1;i<=n;i++){
			l=0;r=n+1;
			l=max(l,i-a[i]);
			r=min(r,i+a[i]+1);
			ps[l]++;
			ps[r]--;
		}
		for(int i=1;i<n+1;i++){
			ps[i]+=ps[i-1];
			a[i]=ps[i];
		}
	}
	for(int i=1;i<n+1;i++)cout<<a[i]<<' ';
}


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

int main()
{
  string a,b;
  int n,i;
  cin>>n;
  cin>>a>>b;
  string c="";
  for(i=0;i<n;i++)
  {
    c+=a[i];
    c+=b[i];
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
a, b, c, d = [int(i) for i in input().split()]
ans = b * d
ans = max(ans, a * d)
ans = max(ans, b * c)
ans = max(ans, a * c)
if a <= 0 and 0 <= b:
    ans = max(ans, 0)
if c <= 0 and 0 <= d:
    ans = max(ans, 0)
print(ans)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  map<ll,ll> mp;
  for(ll i = 1;i < 10;i++){
    for(ll j = 1;j < 10;j++){
      mp[i*j]++;
    }
  }
  ll N; cin >> N;
  if(mp[N] > 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3644
#include <iostream>

int main() {
	int N;
	std::cin >> N;
	int64_t L[100];

	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	std::cout << L[N] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

using namespace std;

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

int main(){
	while(1){
		int d,n,m;
		cin>>d;
		if(d==0)break;
		cin>>n>>m;
		
		vector<int> shop;
		shop.push_back(0);
		shop.push_back(d);
		
		rep(i,n-1){
			int a;
			cin>>a;
			shop.push_back(a);
		}
		
		sort(shop.begin(),shop.end());
		
		int ans=0;
		rep(i,m){
			int a;
			cin>>a;
			
			vector<int>::iterator b = upper_bound(shop.begin(),shop.end(),a);
			ans += min(*b-a,a-*(b-1));
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1436
fn main() {
    let mut input_iter = read_line_as_vector::<i64>().into_iter();
    let n = input_iter.next().unwrap();
    let k = input_iter.next().unwrap();
    let q = input_iter.next().unwrap();
    let mut num_right_ans = vec![0; n as usize];

    for _ in 0..q {
        let person: usize = read_line_as_value();
        num_right_ans[person-1] += 1;
    }

    for num in num_right_ans {
        let score = k - q + num;
        if score > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}


Measured memory_bytes: 2772
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
if n == 2:
    arr[0]=(arr[0]+arr[1])/2
else:
    for i in range(n-1):
        for j in range(n-2):
            arr[j]=(arr[j]+arr[j+1])/2
            arr[j+1]=arr[j+2]
print(arr[0])

Measured memory_bytes: 38640
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
int a,b,c,d,n,m;
signed main(){
    string s;
    cin >> s;
    cerr << s << endl;
    if((s[5]=='0'&&s[6]=='1') || (s[5]=='0'&&s[6]=='2') || (s[5]=='0'&&s[6]=='3') || (s[5]=='0'&&s[6]=='4')){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
 
    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc119.contest.atcoder.jp/tasks/abc119_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

using namespace std;

#define int			long long
#define double 		long double
#define pb			push_back
#define in 			insert
#define mp			make_pair
#define f			first
#define s			second
#define x			first
#define y			second
#define all(el)		el.begin(), el.end()
#define allr(el)	el.rbegin(), el.rend()
#define sz(el)		(int)el.size()
 
template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1ll;} else {return 0ll;}}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1ll;} else {return 0ll;}}

signed main() {
	
	#ifdef BarkovBG
		freopen("input.txt", "r", stdin);
	#endif

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n, m;
	cin >> n >> m;
	int ans = 0;
	ans += m * (m - 1);
	ans += n * (n - 1);
	cout << ans / 2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n";
#define nec cout<<"\n";continue; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007; 

int main()
{
    io();
	li x,y,co=0;
	cin>>x>>y;
	while(x--)
	{
	    li a,b,c;
		cin>>a>>b;
		double ans=sqrt(a*a+b*b);
		//ans=sqrt(ans);
		if(y*1.0>=ans)
		co++;	
	}
	cout<<co;
}

Measured memory_bytes: 3700
#include<stdio.h>
int max(int a, int b)
{
	return a > b ? a : b;
}
int isprime[100002];
int r[100002];
int main()
{
	int t;
	int a, b; char arr[20];
	isprime[0] = isprime[1] = 1;
	for (int i = 2; i < 100002; i++)
	{
		if (!isprime[i])
			for (int j = 2 * i; j <= 100002; j += i)
				isprime[j] = 1;
	}
	int sum = 0;
	for (int i = 0; i <= 100002; i++)
	{
		if (isprime[i] == 0 && isprime[(i + 1) / 2] == 0)
			sum++;
		r[i] = sum;
	}
	while (~scanf("%d", &t))
	{
		while (t--)
		{
			scanf("%d%d", &a, &b);
			printf("%d\n", r[b] - r[a - 1]);
		}
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int n;
    cin >> n;
    ll ar[n];
    for (int i = 0; i < n; ++i)
        cin >> ar[i];

    int a = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            a += ar[i] * ar[j];
        }

    cout << a/2;
    cn;
}


Measured memory_bytes: 3156
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

ll N;
ll Q;
vl c;
vl l;
vl r;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> Q;
    c = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> c[i];
    }
    l = vl(Q);
    r = vl(Q);
    for(int i = 0; i < Q; ++i){
        cin >> l[i];
        cin >> r[i];
    }
    solve();
}

// 1<= N,Q <= 5 × 10^5
// 1<= c_i <= N
// 1<= l_i <= r_i <= N
// 入力はすべて整数である。

#ifndef TEMPLATE_USED
#include "../template/template.hpp"
#endif

struct BinaryIndexedTree {
    int sz;
    vector<ll> data;

    BinaryIndexedTree(int sz):sz(sz){
        data.assign(sz,0);
    }

    void add(int x,ll val){
        while(x<sz)data[x]+=val,x|=x+1;
    }

    ll sum(int to){
        to=min(to,sz-1);
        ll ret=0;
        while(to>=0)ret+=data[to],to=(to&(to+1))-1;
        return ret;
    }

    ll sum(int from,int to){
        if(from>to)return 0;
        return sum(to)-sum(from-1);
    }
};

// ll N, ll Q, vl c, vl l, vl r
// Q 行出力せよ。i 行目には、i 番目のクエリに対する答えを出力せよ。
void solve(){
    rep(i,N)c[i]--;
    rep(i,Q)l[i]--,r[i]--;

    vvl qs(N);
    rep(i,Q)qs[r[i]].push_back(i);

    BinaryIndexedTree bit(N+5);
    vl ans(Q);
    vl pos(N,-1);
    rep(i,N){
        ll old_pos=pos[c[i]];
        if(old_pos!=-1)bit.add(old_pos,-1);
        bit.add(i,1);
        pos[c[i]]=i;

        for(ll j:qs[i]){
            ans[j]=bit.sum(l[j],r[j]);
        }
    }
    rep(i,Q)cout<<ans[i]<<endl;
}


Measured memory_bytes: 48920
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int t[2001][1001];
int p[2001][1001];

int main()
{
	int n, k;
	cin >> n>>k;
	for (int i = 1; i <= n; i++)
	{
		int x, y;
		char c;
		cin >> x >> y >> c;
		x += (c == 'W') * k;
		x %= (k * 2);
		y %= (k * 2);
		if (y >= k)
		{
			y -= k;
			x += k;
			x %= (k*2);
		}
		t[x][y]++;
	}
	for (int i = 0; i < k; i++)
	{
		for (int j = 0; j < k; j++)
		{
			p[0][i] += t[j][i];
		}
		for (int j = 1; j < 2 * k; j++)
		{
			p[j][i] = p[j - 1][i] - t[j - 1][i] + t[(j + k - 1) % (2 * k)][i];
		}
	}
	int maxx = 0;
	for (int i = 0; i < 2 * k; i++)
	{
		int tot = 0;
		for (int j = 0; j < k; j++)
		{
			tot += p[i][j];
		}
		maxx = max(maxx, tot);
		for (int j = 0; j < k - 1; j++)
		{
			tot = tot - p[i][j] + p[(i + k) % (2 * k)][j];
			maxx = max(maxx, tot);
		}
	}
	cout << maxx;
}

Measured memory_bytes: 15872
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	k := readInt()

	c := a
	if c < b {
		c = b
	}

	fs := make([]int, 0)
	for i := c; i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			fs = append(fs, i)
		}
	}

	println(fs[k-1])

}

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


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

vector<vector<char>> s;
vector<vector<int>> g;
int h, w;
vector<pint> dyx = {make_pair(-1,0),make_pair(0,1),make_pair(0,-1),make_pair(1,0)};

int bfs(int sy, int sx) {
    queue<pint> q;
    q.push(make_pair(sy,sx));

    pint u;
    int ux, uy, nx, ny;
    g.at(0).at(0) = 0;
    while(!q.empty()) {
        u = q.front(); q.pop();
        uy = u.first;
        ux = u.second;
        if(uy==h-1&&ux==w-1) { 
            return g.at(h-1).at(w-1);
        }
        for(auto idyx:dyx) {
            ny = uy + idyx.first;
            nx = ux + idyx.second;
            if(ny<0||ny>=h||nx<0||nx>=w) continue;
            if(g.at(ny).at(nx)!=-1) continue;
            if(s.at(ny).at(nx)=='#') continue;
            q.push(make_pair(ny, nx));
            g.at(ny).at(nx) = g.at(uy).at(ux) + 1;
        }
    }
    return -1;
}

int main(void) {
    cin >> h >> w;

    int white = 0;
    string stmp;
    s.resize(h, vector<char>(w));
    g.resize(h, vector<int>(w,-1));
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            cin >> s.at(ih).at(iw);
            if(s.at(ih).at(iw)=='.') white++;
        }
    }

    int ans, res;
    res = bfs(0, 0);
    if(res==-1) {
        cout << -1 << endl;
        return 0;
    }
    else {
        ans = white-res-1;
    }
    cout << ans << endl;
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
typedef vector<PT> Poly;
typedef pair<PT, PT> LS;
#define F first
#define S second
#define X real()
#define Y imag()
#define pb push_back

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

const int LEFT = 0, RIGHT = 1, BACK = 2, FRONT = 3, ON = 4;

inline bool Geq(ld a, ld b){ return a + EPS > b; }
inline bool Grt(ld a, ld b){ return a > b + EPS; }
inline bool Leq(ld a, ld b){ return a < b + EPS; }
inline bool Lss(ld a, ld b){ return a + EPS < b; }
inline bool Equ(ld a, ld b){ return Geq(a, b) && Geq(b, a); }

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

ld dot(PT a, PT b){ return real(conj(a)*b); }
ld cross(PT a, PT b){ return imag(conj(a)*b); }
ld sqlen(PT a){ return dot(a, a); }
ld len(PT a){ return sqrt(sqlen(a)); }

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

PT reflect(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + conj(c/b)*b;
}

PT rotate(PT a, PT b, ld theta){
	return (b-a)*polar<ld>(1, theta) + a;
}

int relpos(PT a, PT b, PT c){
	b -= a, c -= a;
	c /= b;
	if (Grt(c.imag(), 0)) return RIGHT;
	if (Lss(c.imag(), 0)) return LEFT;
	if (Lss(c.real(), 0)) return BACK;
	if (Grt(c.real(), 1)) return FRONT;
	return ON;
}

int side(PT a, PT b, PT c){
	b -= a, c -= a;
	ld cr = (c/b).Y;
	return Grt(cr, 0) ? 1 : (Lss(cr, 0) ? -1 : 0);
}

//If LineSegments Intersect
bool intersect(PT a, PT b, PT c, PT d){
	int as = side(c, d, a), bs = side(c, d, b), cs = side(a, b, c), ds = side(a, b, d);
	if (as && as == bs || cs && cs == ds) return false;
	else if (as || bs || cs || ds) return true;
	for (int j = 0; j < 2; j++, swap(a, c), swap(b, d)){
		ld mx = min(a.X, b.X), Mx = max(a.X, b.X), my = min(a.Y, b.Y), My = max(a.Y, b.Y);
		for (int k = 0; k < 2; k++, swap(c, d))
			if (Geq(c.X, mx) && Leq(c.X, Mx) && Geq(c.Y, my) && Leq(c.Y, My))
				return true;
	}
	return false;
}

//LineSegments Intersection (intersect is true)
PT intersection(PT a, PT b, PT c, PT d){
	ld c1 = cross(b-a, c-a), c2 = cross(b-a, d-a);
	return (c1*d - c2*c)/(c1-c2);
}

ld distLSP(PT a, PT b, PT c){
	int pos = relpos(a, b, proj(a, b, c));
	if (pos == BACK) return len(c-a);
	if (pos == FRONT) return len(c-b);
	b -= a, c -= a;
	return abs(imag(c/b))*len(b);
}

ld distLS(PT a, PT b, PT c, PT d){
	if (intersect(a, b, c, d)) return 0;
	return min(min(distLSP(a, b, c), distLSP(a, b, d)), min(distLSP(c, d, a), distLSP(c, d, b)));
}

ld signedArea(Poly poly){
	int n = poly.size();
	ld res = 0;
	for (int i = 0; i < n; i++)
		res += cross(poly[i], poly[(i+1)%n]);
	return res/2;
}

ld area(Poly poly){
	return abs(signedArea(poly));
}

int main(){	
	Poly poly;
	cout << setprecision(1) << fixed;
	for (int i = in(); i; i--){
		PT p;
		cin >> p;
		poly.pb(p);
	}
	cout << area(poly) << endl;
	return 0;
}


Measured memory_bytes: 3336
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[][][] ans = new double[n+1][n+1][n+1];

		for (int k=0;k<=n;k++) {
			for (int j=0;j<=n-k;j++) {
				for (int i=0;i<=n-k-j;i++) {
					if (i>0) {
						ans[i][j][k]+=((double)i/(i+j+k)*(ans[i-1][j][k]));
					}
					if (j>0) {
						ans[i][j][k]+=((double)j/(i+j+k)*(ans[i+1][j-1][k]));
					}
					if (k>0) {
						ans[i][j][k]+=((double)k/(i+j+k)*(ans[i][j+1][k-1]));
					}
					if (i+j+k>0) {
						ans[i][j][k]+=(double)n/(i+j+k);
					}
				}
			}
		}
		
		int[] init = new int[4];
		for (int i=0;i<n;i++) {
			init[sc.nextInt()]++;
		}
		
		System.out.println(ans[init[1]][init[2]][init[3]]);
	}

}


Measured memory_bytes: 302980
#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()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

struct four_pair
{
    int a, b, c, d;
}v[55];

int n, m, q;
int A[15];
int ans = 0;

void dfs(int x){
    if(x == n){
        int sum = 0;
        rep(i, q){
            if(A[v[i].b-1] - A[v[i].a-1] == v[i].c){
                sum += v[i].d;
            }
        }
        ans = max(ans, sum);
        return;
    }

    for (int i = A[x]; i <= m; ++i) {
        A[x+1] = i;
        dfs(x+1);
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cin >> n >> m >> q;

    rep(i, q){
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    }

    A[0] = 1;
    dfs(0);
    cout << ans << "\n";

    return 0;
}


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

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

  vector<int> cand = {135, 189, 105, 165, 195};
  sort(cand.begin(), cand.end());

  int n;
  cin >> n;
  cout << upper_bound(cand.begin(), cand.end(), n) - cand.begin() << '\n';
  return 0;
}

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

long long calc(long long a, long long b, long long c)
{
	long long x = max({ a, b, c });
	long long y = min({ a, b, c });

	return abs(x - y);
}

int main(void)
{
	long long H, W;
	cin >> H >> W;
	/*
	if (H % 3 == 0 || W % 3 == 0) {
		cout << "0" << endl;
		return 0;
	}
	*/
	long long min = 999999999999;
	long long S1, S2, S3, ans;
	for (int j = 0; j < 2; ++j) {
		for (int i = 1; i < H; ++i) {
			S1 = i * W;
			S2 = (H - i) / 2 * W;
			S3 = (H - i + 1) / 2 * W;
			ans = calc(S1, S2, S3);
			if (min > ans)	min = ans;

			S2 = (H - i) * (W / 2);
			S3 = (H - i) * ((W + 1) / 2);
			ans = calc(S1, S2, S3);
			if (min > ans)	min = ans;
		}
		int tmp = H;
		H = W;
		W = tmp;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N, K;
    cin >> N >> K;
    vi X(N, 0);
    rep(i, K)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int p;
            cin >> p;--p;
            X[p]++;
        }
    }
    int ans = 0;
    rep(i, N)
    {
        if(X[i] == 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <queue>
#include <vector>
#include <iostream>
#include <functional>

#pragma warning(disable : 4996)

#define INF (1 << 23)

using namespace std;

int main()
{
	int N, M, s, t, u, v;

	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &s); s--;
	scanf("%d", &t); t--;

	vector<vector<int> > G(N);

	for (int i = 0; i < M; i++)
	{
		scanf("%d", &u);
		scanf("%d", &v);

		G[u - 1].push_back(v - 1);
		G[v - 1].push_back(u - 1);
	}

	vector<int> d1(N, INF); d1[s] = 0;
	vector<int> d2(N, INF); d2[t] = 0;

	queue<int> que;

	que.push(s);

	while (!que.empty())
	{
		int node = que.front(); que.pop();

		for (int i = 0; i < G[node].size(); i++)
		{
			if (d1[G[node][i]] == INF)
			{
				d1[G[node][i]] = d1[node] + 1; que.push(G[node][i]);
			}
		}
	}

	que.push(t);

	while (!que.empty())
	{
		int node = que.front(); que.pop();

		for (int i = 0; i < G[node].size(); i++)
		{
			if (d2[G[node][i]] == INF)
			{
				d2[G[node][i]] = d2[node] + 1; que.push(G[node][i]);
			}
		}
	}

	int shortest = d1[t];

	vector<int> r1(shortest - 1, 0); for (int i = 0; i < N; i++) { if (d1[i] < shortest - 1) { r1[d1[i]]++; } }
	vector<int> r2(shortest - 1, 0); for (int i = 0; i < N; i++) { if (d2[i] < shortest - 1) { r2[d2[i]]++; } }

	long long ret = 0;

	for (int i = 0; i < shortest - 1; i++)
	{
		ret += 1LL * r1[i] * r2[shortest - i - 2];
	}
	
	printf("%lld\n", ret);

	return 0;
}

Measured memory_bytes: 10208
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#include <numeric>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> path(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> path[i][j];
        }
    }

    vector<vector<int>> root(h, vector<int>(w, 0));
    bool flag = true;
    for(int i=0; i<w; i++){
        if(path[0][i] == '#'){
            flag = false;
            continue;
        }
        root[0][i] = flag;
    }
    flag = true;
    for(int i=0; i<h; i++){
        if(path[i][0] == '#'){
            flag = false;
            continue;
        }
        root[i][0] = flag;
    }

    for(int i=1; i<h; i++){
        for(int j=1; j<w; j++){
            if(path[i][j] == '#') continue;
            root[i][j] = ((lint)root[i-1][j] + root[i][j-1]) % 1000000007;
        }
    }

    COUT(root.back().back());
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    set<string> v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.insert(s);
    }
    
 cout<<v.size();
    return 0;
}

Measured memory_bytes: 19176
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
	  



	string s; cin >> s;
	for (int i = 0; i < 19; i++){
		if (s[i] != ',')
			cout << s[i];
		else
			cout << " ";

	}
		return 0;
	
}


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

signed main(){
  int N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  int l=max(A-B,B-A);
  int k=(N-1)*D;
  int out=0;
  int x;
  for(int i=0;i<N;i++){
    x=k-i*D*2;
    if(l>=x-(N-1-i)*(D-C)&&l<=x+i*(D-C))out++;
  }
  if(out)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a, b, h, m;
double ans;
int main(){
	cin>> a>> b>> h>> m;
	double fen= m*6;
	double shi= h*30 + m*0.5;
	double cha= fabs(fen - shi);
	if(cha > 180){
		cha= 360- cha; 
	}
	ans= sqrt(a*a + b*b - 2*a*b*cos(cha*acos(-1.0)/180));
	printf("%.15lf\n", ans);
	return 0;
}

Measured memory_bytes: 4104
N, K = gets.chomp.split.map(&:to_i)
MOD = 998244353

LRs = []
K.times do
    LRs << gets.chomp.split.map(&:to_i)
end

dp = Array.new(3*N, 0)

LRs.each do |l, r|
    dp[l] += 1
    dp[l] %= MOD
    dp[r+1] -= 1
    dp[r+1] %= MOD
end

(1..N).each do |i|
    LRs.each do |l, r|
        dp[i+l] += dp[i]
        dp[i+l] %= MOD
        dp[i+r+1] -= dp[i]
        dp[r+r+1] %= MOD
    end
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
end

puts dp[N-1]

Measured memory_bytes: 19024
#include <stdio.h>
#include <string>
#include <vector>
#include <tuple>

int main(int argc, char* argv[]){
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d %d %f\n",
        a / b,
        a % b,
        double(a) / double(b)
    );
}


Measured memory_bytes: 2748
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 50021
#define MAX_SQRT_N 224

int
main(int argc, char **argv)
{
	bool prime[MAX_N + 1];
	int n;
	int i, j;

	for (i = 0; i <= MAX_N; ++i)
		prime[i] = true;

	for (i = 2; i <= MAX_SQRT_N; ++i)
	{
		if (prime[i])
		{
			for (j = i + i; j <= MAX_N; j += i)
				prime[j] = false;
		}
	}

	while (scanf("%d", &n) != EOF)
	{
		for (i = n - 1; i >= 0; --i)
		{
			if (prime[i])
				break;
		}

		int l = i;
		for (i = n + 1; i <= MAX_N; ++i)
		{
			if (prime[i])
				break;
		}

		printf("%d %d\n", l, i);
	}

	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
const int N=500010;
int n,k,a[N],p[N];
int T[N<<1];
int idx(int l,int r){return l+r|l!=r;}
void update(int l,int r,int p,int num){
    int x=idx(l,r),mid=(l+r)>>1;
    if(l==r){T[x]=num;return;}
    if(p<=mid)update(l,mid,p,num);
    else update(mid+1,r,p,num);
    T[x]=max(T[idx(l,mid)],T[idx(mid+1,r)]);
}
int query(int l,int r,int L,int R){
    int x=idx(l,r),mid=(l+r)>>1,res=0;
    if(L<=l&&r<=R)return T[x];
    if(L<=mid)res=max(res,query(l,mid,L,R));
    if(mid<R)res=max(res,query(mid+1,r,L,R));
    return res;
}
int d[N];
vector<int> v[N];
void topsort(){
    set<int> s;
    for(int i=1;i<=n;i++)if(!d[i])s.insert(i);
    for(int i=1;i<=n;i++){
        int x=p[i]=*s.begin(); s.erase(s.begin());
        for(auto y:v[x])if(!(--d[y]))s.insert(y);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        p[a[i]]=i;
    }
    for(int i=1;i<=n;i++){
        int t=query(1,n,max(1,p[i]-k+1),p[i]);
        if(t)v[p[t]].push_back(p[i]),d[p[i]]++;
        t=query(1,n,p[i],min(n,p[i]+k-1));
        if(t)v[p[t]].push_back(p[i]),d[p[i]]++;
        update(1,n,p[i],i);
    }
    topsort();
    for(int i=1;i<=n;i++)a[p[i]]=i;
    for(int i=1;i<=n;i++)printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 48512
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    cout << string(w + 2, '#') << endl;
    rep(i, 0, h)
    {
        string s;
        cin >> s;
        cout << "#"+s+"#" << endl;
    }
    cout << string(w + 2, '#') << endl;
    return 0;
}

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

using namespace std ;

const int MAXN = 3e3 + 100 ; 

vector<int> ver[MAXN] ;
int a[MAXN] ; 
bool dp[MAXN] ; 
void dfs(int v , int par = -1){
	dp[v] = false ; 
	for(auto u : ver[v]){
		if(u == par) continue ; 
		dfs(u , v) ;
		if(a[v] > a[u] && !dp[u]) dp[v] = true ; 
	}
}
int32_t main() {	
	ios_base::sync_with_stdio(0) ; 
	cin . tie(0) ; cout . tie(0) ; 

	int n ; cin >> n ; 
	for(int i = 0 ; i < n ; i ++)
		cin >> a[i] ; 
	for(int i = 1 ; i < n ; i ++){
		int x , y ; cin >> x >> y ; 
		x -- , y -- ; 
		ver[x] . push_back(y) ; 
		ver[y] . push_back(x) ; 
	}
	for(int i = 0 ; i < n ; i ++){
		dfs(i) ; 
		if(dp[i]) cout << i + 1 << ' ' ; 
	}
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
//#include<bits/stdc++.h>
#include <iostream>
#include<vector>
#include<set>
#include<iterator>
#include<string>
#include<map>
#include<stack>
#include<cmath>
#include<algorithm>
#include <cstdio>
#include<cstdlib>
#include <cstring>
#include <unordered_map>
#include <iomanip>
#include <queue>
#include<numeric>
#define baap_coder17 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define   lli long long int
#define ld long double
#define  endl "\n"
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ui unsigned int
#define mt make_tuple
#define t_(t)[(i)]  get<(i)>((t))
#define vsort(v) sort((v).begin(), (v).end())
#define vsortr(v) sort((v).rbegin(), (v).rend())
#define all(v)  (v).begin(), (v).end()
#define rall(v)  (v).rbegin(), (v).rend()
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ld EPSILON=0.000000001;
const ld mod=1e9+7;
const lli AM=2e5+5;
const ld pi=3.14159265358979323846;
lli max(lli a,lli b){if(a>b)return a;else return b;}
using namespace std;
lli fact(lli n) {lli ans=1; for(lli i=1;i<=n;i++) ans*=i; return ans;}
lli powm(lli a, lli b, lli n){lli x=1, y=a; while (b > 0) {if (b%2 == 1) {x = (x*y) % n; } y = (y*y) % n; b /= 2;}return x % n;}
lli pow(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); y = y >> 1; x = ((x) * (x)); } return res; }
lli min(lli a,lli b) {if(a>b)return b;else return a;}
bool cmp(ld x,ld y){if(abs(x-y)<=EPSILON)return 1;return 0;}
 bool checkprime(lli n){ for(lli i=2;i*i<=n;i++) if(n%i==0)return false;   return true;}
//lli gcd(lli a, lli b){return b ? gcd (b, a % b) : a;}
 int fun(pair<lli,lli> p1,pair<lli,lli> p2)
{
    if(p1.X<=p2.X)
        return 1;
    return 0;
}
//lli lcm(lli a, lli b) { return (a * b) / gcd(a, b); }
//lli modInverse(lli a, lli m) { lli g = gcd(a, m); return powm(a, m - 2, m); }

int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}





int main()
{
    lli n,d;cin>>n>>d;
    int cnt=0;
    while(n--)
    {
        lli x,y;cin>>x>>y;
        if(abs(x*x+y*y)<=abs(d*d))
            cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3156
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  int K,N;
  cin>>N>>K;
  vi A(N);
  Rep(i,N){cin >>A[i];}
  SortA(A);
  intl res=0;
  Rep(i,K){
    res += A[i];
  }
  cout <<res;
}

Measured memory_bytes: 3660
void main() {
    dchar[] n = readln.chomp.to!(dchar[]);
    auto g = n.group.array;
    writeln(g.any!(t => t[1] >= 3) ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
    for (int k = 1; k <= n; k++) {
        sum += gcd(gcd(i, j), k);
    }
    }
    }
    cout << sum << endl;
           
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l,r,d,ans=0;cin>>l>>r>>d;
  for(ll i=l;i<=r;i++) {
    if(i%d==0) ans++;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod_add(int A, int B) { return (A + B) % MOD; }
int mod_sub(int A, int B) { return (A + MOD - B) % MOD; }
int mod_mul(int A, int B) { return ((A % MOD) * (B % MOD)) % MOD; }
int mod_bipow(int X, int Y) {
    if (Y == 0) return 1;
    else if (Y == 1) return X % MOD;
    else if (Y % 2 == 0) {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(Z, Z);
    } else {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(mod_mul(Z, Z), X);
    }
}
int mod_inv(int X) { return mod_bipow(X, MOD - 2); }
int mod_div(int A, int B) { return mod_mul(A, mod_inv(B)); }

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct vertex {
  vector<int> adj = vi(0);
};

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  vi a(n);
  REP(i, n) {
    cin >> a[i];
  }
  SORT(a);
  int index = lower_bound(ALL(a), (a[n - 1] + 1) / 2) - begin(a);
  if (index > 0) {
    ans = abs(a[index] - (a[n - 1] + 1) / 2) < abs(a[index - 1] - a[n - 1] / 2)
      ? index : index - 1;
  }


  cout << a[n - 1] << " " << a[ans] << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 1408
# 2019/03/09
# AtCoder Beginner Contest 121 - B

# Input
n, m, c = map(int,input().split())
b = list(map(int, input().split()))
a = list()

cnt = 0
for idx in range(n):
    a.append(list(map(int, input().split())))

    sum = c
    for idx_2 in range(m):
        sum += a[idx][idx_2]*b[idx_2]
    
    if sum > 0:
        cnt += 1

# Output
print(cnt)


Measured memory_bytes: 3060
N, MOD = gets.split.map(&:to_i)
s = gets.chomp.reverse

ans = 0
if MOD == 2 || MOD == 5
    for i in 0...N do
        ans += (N-i) if s[i].to_i % MOD == 0
    end
else
    cnt = Array.new(MOD, 0)
    total = 0
    coef = 1

    for i in 0...N do
        cnt[total] += 1
        total = (s[i].to_i * coef + total) % MOD
        ans += cnt[total]
        coef = (coef * 10) % MOD

        #p "i:#{i} ai:#{s[i]} coef:#{coef} total:#{total} ans:#{ans} cnt[#{total}]:#{cnt[total]}"
    end
end

puts ans

Measured memory_bytes: 3836
import queue

di = [0,1,0,-1]
dj = [1,0,-1,0]

h, w = map(int, input().split())
field = [input() for i in range(h)]
pdist = [[1000]*w for i in range(h)]
sdist = [[1000]*w for i in range(h)]

pque = queue.Queue()
sque = queue.Queue()
for i,row in enumerate(field):
    for j in range(w):
        if row[j] is '@':
            pque.put((i,j))
            pdist[i][j] = 0
            pi = i
            pj = j
        if row[j] is '$':
            sque.put((i,j))
            sdist[i][j] = 0
        if row[j] is '%':
            gi = i
            gj = j

while not sque.empty():
    i,j = sque.get()
    for k in range(4):
        ni = i+di[k]
        nj = j+dj[k]
        if ni >=0 and ni < h and nj >= 0 and nj < w:
            if (field[ni][nj] is not '#') and sdist[ni][nj] > sdist[i][j]+1:
                sdist[ni][nj] = sdist[i][j]+1
                sque.put((ni,nj))

while not pque.empty():
    i,j = pque.get()
    for k in range(4):
        ni = i+di[k]
        nj = j+dj[k]
        if ni >=0 and ni < h and nj >= 0 and nj < w:
            if (field[ni][nj] is not '#') and pdist[ni][nj] > pdist[i][j]+1 and pdist[i][j]+1 < sdist[ni][nj]:
                pdist[ni][nj] = pdist[i][j]+1
                pque.put((ni,nj))

if pdist[gi][gj] < 1000:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 10028
#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[4000][4000];
int a[8000];
int solve(int l, int r)
{
	if(l > r || l <= 0 || r <= 0)
		return 0;
	if(l == r)
		return a[l];
	if(dp[l][r] != -1)
		return dp[l][r];
	if(r - l + 1 == 2)
		return max(a[l], a[r]);
	return dp[l][r] = max(a[l] + min(solve(l + 2, r), solve(l + 1, r - 1)), a[r] + min(solve(l + 1, r - 1), solve(l, r - 2)));
}
signed main()
{
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	for(int i = 0; i < n + 4; i++)
		for(int j = 0; j < n + 4; j++)
			dp[i][j] = -1;
	for(int i = 1; i <= n; i++)
		dp[i][i] = a[i];
	cout << 2*solve(1, n) - (sum)<< endl;
	
}


Measured memory_bytes: 94336
import java.util.Scanner;
import java.util.Arrays;

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

    s = s.replaceAll("eraser", "-");
    s = s.replaceAll("erase", "-");
    s = s.replaceAll("dreamer", "-");
    s = s.replaceAll("dream", "-");
    s = s.replaceAll("-", "");
    
    if (s.length() == 0) {
      ans = "YES";
    } else {
      ans = "NO";
    }
    System.out.println(ans);
    sc.close();
    return;
  }
}

Measured memory_bytes: 43084
#include <stdio.h>

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

Measured memory_bytes: 2608
#pragma comment(linker, "/STACK:1073741824")
#pragma GCC optimize("Ofast")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std;
using namespace placeholders;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<bool, bool> pbb;
typedef pair<ld, ld> pdd;

const int inf = (int)1e9 + 9;
const ll linf = (ll) 1e18;
const ld eps = 1e-9;
const int mod = (int) 1e9 + 7;
const int smod = 16769023;
const ll lmod = 27644437;
const ld pi = acos(-1);

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vi kek(n);
	for (int i = 0; i < n; i++)
	{
		cin >> kek[i];
	}
	sort(it(kek));
	reverse(it(kek));
	ll a = 0, b = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2)
		{
			b += kek[i];
		}
		else
		{
			a += kek[i];
		}
	}
	cout << a - b;
}

Measured memory_bytes: 256
// for AtCoder
"use strict";(function(){let n,t,i;this.input?n=this.input:"function"==typeof require&&(n=require("fs").readFileSync("/dev/stdin","utf8"));let o=0;this.debug=function t(i){"object"==typeof i?t(i[0]):n=i.trim()},this.next=s,this.nextNumber=function(){return+s()},this.write=function(n){void 0===n&&(n="");var t=(r+=n).match(/([\s\S]*)\n([^\n]*)/);t&&(log(t[1]),r=t[2])},this.flush=function(n){void 0===n&&(n="");""!=(r+=n)&&(log(r),r="")},this.getLine=function(){t||(t=n.split(/[\n\r]+/));return i=null,t[e++]},this.log=console.log.bind(console),this.err=console.error.bind(console);let e=0,r="";function s(){return t||(t=n.split(/[\n\r]+/)),(!i||i.length-1<=o)&&(o=0,i=t[e++].split(/\s+/)),i[o++]}function u(n,t,i){for(var o=n;o<t&&i(o)!==BREAK;o++);}function l(n,t,i){for(var o=t-1;o>=0&&i(o)!==BREAK;o--);}this.FOR=u,this.RFOR=l,this.REP=function(n,t){u(0,n,t)},this.RREP=function(n,t){l(0,n,t)},this.CONTINUE=0,this.BREAK=1,this.range=function n(t,i){if(void 0===i)return n(0,t);return Array.apply(null,{length:i-t}).map((n,t)=>t)},"function"==typeof main&&main()}).call("undefined"!=typeof window?window:global);
//

let a=nextNumber()
let b=nextNumber()
let c=nextNumber()
log(Math.floor((a+b)*c/2))


Measured memory_bytes: 7372
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] n = new int[101];
		int[] m = new int[101];
		
		while(sc.hasNext()){
			n[sc.nextInt()]++;
		}
		
		m = Arrays.copyOf(n,101);
		Arrays.sort(m);
		for(int i=0;i<101;i++){
			if(n[i]==m[100]){
				System.out.println(i);
			}
		}
	
	}	
}

Measured memory_bytes: 18164
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

bool power_of_two(int n){
    return ((n&(n-1))==0);

}

void solve(){

    string s;
    cin >> s;
    
    int f = 0;
    
    for(int i =0;i<s.size();i++){
        f = (f+s[i]-'0')%9;
    }
    if(!f)cout << "Yes" << endl;
    else cout << "No" << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 
    

Measured memory_bytes: 3772