akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[4];
int main(){
	rep(i,0,6){
		ll n;
		scanf("%lld",&n);
		a[n]++;
	}
	ll s=0;
	rep(i,0,4)s+=pow(10,a[i+1]);
	puts(s==220?"YES":"NO");
}

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

long long a,b,c,d,e,f,q,w;
pair<long double,pair<int,int> >ans;
bool used1[4000],used2[4000];


void rec1(int x=0){
    if(x>f){
        return;
    }
    if(used1[x]){
        return;
    }
    used1[x]=true;
    rec1(x+a*100);
    rec1(x+b*100);
}

void rec2(int x=0){
    if(x>f){
        return;
    }
    if(used2[x]){
        return;
    }
    used2[x]=true;
    rec2(x+c);
    rec2(x+d);
}
main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b>>c>>d>>e>>f;
    rec1();
    rec2();
    for(int i=1;i<=f;i++){
        for(int j=0;j<=f;j++){
            if(used1[i] && used2[j] && i*e>=100*j && i+j<=f){
                ans=max(ans,make_pair((long double)j*100/(i+j),make_pair(i+j,j)));
            }
        }
    }
    cout<<ans.second.first<<" "<<ans.second.second;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def solve(): 
    r, D, x =  map(int, input().split())
    res_l = []
    for _ in range(10):
        x = r*x - D
        res_l.append(str(x))
    
    return '\n'.join(res_l)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> Pair;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll INFL = 1e18;

vector<pair<ll,int>> factors(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i<=n; i++){
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i == 0){
            n/=i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll g = __gcd(a,b);
    vector<pair<ll,int>> f = factors(g);
    ll ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int64_t sum = 0;
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            sum += data.at(i) * data.at(j);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
const int N=405,M=100005;
int n,m;
int x[M],y[M];
int vis[N];
int check(){
	for (int i=m;i>=1;i--){
		int a=x[i],b=y[i];
		if (vis[a]&&vis[b])
			return 0;
		if (!vis[a]&&!vis[b])
			continue;
		vis[a]=vis[b]=1;
	}
	return 1;
}
int main(){
	n=read(),m=read();
	for (int i=1;i<=m;i++)
		x[i]=read(),y[i]=read();
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			memset(vis,0,sizeof vis);
			vis[i]=vis[j]=1;
			ans+=check();
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
#define int long long
 
signed main(){
	
 
	string s;
	cin>>s;

	for(int i=0;i<s.size()-8;i++){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define pp pair<int,int>
#define endl "\n"
#define PI 3.14159265
int MAXN = 5000001;
const int mod=1000000007;
const int INF =INT_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
      int d,t,s;
      cin>>d>>t>>s;
      if(s*t>=d)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;


    }
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int sum = accumulate(a.begin(), a.end(), 0);

    int num = a.size();
    int ave = sum / num;
    int dist = 0;
    REP(i, n) dist += pow(ave - a[i], 2);

    int ave2 = sum / num + 1;
    int dist2 = 0;
    REP(i, n) dist2 += pow(ave2 - a[i], 2);

    // int ave3 = sum / num - 1;
    // int dist3 = 0;
    // REP(i, n) dist3 += pow(ave3 - a[i], 2);

    // cout << min({dist, dist2, dist3}) << '\n';
    cout << min(dist, dist2) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

bool check( int a, int b, int c){
	if( (a < b && b < c) || (c < b && b < a) ) {
		return true;
	}else{
		return false;
	}
}

int main() {
	int n; cin >> n;

	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}

	int Ans = 0;
	for (int i = 0; i < n - 2; ++i)
	{
		if(   check(v[i],v[i+1],v[i+2])   ) Ans++;
	}

	cout << Ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    int h, w;
    cin >> h >> w;
    char m[h][w];
    bool height[h];
    bool width[w];
    for (int i = 0; i < h; i++) height[i] = false;
    for (int i = 0; i < w; i++) width[i] = false;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> m[i][j];
            if (m[i][j] == '#') {
                height[i] = true;
                width[j] = true;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (height[i] && width[j]) cout << m[i][j];
        }
        if(height[i]) cout << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			final char[] S = sc.next().toCharArray();
			
			int diff = 0;
			for(int i = 0; i < N; i++) {
				if(S[i] == 'L') {
					if(i == 0) { diff += 1; }
					else if(S[i - 1] != 'L') { diff += 1; }
				}else {
					if(i == N - 1) { diff += 1; }
					else if(S[i + 1] != 'R') { diff += 1; }
				}
			}
			
			System.out.println(N - Math.max(1, diff - 2 * K));
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 24660
import sys
from collections import deque

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
b = [ns() for _ in range(n)]
dr = [1, 0, -1, 0]
dc = [0, 1, 0, -1]
dmax = 0
for i in range(n):
    for j in range(m):
        if b[i][j] == ".":
            q = deque()
            q.append((i, j))
            d = [[9999999] * m for _ in range(n)]
            d[i][j] = 0
            while len(q):
                cur = q.popleft()
                dmax = max(dmax, d[cur[0]][cur[1]])
                for k in range(4):
                    nr, nc = cur[0] + dr[k], cur[1] + dc[k]
                    if 0 <= nr < n and 0 <= nc < m and b[nr][nc] == "." and d[nr][nc] > d[cur[0]][cur[1]] + 1:
                        d[nr][nc] = d[cur[0]][cur[1]] + 1
                        q.append((nr, nc))
print(dmax)


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

ll H, W;

int main(){
  cin >> H >> W;
  
  for(ll i = 0; i < H + 2; i++){
    if(i == 0 || i == H+1){
      for(ll j = 0; j < W+2; j++){
        cout << '#';
      }
      cout << endl;
    }else{
      cout << '#';
      for(ll j = 0; j < W; j++){
        char c; cin >> c;
        cout << c;
      }
      cout << '#' << endl;
    }
  }
  
}

Measured memory_bytes: 384
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

void solve() {
    lli ans  = 0;
    lli n;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 2) ans++;
        n /=10;
    }
    cout << ans << endl;
}

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

    while(t--)
        solve();
    return 0;
}

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

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);

#define endl '\n'

using namespace std ;

typedef long long ll ;


int main(){

 fast();

 string str ;
 cin >> str;
 int cnt = 0;
 int ans = 0;
 str+='$';
 for(auto  i : str){
    if(i == 'R') cnt++;
    else{
        ans = max(ans,cnt);
        cnt = 0;
    }
 }
 cout<<ans<<endl;


 return 0;
}



Measured memory_bytes: 3648
#include <iostream>

int main(){
  int N;
  int A;
  bool flag = true;
  
  std::cin >> N;
  for(int i=0;i<N;i++){
    std::cin >> A;
    if(A % 2 == 0 && A % 3 != 0 && A % 5 != 0){
	flag = false;
	break;
    }
  }

  if(flag == true)
    std::cout << "APPROVED" << std::endl;
  else
    std::cout << "DENIED" << std::endl;
  
  return 0;
}


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

int main(){
    string S;
    cin >> S;

    // cout << S << endl;
    // cout << S.at(3) << endl;

    if(S.at(0) == S.at(1)){
        if((S.at(0) != S.at(2)) && (S.at(2) == S.at(3))){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else if(S.at(0) == S.at(2)){
        if((S.at(0) != S.at(1)) && (S.at(1) == S.at(3))){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else if(S.at(0) == S.at(3)){
        if((S.at(0) != S.at(1)) && (S.at(1) == S.at(2))){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    N = N%10;

    switch(N){
        case 1:
            cout << "pon" << endl;
            break;

        case 2:
            cout << "hon" << endl;
            break;

        case 3:
            cout << "bon" << endl;
            break;

        case 4:
            cout << "hon" << endl;
            break;

        case 5:
            cout << "hon" << endl;
            break;

        case 6:
            cout << "pon" << endl;
            break;

        case 7:
            cout << "hon" << endl;
            break;

        case 8:
            cout << "pon" << endl;
            break;

        case 9:
            cout << "hon" << endl;
            break;

        case 0:
            cout << "pon" << endl;
            break;
    }

    return 0;

}

Measured memory_bytes: 3572
#include <stdio.h>

int main() {
    int pess, doce;
    scanf("%d %d", &pess, &doce);
    int marc[pess], snk, kd;
    
    for (int i = 0; i < pess; ++i)
        marc[i] = 0;
        
    for (int h = 0; h < doce; ++h){
        scanf("%d", &snk);
        for (int i = 0; i < snk; ++i){
            scanf("%d", &kd);
            
            marc[kd-1] = 1;
        }
    }
    int cont = 0;
    for (int i = 0; i < pess; ++i){
        if (marc[i] == 0)
            cont += 1;
    }
    
    printf("%d\n", cont);
    
    return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
int arr[100];
int main(void) {
	int N, i, j, min, count = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", arr + i);
	for (i = 0; i < N; i++) {
		min = i;
		for (j = i; j < N; j++) {
			if (arr[min] > arr[j]) {
				min = j;
			}
		}
		if (min != i) {
			arr[min] ^= arr[i];
			arr[i] ^= arr[min];
			arr[min] ^= arr[i];
			count++;
		}
	}
	printf("%d", *arr);
	for (j = 1; j < N; j++) printf(" %d", arr[j]);
	printf("\n%d\n", count);
}

Measured memory_bytes: 1852
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	int a, b, k; cin >> a >> b >> k;
	for (int i = a; i < min(a + k, b + 1); i++)
		cout << i << endl;
	for (int i = max(b - k+1, a + k); i <= b; i++)
		cout << i << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    string t = "ACGT";
    int ans = 0, cnt = 0;
    rep(i,s.size()){
        bool ok = false;
        rep(j,t.size()){
            if(s[i]==t[j]) ok = true;
        }
        if(ok) {cnt++; ans = max(ans, cnt);}
        else cnt = 0;
        
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {

  int i , n;

  double a , m , total , s[1001] = {};

  while(1) {

    cin >> n;

    if(n == 0) break;

    s[1000] = total = 0;

    for(i = 0; i < n; i++) {

      cin >> s[i];

      s[1000] += s[i];

    }

    m = s[1000] / n;

    for(i = 0; i < n; i++) {

      total += pow(s[i] - m , 2);

    }

    a = sqrt(total / n);

    printf("%.8lf\n",a);

  }

  return 0;

}

Measured memory_bytes: 1252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int K, A, B;

    std::cin >> K >> A >> B;

    if (B / K * K >= A)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 3604
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
x=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            x+=1

y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            y+=1

cnt=(x*k)+(k*(k-1)//2*y)
print(cnt%mod)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N ,x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i,N){
        cin >> a.at(i);
    }
    long ans=0;
    rep(i,N-1){
        if(x<a.at(i)+a.at(i+1)&&a.at(i)>x){
            ans+=a.at(i+1);
            a.at(i+1)=0;
            ans+=a.at(i)-x;
            a.at(i)=x;
        }else if(x<a.at(i)+a.at(i+1)&&a.at(i)<=x){
            ans+=a.at(i+1)-(x-a.at(i));
            a.at(i+1)=x-a.at(i);
        }else if(x>=a.at(i)+a.at(i+1)){
            continue;
        }else{

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

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

int main()
{
    ll N, X; cin >> N >> X;
    vector<ll> m(N, 0);
    ll sum = 0;
    rep(i,N) {
        cin >> m[i];
        sum += m[i];
    }
    sort(m.begin(), m.end());
    ll ans = N;
    X -= sum;
    ans += (X / m[0]);
    cout << ans << endl;
    




}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    char ch;
    cin >> ch;
    if (ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,x,y,z,a[101]={0},b[101]={0},c[101]={0},k,i,cu=0;
	scanf("%d",&n);
	scanf("%d",&x);
	for(i=0;i<x;i++){
		scanf("%d",&k);
		a[k]=1;
	}
	scanf("%d",&y);
	for(i=0;i<y;i++){
		scanf("%d",&k);
		b[k]=1;
	}
	scanf("%d",&z);
	for(i=0;i<z;i++){
		scanf("%d",&k);
		c[k]=1;
	}
	for(i=1;i<=n;i++){
		if(a[i]==0&&c[i]==1||a[i]==1&&b[i]==1&&c[i]==1){
			cu++;
		}
	}
	printf("%d\n",cu);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll f(ll n, ll x) {
  if (n == 0) return 1;
  ll a = (1LL<<(n+1)) - 3; //a_{n-1}
  ll p = (1LL<<(n)) - 1; //p_{n-1}
  debug(a, p, n, x);
  if (x == 1) return 0;
  else if (x <= a+1) return f(n-1,x-1);
  else if (x == a+2) return p+1;
  else return p + 1 + f(n-1, x-(a+2));
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, x;
  cin >> n >> x;
  cout << f(n,x) << endl;
  return 0;
}

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

use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        xx: Chars,
    }
    let mut m = vec![None; n + 10];
    fn f(x: usize, m: &mut [Option<usize>]) -> usize {
        if x == 0 {
            return 0;
        }
        if let Some(r) = m[x] {
            return r;
        } else {
            let r = 1 + f(x % x.count_ones() as usize, m);
            m[x] = Some(r);
            return r;
        }
    }
    let ones = xx.iter().filter(|&&x| x == '1').count() as u64;
    let mut a = 0;
    let mut c = 0;
    for i in 0..n {
        a *= 2;
        c *= 2;
        if xx[i] == '1' {
            a += 1;
            c += 1;
        }
        a %= max(ones, 2) - 1;
        c %= ones + 1;
    }
    let mut p = 1;
    let mut r = 1;
    let mut res = vec![0; n];
    for i in (0..n).rev() {
        p %= max(ones, 2) - 1;
        r %= ones + 1;
        if xx[i] == '0' {
            let x = (c + r) % (ones + 1);
            res[i] = 1 + f(x as usize, &mut m);
        }
        if xx[i] == '1' {
            if ones <= 1 {
                res[i] = 0;
            } else {
                let x = (ones - 1 + a - p) % (ones - 1);
                res[i] = 1 + f(x as usize, &mut m);
            }
        }
        p *= 2;
        r *= 2;
    }
    for i in 0..n {
        println!("{}", res[i]);
    }
}


Measured memory_bytes: 7760
#include <bits/stdc++.h>
const int MAX=1e6+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int n,m,d,t,s;
string p,q;
int a[MAX],b[MAX];
void solve(){
    cin>>p>>q;
    m=p.length();
    n=q.length();
    int minn=INT_MAX;
    for(int i=0;i+n<=m;i++){
        int flag=i;
        int ans=0;
        for(int j=0;j<n;j++){
            if(p[i]==q[j])
                ans++;
            i++;
        }
        i=flag;
        minn=min(minn,n-ans);
    }
    cout<<minn;
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n;cin>>n;
    string s[n];
    unordered_map<string,ll> map;
    ll ans=0;
    for(ll i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        ans+=map[s[i]];
        map[s[i]]++;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 17700
#include <stdio.h>

int main(void) {
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	if (a > b) {
		printf("a > b\n");
	} else if (a < b) {
		printf("a < b\n");
	} else {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main(void) {

	int i;
	int	S;
	int h, m, s;

	scanf("%d", &S);

	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S - h * 3600 - m * 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 2740
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int a[1000001];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) cin >> a[i];
  string l="", r="";
  
  //1
  if(n%2){
    for(int i=n-1; i>=0; i=i-2){
      l += to_string(a[i]);
      l += " ";
    }
    for(int i=1; i<n; i=i+2){
      r += to_string(a[i]);
      r += " ";
    }
  }
  //0
  else{
    for(int i=n-1; i>0; i=i-2){
      l += to_string(a[i]);
      l += " ";
    }    
    for(int i=0; i<n; i=i+2){
      r += to_string(a[i]);
      r += " ";
    }
  }

  
  cout << l + r << endl;
  
  return 0;
}


Measured memory_bytes: 6920
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

int n;
int a[100010];

int main(){

  scanf( "%d" , &n );
  REP( i , n ){
    scanf( "%d" , &a[i] ); a[i]--;
  }
    

  int ans = 0;
  REP( i , n ){
    if( a[ a[i] ] == i ) ans++;
  }

  printf( "%d\n" , ans/2 );
  
  return 0;
}


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

using namespace std;


int main(){
    string S;
    int ans = 0;
    cin >> S;

    for(int i = 0; i < 4; i++){
        if(S[i] == '+')
            ans++;
        else
            ans--;
    }

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AButtons solver = new AButtons();
        solver.solve(1, in, out);
        out.close();
    }

    static class AButtons {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();

            int ans = 0;

            ans = Math.max(ans, a + b);
            ans = Math.max(ans, a + a - 1);
            ans = Math.max(ans, b + b - 1);

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
ll L,a[maxn],ans,s;
int n;
ll s1[maxn],s2[maxn];
ll F(ll x) {
	if (x==0) return 0;
	return L-x;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(L); read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++) s1[i]=s1[i-1]+a[i];
	for (int i=n;i>=1;i--) s2[i]=s2[i+1]+F(a[i]);
	ans=max(a[n],F(a[1]));
	for (int i=1;i<=n/2;i++) {
		s=2*s1[i]+2*(s2[i+1]-s2[i*2+2])-F(a[i+1]);
		ans=max(ans,s);
		s=2*s1[i]+2*(s2[i+1]-s2[i*2+1])-a[i];
		ans=max(ans,s);
	}
	for (int i=1;i<=n;i++) a[i]=L-a[i];
	reverse(a+1,a+n+1);
	for (int i=1;i<=n;i++) s1[i]=s1[i-1]+a[i];
	for (int i=n;i>=1;i--) s2[i]=s2[i+1]+F(a[i]);
	for (int i=1;i<=n/2;i++) {
		s=2*s1[i]+2*(s2[i+1]-s2[i*2+2])-F(a[i+1]);
		ans=max(ans,s);
		s=2*s1[i]+2*(s2[i+1]-s2[i*2+1])-a[i];
		ans=max(ans,s);
	}
	printf("%lld\n",ans);
	/*
	for (int i=0;i<=n;i++)
	for (int j=n+1;j>=1+i;j--) {
		dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][0]+a[i+1]-a[i]);
		dp[i][j-1][1]=max(dp[i][j-1][1],dp[i][j][0]+a[i]+F(a[j-1]));
		dp[i][j-1][1]=max(dp[i][j-1][1],dp[i][j][1]+a[j]-a[j-1]);
		dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][1]+F(a[j])+a[i+1]);
		if (i==2&&j==6) printf("%lld\n",dp[i][j][1]);
	}
	for (int i=0;i<=n;i++)
		ans=max(ans,dp[i][i+1][0]),
		ans=max(ans,dp[i][i+1][1]);
	printf("%lld\n",ans);
	*/
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans=1e18,mx,mn=1e8,sum,cnt;
int main(){
	ll n,y;
	cin>>n>>y;
	for(int i=0; i<=2000; i++){
		for(int j = 0; j<=2000; j++ ){
			ll flag = (i*10000)+(j*5000);
			ll temp=y-flag;
			if(temp < 0) continue;
			if(temp %1000==0){
				if((i+j+temp/1000)==n){
					cout<<i<<" "<<j<<" "<<(y-flag)/1000<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"-1 -1 -1";
}

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

int n,w[101],total=0,mn=10001,sum=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w[i];
		total+=w[i];
	}
	for(int i=0;i<n;i++){
		sum+=w[i];
		if(abs(sum*2-total)<mn){
			mn=abs(sum*2-total);
		}
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL a,b,x;
    R(a,b,x);
    double pi=acos(-1);
    if(x*2<=a*a*b){
        W(90-atan(x*2./(a*b)/b)/pi*180);
    }
    else{
        x=a*a*b-x;
        W(atan(x*2./(a*a)/a)/pi*180);
    }
    return 0;
}


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


int main() {
  string s;
  int k;
  cin>>k>>s;
  if(s.size()>k) {
    for(int i=0;i<k;i++) {
      cout<<s[i];
    }
    cout<<"...";
  }else {
    cout<<s;
  }
  return 0;
}

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


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

	int i = 0;
	int j  = n - 1;
	int ans  =  0;
	while (i < j) {
		while (a[i] == 'R' && i < j) {
			i++;
		}
		while (j > i && a[j] == 'W') {
			j--;
		}
		if (i < j) {
			ans++;
			char temp  = a[i];
			a[i] = a[j];
			a[j] = temp;
			i++;
			j--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3952
S = input()
a = [1,0,0,0]

for s in S:
  if s=="A":
    a[1]+=a[0]
  elif s=="B":
    a[2]+=a[1]
  elif s=="C":
    a[3]+=a[2]
  else:
    a=[3*a[0]]+[3*a[n+1]+a[n] for n in range(3)]
  a=[a[n]%1000000007 for n in range(4)]

print(a[3])

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=1;i<n;i++) {
    ll tmp;
    cin >> tmp;
    tmp--;
    a[tmp]++;
  }
  for(ll i=0;i<n;i++) {
    cout << a[i] << endl;
  }
}

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

using namespace std;

int main(){
    int ai,bi;
    string a,b,u;
    cin >> a >> b;
    cin >> ai >> bi;
    cin >> u;
    if(u == a) ai = ai-1;
    else bi = bi - 1;
    cout << ai << " " << bi << endl;
    return 0;


}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;}

int main() {
  ll n;
  cin >> n;

  ll ans = LINF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) ans = min(ans, i + n / i);
  }
  if (ans == LINF) P(n - 1);
  else P(ans - 2);
  return 0;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Phuong // <3
typedef pair<int,ll> ii;


int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp (n+1,vector<ll> (w+1,0));
    vector<ii> ar(n+1);
    for(int i=1; i<=n; i++)
        cin >> ar[i].first >> ar[i].second;
    for(int i=1; i<=n; ++i)
    {
        ii x=ar[i];
        for(int j=1; j<=w; ++j)
        if (j>=x.first) dp[i][j]=max(dp[i-1][j],dp[i-1][j-x.first] + x.second); else
        dp[i][j]=dp[i-1][j];
    }
    cout << dp[n][w];
    return(0);
}


Measured memory_bytes: 80256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
const int MAX = 1000;
class unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[0] = 0;
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
};
constexpr unko f;
inline void putint(ll X) {
	int ue = X / 1000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 1000;
		rep(i, 3 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei +=(A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6648
K,N = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
C = 0
for i in range(N):
  if i == N-1:
    B[i] = A[0] + K - A[i]
  else:
    B[i] = A[i+1] - A[i]
  if B[i] > C:
    C = B[i]
print(K-C)

Measured memory_bytes: 26436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x;
	cin>>n>>x;
	long long a[n+1],b[n+1];
	a[0]=1;
	b[0]=1;
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1]*2+1;
		b[i]=b[i-1]*2+3;
	}
	long long ans=0;
	while(x>0){
		if(x==b[n]){
			ans+=a[n];
			x=0;
		}
		else if(x>=b[n]/2+1){
			ans+=a[n-1]+1;
			x-=b[n]/2+1;
		}
		else
		   x--;
		n--;
	}
	cout<<ans<<endl;
	return 0;
}



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

#define ll long long

using namespace std;

int main() {
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	ll toprice = D;
	toprice = min(toprice, S*2);
	toprice = min(toprice, H*4);
	toprice = min(toprice, Q*8);
	ll oprice = S;
	oprice = min(oprice, 2*H);
	oprice = min(oprice, 4*Q);
	ll ans = (N/2)*toprice;
	if (N%2 == 1) ans += oprice;
	cout << ans << endl;
	// cin >> N;
}

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

using namespace std;

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

    int n, k, dp[100001] = {}, tmp;
    set<int> bro;
    cin >> n >> k;
    while (k--)
        cin >> tmp, bro.insert(tmp);

    dp[0] = 1;
    dp[1] = (!bro.count(1));
    for (int i = 2; i <= n; i++)
        if (bro.count(i))
            dp[i] = 0;
        else
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
    cout << dp[n] << '\n';

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n,k;
  cin>>n>>k;
  cout<<n%k<<endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 5e5+5;

int n, q, c[N], ci[N], ans[N];
V<P<int, int>> v[N];

struct Seg{
  typedef ll T;
  const T e = 0;
  void merge(const T &a, const T &b, T &c){
    c = a+b;
  }

  int n;
  vector<T> d;

  void init(int m){
    n = 1<<(32-__builtin_clz(m-1));
    d = vector<T>(2*n, e);
  }
  void init(vector<T> &v){
    init(v.size());
    FOR(j, 0, v.size()) d[j+n] = v[j];
    for(int k=n-1;k>0;k--) merge(d[k*2], d[k*2+1], d[k]);
  }
  void update(int k, T a){
    k+=n;
    d[k]=a;
    while(k){
      k >>= 1;
      merge(d[k*2], d[k*2+1], d[k]);
    }
  }
  T query(int L, int R) {
    L += n; R += n;
    T l=e, r=e;
    while (L < R) {
      if (L & 1) merge(l, d[L++], l);
      if (R & 1) merge(d[--R], r, r);
      L >>= 1; R >>= 1;
    }
    merge(l, r, l);
    return l;
  }
  T get(int a){
    return d[n+a];
  }
} seg;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  FOR(i, 0, n) cin >> c[i+1];
  FOR(i, 0, q){
    int l, r;
    cin >> l >> r;
    v[r].emplace_back(i, l);
  }
  seg.init(n+1);
  FOR(i, 1, n+1){
    seg.update(ci[c[i]], 0);
    seg.update(i, 1);
    ci[c[i]] = i;
    for(auto p:v[i]) ans[p.fi] = seg.query(p.se, i+1);
  }
  FOR(i, 0, q) cout << ans[i] << endl;
}

Measured memory_bytes: 39508
while True:
  mem = {}
  try:
    p, q = map(int, raw_input().split())
  except EOFError:
    break
  a, b, c = "", p % q, 0
  while True:
    b = (b % q) * 10
    if b in mem or not b: 
      break
    mem[b] = len(a)
    a += str(b // q)
  print(a)
  if b != 0:
    print(" " * mem[b] + "^" * (len(a) - mem[b]))

Measured memory_bytes: 4220