akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
vector<int> ans;

int main () {
  cin >> N;

  if (N == 3) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(63);
  } else if (N <= 15002) {
    ans.push_back(3);
    ans.push_back(9);

    int m = N - 2;
    int k = m / 3;
    int amari = m % 3;

    rep(i, k) {
      ans.push_back(i * 6 - 4);
      ans.push_back(i * 6 - 2);
      ans.push_back(i * 6);
    }

    if (amari == 1) {
      ans.push_back((k+1)*6);
    } else if (amari == 2) {
      ans.push_back((k+1)*6 - 4);
      ans.push_back((k+1)*6 - 2);
    }
  } else {
    ans.push_back(3);
    ans.push_back(9);

    if (N % 2 == 0) {
      rep(i, 15000) {
        ans.push_back(i * 2);
      }
    } else {
      rep(i, 14999) {
        ans.push_back(i * 2);
      } 
    }

    int noko = N - ans.size();

    rep(i, noko) {
      ans.push_back(i * 6 + 9);
    }
  }

  printv(ans);
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    uint64_t sum=0;
    for(int i=0;i<n-k;i++){
        sum+=h[i];
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(){
    int cap[8] = {1, 4, 1, 4, 1, 2, 1, 2}, p[8];
    while( cin >> p[0] ){
        for(int i = 1; i < 8; i++) cin >> p[i];
        int minv = 10000000;
        vector<int> mem;
        for(int i = 0; i < 8; i++){
            int ms = 0;
            vector<int> tmp;
            for(int j = 0; j < 8; j++){
                ms += (p[j] - cap[(j+i)%8]) < 0 ? 0 : (p[j]-cap[(j+i)%8]);
                tmp.push_back( cap[(j+i)%8] );
            }
            if( ms < minv ){
                minv = ms;
                mem = tmp;
            }else if( ms == minv && tmp < mem ){
                mem = tmp;
            }
        }
        vector<int>::iterator it = mem.begin();
        cout << *it;
        while( (++it) != mem.end() ) cout << ' ' << *it;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> x;
    for(int i=0;i<n;i++){
        int xi;
        cin>>xi;
        x.push_back(xi);
    }
    
    int ans = INT_MAX;
    for(int i=1;i<=100;i++){
        int sum=0;
        for (auto xi:x){
            sum+=pow((xi-i),2);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>

using namespace std;

int main(){
	string s;
	cin>>s;
	long long cnt = 0;
	long long ans = 0;
	for(int i=s.length()-1;i>=0;i--){
		if(s[i] == 'A') {
			ans += cnt;
		} else if(s[i] == 'C') {
			if(i > 0) {
				if(s[i-1] == 'B') {
					i-=1;
					cnt++;
				} else {
					cnt = 0;
				}
			}
		} else {
			cnt = 0;
		}
	}

	cout<<ans<<endl;
	return 0;

}


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

bool loop(int &N,int &Y) {
  int tmp1, tmp2;
  for (int i = 0; i <= N; i++){
    tmp1 = Y - 10*i;
    for (int j = 0; j <= N-i; j++) {
      tmp2 = tmp1 - 5*j;
      if (tmp2 == N-i-j) {
        cout << i << " " << j << " " << tmp2 << endl;
        return false;
      }
    }
  }
  return true;
}

int main() {
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;



  if (loop(N,Y)) {
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 3616
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n    = Integer.parseInt(scanner.nextLine());
		List<Restaurant> list = new ArrayList<Restaurant>();

		for(int i = 1; i <= n; i++) {

			String name = scanner.next();
			int score   = scanner.nextInt();
			list.add(new Restaurant(name, score, i));

		}


        Collections.sort(list);
        for(Restaurant res: list){
        	System.out.println(res.num);
        }

	}

	public static class Restaurant implements Comparable<Restaurant>{

		String machi;
		int score;
		int num;

		public Restaurant(String machi, int score, int num) {

			this.machi = machi;
			this.score = score;
			this.num   = num;
		}

		public int compareTo(Restaurant other) {

			int ans = this.machi.compareTo(other.machi);
			if(ans != 0) return ans;

			return Integer.compare(other.score,this.score);

		}
	}
}

Measured memory_bytes: 35992
#include <stdio.h>

void judge(int x, int y, int z);
int pow2(int x);

int main(void)
{
    int dataset;
    scanf("%d", &dataset);

    int side1, side2, side3;
    while (dataset--){
        scanf("%d %d %d", &side1, &side2, &side3);
        judge(side1, side2, side3);
    }

    return 0;
}

void judge(int x, int y, int z)
{
    enum {YES, NO} yn;
    if (pow2(x) == pow2(y) + pow2(z)){
        yn = YES;
    } else if (pow2(y) == pow2(z) + pow2(x)){
        yn = YES;
    } else if (pow2(z) == pow2(x) + pow2(y)){
        yn = YES;
    } else {
        yn = NO;
    }

    if (yn == YES){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

int pow2(int x)
{
    return x * x;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

int main(){
    int N;
    string S;
    cin>>N>>S;
    vector<char> l,r;
    for(int i=0;i<N;i++) {l.push_back(S.at(i)); r.push_back(S.at(2*N-1-i));}
    vector<char> l2=l,r2=r;
    sort(l2.begin(),l2.end());
    sort(r2.begin(),r2.end());
    bool okay=true;
    for(int i=0;i<N;i++) if(l2.at(i)!=r2.at(i)) okay=false;
    ll ans=0;
    //cout<<l.size()<<endl;
    if(okay){
        unordered_map<string,ll> mp;
        for(int bit=0; bit<(1<<N); bit++){
            string R,B;
            for(int i=0;i<N;i++){
                if(bit & (1<<i)) R.push_back(l.at(i));
                else B.push_back(l.at(i));
            }
            
            R+='.';
            R+=B;
            if(!mp[R]) mp[R]=1;
            else mp[R]++;
        }
        /*for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        cout << "key = " << itr->first           // キーを表示
                        << " val = " << itr->second <<endl;    // 値を表示
        }*/

        for(int bit=0; bit<(1<<N); bit++){
            string R,B;
            for(int i=0;i<N;i++){
                if(bit & (1<<i)) R.push_back(r.at(i));
                else B.push_back(r.at(i));
            }
            R+='.';
            R+=B;
            if(mp[R]) ans+=mp[R];
        }

    }

    cout<<ans<<endl;


}

Measured memory_bytes: 75636
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)




Measured memory_bytes: 84812
#include<stdio.h>

int main(void){
  int i;
  int stu,pres[30];

  for(i=0;i<30;i++)
    pres[i]=0;
  for(i=0;i<28;i++){
    scanf("%d",&stu);
    pres[stu-1]=1;
  }
  for(i=0;i<30;i++)
    if(pres[i]==0)
      printf("%d\n",i+1);
  return 0;
}

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

int main() {
    long long int N, sum=0,a=0,b=0;
    scanf("%lld", &N);
    cin >> a;
    for(int i = 1;i<N;i++){
        cin >> b;
        if(a - b > 0) {
            sum = sum + a - b;
        } else {
            a = b;
        }
    }
    printf("%lld\n", sum);
}

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


int main(void){
    long long n;
    cin >> n;
    string t = "abcdefghijklmnopqrstuvwxyz";
    stack<int> s;
    
    
    while( 1 ){
        n--;
        s.push(n%26);
        n /= 26;
        if(n == 0)break;
    }
    
    while(!s.empty()){
        cout << t[s.top()];
        s.pop();
    }
}


Measured memory_bytes: 3636
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) swap(a, b); while (b) swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    ll n = s.size();
    ll k; cin >> k;

    if (n == 1) {
        cout << k / 2 << endl;
        return 0;
    }
    
    bool is_looped = s.front() == s.back();
    vector<ll> rl;
    for (ll i = 0; i < n; ) {
        ll j = i++;
        while ((i < n && s[i] == s[i-1])) i++;
        rl.push_back(i-j);
    }

    if (rl.size() == 1) {
        cout << n * k / 2 << endl;
        return 0;
    }

    ll ans = 0;
    for (ll len : rl) ans += len / 2;
    ans *= k;

    if (is_looped) {
        ans -= (rl.back() / 2 + rl.front() / 2) * (k - 1);
        ans += (rl.back() + rl.front()) / 2 * (k - 1);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = 3.14159265358979323846;
 
int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
    }
    ll ans=0;
    ll max_num=v[0];
    rep2(i,1,n){
        if (v[i]<max_num){
            ans+=max_num-v[i];
        }
        else{
            max_num=v[i];
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4764
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if((i+j)%2 == 0)System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
}

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

int main(){
    int m,n;
    priority_queue<int> que;

    while(cin>>n>>m,m|n){
        int sum=0;

        for(int i=0;i<n;i++){
            int p;
            cin>>p;
            que.push(p);
        }

        vector<int> bag;

        while(que.size()){
            int p=que.top();que.pop();
            bag.push_back(p);
            if(que.empty() || bag.size()==m){
                for_each(bag.begin(),bag.end(),[&sum](int v){sum += v;});
                if(bag.size()==m) sum-=p;
                bag.clear();
            }
        }

        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int h, w;
char field[72][72];
int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
bool ans = true;
bool flag = false;
void dfs(int x, int y) {
	field[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx&&nx < w && 0 <= ny && ny < h && field[nx][ny] == '#') { flag = true; dfs(nx, ny); }
	}
	if (!flag) { ans = false;  }
	return ;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> field[j][i];
		}
	}
	for (int i = 0; i < w; i++) {
		rep(j, h) {
			flag = false;
			if (field[i][j] == '#') {
				dfs(i, j);
				/*for (int a = 0; a < w; a++) {
					for (int b = 0; b < h; b++) {
						cout << field[a][b];
					}
					cout << endl;
				}*/
			}
		}
	}
	//bool flag = true;
	/*rep(i, w) {
		rep(j, h) {
			if (field[i][j] == '#') { flag = false; cout << "No" << endl; return 0; }
		}
	}*/
	
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
	
		cout << "No" << endl;
	}return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

//最大積載量Pのk台のトラックで何個の荷物を積めるか
int check(llong P){
    int i=0;
    for(int j=0; j<k; j++){
        llong s=0;
        while(s+T[i] <= P){
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000; //荷物の個数　x 1個当たりの最大重量
    llong mid;
    while(right - left >1){
        mid = (right+left)/2;
        int v = check(mid); // mid == Pを決めて何個積めるかチェック
        if(v>=n) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i =0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3972
#include<stdio.h>

int main(){
  int n,i;
  int F[50];

  scanf("%d",&n);

  F[0]=F[1]=1;
  for(i=2;i<=n;i++)
    F[i]=F[i-1]+F[i-2];

  printf("%d\n",F[n]);

  return 0;
}



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

using namespace std;


int main() {
	
	int index = 0;

	int N;

	std::vector<string> v;

	cin >> N;

	string S;

	for (int i = 0; i < N; i++)
	{
		cin >> S;
		v.push_back(S);
	}

	for (int i = 0; i < N-1; i++)
	{

		if ( v[i].back() != v[i + 1].front() )
		{
			cout << "No" << endl;
			return 0;
		}

	}

	sort(v.begin(), v.end());

	for (int i = 0; i < N - 1; i++)
	{

		if (v[i] == v[i + 1] )
		{
			cout << "No" << endl;
			return 0;
		}

	}


	cout << "Yes" << endl;
	return 0;

}


Measured memory_bytes: 256
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not cards[i][j]:
            print(n2s[i], j+1)

Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int mod=1e9+7;
int pw(int a,int t){
	int x=1;
	while(t>0){
		if(t&1)x=x*a%mod;
		a=a*a%mod,t>>=1;
	}
	return x;
}
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k,c=0,sum=0;
    cin >> n >> k;
    int a[k+1];
    for(int i=1;i<=k;i++)
    	a[i]=pw(k/i,n);
    for(int i=k;i>=1;i--){
    	for(int j=2;j<=k;j++){
    		if(j*i>k)break;
    		a[i]=(a[i]-a[j*i]+mod)%mod;
    	}
    }
    for(int i=1;i<=k;i++){
    	sum=(sum+i*a[i]%mod)%mod;
    }
    cout << sum ;
}

Measured memory_bytes: 4392
import math

Q = int(input())

# 素数表
n = 100000
P = [False] * n
P[2] = True
for i in range(3, n, 2):
    k = True
    for j in range(3, int(math.sqrt(i)) + 1, 2):
        if i % j == 0:
            k = False
            break
    if k:
        P[i] = True

# Nと(N+1)÷2が素数か否か
a = [0] * n
for i in range(1, n, 2):
    j = (i + 1) // 2
    if P[i] and P[j]:
        a[i] = 1
# 累積和
for i in range(n - 1):
    a[i + 1] += a[i]

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


Measured memory_bytes: 9076
# coding: utf-8
#72

n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
#print(X,Y)

D=[]
for j in range(n):
    d=abs(X[j]-Y[j])
    D.append(d)
print('{:.05f}'.format(sum(D)))

E=[]
for i in range(n):
    e=D[i]**2
    E.append(e)
A=sum(E)**(1/2)
print('{:.05f}'.format(A))

F=[]
for i in range(n):
    f=D[i]**3
    F.append(f)
B=sum(F)**(1/3)
print('{:.05f}'.format(B))

print('{:.05f}'.format(max(D)))




Measured memory_bytes: 5652
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

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

int main()
{
  ll INF = 1000000000000000000LL;
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &a_i : a)
  {
    cin >> a_i;
    if (a_i == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  for (auto a_i : a)
  {
    if (ans <= INF / a_i)
    {
      ans *= a_i;
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m, a[1010], votes = 0, cnt = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        votes += a[i];
    }
    double cri = (double) votes / (4 * m);
    for (int i = 0; i < n; i ++) {
        if (a[i] >= cri) cnt ++;
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
int f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    string a,b;
    cin>>a;
    FOR(i,0,a.length()-1) cout<<'x';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	
	static long r,c;
	public static void main(String[] __){
		while(true){
			c=s.nextInt();
			r=s.nextInt();
			if(r+c==0) return;
			char[][] f=INS(r).map(String::toCharArray).toArray(char[][]::new);
			
			
			ArrayDeque<Point> deque=new ArrayDeque<>();
			
			serachStart:
			for(int i=0;i<r;i++){
				for(int j=0;j<c;j++){
					if(f[i][j]=='@'){
						deque.add(new Point(i,j));
						f[i][j]='#';
						break serachStart;
					}
				}
			}
			int res=1;
			while(!deque.isEmpty()){
				for(int l=deque.size();l>0;l--){
					Point poll=deque.pollFirst();
					for(int d=0;d<dr.length;d++) {
						Point p=(Point)(poll.clone());
						p.translate(dr[d],dc[d]);
						if(ranged(p)&&f[p.x][p.y]=='.') {
							deque.addLast(p);
							f[p.x][p.y]='#';
							res++;
						}
					}
				}
			}
			System.out.println(res);
		}
	}
	static int[] dr={0,1,0,-1},dc={-1,0,1,0};
	static boolean ranged(Point p){
		return 0<=p.x&&p.x<r&&0<=p.y&&p.y<c;
	}
}

Measured memory_bytes: 44992
n = int(input())
t,a = input().split()
h = input().split()
t = int(t)
a = int(a)
dist = 100000000000000
for i in range(n):
    temp = t - 0.006 * int(h[i])
    if abs(temp - a) < dist:
        dist = abs(temp - a)
        mem = i + 1
print(mem)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<functional>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<vector>
using namespace std;

signed main() {
	int a; cin >> a;
	int sum = 0;
	for (int b = 1;; b++) {
		sum += b;
		if (sum >= a) { cout << b << endl; return 0; }
	}
}

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

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<bool> IsCorrect(N, false);
    vector<int> Penalties(N, 0);

    for(int i=0; i<M; i++){
        int p;
        string s;
        cin >> p >> s;
        
        p=p-1;
        if(s=="AC"){
           IsCorrect[p] = true; 
        }

        if(s=="WA" && IsCorrect[p]==false){
            Penalties[p] += 1;
        }

    }


    int c_ans = 0;
    int c_pena = 0;
    for(int i=0; i<N; i++){
        if(IsCorrect[i]== true){
            c_ans++;
            c_pena += Penalties[i];
        }
    }
    cout << c_ans << " " << c_pena << endl;
    return 0;
}

Measured memory_bytes: 3768
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(a: "List[int]", b: "List[int]"):
    ab = a+b
    t1 = [ab.count(1), ab.count(2), ab.count(3), ab.count(4)]
    
    if t1.count(1) == t1.count(2):
        print(YES)
    else:
        print(NO)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = [int()] * (3)  # type: "List[int]"
    b = [int()] * (3)  # type: "List[int]"
    for i in range(3):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d[6];
  for (int i = 0; i < 6; ++i) cin>>d[i];
  int f=0;
  string s;
  cin>>s;
  for (int i = 0; i < s.size(); ++i)
  {
    int tmp=d[0];
    if(s.at(i)=='N')
    {
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=tmp;
    }
    else if (s.at(i)=='E')
    {
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=tmp;
    }
    else if (s.at(i)=='S')
    {
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=tmp;
    }
    else if (s.at(i)=='W')
    {
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=tmp;
    }
  }
  cout<<d[0]<<endl;
}


Measured memory_bytes: 3184
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            String[] data = line.split(" ");
            int a = Integer.parseInt(data[0]);
            int b = Integer.parseInt(data[2]);
            if (data[1].equals("+")) {
                System.out.println(a + b);
            } else if (data[1].equals("-")) {
                System.out.println(a - b);
            } else if (data[1].equals("*")) {
                System.out.println(a * b);
            } else if (data[1].equals("/")) {
                System.out.println(a / b);
            } else if (data[1].equals("%")) {
                System.out.println(a % b);
            } else if (data[1].equals("?")) {
                break;
            }
        }
        sc.close();
    }
}



Measured memory_bytes: 26368
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);
    	
    	
    	int n = scan.nextInt();
    	int x = scan.nextInt();
    	int t = scan.nextInt();
    	
    	
    	int time = 0;
    	
    	while (n > 0) {
    		n -= x;
    		time += t;
    	}
    
    	System.out.println(time);
    	
    	
    	
    	
    	}
}


Measured memory_bytes: 35540
N = int(input())
n = N

count = 0
num = []

N -= 1

while 1:
  #print(N % 26, N // 26)
  if N // 26 != 0:
    count += 1
    if N % 26 == 0 and count != 1:
      num.append(26)
      N //= 26
      N -= 1
    else:
      num.append(N % 26)
      N //= 26
  else:
    if N == 0:
      break
    else:
      num.append(N % 26)
      break
  	
ans = ''
  	
for i in range(len(num)):
  if i == 0:
  	ans += chr(97 + num[i])
  else:
    ans += chr(96 + num[i])
  
if n == 1:
  print('a')
else:
  print(ans[::-1])


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,k;
	cin>>n;
	int arr[n][3];
	
	for(i=0;i<n;i++)
	for(j=0;j<3;j++)
	cin>>arr[i][j];
	
	int dp[n][3]={0};
	for(i=0;i<3;i++)
	dp[0][i]=arr[0][i];
	
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<3;k++)
			{
				if(k!=j)
				{
					dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = (double)a / (double)b;
	cout << d<<" " << r << " " <<fixed<<setprecision(7)<< f << endl;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main() {
    string s;
    ll k;
    cin >> s >> k;

    ll cnt = 0;
    char c;
    rep(i, s.length()) {
        if (s[i] == '1') ++cnt;
        else {
            c = s[i];
            break;
        }
    }

    if (cnt >= k) {
        cout << 1 << endl;
    }
    else {
        cout << c << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int F[n][10];
    rep(i,n)rep(j,10) cin >> F[i][j];
    int P[n][11];
    rep(i,n)rep(j,11) cin >> P[i][j];

    int ans = -1e9;
    for (int i=1; i<(1<<10); i++){
        bitset<10> bs(i);
        int index = 0;
        rep(j,n){
            int cnt = 0;
            rep(k,10){
                if (F[j][9-k] & bs.test(k)) cnt++;
            }
            index += P[j][cnt];
            //printf("ans:%d index:%d cnt:%d\n", ans, index, cnt);
        }
        ans = max(ans, index);
    }

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


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
long long int n,a[5000];
int main(){
	long long int i,j,t,tmp;
	while(cin >> n && n){
		tmp = 0;
		t = -1000000;
		for(i=0;i<n;i++){
			cin >> a[i];
		}
		for(i=0;i<n;i++){
			tmp += a[i];
			if(t < tmp) t = tmp;
				for(j=i+1;j<n;j++){
					tmp += a[j];
					if(t < tmp) t = tmp;
				}
			tmp = 0;
		}
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 0
h,w = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(h)]

stack = []

cnt = 0
printlist = [[False]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if l[i][j] % 2 == 1:
            if j < w-1:
                l[i][j+1] += 1
                printlist[i][j] = (i,j+1)
                cnt += 1

for i in range(h):
    if l[i][w-1] % 2 == 1:
        if i < h-1:
            l[i+1][w-1] +=1
            printlist[i][w-1] = (i+1,w-1)
            cnt += 1

print(cnt)
for i in range(h):
    for j in range(w-1):
        if printlist[i][j]:
            x = printlist[i][j]
            print(i+1,j+1,x[0]+1,x[1]+1)
for i in range(h):
    if printlist[i][w-1]:
        x = printlist[i][w-1]
        print(i+1,w,x[0]+1,w)

Measured memory_bytes: 84760
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

int n, a, b;

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> a >> b;
	cout << min(b, n * a) << '\n';

	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    int lis[100000];
    for(int i=0;i<N;i++)cin>>lis[i];
    for(int i=N-1;1<=i;i--){
        if(lis[i-1]>lis[i]){
            lis[i-1]--;
            if(lis[i-1]>lis[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> vec(N);
  rep(i,N){cin >> vec.at(i);}
  sort(vec.begin(), vec.end());
  
  int tmp=0;
  rep(i,N-1){tmp=max(vec.at(i+1)-vec.at(i),tmp);}
  tmp=max(K-vec.at(N-1)+vec.at(0),tmp);
  
  cout<<K-tmp<<endl;
  
}

Measured memory_bytes: 4060
class abc_168:
    
    def __init__(self):
        pass
    
    def A(self):
       N=int(input())
       hon=[2,4,5,7,9]
       pon=[0,1,6,8]
       bon=[3]
       
       ans=N%100
       ans=ans%10
       
       if ans in hon:print("hon")
       elif ans in pon:print("pon")
       else :print("bon")
    
    def B(self):
        pass
        
    def C(self):
       pass
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_168()
    obj.A()

Measured memory_bytes: 61796
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	// 入力
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}
	
	int D = 0;
	// 最初の0座標分
	int answer = 1;
	for (int i = 0; i < N; i++)
	{
		D += L[i];
		if (D <= X)
		{
			answer++;
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100
div = np.arange(1,U,dtype=np.int64)
div = div[N%div==0]
answer = (div + (N//div)).min() - 2
print(answer)


Measured memory_bytes: 29604
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    x, a, b = LI()
    if abs(x - a) > abs(x - b):
        print("B")
    else:
        print("A")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N;
  std::cin >> N;

  std::vector<int> Ls(N);
  for (auto& Li : Ls) {
    std::cin >> Li;
  }
  std::sort(Ls.begin(), Ls.end(), std::greater<int>{});

  const auto l = Ls.front();
  const auto m = std::accumulate(Ls.cbegin() + 1, Ls.cend(), 0);

  std::cout << (l < m ? "Yes" : "No") << std::endl;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int  cnt = 0;
	bool ans = true;
	if (s[0] != 'A') {
		ans = false;
	}
	for (int i = 1; i < s.size(); i++) {
		if (isupper(s[i])) {
			if (i == 1 || i == s.size() - 1 || s[i] != 'C') {
				ans = false;
			}
			else if (s[i] == 'C') {
				cnt++;
			}
		}
	}
	if (ans == true && cnt == 1)cout << "AC" << endl;
	else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =99999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

  
  int a,s,d;
  cin>>a>>s>>d;
  vector<int> vec(3);

    vec[0]=abs(a-s);
  vec[1]=abs(s-d);
  vec[2]=abs(d-a);
  
  vsort(vec);
  cout<<vec[0]+vec[1]<<endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	long N,i,x;
 	cin>>N;	
  long min=N;
  	for(i=1;i<=sqrt(N)&&i<=1000000;i++){
  	if(N%i==0){
      x=(i-1)+(N/i-1);
     if(min>x)min=x;
    }	
  }
  cout<<x;
  cout<<endl;
}

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

using namespace std;
typedef long long lint;

struct UnionFind {
    vector<int> par;
    int n, cnt;
    UnionFind(const int& x = 0) {init(x);}
    void init(const int& x) {par.assign(cnt=n=x, -1);}
    inline int find(const int& x) {return par[x] < 0 ? x : par[x] = find(par[x]);}
    inline bool same(const int& x, const int& y) {return find(x) == find(y);}
    inline bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return false;
        --cnt;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    inline int count() const {return cnt;}
    inline int count(int x) {return -par[find(x)];}
};

struct Edge {
    lint cost;
    int u;
    int v;
    Edge() {}
    Edge(lint cost, int u, int v) : cost(cost), u(u), v(v) {}
};

const int MAXN = 111111;
int X[MAXN], Y[MAXN];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    vector<pair<int, int> > xs(N), ys(N);
    for (int i = 0; i < N; i++) {
        xs[i] = make_pair(X[i], i);
        ys[i] = make_pair(Y[i], i);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    vector<Edge> es;
    for (int i = 0; i < N-1; i++) {
        // X
        int u = xs[i].second, v = xs[i+1].second;
        lint cost = min(abs(X[u] - X[v]), abs(Y[u] - Y[v]));
        es.emplace_back(cost, u, v);
        // Y
        u = ys[i].second, v = ys[i+1].second;
        cost = min(abs(X[u] - X[v]), abs(Y[u] - Y[v]));
        es.emplace_back(cost, u, v);
    }
    // minimum-cost-tree
    sort(es.begin(), es.end(), [](const Edge& lhs, const Edge& rhs) {return lhs.cost < rhs.cost;});
    UnionFind uf(N);
    lint ans = 0;
    for (const Edge& e : es) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            ans += e.cost;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1){
        a[i] = 0;
    }
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i){
            a[j]++;
        }
    }
    ll ans = 0;
    rep(i,n+1) ans += i*a[i];
    cout << ans << endl;

}

Measured memory_bytes: 81360
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n;
int a[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    if (a[n - 1] - a[0] >= 2)
    {
        cout << "No";
        return 0;
    }
    ll x = 0, y = 0;
    int i = 0;
    while (i < n)
    {
        if (a[i] == a[0])
            x++;
        else
            y++;
        i++;
    }
    if (y == 0)
    {
        if (a[0] == n - 1)
        {
            cout << "Yes";
            return 0;
        }
        if (a[0] <= n / 2)
        {
            cout << "Yes";
            return 0;
        }
        cout << "No";
        return 0;
    }
    if (x + 1 <= a[n - 1] && a[n - 1] <= x + y / 2)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 640
import math
a = list(map(int,input().split()))

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1] % i == 0 and i <= b:
        if a[1] // i <= b:
            c.append(a[1] // i)
        else:
            c.append(i)
c.sort()
c.reverse()
print(c[0])


Measured memory_bytes: 3060
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}

int main(){
    int n; cin >> n;
    vector<int> a(n,0); 
    rep(i,n) cin >> a[i];
    int i = 1;
    bool j = false;
    int next = 0;
    while(true){
        next = a[next]-1;
        if(next == 1){
            j = true;
            break;
        }
        i++;
        if(i == 100001) break;
    }
    if(j == true) cout << i;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 640