akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;

double EPS = 1e-9; 

struct Point {
    double x, y;
};

struct Line {
	Point s, e;
	Line (Point _s, Point _e) {
		s = _s; e = _e;
	}
};

double distPointLine(const Point& A, const Line& l) {
	double a = (l.s.y - l.e.y)/(l.s.x - l.e.x);
	double c = (-1)*a*l.s.x - l.s.y;
	return fabs(a * A.x + A.y + c)/sqrt(a*a + 1.0);
}

enum { IN, ON, OUT };
int PointInTri(const vector<Point>& tri, const Point& p) {
    int cnt = 0;
    for (int i=1; i<4; i++) {
        Point p0 = tri[i-1], p1 = tri[i%3];
        bool flag0x = (p.x <= p0.x), flag0y = (p.y <= p0.y);
        bool flag1x = (p.x <= p1.x), flag1y = (p.y <= p1.y);
        
        Line p0top1(p0, p1);
        if (distPointLine(p, p0top1) <= EPS) return ON;
         
        if (flag0y != flag1y) {
            if ( flag1x && flag0x) {
                cnt += flag0y ? -1 : 1;
            } else if (p.x <= ( p0.x+(p1.x-p0.x)*(p.y-p0.y)/(p1.y-p0.y) ) ) {
                cnt += flag0y ? -1 : 1;
            }
        }
    }
    return cnt!=0 ? IN : OUT;
}
 
int main() {
    int n; cin >> n;
     
    vector<Point> tri(3);
    for (int i=0; i<n; i++) {
        cin >> tri[0].x >> tri[0].y >> tri[1].x >> tri[1].y >> tri[2].x >> tri[2].y;
        Point p1; cin >> p1.x >> p1.y;
        Point p2; cin >> p2.x >> p2.y;
        bool flag1 = (PointInTri(tri, p1) == IN), flag2 = (PointInTri(tri, p2) == IN);
        if ( flag1 != flag2 ) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1224
//file_name:ABC80_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);


    int ans = min(n*x,y);

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



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll X,k,d; cin >> X >> k >> d;
  X = abs(X);

  ll num = min(k,X/d);
  
  ll x = X-num*d;
  k -= num;

  x = k%2==0 ? x:abs(x-d);

  cout << x << endl;
  
  return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
ll n,ans;
ll a[2][109];
int main(){
  cin >>n;
  for(ll i=0;i<2;i++){
    for(ll j=0;j<n;j++){
      cin >>a[i][j];
    }
  }
  ans=-1;
  ll sum=0;
  for(ll i=0;i<n;i++){
    sum=0;
   for(ll j=0;j<=i;j++){
     sum+=a[0][j];
   }
   for(ll j=i;j<n;j++) sum+=a[1][j];
   ans=max(ans,sum);
  }
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define Inf 2000000000000
#define N 100004
long long DP[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, w;
    cin >> n >> w;
    for (long long i = 1; i <= n; i++)
    {
        long long weight, value;
        cin >> weight >> value;
        for (long long pos = w; pos > 0; pos--)
        {
            if (DP[pos] != 0)
            {
                if (pos + weight <= w) DP[pos + weight] = max(DP[pos + weight], DP[pos] + value);
            }
        }
        DP[weight] = max(DP[weight], value);
    }
    long long result = 0;
    for (long long i = 0; i <= w; i++) result = max(result, DP[i]);
    cout << result;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

const int MAX=1e5+5;
int prefix[MAX];

int main(){
    int n,m,l,r,rta=0,aux=0;
    vector<pii> in;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> l >> r;
        prefix[l-1]++;
        prefix[r]--;
    }
    for(int i=1;i<=n;i++){
        prefix[i]+=prefix[i-1];
    }
    for(int i=0;i<n;i++){
        if(prefix[i]==m) rta++;
    }
    cout << rta << endl;
    return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a;
    str s, t;
    cin >> a >> s;
    for (char c : s)
        if (c != '.')
            t += c;
    int b = atoi(t.c_str());
    cout << a * b / 100 << endl;
    GAME_OVER;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll DigitMod[100001][13] = { 0 };

int main()
{
	string S;
	int len, m13 = 1;
	ll ans = 0;

	cin >> S;
	len = S.length();
	DigitMod[len][0] = 1;

	rrep(i, len) {
		if (i != len - 1) m13 = (m13 * 10) % 13;

		if (S[i] == '?') {
			repc(j, 0, 9) {
				int addmod = (m13 * j) % 13;

				rep(k, 13) {
					DigitMod[i][k] = (DigitMod[i][k] + DigitMod[i + 1][(13 - addmod + k) % 13]) % MOD;
				}
			}
		}
		else {
			int num = S[i] - '0';
			int addmod = (m13 * num) % 13;
			rep(j, 13) {
				DigitMod[i][j] = DigitMod[i + 1][(13 - addmod + j) % 13];
			}
		}
	}

	cout << DigitMod[0][5] << endl;

	return 0;
}


Measured memory_bytes: 10624
a = input()
b = len(a)
aa = 0
zz = 0
for i in range(b-1,-1,-1):
    if a[i] == 'Z':
        zz = i
        break
for i in range(b):
    if a[i] == 'A':
        aa = i
        break

print(zz-aa+1)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    vector<ll> AS(4, 0), BS(4, 0);
    cin >> N >> AS[0] >> AS[1] >> AS[2] >> BS[0] >> BS[1] >> BS[2];
    AS[3] = 1;
    BS[3] = 1;

    const ll ma = 5000*5000 + 10;
    //const ll ma = 10000;
    static ll dp[5][ma];    
    REP(i, 5)REP(j, ma) dp[i][j] = 0;

    // former
    ll limit = N;
    REP(i, 4){
    	REP(j, limit+1){
    		if(j < AS[i]) dp[i+1][j] = dp[i][j];
    		else dp[i+1][j] = max(dp[i][j], dp[i+1][j-AS[i]]+BS[i]);
    	}
    }
    
    ll M = dp[4][limit];


    // latter
    REP(i, 5)REP(j, ma) dp[i][j] = 0;
    limit = M;

    REP(i, 4){
    	REP(j, limit+1){
    		if(j < BS[i]) dp[i+1][j] = dp[i][j];
    		else dp[i+1][j] = max(dp[i][j], dp[i+1][j-BS[i]]+AS[i]);
    	}
    }

    cout << dp[4][limit] << endl;
    return 0;
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	priority_queue<ll> pq;
	rep(i, 0, n) {
		ll t; cin >> t;
		pq.push(t);
	}
	rep(i, 0, m) {
		ll t = pq.top(); pq.pop();
		pq.push(t/2);
	}
	ll sum = 0;
	while (!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main() {
    int n; cin >> n;
    if(n < 105) {
        cout << 0 << endl;
    } else if(n < 135) {
        cout << 1 << endl;
    } else if (n < 165) {
        cout << 2 << endl;
    } else if(n < 189) {
        cout << 3 << endl;
    } else if(n < 195){
        cout << 4 << endl;
    } else {
        cout << 5 << endl;
    }
}


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

using namespace std;
#define INF 1000000001

int main()
{
    int N,W;
    cin >> N >> W;
    vector<long > v(N,0);
    vector<long > w(N,0);
    vector<long > dp(W+1,0);
    for(int i = 0 ;i < N;i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0;i < N;i++){
        for(int j = W; j >= w[i];j--){
            dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << "\n";
    return 0;
}



Measured memory_bytes: 1024
import Control.Monad
import Data.Function
import Data.List
import Data.Tuple

cond a _ True = a
cond _ b False = b

main = zip <$> getLine <*> getLine >>= \ps -> putStrLn $ cond "Yes" "No" $ all (all ((==1) . length . group) . groupBy (on (==) fst) . sort) [ps, map swap ps]

Measured memory_bytes: 49532
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=300005;
int n;
int a[N],s[N];
bool check(int x){
	int v=0;
	for (int i=1;i<n;i+=2)
		if (s[i]-v>=x)
			v=min(v,s[i+1]);
	return s[n]-v>=x;
}
int main(){
	n=read();
	For(i,1,n)
		a[i]=read();
	if (n%2==0){
		int s0=0,s1=0;
		For(i,1,n)
			if (i&1)
				s0+=a[i];
			else
				s1+=a[i];
		cout<<max(s0,s1)<<" "<<min(s0,s1)<<endl;
		return 0;
	}
	For(i,1,n)
		if (i&1)
			s[i]=s[i-1]+a[i];
		else
			s[i]=s[i-1]-a[i];
	int L=1,R=n*1000,mid,ans=L;
	while (L<=R){
		mid=(L+R)>>1;
		if (check(mid))
			L=mid+1,ans=mid;
		else
			R=mid-1;
	}
	For(i,1,n)
		if (i%2==0)
			ans+=a[i];
	int s=0;
	For(i,1,n)
		s+=a[i];
	cout<<ans<<" "<<s-ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	char s[12];
	cin >> s;
	int i, count = 0, temp = 0;
	int l = strlen(s);
	for(i=0; i<l; i++){
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
			temp++;
		}
		else{
			count = max(temp, count);
			temp = 0;
		}
	}
	count = max(count, temp);
	cout << count << endl;
	return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

// .init(??°)??§?????????, .update(???????????°???)??§?????????????????????
// .query(a,b)??§??????[a,b)??§????°???????????????????
// ?????§???????????´???????????? comp???min->max ??¨ INF=-1LL*1LL<<61
struct Segtree{
	typedef int sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF= 0; // min:+inf,max:-inf
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return max(l, r);}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)
};


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,q;
	cin >>n >>q;
	Segtree sga;
	sga.init(n+5);
	rep(i,q){
		int a,v;
		cin >>a >>v;
		int w = sga.get(a);
		sga.update(a, w +v);
		int lo=0, hi=n+1;
		int qk = sga.query(lo, hi);
		while(hi - lo >1){
			int md = (hi + lo) >> 1;
			if( sga.query(lo, md) >= qk ) hi = md; else lo = md; 
		}
		cout << lo  <<" "<< qk <<"\n";
		//rep(i,n+3) printf("%d:%d ",i,sga.query(i,i+1));puts("");

	}
	
	return 0;
}

Measured memory_bytes: 10948
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

N = I()

ans=0
for n in range(N+1):
    if n%3 != 0 and n%5 != 0:
            ans += n

print(ans)

Measured memory_bytes: 76436
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
main()
{
	int n;
	cin>>n;
	int m=n,k=0;
	while(m!=0)
	{
		k++;
		m/=10;
	}
	int ans=0;
	for(int i=0;i<=k/2-1;i++)
	{
		ans+=9*pow(10,2*i);
	}
	if(k%2)ans+=n+1-pow(10,k-1);
	cout<<ans;
}

Measured memory_bytes: 256
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dump_l(x) dump(x) << endl
#else
const bool test = false;
#define dump(x)
#define dump_l(x)
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}

string reverse_str(string input) {
  string res = input;
  reverse(all(res));
  return res;
}

vector<int> sorted(vector<int> a) {
  vector<int> b = a;
  sort(all(b));
  return b;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}

int H = 20, W = 30;

bool ng(int y, int x) {
  return y < 0 || H <= y || x < 0 || W <= x;
}

void solve();

class Solver {
public:
  int A, B, C;

  void solve() {
    cin >> A >> B >> C;
    int M = max({A, B, C});
    int D = M * 3 - A - B - C;
    int res = [&]() {
      if (D % 2 == 0) return D / 2;
      else return (D + 3) / 2;
    }();
    cout << res << endl;
  }
};
 
signed main()
{
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {
  //   auto ptr = new Solver();
  //   ptr->solve();
  //   delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'
 


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  ll m=(1<<n);
  vector<ll>a(m);
  rep(i,0,m)cin>>a[i];
  ll maxbuf=0;
  rep(i,1,m){
    ll fir=a[0],sec=0;
    for(ll j=i;j>0;j=(j-1)&i){
      if(a[j]>=fir){
        sec=fir;fir=a[j];
      }
      else chmax(sec,a[j]);
    }
    chmax(maxbuf,fir+sec);
    cout<<maxbuf<<endl;
  }
  return 0;
}

Measured memory_bytes: 5248
import itertools


def main():
    N = int(input())
    P = tuple(int(s) for s in input().split())
    Q = tuple(int(s) for s in input().split())

    if P == Q:
        print(0)
        return

    i = 0
    a, b = 0, 0
    for v in itertools.permutations(range(1, N+1)):
        i += 1
        if v == P:
            a = i
        elif v == Q:
            b = i

    print(abs(a-b))


if __name__ == "__main__":
    main()


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int c[10][10] ;
  rep(i,10) rep(j,10) c[i][j] = 0;
  REP(i, 1, n + 1){
    int b = i % 10;
    int a = to_string(i)[0] - '0';
    c[a][b]++;
  }
  ll ans = 0;
  rep(i,10) {
    rep(j, 10){
      ans += c[i][j] * c[j][i];
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N))cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N))cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N))cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUT4(P1,P2,P3,P4) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<" "<<(P4)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int x[4],y[4],i,d[2];
inline void solve(){
  INS2(i,2,x,y);
  d[0]=x[1]-x[0];
  d[1]=y[1]-y[0];
  x[2]=x[1]-d[1];
  y[2]=y[1]+d[0];
  x[3]=x[0]-d[1];
  y[3]=y[0]+d[0];
  OUT4(x[2],y[2],x[3],y[3]);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

long long stone[262145];
long long f[262145];

int main(void){
	long long n, game;
	long long i, j, t;
	
	scanf("%lld", &n);
	
	game = (int)(pow(2.0, (double)n));
	
	for (i = 0; i < game; i++){
		scanf("%lld", &stone[i]);
	}
	
	for (t = 0; t < n; t++){
		j = 0;
		for (i = 0; i < game; i = j+1){
			if (f[i] == 0){
				for (j = i+1; j < game; j++){
					if (f[j] == 0){
						if (stone[i] > stone[j]){
							stone[i] -= stone[j];
							f[j] = 1;
						}
						else if (stone[i] == stone[j]){
							f[j] = 1;
						}
						else {
							stone[j] -= stone[i];
							f[i] = 1;
						}
						break;
					}
				}
			}
			else if (i > 0) j++;
		}
	}
	
	for (i = 0; i < game; i++){
		if (f[i] == 0) printf("%lld\n", stone[i]);
	}
	
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main () {
	io_optimized
	double a,b;
	while(cin>>a>>b)
	{
		cout<<ceil(a/b)<<'\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

ll f(ll b,ll n){
	if(n<b)return n;
	else return f(b,floor((double)n/b)) + (n%b);
}

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

	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	
	for(int b=2;b<=sqrt(n);b++){
		if(f(b,n)==s){
			cout<<b<<endl;
			return 0;
		}
	}
	
	for(int p=sqrt(n)-(1e-9);p>=1;p--){
		ll b = (n-s)/p+1;
		
		if(b<2)continue;
		
		if(p+n%b==s){
			cout<<b<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int input[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << input[k-1]<<endl;
}




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

int main(){
    int N,M;
    long long x[1002],y[1002],z[1002];
    long long score[1002];
    long long maxscore = 0;

    cin >> N >> M;
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
 
    for(int i=-1;i<=1;i+=2){
        for(int j=-1;j<=1;j+=2){
            for(int k=-1;k<=1;k+=2){
                for(int n=0;n<N;n++){
                    score[n] = i*x[n]+j*y[n]+k*z[n];
                }
                sort(score, score+N, greater<long long>());
                long long temp=0;
                for(int m=0;m<M;m++){
                    temp += score[m];
                }
                maxscore = max(maxscore,temp);
            }
        }
    }
    cout << maxscore << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7
inside = 0
outside = 0
for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      outside += 1
      if i < j:
        inside += 1
inside *= k
outside *= k * (k-1) // 2
print((inside + outside) % mod)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define int long long 
int cnt[10];
signed main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int ans;
	for (int i = 1; i <= 5; i++) {
		cin >> cnt[i];
		if (cnt[i] == 0) ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI a;
	while (true) {
		int x; cin >> x;
		if (x == 0)break;
		a.PB(x);
	}
	rep(i, SZ(a)) {
		cout << "Case " << i + 1 << ": " << a[i] << endl;
	}
}


Measured memory_bytes: 3260
def main():
    n, d = map(int, input().split())
    cnt = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d ** 2:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int mod[MAX];
int first[2019];
vector<int> possible;
void pre() {
	memset(first, -1, sizeof first);
	int i;
	int x = 10;
	for(i=1;i<MAX;i++) {
		if(first[x] == -1) {
			first[x] = i;
		}
		x = (x*10) % 2019;
	}
	
	for(i=1;i<2019;i++) {
		if(first[i] != -1) possible.PB(i);
	}
}

vector<int> mods[2019];
int main() {
	string s;
	int i, j;
	pre();
	cin>>s;
	
	LL ans = 0;
	for(i=0;i<s.length();i++) {
		mod[i] = (i == 0) ? (s[i]-'0') % 2019 : (mod[i-1] * 10 + s[i] - '0') % 2019;
		if(mod[i] == 0) ans++;
	}
	
	int oc[2019][225] = {0};
	
	for(i=0;i<s.length();i++) {
		oc[mod[i]][i%224]++;
	}
	
	//cout<<possible.size()<<endl;
	
	for(i=0;i<s.length();i++) {
		oc[mod[i]][i%224]--;
		for(j=0;j<possible.size();j++) {
			int start = first[possible[j]];
			int pos = (i+start) % 224;
			int target = (mod[i] * possible[j]) % 2019;
			ans += oc[target][pos];
			
		} 
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 6328
#include<bits/stdc++.h>
using namespace std;
int n;
char str[15];
string s[100005],s1;
map<string,int>mp;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		s1="";
		scanf("%s",str+1);
		int l=strlen(str+1);
		sort(str+1,str+l+1);
		for(int j=1;j<=l;++j)s1+=str[j];
		mp[s1]++;
		s[i]+=s1;
	}
	long long ans=0;
	for(int i=1;i<=n;++i)ans+=mp[s[i]]-1;
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	ll sum = 0;
	for (auto &it : v) {
		cin >> it;
		sum += it;
	}
	int cnt = 0;
	for (auto &it : v) {
		cnt += (it * 4LL * m >= sum);
	}
	cout << (cnt < m ? "No" : "Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    long long a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0){
        cout<<0<<endl;
    }
    else{
        cout<<a[0]*a[1]<<endl;
    }
    return 0;
}



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

typedef long long ll;

const int N = 2e5;
ll arr[N + 5];

vector<ll> positive, negative;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll pos = 0, neg = 0, zero = 0;
  ll n, k;
  cin>>n>>k;
  ll kk = k;
  for(int i = 0;i < n;i++) {
    cin>>arr[i];
    if(arr[i] > 0) {
      pos++;
      positive.push_back(arr[i]);
    }
    else if(arr[i] == 0) zero++;
    else {
      neg++;
      negative.push_back(arr[i]);
    }
  }
  sort(positive.begin(), positive.end());
  sort(negative.begin(), negative.end());
  reverse(negative.begin(), negative.end());
  if(pos * neg >= k) { //it is negative
    ll lo = -1e18;
    ll hi = 0;
    ll ans = 0;
    while(lo <= hi) {
      ll mid = (lo + hi) / 2;
      ll st = negative.size() - 1;
      ll ujung = negative.size() - 1;
      ll total = 0;
      for(int i = 0;i < positive.size();i++) {
        ll val = positive[i];
        while(st != -1 && negative[st] * val <= mid) st--;
        total += (ujung - st);
      }
      if(total < k) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
        ans = mid;
      }
    }
    cout<<ans<<endl;
    return 0;
  }
  k -= pos * neg;
  if(zero * (pos + neg) + zero * (zero - 1) / 2 >= k) { //it is zero
    cout<<0<<endl;
    return 0;
  }
  k -= zero * (pos + neg) + zero * (zero - 1) / 2;
  ll lo = 0;
  ll hi = 1e18;
  ll ans = 0;
  while(lo <= hi) {
    ll mid = (lo + hi) / 2;
    ll total = 0;
    ll ujung = 0;
    ll st = positive.size() - 1;
    for(int i = 0;i < positive.size();i++) {
      ll val = positive[i];
      while(st != -1 && positive[st] * val > mid) st--;
      int red = 0;
      if(st >= i) red = 1;
      total += (st + 1 - red);
    }
    st = negative.size() - 1;
    for(int i = 0;i < negative.size();i++) {
      ll val = negative[i];
      while(st != -1 && negative[st] * val > mid) st--;
      int red = 0;
      if(st >= i) red = 1;
      total += (st + 1 - red);
    }
    total /= 2;
    if(total < k) {
      lo = mid + 1;
    } else {
      hi = mid - 1;
      ans = mid;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll n;
    cin >> n;
    ll ans = INF;
    for(ll i = 1;i*i<=n;i++){
        if(n%i==0){
            ll j =n/i;
            ans = min(i+j-2,ans); 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;
		
		if (n == 2) {
			if (s[0] == s[1]) {
				out.println("1 2");
			} else {
				out.println("-1 -1");
			}
			return;
		}
		
		for (int i = 0; i + 3 < n; i++) {
			char c0 = s[i];
			char c1 = s[i+1];
			char c2 = s[i+2];
			if (c0 == c1 || c1 == c2 || c0 == c2) {
				out.println((i+1) + " " + (i+3));
				return;
			}
		}
		out.println("-1 -1");
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    // yyyy/mm/dd
    cin >> S;
    int month = atoi(S.substr(5, 2).c_str());
    cout << ((month > 4) ? "TBD" : "Heisei")
         << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int H,W;
	int i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(i=1;i<=W;i++){
			printf("#");
		}
		printf("\n");
		for(i=2;i<=H-1;i++){
			printf("#");
			for(j=2;j<=W-1;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(i=1;i<=W;i++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1016
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

int main() {

	ll H, W;
	cin >> H >> W;
	if(H == 1){
		cout << 1 << endl;
		return 0;
	}
	if (W == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (W % 2 == 0 && H % 2 == 0) {
		cout << W * H / 2 << endl;
	}
	else if(W % 2 == 0 && H % 2 == 1){
		cout << W * H / 2 << endl;
	}
	else if (W % 2 == 1 && H % 2 == 0) {
		cout << W * H / 2 << endl;
	}
	else {
		cout << (W / 2) * (H / 2) + (W / 2 + 1) * (H / 2 + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,s;
	cin >> n >> k >> s;
	for(int i=1;i<=k;i++){
		if(i!=1)
		cout << " ";
		cout << s;
	}
	if(s==1e9)
	s=s-2;
	for(int i=k+1;i<=n;i++){
		cout << " " << s+1;
	}
	return 0;
} 

Measured memory_bytes: 1280
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
int n,a,b;

int main(){
	fast_io();
	cin >> n >> a >> b;
	if(a + b > n + 1 || a > n || b > n){cout << -1 << '\n';return 0;}
	vector<int> res;
	res.pb(b);
	int left = n - b - (a - 1);
	if(left < 0){cout << -1 << '\n';return 0;}
	cu(i,1,a){
		int c = 1;
		if(left){
			c+=min(left,b-1);	
			left-=min(left,b-1);
		}
		res.pb(c);
	}
	vector<int> ans;
	int cmax = 0;
	cu(i,0,res.size()){
		cmax+=res[i];
		fd(j,cmax,cmax-res[i]+1)ans.pb(j);
	}
	if(ans.size() == n){
		for(int a:ans){
			cout << a << ' ';
		}
		cout << '\n';
	}
	else {cout << -1 << '\n';return 0;}
}



Measured memory_bytes: 4336
#include <iostream>
#include <stdio.h>


static void B_RedOrBlue();

int main()
{
	B_RedOrBlue();

	return 0;
}

static void B_RedOrBlue()
{
	int		N = 0;
	char	s[128] = { 0 };

	scanf("%d", &N);
	scanf("%s", s);

	int red = 0, blue = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') {
			red++;
		}
		else if (s[i] == 'B') {
			blue++;
		}
	}

	const char* yesno = "Yes";
	if (blue >= red) {
		yesno = "No";
	}

	printf("%s\n", yesno);
	fflush(stdout);

	return;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] remainder_mapping = new int[2019];
        remainder_mapping[0]++;
        Scanner sc = new Scanner(System.in);
        String target_string = sc.next();
        int remainder = 0;
        int pow_of_ten = 1;
        for(int i = target_string.length()-1 ;i >= 0; i--){
            int target_number = (target_string.charAt(i) - '0');
            remainder += target_number*pow_of_ten;
            remainder %= 2019;
            remainder_mapping[remainder]++;
            pow_of_ten *= 10;
            pow_of_ten %= 2019;
        }
        int answer = 0;
        for(int i = 0;i < 2019;i++){
            int candidates = remainder_mapping[i];
            if(candidates != 1){
                answer += ((candidates-1)*candidates)/2;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 39976
N = int(input())

B = ""
i = 0
if N == 0:
  print (0)
else:
  while N != 0:
    B = str(abs(N % (-2))) + B
    if i % 2 == 0:
      N = (N + (N % (-2))) // 2
    else:
      N = (N - (N % (-2))) // 2
    i += 1
  print (B)


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

using namespace std;

const int maxn = 110;
const int maxk = 1e5+10;
const long long mod = 1e9+7;

typedef long long ll;

int a[maxn];

ll dp[maxk], pref[maxk];

int main(void)
{
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	dp[0] = 1LL;
	for (int i = 0; i <= k; i++)
		pref[i] = 1LL;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			ll l;
			if (a[i] >= j) l = 0;
			else l = pref[j-a[i]-1];

			dp[j] = ((pref[j] - l + mod)%mod);
		}

		for (int j = 1; j <= k; j++)
			pref[j] = (pref[j-1] + dp[j])%mod;
	}

	cout << dp[k] << "\n";
}

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

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

const long long MOD = 1000000007;

int main(){
  string s,t;
  bool ck = false;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  
  for(int i=n-1;i>=m-1;i--){
    if(ck) break;
    
    rep(j,m){
      if(s.at(i-j) != t.at(m-j-1) && s.at(i-j) != '?') break;
      else if(j == m-1){ 
        ck = true;
        rep(k,m) s.at(i-m+1+k) = t.at(k);
      }
    }
  }
  
  if(ck){
    rep(i,n){
      if(s.at(i) == '?') s.at(i) = 'a';
    }
    cout << s << endl;
  }
  else cout << "UNRESTORABLE" <<endl;
}


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

int main() {
    // input
    int N;
    cin >> N;
    vector<pair<long long, long long>> ranges(N);
    for (int i = 0; i < N; i++) {
        long long x, l;
        cin >> x >> l;
        // right
        ranges.at(i).first = x + l;
        // left
        ranges.at(i).second = x - l;
    }

    // sort
    sort(ranges.begin(), ranges.end());

    // count
    int count = 0;
    long long current = -1000000000;

    for(int i = 0; i < N; i++) {
        if(current <= ranges.at(i).second) {
            count++;
            current = ranges.at(i).first;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 4824
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

char T[7][7]{"MON","TUE","WED","THU","FRI","SAT","SUN"};
int a[7]{6,5,4,3,2,1,7};
char G[7];

int main()
{
	while(cin>>G)
	{
		for(int i=0;i<7;i++)
		{
			if(strcmp(T[i],G)==0)
			{
				cout<<a[i]<<endl;
				break; 
			}
		}
	}
}


Measured memory_bytes: 256