akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
int N; cin >> N;
vector<string> s(N);
for (int i = 0; i < N; i++) {
    cin >> s[i];
}
int M; cin >> M;
vector<string> t(M);
for (int i = 0; i < M; i++) {
    cin >> t[i];
}

int ans = 0;
for (int c = 0; c < N; c++) {
    int count = 0; 
    for (int d = c; d < N; d++) {
        if (s[c] == s[d]) {
            count++;
        }
    }
    for (int d = 0; d < M; d++) {
        if (s[c] == t[d]) {
            count--;
        }
    }
    ans = max(ans, count);
}

cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;

void test(int n){
    vector<int> p(n);
    rep(i,n) p[i] = i;

    vector<int> cr(n),cl(n);
    do{
        // dbg(p);
        vector<bool> rem(n+1,true);
        rep(i,n){
            int l = p[i];
            while(l>=0 && rem[l]) --l;
            ++l;

            int r = p[i];
            while(r<n && rem[r]) ++r;
            --r;

            // printf(" %d:  %d %d\n",i,l,r);
            cl[l]++;
            cr[r]++;

            rem[p[i]] = false;
        }
    }while(next_permutation(all(p)));
    dbg(cl);
    dbg(cr);
}

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret *= x) %= mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

const int N = 100010;
ll f[N];

int main(){
    f[0] = 1;
    for(int i=1; i<N; ++i) f[i] = (f[i-1]*i)%mod;

    int n;
    cin >>n;

    vector<ll> a(n+1);
    rep(i,n) cin >>a[i+1];

    vector<ll> s(n+1);
    for(int i=1; i<=n; ++i) s[i] = (s[i-1]+a[i])%mod;
    // dbg(s);
    // test(n);

    vector<ll> cr(n+1);
    for(int i=1; i<n; ++i){
        cr[i] = (f[n]*(1 - mod_inv(i+1) + mod))%mod;
    }
    for(int i=1; i<=n; ++i){
        (cr[n] += mod_inv(i)) %= mod;
    }
    (cr[n] *= f[n]) %= mod;
    // dbg(cr);

    vector<ll> cl(n+1);
    for(int i=1; i<=n; ++i) cl[n+1-i] = cr[i];
    // dbg(cl);

    ll ans = 0;
    for(int i=1; i<=n; ++i){
        (ans += cr[i]*s[i]) %= mod;
        ans = (ans - (cl[i]*s[i-1])%mod + mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


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

    ll s, w;
    cin >> s >> w;
    if(s > w){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
import java.util.*;


public class Main {
    public static int[][] ban; //盤面
    public static int N; //街の数
    public static int H; //盤面の縦
    public static int W; //盤面の横
    public static int crrPosX; //現在位置X
    public static int crrPosY; //現在位置Y
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int input = Integer.parseInt(str);
        String answer = "ABC";
        if(input > 999) {
          answer = "ABD";
          // input = input - 999;
        }
        // answer += String.valueOf(input);
        System.out.println(answer);
    }
}


Measured memory_bytes: 22996
N,M = map(int,input().split())
DP = [0] * (N+1)
F = [True] * (N+1)
ANS = -1

BC=-1
for i in range(M):
  f = int(input())
  if BC == f - 1:
    print(0)
    exit(0)
  BC = f
  F[f] = False

DP[0] = 1
if F[1]:
  DP[1] = 1
for i in range(2, N+1):
  if F[i - 1]:
    DP[i] += DP[i-1]
  if F[i-2]:
    DP[i] += DP[i-2]
A = 1000000007
#print(DP)
#print(F)
print(DP[N] % A)

Measured memory_bytes: 463476
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,ans = 0;
  string s,ss,sss;
  cin>>a>>b>>c;
  for(ll i=b;i<=c;i++){
    if(i%a == 0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}


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

#define N 1024
bool used[2*N+1][2*N+1];

typedef struct {
    long x;
    long y;
} pos_t;

void bfs(const pos_t s, const pos_t t){
    stack<pair<pos_t, string>> q;
    q.push(make_pair(s, ""));
    while(q.size()>0){
        const auto v = q.top(); q.pop();
        const pos_t& p = v.first;
        if(p.x == t.x && p.y == t.y){
            cout << v.second;
            pos_t pos = s;
            const auto& str = v.second;
            for(size_t i=0; i<str.length()-1; i++){
                switch(str[i]){
                    case 'U':
                        pos.y++;
                        break;
                    case 'D':
                        pos.y--;
                        break;
                    case 'R':
                        pos.x++;
                        break;
                    case 'L':
                        pos.x--;
                        break;
                }
                used[pos.x+N][pos.y+N] = true;
            }
            break;
        }else{
            if(v.second.length()>3900){
                printf("(%4ld,%4ld) %4zd\n", p.x, p.y, v.second.length());
            }
            if(p.y<=t.y && v.second.back() != 'D' && !used[p.x+N][p.y+1+N]){
                q.emplace(make_pair<pos_t,string>({p.x, p.y+1}, v.second+"U"));
            }
            /*
            if(p.y>=s.y-3 && v.second.back() != 'U' && !used[p.x+N][p.y-1+N]){
                q.emplace(make_pair<pos_t,string>({p.x, p.y-1}, v.second+"D"));
            }
            if(p.x>=s.x-3 && v.second.back() != 'R' && !used[p.x-1+N][p.y+N]){
                q.emplace(make_pair<pos_t,string>({p.x-1, p.y}, v.second+"L"));
            }
            */
            if(p.x<=t.x && v.second.back() != 'L' && !used[p.x+1+N][p.y+N]){
                q.emplace(make_pair<pos_t,string>({p.x+1, p.y}, v.second+"R"));
            }
        }
    }
}

int main(void){
    long sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string s0(tx-sx, 'R');
    string s1(ty-sy, 'U');
    string s2(tx-sx, 'L');
    string s3(ty-sy, 'D');
    cout << s0 << s1 << s2 << s3;
    cout << "D" << s0 << "RU" << s1 << "L";
    cout << "U" << s2 << "LD" << s3 << "R";
    //bfs({sx,sy}, {tx,ty});
    //bfs({tx,ty}, {sx,sy});
    //bfs({sx,sy}, {tx,ty});
    //bfs({tx,ty}, {sx,sy});
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

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


void solve(){
	ll a,b,c;
	cin >> a >> b >> c;
	ll x = min(c,b-1);

	ll ans = a*x/b;
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}

Measured memory_bytes: 3600
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

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



int main(){
    int N,A,B;
    cin>>N;
    A=N/4;
    B=N/7;
    
    int num=0;
    for (int i=0; i<=A; i++) {
        for (int k=0; k<=B; k++) {
            if (i*4+k*7==N) {
                num++;
                i=A+1;
                k=B+1;
            }
        }
    }
    
    if (num>0) {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


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

int main() {
  string s;
  cin>>s;
  if(s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < (int) s.size(); i++) {
		if (s[i] != t[i])
			ans++;
	}
	cout << ans;
}


Measured memory_bytes: 3860
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

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

    ll ans = 0;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    ans += (N - K + 1) * (N - K) / 2;
    // cout << ans << endl;

    reps(i, K + 1, N + 1) {
        ll cnt = (N - i + 1) / i;
        ll res = (N - i + 1) % i;

        // cout << "i: " << i << ", cnt:" << cnt << ", res: " << res << endl;
        // cout << cnt * (i - K) << ", " << max(0LL, res - K) << endl;

        ans += cnt * (i - K);
        ans += max(0LL, res - K);
    }

    // reps(n, K, N + 1) {
    //     ans += N - n;
    //     reps(i, K + 1, n + 1) {
    //         // cout << "(" << n << "," << i << ")" << endl;
    //         if (n % i >= K) ans++;
    //     }
    // }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660
N = int(input())
A = list(map(int,input().split()))
def zero_min(Alist,L):
    Alist.sort()
    for i in range(L):
        if Alist[i] != 0:
            return Alist[i]
            break
        else:
            pass
        
def euc(Alist,L):
    Alist.sort()
    MIN = zero_min(Alist,L)
    minindex = Alist.index(MIN)
    for i in range(L):
        if A[i] == 0 or i == minindex:
            pass
        else:
            Alist[i] = Alist[i]%MIN
            
    if 1 in Alist:
        return 1
    elif sum(Alist) == MIN:
        return MIN
    else:
        return euc(Alist,L)
print(euc(A,N))

Measured memory_bytes: 14224
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, K: int, H: "List[int]"):
    H.sort(reverse=True)
    print(sum(H[K:]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (abs(b - c) % 2 == 0) cout << "Alice" << '\n';
    else cout << "Borys" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{ 
  long double a,b,c;
  cin >> a >> b;
  c=b*a;
  int d=c;
    cout<<d<<endl;
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int cur = 1;
  long long ans = 0;

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    if (!i) {
      ans += x-1;
      ++cur;
      continue;
    }
    if (cur == x) cur++;
    else if (x % cur == 0) {
      ans += x/cur - 1;
    } else {
      ans += x / cur;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int X =sc.nextInt();
    if(X>=2000){System.out.println(1);}
    else{
      for(int i=1;i<=20;i++){
        if(X<=105*i){
          if(X>=100*i){System.out.println(1);System.exit(0);}
          else{System.out.println(0);System.exit(0);}
        }
      }
    }
  }
}
      

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N, M; 
	cin >> N >> M; 
	vector<pair<int, int>> V[100010] = {}; 
	for(int i = 0; i < M; i++){
		int l, r, d; 
		cin >> l >> r >> d; 
		V[l].push_back(pair<int, int>(r, d)); 
		V[r].push_back(pair<int, int>(l, -d)); 
	}
	long long int X[100010] = {};
	for(int i = 1; i <= N; i++){
		X[i] = 1145141919; 
	}
	string ans = "Yes"; 
	queue<int> que;
	for(int j = 1; j <= N; j++){
		if(X[j] == 1145141919){
            		X[j] = 0; 
			que.push(j); 
			while(que.size()){
				int p = que.front(); que.pop(); 
				for(int i = 0; i < V[p].size(); i++){
					int n = (V[p].at(i)).first;  
					if(X[n] == 1145141919){
						que.push(n); 
						X[n] = X[p] + (V[p].at(i)).second; 
					}
					else if(X[n] != X[p] + (V[p].at(i)).second){
						ans = "No"; 
					}
				}
			}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 9728
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		long K = sc.nextLong();

		int[][] AB = new int[N][2];
		for (int i = 0; i < N; i++) {
			AB[i] = new int[] { sc.nextInt(), sc.nextInt() };
		}

		sc.close();

		Arrays.sort(AB, (a, b) -> Integer.compare(a[0], b[0]));

		int idx = 0;
		long sum = 0;
		while ((sum += AB[idx][1]) < K) {
			idx++;
		}

		out.println(AB[idx][0]);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 95144
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL -1
struct node{
  int key;
  struct node* right;
  struct node* left;
  struct node* parent;
};
typedef struct node* nodepointer;
nodepointer none;
nodepointer root;

nodepointer treeMinimum(nodepointer x){
  while(x->left != none)x = x->left;
  return x;
}
nodepointer treeSuccessor(nodepointer x){
  nodepointer y;
  if(x->right != none)return treeMinimum(x->right);
  y = x->parent;
  while(y != none && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

/*
void insert(int data){
  nodepointer y = NULL;
  nodepointer x = root;
  nodepointer new;
  new = malloc(sizeof(struct node));
  new->key = data;
  new->left = NULL;
  new->right = NULL;
  while(new != NULL){
    y = x;
    if(new->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  new->parent = y;
  if(y == NULL){
    root = new;
  }else{
    if(new->key < y->key){
      y->left = new;
    }else{
      y->right = new;
    }
  }
}
*/
void insert(int k){
struct node *y = NULL;
struct node *x = root;
struct node *z;
 
z = malloc(sizeof(struct node));
z->key = k;
z->left = NULL;
z->right = NULL;

while(x != NULL){
y = x;
 if(z->key < x->key){
x = x->left;
}else{
x = x->right;
}
}

z->parent = y;

if(y == NULL){
root = z;
}else{
if(z->key < y->key){
y->left =  z;
}else{
y->right = z;
}
}
}




nodepointer find(nodepointer u,int data){
  while(u != NULL && data != u->key){
    if(data < u->key)u = u->left;
    else u = u->right;
  }
  return u;
}
void inorder(nodepointer u){
  if(u == NULL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(nodepointer u){
  if(u == NULL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}
void delete(nodepointer z){
  nodepointer y;
  nodepointer x;
  if(z->left == none || z->right == none)y = z;
  else y = treeSuccessor(z);
  if(y->left != none){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x != none){
    x->parent = y->parent;
  }
  if(y->parent == none){
    root = x;
  }else{
    if(y == y->parent->left){
      y->parent->left = x;
    }else{
      y->parent->right = x;
    }
  }
  if(y != x){
    z->key = y->key;
  }
  free(y);
}

int main(){
  int datanum,temp,i;
  char command[11];
  nodepointer a;
  scanf("%d",&datanum);
  for(i=0;i<datanum;i++){
    scanf(" %s",command);
    if(command[0] == 'i'){
      scanf(" %d",&temp);
      insert(temp);
    }else if(command[0] == 'f'){
      scanf(" %d",&temp);
      a = find(root,temp);
      if(a != none)printf("yes\n");
      else printf("no\n");
    }else if(command[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(command[0] == 'd'){
      scanf(" %d",&temp);
      delete(find(root,temp));
    }
  }
  return 0;
}



Measured memory_bytes: 20552
def kakuketa(x):
    s = 0
    for i in range(len(str(x))):
        s += x%10
        x = int(x/10)
    return s

def kakuketaa(x):
    s = 0
    for i in range(len(str(x))):
        s += int(str(x)[i])
    return s


def main():
    N, A, B = list(map(int, input().split()))

    count = 0
    for i in range(N+1):
        sum = kakuketa(i)
        if A <= sum <= B:
            count += i
    print(count)

main()

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

int main() {
  string a;
  cin >> a;
  for(int i = 0; i < a.size(); i++){
    cout << a.at(i);
    if(i == 3)
      cout << ' ';
    else if(i == a.size() - 1)
      cout << endl;
  }
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

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

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

int32_t main()
{
    FASTIO;

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int t = 0;
    for(int i = 0; i < n; i+=2)
        t ^= (a[i]^a[i+1]);

    for(int i = 0; i < n; i++){
        int ans = (t^a[i]);
        cout << ans << " ";
    }

    return 0;
}

Measured memory_bytes: 3968
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_b

package main

import "fmt"
import "bufio"
import "os"
import "strconv"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := nextInt()
	K := nextInt()
	A := make([]int, N)

	for i := range A {
		A[i] = nextInt()
	}

	w := 0
	h := 0
	for i := range A {
		for j := range A {
			if A[i] > A[j] {
				w++
				if i < j {
					h++
				}
			}
		}
	}

	D := 1000000000 + 7
	ans := (K*h%D + ((K-1)*K/2%D)*w) % D
	fmt.Println(ans)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

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

func nextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

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

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


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


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

struct edge {int to; ll cost; };

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

 
int main(){
  int n;
  cin >> n;
  set<int> st;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    st.insert(a);
  }
  string ans;
  if(n==st.size()) ans = "YES";
  else ans = "NO";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12976
import re
n = int(input())
h = list(map(int, input().split()))

count = [0]*(n-1)
ans=0

for i in range(n-1):
    if h[i] >= h[i+1]:
        count[i] = 1
    else:
        count[i] = 0

vset = re.findall(r'11*', ''.join(map(str, count)))

if vset == []:
    print(0)

else:
    for j in str(max(map(int, vset))):
        ans = ans +int(j)
    print(ans)

Measured memory_bytes: 14820
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var distinct = S.Distinct().ToArray();
            Array.Sort(distinct);
            var all = "abcdefghijklmnopqrstuvwxyz";
            var reference = all.ToCharArray();
            var answer = reference.Except(distinct).ToArray();
            Console.WriteLine(answer.Any() ? answer[0].ToString() : "None");
        }
    }
}


Measured memory_bytes: 26808
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Map<String, Integer> map = new HashMap<String, Integer>();

            for (int i = 0; i < n; i++) {
                String str = in.next();
                if (map.containsKey(str)) {
                    int cnt = map.get(str);
                    map.put(str, ++cnt);
                } else {
                    map.put(str, 1);
                }
            }

            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                String str = in.next();
                if (map.containsKey(str)) {
                    int cnt = map.get(str);
                    map.put(str, --cnt);
                } else {
                    map.put(str, -1);
                }
            }

            int ans = 0;

            for (String key : map.keySet()) {
                ans = Math.max(ans, map.get(key));
            }
            out.print(ans);

        }

    }
}



Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Integer> prime = prime(N);
        int[] divisor = new int[N+1];
        BigInteger factorial = BigInteger.ONE;
        for (int i = 1; i <= N; i++) {
            factorial = factorial.multiply(new BigInteger(Integer.toString(i)));
        }
        for (int p : prime) {
            BigInteger current = factorial;
            BigInteger d = new BigInteger(Integer.toString(p));
            while(current.mod(d).compareTo(BigInteger.ZERO) == 0) {
                divisor[p] += 1;
                current = current.divide(d);
            }
        }
        Arrays.sort(divisor);
        int more_than_equal_2 = 0;
        int more_than_equal_4 = 0;
        int more_than_equal_14 = 0;
        int more_than_equal_24 = 0;
        int more_than_equal_74 = 0;
        for (int i = 1; i < N+1; i++) {
            if (2 <= divisor[i]) {
                more_than_equal_2 += 1;
            }
            if (4 <= divisor[i]) {
                more_than_equal_4 += 1;
            }
            if (14 <= divisor[i]) {
                more_than_equal_14 += 1;
            }
            if (24 <= divisor[i]) {
                more_than_equal_24 += 1;
            }
            if (74 <= divisor[i]) {
                more_than_equal_74 += 1;
            }
        }
        long answer = 0;
        if (3 <= more_than_equal_2 && 2 <= more_than_equal_4) {
            answer += (more_than_equal_2 - 2) * more_than_equal_4 * (more_than_equal_4 - 1) / 2;
        }
        if (1 <= more_than_equal_24 && 2 <= more_than_equal_2) {
            answer += (more_than_equal_2-1)*more_than_equal_24;
        }
        if (1 <= more_than_equal_14 && 2 <= more_than_equal_4) {
            answer += (more_than_equal_4-1)*more_than_equal_14;
        }
        if (1 <= more_than_equal_74) {
            answer += more_than_equal_74;
        }
        System.out.println(answer);
    }
    private List<Integer> prime(int N) {
        boolean[] d = new boolean[N+1];
        List<Integer> prime = new ArrayList<>();
        int i = 2;
        for (; i * i <= N; i++) {
            if (!d[i]) {
                prime.add(i);
            }
            for (int j = 2; j * i <= N; j++) {
                d[i * j] = true;
            }
        }
        for (; i <= N; i++) {
            if (!d[i]) {
                prime.add(i);
            }
        }
        return prime;
    }
}


Measured memory_bytes: 21844
import math
s = input()

def ispalindrome(str): return 1 if str == str[::-1] else 0

buf1 = s[0:(len(s)-1)//2]
buf2 = s[(len(s) + 3)//2 - 1:len(s)]

if ispalindrome(s) == 1 and ispalindrome(buf1) == 1 and ispalindrome(buf2) == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,x;
    cin>>k>>x;
    Yn(k*500>=x);
    return 0;
}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

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

  ll N;
  cin >> N;

  if (N % 2) {
    cout << 0 << endl;
    return 0;
  }

  N -= N % 5;

  ll ans = 0;
  for (ll i = 0;;i++) {
    ll j = 10;
    rep(k, 0, i) j *= 5;
    if (j > N) break;
    ans += N / j;
  }
  cout << ans << endl;
}


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

typedef pair <int, int> ii;

const int Maxn = 200005;

int n;
int A[Maxn];
vector <ii> S;

bool Check(int val)
{
    S.clear();
    S.push_back(ii(1, 1));
    for (int i = 1; i < n; i++)
        if (A[i] > A[i - 1]) S.push_back(ii(A[i - 1] + 1, 1));
        else {
            int rem = A[i];
            while (rem >= 1) {
                while (S.back().first > rem)
                    S.pop_back();
                if (S.back().second == val) {
                    rem = S.back().first - 1;
                    S.pop_back();
                } else {
                    int nw = S.back().second + 1;
                    S.push_back(ii(rem, nw));
                    if (rem < A[i]) S.push_back(ii(rem + 1, 1));
                    break;
                }
            }
            if (rem < 1) return false;
        }
    return true;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    int lef = 1, rig = Maxn;
    while (lef <= rig) {
        int mid = lef + rig >> 1;
        if (Check(mid)) rig = mid - 1;
        else lef = mid + 1;
    }
    printf("%d\n", rig + 1);
    return 0;
}


Measured memory_bytes: 3188
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        long N = long.Parse(input[0]);
        long K = long.Parse(input[1]);

        Console.WriteLine(Math.Min(K - N%K,N%K));

    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  string ans = "Balanced";
  if (A + B > C + D) {
    ans = "Left";
  } else if (A + B < C + D) {
    ans = "Right";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//abs(x) = (x の絶対値)
//string S  S[i],S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1;
//find(all(x), key)boolソート済みのベクトル
//lower_bound(all(x),k)以上,uppper_bound(all(x),k)より大きい
int main(){

    int N;
    cin >> N;
    vi vec;
    rep(i,N){
        int a;
        cin >> a;
        vec.pb(a);
    }
    sort(all(vec));
    int ans = 0;
    int fu = 1;
    rep(i,N){
        ans += vec.back()*fu;
        vec.pop_back();
        fu *= -1;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int a[10]={64,32,16,8,4,2};
    int n;
    scanf("%d",&n);
    bool flag=1;
    for(int i=0;i<=5;i++)
        if(a[i]<=n){
            printf("%d",a[i]);
            flag=0;
            break;
        }
    if(flag) printf("1");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if(a>b){
    rep(i,a){
      cout << b;
    }
    cout  << "\n";
  }
  else{
    rep(i,b){
      cout << a;
    }
    cout  << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
# ABC 116 B

s = int(input())

a = [0]

a.append(s)

while True:
    if a[-1] % 2 == 0:
        x = int(a[-1] / 2)
    else:
        x = int(3 * a[-1] + 1)

    if x in a:
        print(len(a))
        break
    else:
        a.append(x)


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int x = in.nextInt();
		int y = in.nextInt();

		int ans = Integer.MAX_VALUE;

		int a = y - x;
		if (a >= 0) ans = Math.min(ans, a);

		a = y + x;
		if (a >= 0) ans = Math.min(ans, a + 1);

		a = x - y;
		if (a >= 0) ans = Math.min(ans, a + 2);

		a = -y - x;
		if (a >= 0) ans = Math.min(ans, a + 1);

		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 9808
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define sz 100005
using namespace std;



int main()
{

    FASTIO
    ll n;
    cin >> n;
    ll re = (n-1)*(n)/2;
    cout<<re;



return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <unordered_map>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	int n = in();
	vector<unordered_map<int, vector<int>>> g(3);
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			g[j][in()].push_back(i);
	for (auto i: g)
		for (auto j: i)
			if (j.second.size() == 1)
				p[j.second[0]] += j.first;
	for (int i: p)
		out(i, '\n');
}


Measured memory_bytes: 2640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}


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

    ll A, B ,C;
    ll X,Y;
    cin >> A >> B >> C;
    cin >> X >> Y;
    
    ll ans = 5000000000;

    rep(i,(X+Y)*2+1){
        ll c = i;
        ll d = c/2;
        ll a = max((ll)0,(X-d));
        ll b = max((ll)0,(Y-d));
        ll ret =a*A+b*B+c*C;

        ans = min(ans,ret);
    }
    
    cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int cnt = 0;
    char c = S[0];
    for(int i = 1;i < S.length();i++){
        if(c == S[i])continue;
        if(S[i] == 'B')c = 'B';
        else c = 'W';
        cnt++;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
ll n,ans=1000000000001;
int main(){
  cin >> n;
  for (size_t i = 1; i*i <= n; i++) {
    if(i*(n/i) != n)continue;
    ans = min(ans,i+roundup(n,i)-2);
  }
  cout << ans << endl;
}


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

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();char[] a=sc.next().toCharArray();
		
		ArrayDeque<Character> ad=new ArrayDeque<>();int curr=0;
		
		for(int i=0;i<n;i++)
		{
			if(a[i]==')')
			{
				curr--;
			}
			
			else
			{
				curr++;
			}
			
			if(curr<0)
			{
				ad.addFirst('(');curr++;
			}
			
			ad.addLast(a[i]);
		}
		
		while(curr>0)
		{
			ad.addLast(')');curr--;
		}
		
		for(char ch:ad)
		{
			out.print(ch);
		}
		
		out.println("");out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 22484
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
char board[10][10];
int d1[8] = { -1,-1,-1,0,0,1,1,1 };
int d2[8] = { -1,0,1,-1,1,-1,0,1 };
char inv(char a) {
	if (a == 'o')return 'x';
	else return 'o';
}
int count(P x,char a) {
	int res = 0;
	rep(i, 8) {
		int cnt = 1;
		while (board[x.first + cnt * d1[i]][x.second + cnt * d2[i]]==inv(a)) {
			cnt++;
		}
		if (board[x.first + cnt * d1[i]][x.second + cnt * d2[i]]==a) {
			res += cnt - 1;
		}
	}
	return res;
}
void paint(P x, char a) {
	rep(i, 8) {
		int cnt = 1;
		while (board[x.first + cnt * d1[i]][x.second + cnt * d2[i]] == inv(a)) {
			cnt++;
		}
		if (board[x.first + cnt * d1[i]][x.second + cnt * d2[i]] == a) {
			rep(j, cnt) {
				board[x.first + j * d1[i]][x.second + j * d2[i]] = a;
			}
		}
	}
	return;
}
void nex(char a) {
	int ma = 0; P chk;
	rep1(i, 8) {
		rep1(j, 8) {
			if (board[i][j] == '.') {
				int r = count({ i,j }, a);
				if (a=='o'&&ma < r) {
					ma = r; chk = { i,j };
				}
				else if (a == 'x'&&ma <= r) {
					ma = r; chk = { i,j };
				}
			}
		}
	}
	if (ma == 0)return;
	paint(chk, a);
}
int main() {
	rep(i, 10) {
		rep(j, 10) {
			board[i][j] = '.';
		}
	}
	string s;
	rep1(i, 8) {
		cin >> s;
		rep1(j, 8) {
			board[i][j] = s[j - 1];
		}
	}
	char t = 'o';
	rep(k, 64) {
		nex(t); t = inv(t);
	}
	rep1(i, 8) {
		rep1(j, 8) {
			cout << board[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N;
ll D;
ll A[200010];
using P = pair<int,int>;
using PP = pair<ll,P>;
struct UnionFind{
	vector<int> par;
	UnionFind(int N){
		par.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
	}
};
vector<PP> es;
ll inf = 1e18;
void solve(int l,int r){
	if(r-l==1) return;
	int m = (l+r)/2;
	solve(l,m);
	solve(m,r);
	{
		ll bestl = inf;
		int agl = -1;
		for(int i=l;i<m;i++){
			ll cost = -i*D+A[i];
			if(bestl>cost){
				bestl = cost;
				agl = i;
			}
		}
		int agr = -1;
		ll bestr = inf;
		for(int i=m;i<r;i++){
			ll cost = i*D+A[i];
			if(bestr>cost){
				bestr = cost;
				agr = i;
			}
		}

		for(int i=l;i<m;i++){
			es.pb(PP(-i*D+A[i]+bestr,P(i,agr)));
		}
		for(int i=m;i<r;i++){
			es.pb(PP(i*D+A[i]+bestl,P(i,agl)));
		}
	}
}
int main(){
	cin>>N>>D;
	rep(i,N) cin>>A[i];
	solve(0,N);
	sort(all(es));
	UnionFind UF(N);
	ll ans = 0;
	for(PP e:es){
		ll c = e.fs;
		int x = e.sc.fs, y = e.sc.sc;
		if(!UF.same(x,y)){
			UF.unite(x,y);
			ans += c;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 69216