akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = min(n % k, abs(n % k - k));
  print(ans);

  return 0;
}

Measured memory_bytes: 256
import os, sys, re, math

N = int(input())

#memo = [0 for _ in range(int(2*1e5)+1)]
memo = {}

for _ in range(N):
	A,B = [int(s) for s in input().split(' ')]
	if B in memo:
		memo[B] += A
	else:
		memo[B] = A

s = 0
flg = True
key = list(memo.keys())
key = sorted(key)
for i in range(len(key)):
	s += memo[key[i]]
	if s > key[i]:
		flg = False
		break
if flg:
	print('Yes')
else:
	print('No')


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

int main() {
    int N, H, max_H, ans;
    cin >> N; max_H = 0; ans = 0;
    for (int i=0; i<N; i++) {
        cin >> H;
        if (H >= max_H){
            ans++;
            max_H = H;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>?) {
    readLine()!!.toInt()
    val str = readLine()!!
    val memo = IntArray(str.length + 1){0}
    for (i in memo.indices.reversed().drop(1)) {
        memo[i] = memo[i + 1]
        if (i + 1 in str.indices && str[i] != str[i + 1]) {
            memo[i] = java.lang.Math.max(memo[i], memo[i + 2] + 1)
        }
    }
    println(memo.first())
}


Measured memory_bytes: 35172
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 18:05:57 2019
//
package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func max(slice ...int) int {
	ret := slice[0]
	for _, v := range slice {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func min(slice ...int) int {
	ret := slice[0]
	for _, v := range slice {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	var N, Z, W int
	fmt.Scan(&N, &Z, &W)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	if N == 1 {
		fmt.Println(abs(arr[0] - W))
	} else {
		last := arr[len(arr)-1]
		lastPred := arr[len(arr)-2]
		fmt.Println(max(abs(W-last), abs(last-lastPred)))
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string t[4] = {"Sunny", "Cloudy", "Rainy","Sunny" };
    string s;
    cin >> s;

    rep(i,0,3){
	if(t[i] == s){
	    P(t[i+1]);
	    ret 0;
	    
	}
    }
    return  0;
}


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

int main() {
  char a; cin>>a;
  string s="abcdefghijklmnopqrstuvwxyz";
  char ans='x';
  rep(i,s.size()){
    if(a==s.at(i)){ans='a';break;}
  }
  if(ans=='x'){ans='A';}
  cout<<ans;
                  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

l_l cal(vector<ll>&v){
    sort(v.begin(),v.end());
    ll sum=0;
    l_l res=l_l(0,0);
    if(v.size()==0)return res;
    rep(i,0,v.size()-1){
        ll c=1;
        while(i<=v.size()-2&&v[i]==v[i+1]){
            c++;i++;
        }
        sum+=c/2;
    }
    res=l_l(v.size(),sum);
    return res;
}
ll c(l_l a,l_l b){
    ll res=0;
    if(a.first<b.first)swap(a,b);
    res=min((a.first+b.first)/2,b.first+a.second);
    return res;
}
int main(){fastio
    ll n,m;cin>>n>>m;
    ll x[n];rep(i,0,n-1)cin>>x[i];
    vector<ll>v[m];
    rep(i,0,n-1){
        v[x[i]%m].pb(x[i]);
    }
    l_l sco[m];
    rep(i,0,m-1){
        sco[i]=cal(v[i]);
    }
    //rep(i,0,m-1)cout<<sco[i].first<<" "<<sco[i].second<<endl;
    ll ans=0;
    rep(i,0,m/2){
        if((i*2)%m==0){
            ans+=(sco[i].first)/2;
        }else{
            ans+=c(sco[i],sco[m-i]);
        }
        //cout<<i<<":"<<ans<<endl;
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 8064
#include<stdio.h>

#include<math.h>

int main(void){

  double r,c,s;

  while(scanf("%lf\n",&r)!=EOF)

{

    c = 2.0*r*M_PI;

    s = r*r*M_PI;

    printf("%.6lf %lf\n",s,c);

  }

return 0;

}

Measured memory_bytes: 656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p,a,b) for(ll p=a ; p<b ; p++)
#define F first
#define S second
using namespace std;

typedef vector <ll> vll;
typedef vector <ld> vld;
typedef pair< ll ,ll > pll;


int main()
{
    ll t,i,j,k,ans,n;

    //cin>>t;
    t=1;
    while(t--)
    {
        char c;
        cin>>c;
        cout<<(char)(c+1);
    }
    
    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, a, b) for (int i = (a); i < (int)(b); i++)
#define PYMOD(A, M) ((((A) % (M)) + (M)) % (M))
typedef long long ll;

using namespace std;

const int mod = 1e9 + 7;

int idx(const vector<int>& s, int x) {
    auto it = lower_bound(all(s), x);
    if (it == s.end())
        return s.size();
    if (*it != x)
        return s.size();
    return it - s.begin();
}

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    forn(i, n)
        cin >> a[i];
    vector<int> b(m);
    forn(j, m)
        cin >> b[j];
    vector<int> sa = a;
    sort(all(sa));
    vector<int> sb = b;
    sort(all(sb));

    for (int i = 0; i < n - 1; i++)
        if (sa[i] == sa[i + 1]) {
            cout << 0 << endl;
            return 0;
        }

    for (int i = 0; i < m - 1; i++) {
        if (sb[i] == sb[i + 1]) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll places = 0;
    ll ans = 1;

    for (int i = n * m; i >= 1; i--) {
        int ina = idx(sa, i);
        int inb = idx(sb, i);
        int lba = lower_bound(all(sa), i) - sa.begin();
        int lbb = lower_bound(all(sb), i) - sb.begin();

        if (ina != n && inb != m) {
            places += (n - ina - 1) + (m - inb - 1);
        } else if (ina != n) {
            ans = (ans * (m - lbb)) % mod;
            places += m - lbb - 1;
        } else if (inb != m) {
            ans = (ans * (n - lba)) % mod;
            places += n - lba - 1;
        } else {
            ans = (ans * places) % mod;
            --places;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int x, y;
    cin >> x >> y;

    int ans = 0;
    if(x == 3) ans += 100000;
    if(x == 2) ans += 200000;
    if(x == 1) ans += 300000;
    if(y == 3) ans += 100000;
    if(y == 2) ans += 200000;
    if(y == 1) ans += 300000;
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  lint res=0;
  rep1(i,n){
    res+=(n-1)/i;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3632
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {

    int R, G, B; cin >> R >> G >> B;
    int c = R * 100 + G * 10 + B;
    if(c % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
Mod = 998244353

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

a.sort()

ans = 1
for i in range(N):
    ans *= gcd(a[i],i)
    ans %= Mod

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)

struct Data {
    int n1, n2, n3;
};

//2分割し、2つの差が最も小さくなる場合の個数を返す。
pair<ll, ll> split2(ll h, ll w) {
    Data d;
    ll total = h * w;
    if (h % 2 == 0 || w % 2 == 0) {
        return make_pair(total / 2, total / 2);
    }

    //横に割る。均等に分割できそうな境の左と右の両方で計算
    ll num11 = h / 2 * h;
    ll num12 = total - num11;
    ll num21 = (h / 2 + 1) * h;
    ll num22 = total - num21;
    //次に縦
    ll num31 = (w / 2) * w;
    ll num32 = total - num31;
    ll num41 = (w / 2 + 1) * w;
    ll num42 = total - num41;

    //最小値を計算。効率わるいな...
    vector<pair<int, int>> list(4);
    list[0] = {num11, num12};
    list[1] = {num21, num22};
    list[2] = {num31, num32};
    list[3] = {num41, num42};

    ll minDiff = INT_MAX;
    auto ret = list[0];
    for (auto p : list) {
        ll d = abs(p.first - p.second);
        if (minDiff > d) {
            minDiff = d;
            ret = p;
        }
    }
    return ret;
}
//3分割して最も小さいパターンを返す
ll split3(int h, int w) {
    ll total = h * w;
    //縦に割る
    Data d1;
    ll h1 = h / 3;
    d1.n1 = h1 * w;
    auto p1 = split2(h - h1, w);
    d1.n2 = p1.first;
    d1.n3 = p1.second;
    //
    Data d2;
    ll h2 = h / 3 + 1;
    d2.n1 = h2 * w;
    auto p2 = split2(h - h2, w);
    d2.n2 = p2.first;
    d2.n3 = p2.second;

    //横
    Data d3;
    ll w3 = w / 3;
    d3.n1 = w3 * h;
    auto p3 = split2(h, w - w3);
    d3.n2 = p3.first;
    d3.n3 = p3.second;
    //
    Data d4;
    ll w4 = w / 3 + 1;
    d4.n1 = w4 * h;
    auto p4 = split2(h, w - w4);
    d4.n2 = p4.first;
    d4.n3 = p4.second;

    //
    vector<Data> list(4);
    list[0] = d1;
    list[1] = d2;
    list[2] = d3;
    list[3] = d4;

    ll minDiff = INT_MAX;
    for (auto d : list) {
        ll m1 = min(d.n1, min(d.n2, d.n3));
        ll m2 = max(d.n1, max(d.n2, d.n3));
        ll dif = m2 - m1;
        if (minDiff > dif) {
            minDiff = dif;
        }
    }
    return minDiff;
}



int main() {
    ll H, W;
    cin >> H >> W;
    cout << split3(H, W) << endl;
    return 0;
}


Measured memory_bytes: 256
long m=1e9+7,a[]={1,0,0,0};
char buf[114514],*p=buf;
main()
{
	read(0,buf,114514);
	for(;*p>10;p++)
	{
		if(*p>64)a[*p-64]=(a[*p-64]+a[*p-65])%m;
		else
		{
			a[3]=(a[3]*3+a[2])%m;
			a[2]=(a[2]*3+a[1])%m;
			a[1]=(a[1]*3+a[0])%m;
			a[0]=a[0]*3%m;
		}
	}
	printf("%d",a[3]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> cont1(n);
  vector<int> cont2(n);
  vector<int> cont3(n-1);
  
  for(int i = 0 ; i < n ; i++){
    cin >> cont1.at(i);
    cont1.at(i)--;
  }
  for(int i = 0 ; i < n ; i++){
    cin >> cont2.at(i);
  }
  for(int i = 0 ; i < n-1 ; i++){
    cin >> cont3.at(i);
  }
  
  int ans = 0;
  int a = -12;
  for(int i = 0 ; i < n ; i++){
    ans += cont2.at(cont1.at(i));
    
    if(cont1.at(i) == a+1){
      ans += cont3.at(a);
    }
    a = cont1.at(i);
  }
  cout << ans << endl;
}
  

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

int main() {
  int A, B, C, D, E, K;
  cin >> A >> B >> C >> D >> E >> K;
  
  int I = B - A;
  int J = C - A;
  int Z = D - A;
  int L = E - A;
  int M = C - B;
  int N = D - B;
  int O = E - B;
  int P = D - C;
  int Q = E - C;
  int R = E - D;
  
  if (I > K || J > K || Z > K || L > K || M > K || N > K || O > K || P > K || Q > K || R > K) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,k;
	ll h[alength];
	cin>>n>>k;
	fori(n){cin>>h[i];}
	sort(h,h+n);
	ll ans=INF;
	fori(n-k+1){
		ans=min(h[i+k-1]-h[i],ans);
	}
	cout<<ans;
}

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

using namespace std;

main() {
  int64_t a, b;
  cin >> a >> b;
  a = (a + 11) % 13;
  b = (b + 11) % 13;
  
  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a+2),t(b+2);
  for(int i=1;i<=a;i++)
  {
    cin>>s[i];
  }
  for(int i=1;i<=b;i++)
  {
    cin>>t[i];
  }
  s[0]=SE;t[0]=SE;
  s[a+1]=EE;t[b+1]=EE;
  long x;
  long res;
  for(int i=0;i<q;i++)
  {
    cin>>x;
    auto si=lower_bound(s.begin(), s.end(), x);
    auto ti=lower_bound(t.begin(), t.end(), x);
    res=0;
    res=min(x-min(*(si-1),*(ti-1)),max(*si,*ti)-x);
    res=min(res,*ti-*(si-1)+min(*ti-x,x-*(si-1)));
    res=min(res,*si-*(ti-1)+min(*si-x,x-*(ti-1)));

    cout<<res<<"\n";




  }

  return 0;

}


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

double dp[3001][3001] = {};

int main() {
	dp[0][0] = 1;
	int N;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		double p;
		cin >> p;
		for(int j=0;j<i;j++) {
			dp[j][i-j] += dp[j][i-j-1]*(1-p);
			dp[j+1][i-j-1] += dp[j][i-j-1]*p;
		}
	}
	double ans = 0;
	// for(int i=0;i<=N;i++) {
	// 	for(int j=0;j<=N;j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	for(int i=N;i>N-i;i--) {
		ans += dp[i][N-i];
	}
	printf("%.9lf", ans);
}

Measured memory_bytes: 70016
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  i64 n;
  cin >> n;
  i64 base = 26;
  string ans = "a";
  while (n > base) {
    n -= base;
    base *= 26;
    ans += 'a';
  }
  --n;
  int i = SZ(ans);
  while (n) {
    ans[--i] += n % 26;
    n /= 26;
  }
  kek(ans);
}


Measured memory_bytes: 3572
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
int a[N][N];
void floyd(int n)
{
	for (int i = 1; i <= n; i++) a[i][i] = 0;
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m, r;
	cin >> n >> m >> r;
	vector<int> v(r);
	for (auto &x : v) cin >> x;
	sort(v.begin(), v.end());
	MEM(a, 0x3f);
	while (m--)
	{
		int x, y, w;
		cin >> x >> y >> w;
		a[x][y] = a[y][x] = w;
	}
	floyd(n);
	LL ans = INF * INF;
	do
	{
		LL sum = 0;
		for (int i = 0; i + 1 < v.size(); i++)
		{
			sum += a[v[i]][v[i + 1]];
		}
		ans = min(ans, sum);
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
import sys

lines = sys.stdin.readlines()

H, M = list(map(int, lines[0].split()))
AB = []

max_at = 0
min_mg = sys.maxsize
at_min_mg = 0
for i in range(M):
  t = tuple(map(int, lines[i+1].split()))
  AB.append(t)
  if t[0]>=max_at:
    max_at = t[0]
  if t[1]<=min_mg:
    min_mg = t[1]
    at_min_mg = t[0]

ABlen = len(AB)

DP = [0]
for i in range(1, at_min_mg+1):
  DP.append(min_mg)
  
for i in range(at_min_mg+1,H+max_at+1):
  mm = sys.maxsize
  for j in range(ABlen):
    if i-AB[j][0]<0:
      continue
    if mm > DP[i-AB[j][0]]+AB[j][1]:
      mm = DP[i-AB[j][0]]+AB[j][1]
  DP.append(mm)
print(min(DP[H:H+max_at]))

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

int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  int tot = 0;
  rep(i,n){
    cin >> a[i];
    tot +=a[i];
  }
  if(tot<h)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


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

int main(){
	ll N, M;
	cin >> N >> M;
	ll mod = 1e9+7;

	if (abs(N-M)>1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	rep(i,N) {
		ans *= i+1;
		ans %= mod;
	}
	rep(i,M) {
		ans *= i+1;
		ans %= mod;
	}
	if (abs(N-M) == 0) {
		ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> FB(N + 1, 0);
    for (long long i = 0; i <= N; ++i) {
        if (i % 3 != 0 && i % 5 != 0) FB[i] = i;
    }
    long long ans = 0;
    rep(i, N + 1) ans += FB[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, i, j, k, l, m, n, ans, tmp, hoge;

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

    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];

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

    a = n / 2;
    if (d[a - 1] == d[a])
    {
        cout << 0 << endl;
    }
    else
    {
        int count = 0;
        repm(i, d[a - 1] + 1, d[a] + 1)
        {
            count++;
            //cout << i << endl;
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> a(10, 0);
  for (int i = 0; i < N; i++)
  {
    int b;
    cin >> b;
    if (b < 3200) a.at(b / 400)++;
    else a.at(8)++;
  }
  
  int min = 0;
  for (int i = 0; i < 8; i++)
  {
    if (a.at(i) > 0) min++;
  }
  
  int max = min + a.at(8);
  if (min == 0) min = 1;
  
  cout << min << " " << max << endl;
}

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


def main():
    a, b, x = map(int, input().split())
    if x > a**2*b/2:
        ans = 2*(a**2*b-x)/a**3
    else:
        ans = (a*b**2)/(2*x)
    print(math.degrees(math.atan(ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t sum = 0;
  int h, n;
  cin >> h >> n;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    sum += a;
  }
  if (sum < h) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long

int32_t main(){ fast;
               char ch; cin>>ch;
               if(ch == tolower(ch)){
                   cout<<'a';
               }
               else cout<<'A';
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
long long n,a[123456],b[123456],c;
int main(){
    cin>>n;
    for(int i=0;i<(n+1);i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        if(a[i]>=b[i])c+=b[i];
        else if((a[i]+a[(i+1)])<=b[i]){
            c+=(a[i]+a[(i+1)]);
            a[(i+1)]=0;
        }
        else{
            c+=b[i];
            a[(i+1)]=((a[i]+a[(i+1)])-b[i]);
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main ()
{

    int a,b,c,x=0;
    scanf("%d %d %d",&a,&b,&c);
    x=a+b+c;
    if (x>=22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

LL N;
set<LL>ans;

void test(LL K) {
	if (K == 1)return;
	LL M = N;
	while (M % K == 0)M /= K;
	if ((M - 1) % K == 0) {
		ans.insert(K);
	}
}

int main() {
	cin >> N;
	for (LL i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			test(i);
			test(N / i);
		}
	}
	N--;
	for (LL i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			ans.insert(i);
			ans.insert(N / i);
		}
	}
	ans.erase(1);
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = (ll)1e10;
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)

signed main() {
	string r,s,t;
	cin>>r; s=r+r;
	cin>>t;

	vector<vector<ll>> s_position(26,vector<ll>());
	vector<ll> t_num(26,0);
	rep(i,s.size()){
		ll ch=s[i]-'a';
		s_position[ch].push_back(i);
	}
	rep(i,t.size()){
		ll ch=t[i]-'a';
		t_num[ch]++;
	}
	rep(i,26){
		if(s_position[i].size()==0 && t_num[i]>0){
			cout<<-1<<endl;
			return 0;
		}
	}

	vector<vector<ll>> next(26,vector<ll>(s.size(),INF));
	ll ch=s[s.size()-1]-'a';
	next[ch][s.size()-1]=s.size()-1;
	for(ll i=s.size()-2;i>=0;i--){
		rep(j,26){
			next[j][i]=next[j][i+1];
		}
		ll ch=s[i]-'a';
		next[ch][i]=i;
	}

	ll ans=0;
	ll index=0;
	rep(i,t.size()){
		ll ch=t[i]-'a';
		ll nextindex=next[ch][index];
		ans+=nextindex-index+1;
		index=nextindex+1;
		if(index>=r.size())index-=r.size();
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 44928
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    int x;
    cin >> x;
    if(x<=599) cout << 8 << endl;
    else if(x<=799) cout << 7 << endl;
    else if(x<=999) cout << 6 << endl;
    else if(x<=1199) cout << 5 << endl;
    else if(x<=1399) cout << 4 << endl;
    else if(x<=1599) cout << 3 << endl;
    else if(x<=1799) cout << 2 << endl;
    else if(x<=1999) cout << 1 << endl;

    
    return 0;
}


Measured memory_bytes: 3616
import numpy as np
from itertools import combinations

H, W, K = map(int, input().split())

C = np.zeros((H, W))
for i in range(H):
    S = input()
    for j, s in enumerate(S):
        if s == '#':
            C[i, j] = 1
ans = 0
for h in range(H):
    for i in combinations(range(H), h):
        for w in range(W):
            for j in combinations(range(W), w):
                C_ = C.copy()
                for a in i:
                    C_[a, :] = 0
                for b in j:
                    C_[:, b] = 0
                if np.sum(C_) == K:
                    ans += 1
print(ans)

Measured memory_bytes: 27168
#include <bits/stdc++.h> 
using namespace std;
#define ld long double 
#define float long double 
#define ll long long
#define int long long
#define vl vector<ll> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=1e9+7;
int i,j,k;
void solve(){ 
      int n, r; cin >> n >> r;
      if(n >= 10) {
        cout << r << endl;
        return ;
      }
        int x = 100 *(10 - n);
        cout <<  r + x << endl;
        



    return ;

} 
    signed main(){
   
     //CASET
    solve();
    
   
    return 0;
  }


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k=0;
    cin >> n;
    vector<vector<int> > g(n);
    vector<int> deg(n, 0);
    vector<pair<int, int> > ed(n-1);
    for(int i=0, u, v; i<n-1; i++){
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
        ed[i] = {u, v};
        deg[u]++; deg[v]++;
        k = max(k, max(deg[u], deg[v]));
    }
    cout << k << endl;
    vector<set<int> > s(n);
    map<int, map<int, int> > mp;
    for(int i=0; i<n; i++){
        int c = 1;
        for(auto x : g[i]) if(!mp[x][i]){
            while(s[x].find(c)!=s[x].end()||s[i].find(c)!=s[i].end()) c++;
            s[i].insert(c);
            s[x].insert(c);
            mp[i][x] = mp[x][i] = c;
            c++;
        }
    }
    for(auto x : ed)
        cout << mp[x.first][x.second] << endl;
    return 0;
}


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

int n;
int a[200];

int main(){
  int ans = 0;

  cin >> n;

  for (int i = 0;i < n;i++) {
    cin >> a[i];
  }

  while (true){
    bool f = false;
    for (int i = 0;i < n;i++){
      if (a[i]%2 == 1) {
	f = true;
      }
      a[i] /= 2;
    }
    if (f) break;
    ans++;
  }

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

Measured memory_bytes: 256
A,B,C = map(int,input().split(" "))
ans = 0

l = [A,B,C]

for i in range(3):
  if ans < (10*l[i%3] + l[(i+1)%3] + l[(i+2)%3]):
    ans = 10*l[i%3] + l[(i+1)%3] + l[(i+2)%3]

print(ans)

Measured memory_bytes: 3060
S=input()
K=int(input())
T=S+S
if len(set(S))!=1:
  A=[]
  D=1
  for i in range(len(S)-1):
    if S[i]==S[i+1]:
      D+=1
    else:
      A.append(D)
      D=1
  A.append(D)
  B=[i for i in A if not i==1]
  C=[(i//2) for i in B]
  Scount=(sum(C))

  E=[]
  H=1
  for j in range(len(T)-1):
    if T[j]==T[j+1]:
      H+=1
    else:
      E.append(H)
      H=1
  E.append(H)
  F=[j for j in E if not j==1]
  G=[(j//2) for j in F]
  Tcount=(sum(G))
  ans=(Tcount-Scount)*(K-1)+Scount
  print(ans)
else:
  print(K*len(S)//2)

Measured memory_bytes: 3064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: String,
    }
    let sum: u32 = n.chars().map(|x| x.to_digit(10).unwrap()).sum();

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2364
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a>b){
    swap(a,b);
  }
  long long h=1;
  while((h*a)%b!=0){
    h++;
  }
  cout<<h*a<<endl;
 return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 105, inf = 1e9;
char s[N][N];
int dp[N][N];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> (s[i] + 1);
        for (int j = 1; j <= m; ++j)
            s[i][j] = s[i][j] == '#';
    }
    dp[n][m] = s[n][m];
    for (int w = n + m - 1; w >= 2; --w) {
        for (int i = 1; i <= n; ++i) {
            int j = w - i;
            if (j < 1 || j > m)
                continue;
            dp[i][j] = inf;
            if (i + 1 <= n)
                dp[i][j] = min(dp[i][j], (s[i][j] == 1 && s[i + 1][j] == 0) + dp[i + 1][j]);
            if (j + 1 <= m)
                dp[i][j] = min(dp[i][j], (s[i][j] == 1 && s[i][j + 1] == 0) + dp[i][j + 1]);
        }
    }
    cout << dp[1][1] << endl;
}


Measured memory_bytes: 256
# coding: utf-8
N,X,M = map(int,input().split())
INF = 10**10+1
flg = [INF for i in range(M)]
loop = INF
ruiseki = [X]
ans = 0

An = X

for i in range(1,N):
    flg[An] = i
    An = (An**2)%M
    
    ruiseki.append(ruiseki[-1] + An)
    
    if flg[An] != INF:
        k = flg[An]
        loop = i - flg[An] + 1
        loop_v = ruiseki[-1] - ruiseki[k-1]
        break


if N > loop:
    l = (N-k+1)%loop
    if k >=2:
        ans += ruiseki[k-2]
        if l != 0:
            ans += ruiseki[k+l-2] - ruiseki[k-2]
    else:
        if l != 0:
            ans += ruiseki[k+l-2]
    ans += ((N-k+1)//(loop))*loop_v

else :
    ans = ruiseki[-1]

print(ans)

Measured memory_bytes: 73312
import math

n, d = map(int, input().split())
X = []
for i in range(n):
    X.append([int(x) for x in input().split()])

count = 0
dif2sum = 0
    
for i in range(n - 1):
    for j in range(i + 1, n):
        for k in range(d):
            dif = X[i][k]-X[j][k]
            dif2sum += dif * dif
        if math.sqrt(dif2sum).is_integer():
            count += 1
        dif2sum = 0
    
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    char b;
    cin >> b;
    if(b=='A')cout << 'T';
    if(b=='T')cout << 'A';
    if(b=='G')cout << 'C';
    if(b=='C')cout << 'G';
    


}

/*



 */


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  if(n>=10000){
    cout<<1;
    return 0;
  }
  if(n<100){
    cout<<0;
    return 0;
  }
  if(5*((n/100)%100)<n%100)cout<<0;
  else cout<<1;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;

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

  double ans = 0.0;
  if (N % 2 == 0) {
    int tmp = N / 2;
    ans = (double)tmp / N;
  } else {
    int tmp = N / 2;
    ans = ((double)tmp + 1.0) / N;
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq,copy

N,K = (int(x) for x in input().split())
V = list(map(int, input().split()))
v = copy.copy(V)
ans = 0
if N <= K:
    heapq.heapify(v)
    for i in range(min(K-N,len(v))):
        temp = heapq.heappop(v)
        if temp >= 0:
            ans = max(ans,sum(v)+temp)
            break
    else:
        ans = max(ans,sum(v))
for i in range(min(N,K+1)):
    for j in range(min(N,K+1)-i):
        if (i == 0 and j == 0) or i + j == N:
            continue
        else:
            l = V[:j] + V[N-1:N-1-i:-1]
            heapq.heapify(l)
            for k in range(min(K-i-j,len(l))):
                temp = heapq.heappop(l)
                if temp >= 0:
                    ans = max(ans,sum(l)+temp)
                    break
            else:
                ans = max(ans,sum(l))
print(ans)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")


int main(){

  //  freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();

    ll n; cin >> n;
    ll ans = n - 1;
    for(ll i = 2; i * i <= n; i ++) {
        if(n % i == 0) {
            ans = min(ans, i + n / i - 2);
        }
    }

    cout << ans ;
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int a,ans=0;
  for(int i = 0; i<N;++i){
  	cin >> a;
    while(a % 2 == 0){
      a /= 2;
      ++ans;
  	}
  }
  cout << ans << endl;
  return 0;
}
  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll A;
    long double B;
    cin >> A >> B;
    cout << (ll)(A * B + 0.001) << endl;
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<algorithm>
using namespace std;
int l[31000];
int r[31000];
double x[31000];
double y[31000];
int h[31000];
int s[31000];
int sum[31000];
int hsum[31000];
int main(){
	int a,b,c,d,e;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&e),a){
		for(int i=0;i<b;i++){
			scanf("%d%d",l+i,r+i);
		}
		for(int i=0;i<b;i++)h[i]=0;
		for(int i=0;i<b;i++){
			if(i)s[i]=(l[i]+r[i]-l[i-1]-r[i-1])*c;
			else s[i]=(l[0]+r[0])*c;
		}
		sum[0]=s[0];
		for(int i=1;i<b;i++){
			sum[i]=sum[i-1]+s[i];
		}
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		e*=2;
		for(int i=0;i<a;i++){
			int L=0;
			int R=b;
			while(L+1<R){
				int M=(L+R)/2;
				double at=(double)l[M-1]+(double)(r[M-1]-l[M-1])/c*x[i];
				if(at>y[i])R=M;
				else L=M;
			}
			h[L]++;
		}
		for(int i=0;i<=b;i++)hsum[i]=0;
		for(int i=0;i<b;i++)hsum[i+1]=hsum[i]+h[i];
		int ret=999999999;
		int now=0;
		for(int i=0;i<b;i++){
			//if(c*d*2-now<e)break;
			int to=upper_bound(sum,sum+b,now+c*d*2-e)-sum;
			ret=min(ret,a-(hsum[to]-hsum[i]));
			now+=s[i];
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2264
#include <iostream>
#include <vector>
#include <set>

using Bool = bool;
using Int = long long int;
template <class T>
using Vector = std::vector<T>;
template <class T>
using Set = std::set<T>;

constexpr Int L = 531441;  // 9^6
constexpr Int F = 4;       // [4, 0, 0, 0, 0, 0]
const Vector<Int> mask{
    0b1100110000000000,
    0b0110011000000000,
    0b0011001100000000,
    0b0000110011000000,
    0b0000011001100000,
    0b0000001100110000,
    0b0000000011001100,
    0b0000000001100110,
    0b0000000000110011,
};

Vector<Int> wet;

void init() {
    wet.assign(L, 0);
    for (Int b = 0; b < L; ++b) {
        {
            Int c = b;
            for (Int j = 0; j < 6; ++j) {
                wet[b] |= mask[c % 9];
                c /= 9;
            }
        }
    }
}

Bool solve() {
    Int n;
    std::cin >> n;
    if (n == 0) return false;

    Set<Int> pos, npos;
    pos.clear();
    pos.insert(F);

    for (Int q = 0; q < n; ++q) {
        Int req = 0;
        for (Int j = 0; j < 16; ++j) {
            Int b;
            std::cin >> b;
            req = (req << 1) + b;
        }

        npos.clear();
        for (Int p = 0; p < 9; ++p) {
            if (q == 0 && p != 4) continue;
            if (req & mask[p]) continue;

            for (Int b : pos) {
                if (q >= 6 &&
                    (wet[b] | mask[p]) != ((1 << 16) - 1)) continue;

                Int prev = b % 9;
                if (p / 3 != prev / 3 &&
                    p % 3 != prev % 3) continue;

                npos.insert((b * 9 + p) % L);
            }
        }

        std::swap(pos, npos);
    }

    std::cout << !pos.empty() << std::endl;
    return true;
}

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



Measured memory_bytes: 7300
n=int(input())
p=1000000000000001
n2a = lambda c: chr(c+65).lower()
# 何桁か計算
cnt=0
keta=0
while cnt+pow(26,keta)<=n:
  cnt+=pow(26,keta)
  keta+=1
#print(cnt,keta)
n-=cnt
# cnt桁のn番目の数字
ans=['a']*keta
for i in range(keta):
  ans[-i-1]=n2a(n%26)
  n//=26
#ans.reverse()
print(''.join(ans))



Measured memory_bytes: 61952
# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね？」とか思ってて2時間経過した
# 落ち着いて読んだら最小の辺の数だった

from collections import Counter

n = int(input())
arr = list(map(int, input().split()))
if arr[0] != 0:
    print(0)
    exit()
arr = sorted(list(Counter(arr).items()), key=lambda x: x[0])
if arr[0][1] > 1:
    print(0)
    exit()

mod = 998244353
ans = 1
tmp = 1
for i in range(1, len(arr)):
    if arr[i][0] != i:
        print(0)
        exit()
    ans *= pow(tmp, arr[i][1])
    ans %= mod
    tmp = arr[i][1]

print(ans)


Measured memory_bytes: 68140
#include<cstdio>
#include<iostream>
using namespace std;
long long dfs(long long n,long long x){
    if(n%x==0) return n*2-x;
    long long ans=n/x*2*x;
    return ans+dfs(x,n%x);
}
int main(){
    long long n,x;
    scanf("%lld%lld",&n,&x);
    printf("%lld",dfs(x,n-x)+n);
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  Competitive
//
//  Created by Ashutosh Tiwari on 16/05/20.
//  Copyright © 2020 Ashutosh Tiwari. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <climits>
#include <functional>
#include <unordered_map>
#include <tuple>
#include <iterator>
#include <unordered_set>
#include <chrono>
#include <regex>

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("../in.txt", "r", stdin);
    int N;
    cin >> N;
    vector<int> cur(3, INT_MIN), previous(3, 0);
    for (int i = 0; i < N ; i ++) {
        cin >> cur[0] >> cur[1] >> cur[2];
        for (int j = 0; j < 3; j ++) {
            int mx = INT_MIN;
            for (int k = 0; k < 3; k++) {
                if (k != j) mx = max(mx, previous[k]);
            }
            cur[j] += mx;
        }
//        for (auto x: cur) cout << x << " ";
//        cout << endl;
        previous = cur;
    }

    cout << max(cur[0], max(cur[1], cur[2])) << endl;

    return 0;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N), D(N);
	for (int i = 0;i < N;i++) {
		A[i] = B[i] = i + 1;
	}
	for (int i = 0;i < N;i++)cin >> C[i];
	for (int i = 0;i < N;i++)cin >> D[i];
	int c1 = -1, c2 = -1, x = 0;
	bool bp, bq;
	while (c1 < 0 || c2 < 0) {
		bp = 1, bq = 1;
		for (int i = 0;i < N;i++) {
			if (A[i] != C[i])bp = 0;
			if (A[i] != D[i])bq = 0;
		}
		if (bp) {
			c1 = x;
		}
		if (bq) {
			c2 = x;
		}
		next_permutation(all(A));
		x++;
	}
	cout << abs(c2 - c1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, e, k, ans = 0,sum,d[50];
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
int nlcm(vector<int> numbers) {
	int res;
	res = numbers[0];
	for (int i = 1; i < numbers.size(); i++) {
		res = lcm(res, numbers[i]);
	}
	return res;
}
int main(void) {
	int n;long double u = 0, q = 0;cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	long double d = nlcm(a);
	rep(i, n) {
		long double r = d / a[i];
		sum += r;
	}
	u = d / sum;
	cout << fixed << setprecision(10) << u << endl;
}

Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	a := scanInts(n)
	answer := notDivisible(n, a)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func notDivisible(n int, a []int) int {
	sort.Ints(a)
	prev := -1
	maxA := a[n-1]
	divisors := make([]int, maxA+1)
	for i := 0; i < n; i++ {
		if prev == a[i] {
			continue
		}
		for j := 1; a[i]*j <= maxA; j++ {
			divisors[a[i]*j]++
		}
	}
	debug(divisors)
	count := 0
	for i := 0; i < n; i++ {
		if divisors[a[i]] == 1 {
			count++
		}
	}
	return count
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll x, a, b;
    cin >> x >> a >> b;

    if (a - b >= 0)
    {
        cout << "delicious" << endl;
    }
    else if (x + a - b >= 0)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256