akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  boutarou
*    created: 28.06.2020 20:54:48
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;
const int INF = 1e9;

int d;
int c[26];
int s[365][26];
vector<int> previous(26);

int score(int day, int contest, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest];
    before[contest] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score2(int day, int contest1, int contest2, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }

    rep(i, 26) previous[i] = -1;

    int now = 0;
    for (int i = 0; i + 1 < d; i += 2) {
        int ma = -INF;
        rep(j, 26) {
            rep(k, 26) {
                ma = max(ma, score2(i, j, k, previous));
            }
        }
        rep(j, 26) {
            rep(k, 26) {
                if (ma == score2(i, j, k, previous)) {
                    cout << j + 1 << endl;
                    cout << k + 1 << endl;
                    now += score2(i, j, k, previous);
                    previous[j] = i;
                    previous[k] = i + 1;
                    goto bou;
                } 
            }
        }
        bou:;
    }
    if (d % 2 == 1) {
        int i = d - 1;
        int ma = -INF;
        rep(j, 26) {
            ma = max(ma, score(i, j, previous));
        }
        rep(j, 26) {
            if (ma == score(i, j, previous)) {
                cout << j + 1 << endl;
                now += score(i, j, previous);
                previous[j] = i;
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3692
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        double x1 =sc.nextDouble();
        double y1 =sc.nextDouble();
        double x2 =sc.nextDouble();
        double y2 =sc.nextDouble();
        
        System.out.println(Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    }
}



Measured memory_bytes: 27956
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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 rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int c=0;
    rep(i,n-1){
        int mi=INF,key;
        rrep(j,i,n){
            if(chmin(mi,a[j]))key=j;
        }
        if(key!=i){
            swap(a[i],a[key]);
            c++;
        }
    }
    rep(i,n-1){
        std::cout << a[i] << ' ';
    }
    std::cout  <<a[n-1]<< std::endl;
    std::cout << c << std::endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[20010],to[1000010],nt[1000010],co[1000010],F[20010];
int MF(int s,int t,int e,int min){
  if(s==t||min==0)return min;
  int i,r;
  F[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(F[to[i]])continue;
    r=MF(to[i],t,e,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
//呼び出す方
//sからtへの最大流を求める　ノード数v辺の数e　aからbへキャパcのフローが流れる
int maxf(int s,int t,int v,int e,int *a,int *b,int *c){
  int i,f,r;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];
    co[ta[b[i]]=i+e]=0;
  }
  for(f=0;r=MF(s,t,e,1e9);f+=r){
    for(i=0;i<v;i++)F[i]=0;
    if(f>1000)break;
  }
  return f;
}
int Y[]={0,1,0,-1};
int X[]={1,0,-1,0};
int main(){
  int h,w,M=1e9,a[100010],b[100010],c[100010],i,j,k,p,ny,nx,np,ans,r=0;
  char s[110][110]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i+1]+1);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      p=(i-1)*w+j+1;
      a[r  ]=p+h*w;
      b[r  ]=p;
      c[r++]=1;
      if(s[i][j]=='X'){
	a[r  ]=0;
	b[r  ]=p;
	c[r++]=M;
      }
      for(k=0;k<4;k++){
	ny=i+Y[k];
	nx=j+X[k];
	np=(ny-1)*w+nx+1+h*w;
	a[r]=p;
	b[r]=s[ny][nx]?np:1;
	c[r++]=M;
      }
    }
  }
  ans=maxf(0,1,h*w*2+2,r,a,b,c);
  printf("%d\n",ans>1000?-1:ans);
  return 0;
}
  
	  


Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N:usize,
    }
    let N = N % 10;
    if N == 0 || N == 1 || N == 6 || N == 8 {
        println!("pon");
    } else if N == 3 {
        println!("bon");
    } else {
        println!("hon");
    }
}


Measured memory_bytes: 2080
N = int(input())
aD = []
if N % 2 :
    aD.append([N])
    for i in range(1,(N+1)//2):
        aD.append([i,N-i])
else:
    for i in range(1,(N//2) + 1):
        aD.append([i,N+1-i])
iD = len(aD)
aRes = []
def strfy(aD):
    return " ".join(str(_) for _ in sorted(aD))
for i in range(iD):
    for j in range(iD):
        if i == j :
            pass
        else:
            if len(aD[i]) == 1:
                aRes.append(strfy([aD[i][0],aD[j][0]]))
                aRes.append(strfy([aD[i][0],aD[j][1]]))
            elif len(aD[j])== 1:
                aRes.append(strfy([aD[i][0],aD[j][0]]))
                aRes.append(strfy([aD[i][1],aD[j][0]]))
            else:
                aRes.append(strfy([aD[i][0],aD[j][0]]))
                aRes.append(strfy([aD[i][0],aD[j][1]]))
                aRes.append(strfy([aD[i][1],aD[j][0]]))
                aRes.append(strfy([aD[i][1],aD[j][1]]))
aRes = list(set(aRes))
print(len(aRes))
print(*aRes,sep="\n")


Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100001
#define infinity 20000000
#define pb push_back
#define ll long long int
int main()
{
    int n,k,i;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    string si;
    cin >> si;
    string z="";
    map < char,char>m;
    map < char,int>mi;
    m['r']='p';
    m['p']='s';
    m['s']='r';
    mi['r']=r;
    mi['p']=p;
    mi['s']=s;
    ll sum=0;
    for(i=0; i<n; i++)
    {
        if(i<k)
        {
            char u;
            u=m[si[i]];
            z+=u;
            sum+=mi[u];
        }

        else
        {
            char u;
            u=m[si[i]];
            if(z[i-k]==u)
            {
                if((i+k)<n)
                {
                    char f=m[si[i+k]];
                    if(f!='r' && u!='r')
                        z+='r';
                    else if(f!='s' && u!='s')
                        z+='s';
                    else
                        z+='p';
                }

                else
                    z+=si[i];
            }

            else
            {
                z+=u;
                sum+=mi[u];
            }
        }
    }
    cout << sum<< endl;
    return 0;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define vvl vector<vl>
#define tc ll t; cin >> t; while (t--)
#define yes {cout << "Yes" << endl; return 0;}
#define no cout << "No" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);
#define forij _for(i,0,3) _for(j,0,3)

ll a[3][3], appear[3][3];
int main() {
    godspeed;
    forij cin >> a[i][j];

    ll n, x; cin >> n;
    while(n--) {
    	cin >> x;
    	forij if(a[i][j] == x) appear[i][j] = 1;
    }

    // _for(i,0,3) {_for(j,0,3) cout << a[i][j] << " "; cout << endl;}
    // _for(i,0,3) {_for(j,0,3) cout << appear[i][j] << " "; cout << endl;}
    
    if(appear[0][0] == 1 and appear[1][1] == 1 and appear[2][2] == 1) yes;
    if(appear[2][0] == 1 and appear[1][1] == 1 and appear[0][2] == 1) yes;

    _for(i,0,3) {
    	ll sum = 0;
    	_for(j,0,3) sum += appear[i][j];
    	if(sum == 3) yes;
    }

    _for(j,0,3) {
    	ll sum = 0;
    	_for(i,0,3) sum += appear[i][j];
    	if(sum == 3) yes;
    }

    no;


}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
	int N;

	cin >> N ;

	if (N >= 30){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
int a[100000],p[100000]={1,1},Q,i=1,j;int main(){for(;++i<100000;)if(!p[i])for(j=i;(j+=i)<100000;p[j]=1);for(i=0;++i<100000;)a[i]=a[i-1]+!(p[i]|p[(i+1)/2]);scanf("%d",&Q);while(Q--){scanf("%d%d",&i,&j);printf("%d\n",a[j]-a[i-1]);}return 0;}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ull unsigned long long
#define lowbit(x) ((x)&(-x))
#define dis(p,q) sqrt((p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y))

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
typedef long long ll;
typedef double db;
using namespace std;

namespace _{
    bool rEOF = 1;//为0表示文件结尾
    inline char nc(){
        static char buf[100000], *p1 = buf, *p2 = buf;
        return p1 == p2&&rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
    }
    template<class _T>
    inline bool read(_T &num){
        char c = nc(), f = 1; num = 0;
        while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
        while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
        return (bool)(num *= f);
    }
    inline bool need(char &c){ return c >= 'a'&&c <= 'z' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
    inline bool read_str(char *a){
        while ((*a = nc()) && need(*a) && rEOF)++a;
        *a = '\0'; return rEOF;
    }
}using namespace _;
int sum[100005];
int main()
{
    int n,m;
    memset(sum,0,sizeof sum);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        sum[l]++;
        sum[r+1]--;
    }
    for(int i=1;i<=n+2;i++)
        sum[i]=sum[i-1]+sum[i];
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(sum[i]==m)cnt++;
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(lambda x:int(x),input().split()))
b=[0]*n
c=[0]*10001
for j in range(n):
    c[a[j]]+=1

for i in range(1,10001):
    c[i]=c[i]+c[i-1]

for j in range(n):
    b[c[a[j]]-1]=a[j]
    c[a[j]]-=1

for j in range(n-1):
    print(b[j],end=" ")
print(b[n-1])



Measured memory_bytes: 224540
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	sum := make([]int, 5001)
	for {
		n := nextInt()
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			a := nextInt()
			sum[i+1] = sum[i]+a
		}
		ret := sum[1]
		for i := 0; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				ret = max(ret, sum[j]-sum[i])
			}
		}
		fmt.Println(ret)
	}
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    int c[26] = {0};

    for (int i = 0; i < s.size(); ++i) {
        int num = s[i] - 'a';

        if (c[num] > 0) {
            puts("no");
            return 0;
        }

        c[num]++;
    }

    puts("yes");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   
   int N;
   
   scanf("%d",&N);
   
   int V[N];
   int C[N];
   
   int i;
   
   for(i = 0;i < N;i++){
      scanf("%d",&V[i]);
   }
  
   for(i = 0;i < N;i++){
      scanf("%d",&C[i]);
   }
   
   int ans = 0;
   
   for(i = 0;i < N;i++){
      if(V[i] - C[i] > 0) {
         ans = ans + V[i] - C[i];
      }
   }
   
   printf("%d\n",ans);
   
   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n,m;
    int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a>=b)
            m=b;
        else
            m=a;
        if(c>=d)
            n=d;
            else
            n=c;
        printf("%d\n",n+m);
    }
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int n,d,x;
    cin >> n >> d>>x;
    int a[n];
    int ans=0;
    REP(i, n){
        cin>>a[i];
        int j=1;
        while (j<=d) {
            ans++;
            j+=a[i];
        }
    }
    cout << ans+x << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n,a,b;
  cin >> n >> a >> b;

  if(n<a+b-1||a*b<n) {
    cout << -1 << "\n";
    return 0;
  }

  if(a==1) {
    rep(i,n) cout << n-i << " ";
    cout<< "\n";
    return 0;
  }
  vector<ll> res(0);
  
  ll x = (n-b-1)/(a-1);
  ll cnt = 1;
  
  rep(i,x){
    rep(j,a){
      res.push_back(cnt+a-1-j);
    }
    cnt += a;
  }

  ll y = n+x+2-b-cnt;

  rep(i,y) res.push_back(cnt+y-1-i);
  cnt += y;
  
  for(ll i=cnt;i<=n;++i) res.push_back(i);

  reverse(res.begin(), res.end());

  rep(i,n) cout << res[i] << " ";
  cout  << "\n";
  

  return 0;
}


Measured memory_bytes: 6000
#include<stdio.h>
int main(void)
{
  int n, r[100], i, j, key;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&r[i]);
  }
  for(j=0;j<n-1;j++)
  {
    printf("%d ",r[j]);
  }
  printf("%d\n",r[j]);
  for(i=1;i<n;i++)
  {
    key = r[i];
    for(j=i-1;j>=0;j--)
    {
      if(key > r[j]) break;
      else r[j+1] = r[j];
    }
    r[j+1] =key;
    for(j=0;j<n-1;j++)
    {
      printf("%d ",r[j]);
    }
    printf("%d\n",r[j]);
  }
  return 0;
}


Measured memory_bytes: 2072
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	int n,r,ans;
	cin>>n>>r;
	if(n>=10){
		ans = r;
	} else {
		ans = r + 100*(10-n);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm> // for sort
#include <limits.h>

using namespace std;

int main(void){
  long long int x,y,z,kLen;
  int i,j,k;
  vector<long long int> a,b,c;
  vector<long long int> total;
  
  cin >> x >> y >> z >> kLen;
  for(i=0; i<x; i++){
    long long int value;
    cin >> value;
    a.push_back(value);
  }
  for(i=0; i<y; i++){
    long long int value;
    cin >> value;
    b.push_back(value);
  }
  for(i=0; i<z; i++){
    long long int value;
    cin >> value;
    c.push_back(value);
  }
  
  std::sort(a.begin(),a.end(),std::greater<long long int>());
  std::sort(b.begin(),b.end(),std::greater<long long int>());
  std::sort(c.begin(),c.end(),std::greater<long long int>());
/*
  for(i=0;i<x;i++){
    cout << a[i] << " ";
  }
  cout << endl;
  for(i=0;i<y;i++){
    cout << b[i] << " ";
  }
  cout << endl;
  for(i=0;i<z;i++){
    cout << c[i] << " ";
  }
  cout << endl;
*/
  long long int aMax = a[0];
  long long int bMax = b[0];
  long long int cMax = c[0];
  i=j=k=1;
  long long int diff = 0;
  long long int aDiff, bDiff, cDiff;
  int count = 0;
  while(1){
    aDiff = bDiff = cDiff = LLONG_MAX;
    if(i<a.size()){
      aDiff = aMax - a[i];
    }
    if(j<b.size()){
      bDiff = bMax - b[j];
    }
    if(k<c.size()){
      cDiff = cMax - c[k];
    }
	if(aDiff <= bDiff && aDiff <= cDiff){
      i++;
    }
	if(bDiff <= aDiff && bDiff <= cDiff){
      j++;
    }
	if(cDiff <= aDiff && cDiff <= bDiff){
      k++;
    }
    if( i==a.size()
       && j==b.size()
       && k==c.size() ) break;
    if(i*j*k>kLen)break;
  }

  
  int l,m,n;
  for (l=0;l<i;l++){
    for(m=0;m<j;m++){
      for(n=0;n<k;n++){
        total.push_back(a[l]+b[m]+c[n]);
      }
    }
  }
  
  std::sort(total.begin(),total.end(),std::greater<long long int>());

  
  while(1){
	std::sort(total.begin(),total.end(),std::greater<long long int>());
    if(i < a.size() && total[kLen-1]<a[i]+bMax+cMax){
      for(m=0;m<j;m++){
        for(n=0;n<k;n++){
          total.push_back(a[i]+b[m]+c[n]);
        }
      }
      i++;
    }
    else if(j < b.size() && total[kLen-1]<aMax+b[j]+cMax) {
      for(m=0;m<i;m++){
        for(n=0;n<k;n++){
          total.push_back(a[m]+b[j]+c[n]);
        }
      }
      j++;
    }
    else if(k < c.size() && total[kLen-1]<aMax+bMax+c[k]) {
      for(m=0;m<i;m++){
        for(n=0;n<j;n++){
          total.push_back(a[m]+b[n]+c[k]);
        }
      }
      k++;
    }
    else{
      break;
    }
  }

  //cout << i << "," << j << "," << k << endl;


  for(i=0;i<kLen;i++){
    cout << total[i] << endl;
  }

  return 0;
}





Measured memory_bytes: 904
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 2000
LL mn[MAXN+10];
void solve(long long N, long long x, vector<long long> a){
	LL ans=0;
	for(int i=0; i<N; ++i) {
		a.push_back(a[i]);	
		ans+=a[i];
		mn[i+1]=a[i];
	}
	for(LL k=1; k<=N; ++k) {
		for(int i=1; i<=N; ++i) {
			mn[i]=min(mn[i],a[i+N-k-1]);
		}
		LL sum=k*x;
		for(int i=1; i<=N; ++i) {
			sum+=mn[i];
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long x;
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}



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


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

	uint64_t sum{};
	for(std::size_t i = 1; i <= N; ++i) {
		if(i%3==0||i%5==0)
			continue;
		sum += i;
	}

	std::cout << sum << std::endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);
int digit_sum(int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int summation = 0;
    REPN(i, N) {
        int d_sum = digit_sum(i);
        if ((A <= d_sum) && (d_sum <= B)) {
            summation += i;
        }
    }
    cout << summation << endl;
    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int digit_sum(int num) {
    int sum = 0;
    while (num > 0) {
        sum += num%10;
        num /= 10;
    }
    return sum;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    string x;
    cin>>x;
    if(x[0]==x[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, M, X[100005];
vi A[100005];
// same val
int B[100005];

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

    cin >> N >> M;
    rep(i, N) {
        cin >> X[i];
        A[X[i] % M].push_back(X[i]);
    }
    rep(i, M) {
        sort(all(A[i]));
        int pre = 0, suc = 0;
        A[i].push_back(0);
        each(x, A[i]) {
            if (x != pre) {
                // 同じ値
                B[i] += suc / 2;
                suc = 1;
                pre = x;
            } else suc++;
        }
        A[i].pop_back();
    }

    int ans = 0;
    for (int i = 0; i <= M / 2; ++i) {
        int n = sz(A[i]);
        if (i * 2 % M == 0) {
            ans += n / 2;
            continue;
        }
        int j = M - i;
        int m = sz(A[j]);
        int ma = 0;
        // i同士でp個作る
        for (int p = 0; p <= B[i]; ++p) {
            // 残り
            int nn = n - p * 2;
            // mod M = 0
            int cnt = min(nn, m);
            int q = min((m - cnt) / 2, B[j]);
            smax(ma, cnt + p + q);
        }
        ans += ma;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7040
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
    };
    let mut ans = false;
    for r in 0..=n {
        for c in 0..=m {
            if r * (m - c) + c * (n - r) == k {
                ans = true;
            }
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


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

int main(int argc, char *argv[])
{
    map<char, int> counts;

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

    // 4s
    bool valid = true;
    //cout << (h/2) * (w/2) << endl;
    for(int i = 0; i < (h/2) * (w/2); ++i)
    {
        char ch = 0;
        for(auto& count : counts)
        {
            if(count.second >= 4)
            {
                ch = count.first;
                break;
            }
        }

        if(ch == 0) valid = false;
        counts[ch] -= 4;
    }

    int count = 0;
    if(w % 2 != 0 && h % 2 != 0)
    {
        count = h / 2 + w / 2;
    }
    else if(w % 2 != 0 || h % 2 != 0)
    {
        count = w % 2 != 0 ? h / 2 : w / 2;
    }

    for(int i = 0; i < count; ++i)
    {
        char ch = 0;
        for(auto& count : counts)
        {
            if(count.second >= 2)
            {
                ch = count.first;
                break;
            }
        }

        if(ch == 0) valid = false;
        counts[ch] -= 2;
    }

    char ch = 0;
    for(auto& count : counts)
    {
        if(count.second >= 1)
        {
            ch = count.first;
            break;
        }
    }

    if(w % 2 != 0 && h % 2 != 0)
    {
        valid &= ch != 0;
    }

    cout << (valid ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m,x[max_n],y[max_n];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",x+i),x[i]=Add(x[i],mod);
    for(int i=1;i<=m;i++)scanf("%d",y+i),y[i]=Add(y[i],mod);
    int ans=0;
    int a=0,b=0,c=0,d=0;
    for(int i=1;i<=n;i++)a=Add(a,Mul(i-1,x[i]));
    for(int i=1;i<=n;i++)b=Add(b,Mul(n-i,x[i]));
    for(int i=1;i<=m;i++)c=Add(c,Mul(i-1,y[i]));
    for(int i=1;i<=m;i++)d=Add(d,Mul(m-i,y[i]));
    ans=Add(ans,Mul(a,c));
    ans=Sub(ans,Mul(a,d));
    ans=Sub(ans,Mul(b,c));
    ans=Add(ans,Mul(b,d));
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  string p,q;
  bool check = true;
  cin >> p >> q;
  for (int i = 0; i < p.size(); i++) {
    if (!(p.at(i) == q.at(i))) {
      check = false;
      break;
    }
  }
  if (check) cout << "Yes" <<endl;
  
  else cout << "No" <<endl;
}

Measured memory_bytes: 3604
n, m = map(int, input().split())

a = []
b = []
for i in range(m):
    tmp1, tmp2 = map(int, input().split())
    a.append(tmp1)
    b.append(tmp2)

link = []

for i in range(n):
    num = i + 1
    link.append([])
    for a_i, b_i in zip(a, b):
        if a_i == num:
            link[i].append(b_i)
        if b_i == num:
            link[i].append(a_i)
pass_count = 0

hie_ind = [0 for i in range(n)]
pass_his = [1]
finish = False
while True:
    if len(pass_his) == n:
        pass_count += 1
        pass_his.pop()

    hierarchy = len(pass_his) - 1
    now_n = pass_his[-1]-1
    now_ind = hie_ind[hierarchy]

    while True:
        if now_ind > (len(link[now_n]) - 1):
            if now_n == 0:
                finish = True
                break
            pass_his.pop()
            hie_ind[hierarchy] = 0

            hierarchy = len(pass_his) - 1
            now_n = pass_his[-1]-1
            now_ind = hie_ind[hierarchy]
        else:
            break
    if finish:
        break

    cand_n = link[now_n][now_ind]

    if not(cand_n in pass_his):
        pass_his.append(cand_n)
    hie_ind[hierarchy] += 1

print(pass_count)



Measured memory_bytes: 3188
import java.util.Scanner;

/**
 * Created by zzt on 17-2-4.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] a = new long[n];
        long s = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextLong();
            s += a[i];
        }
        long t = n * (n + 1L) / 2;
        if (s % t != 0) {
            System.out.println("NO");
            return;
        }
        long k = s / t;
        long[] d = new long[n];
        for (int i = 0; i < n; i++) {
            d[i] = a[(i + 1) % n] - a[i];
            if (k < d[i] || (k - d[i]) % n != 0) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

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

int main(){
  int x,y,t;
  while(1){
    cin >> x >> y;
    if(x==0&&y==0){
      break;
    }else{
      if(x>y){
        t=x;
        x=y;
        y=t;
      }
      cout << x << " " << y <<endl;
    }
  }
   return 0;
}

Measured memory_bytes: 3024
#include<cstdio>
int a,b,c;
int ma(int a,int b){return a>b?a:b;}
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)printf("%d",ma(c-a+b,0));
	else printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;

	vector<string> grid(H);
	rep(h, H) cin>>grid[h];

	vvi dp(H, vi(W, 0)); // (h,w): count
	queue<pair<int,int>> q; // <h,w>
	q.push({0,0});

	while(q.size()){
		int h,w; tie(h,w) = q.front(); q.pop();

		if(W <= w || H <= h) continue; // range over
		if(grid[h][w] == '#') continue; // blocked wall
		if(dp[h][w] > 0) continue; // already visited

		if(h==0 && w==0) dp[h][w] = 1;
		else{
			dp[h][w] = 0;
			if(0 <= w-1) dp[h][w] += dp[h][w-1]; // left
			if(0 <= h-1) dp[h][w] += dp[h-1][w]; // up
		}
		dp[h][w] %= MOD;

		q.push({h,w+1}); // right
		q.push({h+1,w}); // down
	}
	cout<< dp[H-1][W-1] <<endl;

}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Mod 1000000007
int main()
{
    ll n, x;
    cin>>n>>x;
    vector<ll> h(n), s(n), dp(100010);
    for(ll i=0; i<n; i++) cin>>h[i]>>s[i];
    for(ll i=0; i<n; i++)
        for(ll j=x; j>=h[i]; j--)
            dp[j]=max(dp[j],dp[j-h[i]]+s[i]);
    cout<<dp[x]<<endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
   

  int n;
  cin>>n;
  
  int count = 0;

  
  for(int i = 1 ; i<= n/2 ; i++)
  {
      if(n % i == 0)
      {
          count = count + n / i - 1;
      }
      else
      {
          count = count + n / i ;
      }
  }
  
  count = count + n/2;
  if(n % 2 == 0)
  count--;
  
  cout<<count<<endl;
}


Measured memory_bytes: 3636
A,B,C,D=map(int,input().split())
if C//B<=A//D and A/D!=A//D:
  print('Yes')
elif C//B==A//D and  A/D==A//D and C//B==C/B:
  print('Yes')
elif C//B-1==A//D and C//B==C/B and A//D!=A/D:
  print('Yes')
else:
  print('No')


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=0 && 0<=b){
    cout << "Zero" << endl;
  }
  else if(0<a){
    cout << "Positive" << endl;
  }
  else if(b<0 && (b-a+1)%2==0){
    cout << "Positive" << endl;
  }
  else{
    cout << "Negative" << endl;
  }
}

Measured memory_bytes: 256
import re
while 1:
    try:N=input()
    except:break
    NUMBER=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',N)])
    N=N.replace('=','==')
    for i in '0123456789'[NUMBER:]:
        if eval(N.replace('X',i)):
            print(i)
            break
    else:print('NA')


Measured memory_bytes: 6560
#include <iostream>
#include <vector>
#include <string>



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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = 0;
    if (k <= a)
        res = k;
    else if (k <= a + b)
        res = a;
    else
        res = a - (k - a - b);

    cout << res;
}


Measured memory_bytes: 3644
import numpy as np
N=int(input())
a=[]
b=[]
xa=[]
xb=[]
y=[]
for i in range (0,N):
    c,d=(int(x) for x in input().split(" "))
    xa.append(c)
    xb.append(d)
     
z=np.argsort(xb)

for i in range (0,N):
    a.append(xa[z[i]])
    b.append(xb[z[i]])
for i in range (0,N):
    if i==0:
      	y.append(a[0])
    else:
      	y.append(a[i]+y[i-1])
def check(i,a,b):
    if b[i]>=y[i]:
        return True
    else:
        return False
def final_check(a,b,N):
    for i in range (0,N):
        if check(i,a,b)==False:
            return "No"
    return "Yes"
print (final_check(a,b,N))


Measured memory_bytes: 40864
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::collections::{BinaryHeap, HashSet};
 
const MOD: i64 = 1e9 as i64 + 7;
 
fn main(){
    let s : String = read();
    let mut ans : String = "".to_string();
    for _ in 0..s.len() {
        ans += "x";
    }
    println!("{}", ans);
}
 
fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var NKM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var A = NKM[0];
            //var B = NKM[1];

            var a = 0L;
            var b = 0L;
            for (int i = (int)Sqrt(N); i >= 1; i--)
            {
                if (N%i == 0)
                {
                    a = i;
                    b = N / i;
                    break;
                }
            }


            Console.WriteLine(a+b-2);
        }


    }

}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(s.size(),0);
    int cnt = 0;
    rep(i,n){
        if(s[i] == 'L'){
            ans[i] += cnt/2;
            ans[i-1] += (cnt+1)/2;
            cnt = 0;
        }
        if(s[i] == 'R') cnt++;
    }
    cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == 'R'){
            ans[i] += cnt/2;
            ans[i+1] += (cnt+1)/2;
            cnt = 0;
        }
        if(s[i] == 'L') cnt++;
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3840
use proconio::{*, marker::Chars};

fn main() {
    input!{
        n: usize,
        c: Chars,
    }

    let mut red_cnt = 0;
    for &i in c.iter() {
        if i == 'R' {
            red_cnt += 1;
        }
    }

    let mut ans = 0;
    for i in 0..red_cnt {
        if c[i] == 'W' {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 3100
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
const ll mod=1e9+7;
int a[N],b[N],n;
int cnta[N],cntb[N];
int ans[N];

int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1;i<=n;i++) 
        {
            cin>>a[i];
            cnta[a[i]]++;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
            cntb[b[i]]++;
        }
        for(int i=1;i<=n;i++)
            if(cnta[i]+cntb[i]>n) return cout<<"No\n",0;
        reverse(b+1,b+1+n);
        vector<int> p,q;
        int now=0,cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=b[i]) continue;
            cnt++;
            p.push_back(i);
            now=b[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(!cnt) break;
            if(a[i]==b[i]) continue;
            if(a[i]!=now&&b[i]!=now)
            {
                cnt--;
                q.push_back(i);
            }
        }
        for(int i=0;i<q.size();i++) swap(b[p[i]],b[q[i]]);
        cout<<"Yes\n";
        for(int i=1;i<=n;i++) cout<<b[i]<<' ';
        cout<<'\n';
    }
    return 0;
}

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

int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		string s;
		for (int i = 0; i < a.size() - b.size(); i++)s.push_back('0');
		s += b;
		b = s;
	}
	else if (a.size() < b.size()) {
		string s;
		for (int i = 0; i < b.size() - a.size(); i++)s.push_back('0');
		s += a;
		a = s;
	}
	if (a > b)cout << "GREATER" << endl;
	else if (a < b)cout << "LESS" << endl;
	else cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

inline void judge(vector <int>& num, vector <int>& cntType, vector<char>& cho, int c1, int c2, int cp, int idx, int target) {
    const char ch[3] = {'A', 'B', 'C'};
    int N = cho.size();

    if (num[c1] > num[c2]) {
        --num[c1];
        ++num[c2];
        cho[idx] = ch[c2];
    } else if (num[c2] > num[c1]) {
        ++num[c1];
        --num[c2];
        cho[idx] = ch[c1];
    } else {
        if (idx+1 < N && num[cp] == 0) { // peeking
            if (cntType[idx+1] == target) {
                ++num[c1];
                --num[c2];
                cho[idx] = ch[c1];
            } else {
                --num[c1];
                ++num[c2];
                cho[idx] = ch[c2];
            }
        } else {
            ++num[c1];
            --num[c2];
            cho[idx] = ch[c1];
        }
    }
}

int main() {
    int N;
    vector <int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];

    vector <int> cntType(N);

    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;

        if (s == "AB") {
            cntType[i] = 0;
        } else if(s == "AC") {
            cntType[i] = 1;
        } else {
            cntType[i] = 2;
        }
    }

    vector <char> cho(N);
    bool failed = false;

    for (int i = 0; i < N; ++i) {
        if (cntType[i] == 0) { // AB
            judge(num, cntType, cho, 0, 1, 2, i, 1);
        } else if(cntType[i] == 1) { // AC
            judge(num, cntType, cho, 0, 2, 1, i, 0);
        } else { // BC
            judge(num, cntType, cho, 1, 2, 0, i, 0);
        }

        for (int j = 0; j < 3; ++j) {
            if (num[j] < 0) {
                failed = true;
                break;
            }
        }
    }

    if (failed) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 0; i < N; ++i) {
            cout << cho[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

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

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  
  return i;
}
bool judge(string s){
  bool ret = false;
  string t = s;
  reverse(t.begin(), t.end());
  if(s == t){
    ret = true;
  }
  return ret;
}

map<ll,ll> m;
void solve(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i = 0;i < n;i++) {
    cin >> a[i];
    if(m.count(a[i])){
      m[a[i]]++;
    }else{
      m.insert(make_pair(a[i],1));
    }
  }

  ll sum = 0;

  for(int i = 0;i <= n;i++){
    if(m.count(i)){
      sum += m[i]*(m[i]-1)/2;
    }
  }

  for(int i = 0;i < n;i++){
    cout << sum-(m[a[i]]-1) << endl;
  }
  
}


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


Measured memory_bytes: 11136