akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200111];
int B[300111];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    int l = 150000, r = 150000;
    REP (i, N) {
	if (i & 1) B[r++] = A[i];
	else B[--l] = A[i];
    }

    if (N % 2 == 0) reverse(B+l, B+r);
    rprintf("%d", B+l, B+r);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0] - 32) << (char)(s2[0] - 32) << (char)(s3[0] - 32) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
        int n,q;
        cin>>n>>q;
        vector<int> a(n);
        vector<ll> x(q);
        rep(i,n)cin>>a[i];
        rep(j,q)cin>>x[j];
        rep(i,q){
            ll query=x[i];
            ll res=0;
            int right=0;
            ll sum=0;
            for(int left=0;left<n;left++){
                while(right<n&&sum+a[right]<=query){
                    sum+=a[right]; right++;
                }
                res+=(right-left);
                if(left==right)right++;
                else sum-=a[left];
            }
            cout<<res<<endl;
        }
    return 0;
}





Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int mn = 0;
   ll ans = 0;
   rep(i, 0, n) {
      ans += max(mn - a[i], 0);
      mn = max(mn, a[i]);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int Sign(ll a) {
	return (a > 0) - (a < 0);
}

int main(void) {
	int num, i, j;
	ll ans = 1;
	ll d1, d2, a1, a2, b1, b2, t1, t2;
	cin >> t1 >> t2;
	cin >> a1 >> a2;
	cin >> b1 >> b2;
	d1 = (a1 - b1) * t1;
	d2 = (a2 - b2) * t2 + d1;
	if (Sign(d1) * Sign(d2) >= 0) {
		if (Sign(d1) * Sign(d2) == 0)
			printf("infinity\n");
		else
			printf("0\n");
	}
	else {
		ans += abs(d1) / abs(d2) * 2;
		if (abs(d1) % abs(d2) == 0)
			ans--;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3592
// B - Ruined Square
// https://abc108.contest.atcoder.jp/tasks/abc108_b

import scala.io.StdIn.readLine

object Main extends App {

  val Array(x1, y1, x2, y2) = readLine.split(" ").map(_.toInt)

  val vec = (x2 - x1, y2 - y1)

  def nextVec(d: (Int, Int)): (Int, Int) = (-d._2, d._1)
  def add(a: (Int, Int), b: (Int, Int)): (Int, Int) = (a._1 + b._1, a._2 + b._2)

  val vec2 = nextVec(vec)
  val (x3, y3) = add((x2, y2), vec2)

  val vec3 = nextVec(vec2)
  val (x4, y4) = add((x3, y3), vec3)

  println(List(x3, y3, x4, y4).mkString(" "))

}

Measured memory_bytes: 25668
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

int n;
vector<int> a;

//Range Sum Query
//segment_tree<int> st(n+1, 0, [](int a, int b){return a+b;});

template <typename T>
class segment_tree{
    private:
        static int calc_size(int n){
            int m = 1;
            while(m < n){
                m *= 2;
            }
            return m;
        }

        T query(int s, int t, int i, int l, int r) const {
            if(r <= s || t <= l){
                return init;
            }

            if(s <= l && r <= t){
                return node[i];
            }

            int m = l + (r - l) / 2;
            T vl = query(s, t, i * 2 + 1, l, m);
            T vr = query(s, t, i * 2 + 2, m, r);
            return f(vl, vr);
        }

    public:
        int n;
        vector<T> node;
        T init;
        function<T(T, T)> f;

        segment_tree(int n, T init, function<T(T, T)> f)
            : n(calc_size(n)), node(calc_size(n) * 2, init), init(init), f(f){}

        void update(int i, const T& x){
            i += (n - 1);
            node[i] += x;
            while(i > 0){
                i = (i - 1) / 2;
                node[i] = f(node[2*i+1], node[2*i+2]);
            }
        }

        //[s, t)
        T query(int s, int t) const {
            return query(s, t, 0, 0, n);
        }
};

int solve(int x){
    vector<int> s(n+1);
    s[0] = 0;
    int min = s[0];
    for(int i = 0; i < n; i++){
        s[i+1] = s[i] + (a[i] < x ? -1 : 1);

        if(s[i+1] < min){
            min = s[i+1];
        }
    }

    min = abs(min);
    rep(i, n+1){
        s[i] += min;
    }

    segment_tree<int> st(n+1, 0, [](int a, int b){return a+b;});
    int inv = 0;
    rep(i, n+1){
        inv += st.query(0, s[i]+1);
        st.update(s[i], 1);
    }

    return inv;
}

signed main(){
    cin >> n;
    a = vector<int>(n);
    rep(i, n) cin >> a[i];
    int m = (1 + n) * n / 2;
    m = (m+1) / 2;

    int lo = 1;
    int hi = 1e9+1;
    while(hi - lo > 1){
        int mid = (lo + hi) / 2;
        if(solve(mid) >= m){
            lo = mid;
        }else{
            hi = mid;
        }
    }
    cout << lo << endl;

    return 0;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
     
int main() {
    int N, x[8], y[8];
    cin >> N;
    rep(i, N) cin >> x[i] >> y[i];

    double ans = 0;
    rep(i, N) rep(j, N) {
        ans += hypot(x[i] - x[j], y[i] - y[j]);
    }
    printf("%.9f\n", ans / N);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    int tmp;

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  S = input()
  if S == "AC":
    ac += 1
  if S == "WA":
    wa += 1
  if S == "TLE":
    tle += 1
  if S == "RE":
    re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 9204
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    return gcd(b, a % b);
}

int main(){
    int N, tmp;
    cin >> N;

    int a[N];
    REP(i, N) a[i]=0;

    REP(i, N-1){
        cin >> tmp;
        a[tmp-1]++;
    }

    REP(i, N) cout << a[i] << endl;



    return 0;
}



Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  long long a=0,b=0,c=0,ans=1;
  long long p=1000000007;
  rep(i,n){
    long long u;
    cin >> u;
    if(a!=u&&b!=u&&c!=u)ans*=0;
    else if(a==u&&b==u&&c==u){
      ans=(ans*3)%p;
      a++;
    }
    else if(a==u&&b!=u&&c!=u){
      a++;
    }
    else if(a!=u&&b==u&&c!=u)b++;
    else if(a!=u&&b!=u&&c==u)c++;
    else if(a==u&&b==u&&c!=u){
      a++;
      ans=ans*2%p;
    }
    else if(a==u&&b!=u&&c==u){
      a++;
      ans=ans*2%p;
    }
    else if(a!=u&&b==u&&c==u){
      b++;
      ans=ans*2%p;
    }

  }
  /*if(a==b&&b==c)cout << ans << endl;
  else if(a!=b&&b!=c&&c!=a)cout << ans*6%p << endl;
  else cout << ans*3%p << endl;*/
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,h[100000],i,j,dp[100000],s,min;
  scanf("%d%d",&n,&k);
  for (i=0;i<n;i++) scanf("%d",&h[i]);
  dp[0]=0;
  for (i=1;i<n;i++){
    min=1000000000;
    for (j=i-1;j>=0&&i-j<=k;j--){
      s=(h[i]>h[j])? h[i]-h[j]:h[j]-h[i];
      s+=dp[j];
      if (min>s) min=s;
    }
    dp[i]=min;
  }
  printf("%d\n",dp[n-1]);
  return 0;
}


Measured memory_bytes: 896
/*
 * @Author: Kaizyn
 * @Date: 2020-04-12 20:23:56
 * @LastEditTime: 2020-04-12 20:25:12
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 100;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n;

inline void solve()
{
    cin >> n;
    if (n%10 == 7 || n/10%10 == 7 || n/100 == 7) cout << "Yes";
    else cout << "No";
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

ll sc(int x, int p) { return pow((x - p), 2); }

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N);
  REP(i, N) cin >> X[i];

  ll ans = inf;
  for (int i = -1; i <= 101; i++) {
    int p = i;
    ll sum = 0;
    REP(i, N) { sum += sc(X[i], p); }
    ans = min(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    ll n;
    string s,t;
    cin >> n;
    cin >> s;
    cin >> t;

    ll res;


    //方針 s[i] と t[0] の一致を探す s[n-1]まで、動かせたらそこ

    for(ll i = 0; i < n; ++i)
    {  
        if(s[i] == t[0])
        {
            bool ok = true;
            for(ll j = i; j < n; ++j)
            {
                if(s[j] != t[j-i])
                {
                    ok= false;
                    break;
                }
            }
            if(ok)
            {
                res = i + t.size();
                cout << res << endl;
                return 0;
            }
        }
    }

    res = s.size() + t.size();
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import random


def main():
    a,b,c = map(int, input().strip().split())
    if a+b+c>=22:
        print("bust")
    else:
        print("win")
        
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 67436
#include<bits/stdc++.h>
using namespace std;
#define N 100000
bool ch[N+5];
int dp[N+5];
vector<int>v[N+5];
void dfs(int x) {
	ch[x]=true;
  	for(int t:v[x]) {
    	if(!ch[t]) {dfs(t);}
      	dp[x]=max(dp[x],1+dp[t]);
    }
}
int main() {
  	int n,m,x,y;
  	cin>>n>>m;
  	for(int i=0;i<m;i++) {
    	cin>>x>>y;
      	v[x].push_back(y);
    }
  	memset(ch,false,n+1);
  	memset(dp,0,n+1);
  	for(int i=1;i<=n;i++) {
    	if(!ch[i]) {dfs(i);}
    }
  	x=INT_MIN;
  	for(int i=1;i<=n;i++) {x=max(x,dp[i]);}
  	cout<<x<<endl;
return 0;
}


Measured memory_bytes: 12084
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX=100000;
int main()
{
    int n,A[MAX],L[MAX+1],length=1;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    L[0]=-1;
    for(int i=0;i<n;i++)
    {
        if(A[i]>L[length-1])
        {
            L[length++]=A[i];
        }
        else{
            *lower_bound(L,L+length,A[i])=A[i];
        }
    }
    cout<<length-1<<endl;
    return 0;
}


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

struct robot {
    int left;
    int right;
};

bool struct_cmp(const struct robot& p, const struct robot& q) {
    return p.right < q.right;
}

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

    vector<robot> robots(N);
    for (int i = 0; i < N; i++) {
        int x, l;
        cin >> x >> l;
        robots[i].left = x - l;
        robots[i].right = x + l;
    }

    sort(robots.begin(), robots.end(), struct_cmp);

    int output = 0;
    int max = robots[0].left - 1;
    for (int i = 0; i < N; i++) {
        if (robots[i].left >= max) {
            output++;
            max = robots[i].right;
        }
    }
    cout << output << endl;

    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int curr_prob;
    string verdict;
    int numb;
    int correct = 0;
    int penalty = 0;
    map<int, int> corrects;
    map<int, int> penalties;
    map<int, int> gotten;
    for(int i = 0; i < m; i++) {
        cin >> numb >> verdict;
        if(verdict == "AC") {
            
            if(corrects.find(numb) == corrects.end()) {
                correct++;
                corrects[numb] = 1;
            }
            if(penalties.find(numb) != penalties.end() && gotten.find(numb) == gotten.end()) {
                penalty+=penalties[numb];
                penalties.erase(numb);
                // cout << i << ": " << penalties[numb] << endl;
            }
            gotten[numb] = 1;
        }
        else {
            if(penalties.find(numb) == penalties.end()) {
                penalties[numb] = 1;
            }
            else {
                penalties[numb]++;
            }
        }
    }
    cout << correct << ' ' << penalty << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;
#define INF 1001001001
int dist[300][300];

int main() {
    int H,W,D;
    cin >> H >> W >> D;
    vector<pp> pos(H * W);
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            int a; cin >> a;
            pos[a-1] = pp(i,j);
        }
    }
    for(int i=0; i<D; ++i) {
        int x = pos[i].first;
        int y = pos[i].second;
        dist[x][y] = 0;
        for(int j=i; j+D<H*W; j += D) {
            int nx = pos[j+D].first;
            int ny = pos[j+D].second;
            dist[nx][ny] = dist[x][y] + abs(nx-x) + abs(ny-y);
            x = nx; y = ny;
        }
    }
    
    int Q; cin >> Q;
    while(Q--) {
        int l,r; cin >> l >> r;
        --l; --r;
        cout << dist[pos[r].first][pos[r].second] - dist[pos[l].first][pos[l].second] << endl;
    }
    return 0;
}

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

static bool is_even(int n)
{
    return n % 2 == 0;
}

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

    set<pair<int, int>> list;

    int exchange_count = 0;
    while (is_even(A) && is_even(B) && is_even(C))
    {
        int a = B / 2 + C / 2;
        int b = A / 2 + C / 2;
        int c = A / 2 + B / 2;
        A = a;
        B = b;
        C = c;
        auto p = make_pair(a, b);
        if (list.find(p) != list.end())
        {
            exchange_count = -1;
            break;
        }
        list.insert(move(p));
        exchange_count++;
    }

    cout << exchange_count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A, B, C, D, E, K;
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &K);
    if(E-A > K) printf(":(\n");
    else printf("Yay!\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

#define rep(i, n) for (i = 0; i < n; ++i)
#define REP(i, m, n) for (i = m, i < n; ++i)

#define INF 1000 * 1000

using namespace std;

int main() {

  char s[200001];
  scanf("%s", s);

  int find1 = 0;
  while (s[find1++] != 'A')
    ;
  find1--;

  int find2 = strlen(s) - 1;
  while(s[find2--] != 'Z')
    ;
  find2++;

  printf("%d\n", find2 - find1 + 1);

  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vv(n,m) vector<vector<ll> > vec( n , vector<ll> (m, 0))


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
using namespace std;


ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
    
//vst vect={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    
    
}
void solve(){
    ll n;
    cin>>n;
    ll mn=n-1;
    ll i;
    for(i=ceil(sqrt(n));i>=1;i--){
        if(n%i==0){
            mn=i-1+(n/i)-1;
            break;
        }
    }
    cout<<mn;
    
}

// AB DEKHO JAADU...

int main(){

    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }

    return 0;
    }

// KHATAM HO GAYA:)...






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

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

using ll=long long;

int main(){
    int x[2];
    cin>>x[0]>>x[1];
    int g[2];
    rep(i,2){
        if(x[i]==2) g[i]=3;
        else if(x[i]==4 || x[i]==6 || x[i]==9 || x[i]==11) g[i]=2;
        else g[i]=1;
    }
    if(g[0]==g[1]) cout<<"Yes";
    else cout<<"No";
    cout<<endl;

   return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll N, K;
    cin >> N >> K;

    ll ret = (ll)ceil((N-1) * 1.0 / (K - 1));
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_left

N, Q = map(int, input().split())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial = 0))
csum_even = list(accumulate(As[::2], initial = 0))
csum_odd = list(accumulate(As[1::2], initial = 0))


#t回でX以下のAsのみとなってしまうような最小のtを求める。
def calc_t(X):
    ok = -1
    ng = N+1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        aoki = mid // 2
        taka = mid - aoki
        aoki_max = As[-taka]
        aoki_min_index = bisect_left(As, 2*X - aoki_max)
        if N - taka - aoki_min_index < aoki:
            ng = mid
        else:
            ok = mid
    return ok

for _ in range(Q):
    X = int(input())
    t = calc_t(X)
    s = csum[N] - csum[N - (t+1)//2]
    
    if N % 2 == 0:
        s += csum_odd[(N-t)//2]
    else:
        s += csum_even[(N-t+1)//2]
    print(s)


Measured memory_bytes: 24884
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double calcTime()
{
    struct::timespec getTime;
    clock_gettime(CLOCK_MONOTONIC, &getTime);
    return (getTime.tv_sec + getTime.tv_nsec*1e-9);
}

mt19937 mrand(random_device{}());

ll v[400];
ll days[30] = {};
ll c[30];
ll s[370][30];
ll ans[400] = {};
ll D;

ll get_score(){
    ll score = 0;
    rep(i,0,26) days[i] = 0;

    rep(i,0,D){
        score += s[i][ans[i]];
        days[ans[i]] = i+1;
        rep(j,0,26){
            score -= c[j] * (i+1 - days[j]); 
        }
    }
    return score;
}

void solve(){
    double start = calcTime();
    cin >> D;
    rep(i,0,26) cin >> c[i];

    rep(i,0,D){
        rep(j,0,26){
            cin >> s[i][j];
        }
    }

    rep(i,0,D){
        ll r = mrand() % 26;
        ans[i] = r;
        days[r] = i+1;
    }
    ll score = get_score();
    ll iter = 0;

    while(true){
        if(calcTime() - start >= 1.9) break;
        iter++;
        ll d = mrand() % D;
        ll q = mrand() % 26;
        ll prev_val = ans[d];
        ans[d] = q;
        ll new_score = get_score();
        if(new_score > score){
            score = new_score;
        }else{
            ll r = mrand() % 100;
            ans[d] = prev_val;
        }
    }
    rep(i,0,D) print(ans[i]+1);

}

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

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
  int n;
  double r;
  cin >> n >> r;
  map<pii, bool> mp;
  REP(i,n) {
    double x, y;
    cin >> x >> y;
    mp[pii(x/r, y/r)] = 1;
  }
  map<pii, bool> ok;
  int ans = 0;
  FOR(it, mp) {
    int x = it->first.first;
    int y = it->first.second;
    if (ok[it->first]) continue;
    ok[it->first] = 1;
    for (int dy=-1; dy<=1; ++dy)
      for (int dx=-1; dx<=1; ++dx) {
        int xx = x+dx;
        int yy = y+dy;
        if (mp.count(pii(xx,yy)))
          ok[pii(xx,yy)] = 1;
      }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int C[N-1], S[N-1], F[N-1];
    rep(i, N-1) cin >> C[i] >> S[i] >> F[i];

    for (int i = 0; i < N-1; i++) {
        int ans = S[i] + C[i]; 
        for (int j = i+1; j < N; j++) {
            if (j+1 == N) {
                cout << ans << endl;
                break;
            }
            if (ans < S[j]) {
                ans = S[j] + C[j];
                continue;
            }
            //dump(ans);
            if(ans % F[j] != 0) ans += F[j] - (ans % F[j]);
            //dump(ans);
            ans += C[j];
        }
    }
    cout << "0" << endl;

    return 0;
}


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

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }



int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;

    rep(i, 1000) {
        if(i%2==0) {
            // takahashi
            c -= b;
            if(c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if(a <= 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n],b[n];
  for(i=0;i<n;i++)cin>>a[i]>>b[i];
  ll sum=0;
  for(i=0;i<n;i++)sum+=a[i]-b[i];
  ll c[n];
  for(i=0;i<n;i++)c[i]=a[i]+b[i];
  sort(c,c+n,greater<int>());
  for(i=0;i<n;i++){
    if(i%2==0)sum+=c[i];
    else sum-=c[i];
  }
  cout<<sum/2<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n;
		int ans1 = 0, ans2 = 0;
		int num = 0;
		int h[] = new int[30];
		
		for(int i = 0; i < 28; i++){
			n = scan.nextInt();
			h[n - 1] = 1;
		}
		
		while(num != 2){
			for(int i = 0; i < 30; i++){
				if(h[i] == 0){
					if(ans1 == 0){
						ans1 = i + 1;
						num++;
					}else{
						ans2 = i + 1;
						num++;
					}
				}
			}
		}
		
		if(ans1 < ans2){
			System.out.println(ans1);
			System.out.println(ans2);
		}else{
			System.out.println(ans2);
			System.out.println(ans1);
		}
	}
}

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

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

  vector<int> res(4);

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

    if (input == "AC") {
      res[0] += 1;
    } else if (input == "WA") {
      res[1] += 1;
    } else if (input == "TLE") {
      res[2] += 1;
    } else if (input == "RE") {
      res[3] += 1;
    }
  }

  cout << "AC x " << res[0] << endl;;
  cout << "WA x " << res[1] << endl;;
  cout << "TLE x " << res[2] << endl;;
  cout << "RE x " << res[3] << endl;;
}


Measured memory_bytes: 3224
Scanf.scanf "%d" (fun n ->
    let nmax = 1000000 in
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let z = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in

    let minprime =
        let r = Array.init (nmax + 1) (fun a -> a) in
        for i = 2 to nmax do
            let rec loop j =
                if j <= nmax then (
                    r.(j) <- min r.(j) i;
                    loop (j + i)
                )
            in
            loop (i * i)
        done;
        r
    in

    let invsum = Array.fold_left (fun acc v -> acc +@ inv v z) 0 a in
    let lcm = Array.make (nmax + 1) 0 in
    Array.iter (fun v ->
        let rec loop v =
            if v > 1 then (
                let q = minprime.(v) in
                let rec count r i =
                    if r mod q = 0 then count (r / q) (i + 1) else (
                        lcm.(q) <- max lcm.(q) i;
                        loop r
                    )
                in
                count v 0
            )
        in
        loop v
    ) a;

    let pow_mod a b =
        let rec loop r i acc =
            if i = 0 then acc else
                let acc = if i land 1 = 1 then acc *@ r else acc in
                loop (r *@ r) (i lsr 1) acc
        in
        loop a b 1
    in
    let reduce =
        let rec loop i acc =
            if i > nmax then acc else loop (i + 1) (acc *@ pow_mod i lcm.(i))
        in
        loop 2 1
    in
    reduce *@ invsum |> Printf.printf "%d\n"
)

Measured memory_bytes: 21884
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll x,y;

int main(){

  cin>>x>>y;
  ll ans = 1e10;

  if(x<=y) ans = min(ans,y-x);
  x*=-1;
  if(x<=y) ans = min(ans,y-x+1);
  y*=-1;
  if(x<=y) ans = min(ans,y-x+2);
  x*=-1;
  if(x<=y) ans = min(ans,y-x+1);

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
int dp[100010][3];
int a[100010][3];
int main(){
    string s;
    int n;
    cin >> n;
    s = to_string(n);
    ll ans = 0;
    rep0(i,s.size()){
        ans += s[i] -= '0';
    }
    if(n % ans== 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define int long long 
const int MAXN = 2000 + 10 , MOD = 1e9+7 ; 

int n , k , dp[MAXN][MAXN] , fact[MAXN*MAXN] ,inv[MAXN*MAXN];

int pw(int a , int b)
{
	if(!b)
		return 1 ; 
	int res = pw(a , b/2) ; 
	res*=res ;
	res%=MOD ; 
	if(b%2)
		res*=a ; 
	return res%MOD ;  
}

int C(int a , int b)
{
	if(b>a)	
		return 0 ; 
	return ( (fact[a] * inv[b])%MOD ) *inv[a-b] %MOD ; 
}


int32_t main()
{
	cin >> n >> k ; 
	if(k==1)
		return cout << 1 , 0 ; 
	fact[0]=1 ; 
	for(int i=1 ; i<MAXN*MAXN ; i++)
		fact[i] = fact[i-1]*i %MOD ; 
	for(int i=0 ; i<MAXN*MAXN ; i++)
		inv[i] = pw(fact[i] , MOD-2) ;
	dp[n][n] = 1 ; 
	for(int i=n ; i>=0 ; i--)
	{
		for(int j=n ; j>=i ; j--)
		{
			if(i) 
				dp[i-1][j]=(dp[i-1][j] + dp[i][j])%MOD;
			if(j>i) 
				dp[i][j-1]= (dp[i][j-1] + dp[i][j]*(C(i+j*(k-1)-1,k-2))%MOD)%MOD;
		}
	}
	cout << (dp[0][0]*fact[n])%MOD << endl ; 
}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const lint INF=1e18+1e9;

struct Node{
	lint r,b;
}a[MAXN];

lint Ans=INF,maxn,minn=inf;
bool vis[MAXN],vmax,vmin;
int n;

bool Cmpr(Node A,Node B){
	return (A.r==B.r ? A.b<B.b : A.r<B.r);
}

bool Cmpb(Node A,Node B){
	return (A.b==B.b ? A.r<B.r : A.b<B.b);
}

void Solve1(){
	lint maxm=maxn,minm=minn;
	for(int i=1;i<=n;i++) maxm=min(a[i].b,maxm),minm=max(a[i].r,minm);
	// printf("minn = %lld, maxn = %lld, maxm = %lld, minm = %lld\n",minn,maxn,maxm,minm);
	Ans=min((minm-minn)*(maxn-maxm),Ans);
	return;
}

void Solve2(){
	lint maxm=max(a[n].r,a[1].b),minm=min(a[n].r,a[1].b),tmp=INF;
	for(int i=2;i<n;i++) if(a[i].b<minm) minm=a[i].b,vis[i]=true;
	for(int i=2;i<n;i++) if(a[i].r>maxm) maxm=a[i].r,vis[i]=true;
	for(int i=2;i<n;i++) if(minm<=a[i].b && a[i].b<=maxm) vis[i]=true;
	for(int i=2;i<n;i++) if(minm<=a[i].r && a[i].r<=maxm) vis[i]=true;
	// printf("maxm = %lld, minm = %lld\n",maxm,minm);
	for(int i=2;i<n;i++) if(!vis[i]){
		tmp=min(maxm-min(a[i].r,minm),tmp);
		maxm=max(a[i].b,maxm);
		// printf("j = %d, tmp = %lld, maxm = %lld, minm = %lld\n",i,tmp,maxm,minm);
	}
	if(tmp<INF) Ans=min((maxn-minn)*tmp,Ans);
	else Ans=min((maxn-minn)*(maxm-minm),Ans);
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) a[i].r=readint,a[i].b=readint;
	for(int i=1;i<=n;i++) if(a[i].r>a[i].b) swap(a[i].r,a[i].b);
	sort(a+1,a+n+1,Cmpb),maxn=a[n].b,vmax=(a[n].b==a[n-1].b);
	sort(a+1,a+n+1,Cmpr),minn=a[1].r,vmin=(a[1].r==a[2].r);
	sort(a+1,a+n+1,Cmpb),sort(a+1,a+n,Cmpr);
	if(!vmax && !vmin && minn==a[n].r && maxn==a[n].b){
		// printf("Oh\n");
		Solve1(),Solve2();
	}
	else minn=a[1].r,maxn=a[n].b,Solve1(),Solve2();
	// for(int i=1;i<=n;i++) printf("i = %d, r = %lld, b = %lld\n",i,a[i].r,a[i].b);
	printf("%lld\n",Ans);

	return 0;
}

Measured memory_bytes: 7116
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int sum = 0;
    int j = i;
    while(j > 0) {
      sum += j % 10;
      j /= 10;
    }
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
a=[chr(ord('a')+j) for j in range(26)]
L=[]
for k in range(n):
  l=[0 for m in range(26)]
  for p in range(26):
    for q in range(len(s[k])):
      if s[k][q]==a[p]:l[p]+=1
  L.append(l)
b=[]
for r in range(26):
  c=[]
  for s in range(n):
    c.append(L[s][r])
  b.append(min(c))
ans=[]
for t in range(26):
  for u in range(b[t]):
    ans.append(a[t])
Ans=''.join(ans)
print(Ans)

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

int main() {
    int x;
    int a, b;
    cin >> x >> a >> b;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 101

int main(){
	char a[MAX];
	char b[MAX*2];
	if(scanf("%100s %100s", a,b)==EOF){return 0;}
	strcat(b,a);
	printf("%s\n", b);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Integer num1 = Integer.parseInt(sc.next());
		Integer num2 = Integer.parseInt(sc.next());
		
		Integer ans = num1 * num2;
		
		if (ans % 2 == 0){
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+2, 0), d(n+1);
    rep(i, 1, n+1) cin >> a[i];
    ll sum = 0;
    rep(i, 0, n+1){
        d[i] = abs(a[i+1] - a[i]);
        sum += d[i];
    }
    rep(i, 1, n+1){
        ll ans = sum - d[i] - d[i-1] + abs(a[i+1] - a[i-1]);
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;cin>>t;
    string s;cin>>s;
    if(s.length()<=t)
    {
        cout << s << endl;
    }
    else
    {
        for(int i=0;i<t;i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    
    
}

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



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	int n, mod = 1e9 + 7;
	long long ans = 1;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		ans = (ans * i) % mod;
	}
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 256
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    var b = 0L
    val m = (1e9 + 7).toLong()
    a.forEach {
        b = (b + it) % m
    }
    var t = 0L
    0.until(n - 1).forEach {
        b -= a[it]
        if (b < 0) {
            b += m
        }
        t = (t + a[it] * b) % m
    }
    println(t.toString())
}

Measured memory_bytes: 65232
#include <iostream>
#include <algorithm>

using namespace std;
int prime[25] = {2,3,5,7,11,13,17,19,23,29,
    31,37,41,43,47,53,59,61,67,71,73,79,
    83,89,97};

int main(){
    int N;
    cin >> N ;
    int count[25] ={0};
    for(int i=0; i<25; i++){
        int n,t;
        n = N;
        while(t=n/prime[24-i]){
            count[i] += t;
            n = t;
        }
    }
    int ans = 0;
    if(count[24] >= 74) ans++;
    int n = count+25 - lower_bound(count,count+25,2);
    int m = count+25 - lower_bound(count,count+25,24);
    if(m>0){
        ans += m*(n-1);
    }
    n = count+25 - lower_bound(count,count+25,4);
    m = count+25 - lower_bound(count,count+25,14);
    if(m>0){
        ans += m*(n-1);
    }
    n = count+25 - lower_bound(count,count+25,2);
    m = count+25 - lower_bound(count,count+25,4);
    if(m>1){
        ans += m*(m-1)/2*(n-2);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = (int)(Math.pow(n,3));
        System.out.println(res);
        sc.close();
    }
}

class io{
    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X = C / B, Y = A / D;
  if (C % B != 0) {
    X++;
  }
  if (A % D != 0) {
    Y++;
  }  
  if (X <= Y) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
     

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a)); reverse(begin(a), end(a));
	
	std::map<int, int> mp;
	for(int i = 0; i < n; i++) mp[a[i]]++;
	int c = 0, ans = 0;
	for(int i = 1 << 30; i > 0; i >>= 1) {
		while(c < n and a[c] >= (i >> 1)) {
			int k = i - a[c];
			if(!mp[k] or !mp[a[c]]) {
				c++;
				continue;
			}
			if(k == a[c] and mp[k] > 1) {
				mp[k] -= 2;
				ans++;
			} else if(k != a[c]) {
				mp[k] -= 1;
				mp[a[c]] -= 1;
				ans++;
			}
			c++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, x = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        x ^= a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (a[i]^x) << ' ';
    }
}

Measured memory_bytes: 5212
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            Func<int, int> withoutTax = x => (int)(Math.Ceiling(x / 1.08));

            var a = (int)(withoutTax(n) * 1.08);

            if (a == n)
            {
                Console.WriteLine(withoutTax(n));
            }
            else
            {
                Console.WriteLine(":(");
            }

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define end return 0;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N, C, K;
    cin >> N >> C >> K;
    ll t[100000], i;
    
    for(i=0; i<N; i++) {
        cin >> t[i];
    }
    sort(t, t+N);
    ll ans=0;
    ll cnt;
    for(i=0; i<N; ) {
        ll j=i;
        ll flag=1;
        cnt=0;
        while(t[i]<=t[j]+K && cnt<C) {
            i++;
            cnt++;
            flag=0;
        }
        if(flag) i++;
        
        ans++;
    }
    
    prin(ans)
}


Measured memory_bytes: 1024