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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

/////////////////////////////////////////////////////////


ll a,b,x;

ll solve(){
	ll ret = b/x - max((ll)0, a-1) / x;
	if(a == 0) ret++;
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b >> x;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
bool solve(int n){
    string s=to_string(n);
    return s.size()%2;
}
int main(void){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(solve(i)){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

ll num( ll a, ll b, ll i ) {
    ll ans = (int)(a*i/b)-a*(int)(i/b);
    // cout << "a " << ans << endl;
    return ans;
}

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = 0;
    if ( n < b ) {
        std::vector<ll> v;
        /*
        rep2(i, n) {
            v.push_back( num(a, b, i) );
        }
        ans = *max_element(ALL(v));*/
        ans = num(a, b, n);
    } else {
        ll nn = b;
        ll i = 2;
        // std::vector<ll> v;
        priority_queue<ll> q;
        while (nn <= n) {
            // v.push_back( num(a, b, nn-1) );
            // v.push_back( num(a, b, nn) );
            ll k = num(a, b, nn-1);
            if ( !q.empty() && k < q.top() ) {
                break;
            }
            q.push( num(a, b, nn-1) );
            q.push( num(a, b, nn) );
            nn = b*i;
            i++;
        }
        ans = q.top();
    }

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


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Train {
    int u, v;
    ll a, b;

};


std::istream &operator>>(std::istream &in, Train &o) {
    cin >> o.u >> o.v >> o.a >> o.b;
    o.u--;
    o.v--;
    return in;
}

struct Edge {
    ll to, cost;
};


class Dijkstra {
    ll vector_count;

    vector<ll> distances;
    vector<vector<Edge>> edges;

public:
    Dijkstra(ll n) {
        vector_count = n;
        distances.resize(n, INF);
        edges.resize(n);
    }

    void insertTowWay(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
        edges[to].push_back({from, cost});
    }

    void insert(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
    }

    void dijkstra(ll k) {
        distances[k] = 0;  // 始点sへの最短距離は0

        priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
        que.push(P(0, k));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
            if (distances[v] < p.first) {
                continue;
            }
            for (auto e : edges[v]) {  // 頂点vから出る辺eを走査
                if (distances[e.to] > distances[v] + e.cost) {
                    distances[e.to] = distances[v] + e.cost;
                    que.push(P(distances[e.to], e.to));
                }
            }
        }
    }

    ll distance(ll to) {
        return distances[to];
    }

};

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;

    s--;
    t--;

    vector<Train> trains(m);
    rep(i, m) cin >> trains[i];

    Dijkstra yen(n), snuuk(n);
    for (Train &train: trains) {
        yen.insertTowWay(train.u, train.v, train.a);
        snuuk.insertTowWay(train.u, train.v, train.b);
    }
    yen.dijkstra(s);
    snuuk.dijkstra(t);


    vector<ll> ans;
    ll mi = 0;
    rep(i, n) {
        int j = n - i - 1;
        ll a = yen.distance(j);
        ll b = snuuk.distance(j);
        ll now = 10e14;
        now -= (a + b);
        cmax(mi, now);
        ans.push_back(mi);
    }
    reverse(ans.begin(), ans.end());
    for (ll l : ans) cout << l << endl;

}


Measured memory_bytes: 23732
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

const MODULO: usize = 998244353;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let (x, d): (Vec<i64>, Vec<i64>) = {
        let mut xd: Vec<(i64, i64)> = vec(n, |_| (scan(tokens), scan(tokens)));
        xd.sort();
        let x = xd.iter().map(|&(xi, _)| xi).collect();
        let d = xd.iter().map(|&(_, di)| di).collect();
        (x, d)
    };
    let mut parent: Vec<usize> = vec(n, |i| i);
    let mut children: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut stack = Vec::new();
    for i in 0..n {
        while !stack.is_empty() && {
            let j = *stack.last().unwrap();
            x[j] + d[j] <= x[i]
        } {
            stack.pop();
        }
        if !stack.is_empty() {
            let j = *stack.last().unwrap();
            parent[i] = j;
            children[j].push(i);
        }
        stack.push(i);
    }
    let mut ans = 1;
    for i in 0..n {
        if parent[i] == i {
            ans = ans * dfs(i, &children) % MODULO;
        }
    }
    println!("{}", ans);
}

fn dfs(i: usize, children: &Vec<Vec<usize>>) -> usize {
    let mut res = 1;
    for &j in &children[i] {
        res = res * dfs(j, children) % MODULO;
    }
    (res + 1) % MODULO
}


Measured memory_bytes: 36212
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll a[n+1];
    ll pref[n+1];
    pref[0]=0;
    for (int i = 1; i < n+1; ++i)
    {
        cin>>a[i];
        pref[i]=pref[i-1]+a[i];
    }

    ll dp[n+1][n+1];
    for (int i = 0; i < n+1; ++i)
    {
        for (int j = 0; j < n+1; ++j)
        {
            dp[i][j]=inf;
        }
    }

    for (int i = 1; i < n+1; ++i)
    {
        dp[i][i]=0;
    }
    for (int i = 1; i < n; ++i)
    {
        dp[i][i+1]=a[i]+a[i+1];
    }

    for (int l = 2; l<=n; ++l)
    {
        for (int i = 1; i < n-l+1; ++i)
        {
            ll j = i+l;
            for (int k = i; k<j; ++k)
            {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]);
            }
            dp[i][j]+=pref[j]-pref[i-1];
        }
    }

    cout<<dp[1][n];

    return 0;
}


Measured memory_bytes: 4888
#include<iostream>
#include<bits/stdc++.h>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <stdio.h>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<string,int> PAIR;


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

Measured memory_bytes: 256
S = input()

s0 = [0 for i in range(len(S))]
s1 = [1 for i in range(len(S))]
for i in range(0, len(S), 2):
    s0[i] = (s0[i] + 1) % 2
    s1[i] = (s1[i] + 1) % 2

s0 = ''.join(map(str, s0))
s1 = ''.join(map(str, s1))


def cnt(x):
    cnt = 0
    while x > 0:
        cnt += x & 1
        x = x >> 1
    return cnt


print(min(cnt(int(S, 2) ^ int(s0, 2)), cnt(int(S, 2) ^ int(s1, 2))))


Measured memory_bytes: 11132
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <deque>

using namespace std;

map<string, int> m;


class State{
	public:
	string str;
	int posz;
	int depth;
};

void solve(void){
	State s,t;
	deque<State> q;
	string back;
	
	s.str="01234567";
	s.posz=0;
	s.depth=0;
	
	q.push_back(s);
	
	while(!q.empty()){
		s = q.front(); q.pop_front();
		
		//cout << s.str;
		if(m.find(s.str) != m.end()){
			//cout << " -> passed" << endl;
			continue;
		}
		m[s.str] = s.depth;
		//cout << " = " << s.depth << endl;
		t = s;
		
		if(s.posz != 0 &&s.posz != 4){
			swap(s.str[s.posz], s.str[s.posz-1]);
			s.posz = s.posz - 1;
			s.depth++;
			q.push_back(s);
		}
		s = t;
		if(s.posz != 3 && s.posz != 7){
			swap(s.str[s.posz], s.str[s.posz+1]);
			s.posz = s.posz + 1;
			s.depth++;
			q.push_back(s);
		}
		s = t;
		if(0 <= s.posz && s.posz <= 3){
			swap(s.str[s.posz], s.str[s.posz+4]);
			s.posz = s.posz + 4;
			s.depth++;
			q.push_back(s);
		}
		s = t;
		if(4 <= s.posz && s.posz <= 7){
			swap(s.str[s.posz], s.str[s.posz-4]);
			s.posz = s.posz - 4;
			s.depth++;
			q.push_back(s);
		}
	}
}

int main(void){
	string str;
	string query;
	char tmp;
	
	solve();
	
	while(getline(cin, str)){
		istringstream iss(str);
		
		query.clear();
		while(iss >> tmp){
			query += tmp;
		}
		
		cout << m[query] << endl;
	}
}

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

int main(){
    ll N, K;
    std::string S;
    cin >> N >> K;
    cin >> S;
    if (S[K-1] == 'A') {
        S[K-1] = 'a';
    } else if (S[K-1] == 'B') {
        S[K-1] = 'b';
    } else {
        S[K-1] = 'c';
    }
    cout << S << endl;
    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<LL>v;
LL n,k;
int f(LL x,LL y)
{
    LL l=0,h=n;
    int mid,ans=0;
    while(l<=h)
    {
        mid=(l+h)/2;
        if(x*v[mid]<=y)
        {
            ans=mid;
            l=mid+1;
        }
        else
            h=mid-1;
    }
    return ans+1;
}
int neg(LL x,LL y)
{
    LL l=0,h=n;
    int mid,ans=0;
    while(l<=h)
    {
        mid=(l+h)/2;
        if(x*v[mid]<=y)
        {
            ans=mid;
            h=mid-1;
        }
        else
            l=mid+1;
    }
    return n-ans;
}
int main()
{
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        LL x;
        cin>>x;
        v.pb(x);
    }
    sort(all(v));
//    cout<<f(3,0);
//    cout<<endl;
    LL l=-1e18,h=1e18;
    LL ans=0;
    while(l<=h)
    {
        LL mid=(l+h)/2;
        LL cnt=0;
        for(int i=0; i<n; i++)
        {
            if(v[i]>0)
            {
                cnt+=LB(v,(long double)mid/v[i]);
            }
            else if(v[i]<0)
            {
                cnt+=n-UB(v,(long double)mid/v[i]);
            }
            if(v[i]==0)
			{
				if(mid>0)
				cnt+=n;
			}
			if(v[i]*v[i]<mid)cnt--;
//         cout<<v[i]<<" "<<cnt<<"\n";

        }
//        cout<<mid<<" "<<cnt<<".....\n";
        if(cnt/2<k)
        {
            ans=mid;
            l=mid+1;
        }
        else
            h=mid-1;
    }
    cout<<ans;

}


Measured memory_bytes: 5272
N = int(input())
H = list(map(int, input().split()))

result = 0
tempres = 0
for i in range(0, N):
    if tempres != 0:
        tempres -= 1
        continue
    for j in range(i, N - 1):
        if H[j] >= H[j + 1]:
            tempres += 1
        else:
            break
    result = max(result, tempres)
    if result >= N - i - 1:
        break
print(result)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  int res = 0;
  string Nstr = to_string(N);
  int left_N = Nstr[0] - '0', right_N = N % 10;
  int len_N = Nstr.size();
  int mid = 1;
  if (len_N > 2) {
    mid = stoi(Nstr.substr(1, len_N - 2)) + 1;
  }
  for (int i = 1; i <= N; i++) {
    string str = to_string(i);
    int left = str[0] - '0', right = i % 10;
    if (right == 0) continue;
    for (int len = 2; len < len_N; len++) {
      int pos = pow(10, len - 2);
      res += pos;
    }
    if (left == right) {
      res++;  // len == 1
    }
    if (len_N == 1) continue;
    if (right < left_N) {
      res += pow(10, len_N - 2);
    } else if (right == left_N) {
      if (left <= right_N) {
        res += mid;
      } else {
        res += mid - 1;
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

int h[100100];
int f[100100];

int main(){
    int N;
    scanf("%d%d",&N,h+1);

    for(int i=2;i<=N;i++){
        scanf("%d",h+i);
        f[i]=f[i-1]+abs(h[i]-h[i-1]);
        if(i-2) f[i]=min(f[i],f[i-2]+abs(h[i]-h[i-2]));
    }

    return printf("%d\n",f[N])&0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define ls(x) (x << 1)
#define rs(x) (x<<1|1)
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T>
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

const int N = 1e5 + 7;
int n, s, a[N], res;

void solve(){
    res = INF;
    int l, r, sum; 
    l = r = sum = 0;
    while (r < n){
        while (sum < s && r <= n){
            sum += a[r++];
        }
        if (sum < s) break;
        while (sum >= s && l < r){
            res = min(res, r - l);
            sum -= a[l++];
        }
    }
    if (res == INF) res = 0;
    printf("%d\n", res);
}

int main(){
    scanf("%d%d", &n, &s);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    solve();
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,n) for(__typeof((n).begin()) it=(n).begin();it!=(n).end();++it)

using namespace std;

typedef long long ll;

ll MOD = 1000000007;
string str;

ll memo[205][205][205];

ll rec(ll index, ll up, ll down) {
    if (up < 0 || down < 0) return 0;
    if (index == 0) return up == 0 && down == 0;
    index--;

    if (memo[index][up][down] >= 0) return memo[index][up][down];
    
    long long ans = 0;
    if (str[index] == 'U') {
        ans += rec(index, up, down) * up;
        ans += rec(index, up - 1, down - 1);
    } else if (str[index] == 'D') {
        ans += rec(index, up + 1, down + 1) * (up + 1) * (down + 1);
        ans += rec(index, up, down) * down;
    } else {
        ans = rec(index, up, down);
    }
    //cerr << index << " " << up << " " << down << " " << ans << endl;
    return memo[index][up][down] = ans % MOD;
}

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

    rep(i, 205) rep(j, 205) rep(k, 205) memo[i][j][k] = -1;

    rep(i, n) {
        char c;
        cin >> c;
        str += c;
    }

    cout << rec(n, 0, 0) << endl;
    
    return 0;
}

Measured memory_bytes: 68508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, s;
  while(scanf("%d%d", &n, &s) && n && s){
    vector<int>p(n);
    rep(i, n) scanf("%d", &p[i]);
    int cnt = 0;
    REP(i, 0, n-1) REP(j, i+1, n)
      if(p[i] + p[j] > s) cnt++;
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 1224
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
def main():
    N = int(input())
    ans = N-1
    max_sq = int(math.sqrt(N)+1)
    for i in range(1, max_sq):
        if N % i != 0:
            continue
        j = N // i
        ans = min(ans, i+j-2)
    print(ans)
main()



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



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

    int ans = 0;
    rep(i,S.size()) {
        if (S[i] == '+') ++ans;
        else --ans;
    }
    cout << ans << endl;
} 



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

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    ll a = A[0]/2, b = 1;
    while ( a % 2 == 0 ) {
        a /= 2;
        b *= 2;
    }
    ll m = A[0]/2;
    for ( int i = 1; i < N; i++ ) {
        if ( A[i]/2 % b != 0 ) return 0;
        if ( A[i]/2 % (b*2) == 0 ) return 0;
        ll d = gcd(m, A[i]/2);
        m = m / d * (A[i]/2);
        if ( m > M ) return 0;
    }
    ll ans = M/m - M/(2*m);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> p(N);
    for ( int i = 0; i < N; ++i){
        cin >> p[i];
    }
    
    sort(p.begin(),p.end());
    
    int sum = 0;
    for ( int i = 0; i < K; ++i){
        sum = sum + p[i];
    }
    cout << sum << endl;
    
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n; cin >> n;
    vector<int> a(n);
    int negs = 0, sum = 0;
    for(int i = 0; i < n; ++i) {
        int cur; cin >> cur;
        if(cur < 0) {
            negs++;
            cur *= -1;
        }
        sum += cur;
        a[i] = cur;
    }

    if(negs%2) {
        int mn = a[0];
        for(int ai : a) mn = min(mn, ai);
        sum -= mn*2;
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
int n,arr[101];
int cal(int a,int b){return (arr[a]+arr[b])*(abs(a-b));}
void Min(int &a,int b){a=min(a,b);}

int mem[3][101][101][101];
int dfs(int f,int num,int l,int r){
  if(l>r)return 0;
  if(l==r)return (arr[l]==l+1) ? INF:0;
  if(r-l==1)return (arr[l]==l+1||arr[r]==r+1)? cal(l,r):0;
  if(mem[f][num][l][r]!=-1)return mem[f][num][l][r];

  int res=INF;  
  for(int i=l+1;i<r;i++){
    if((f==0||f==1)&&arr[i]!=l+1){
      swap(arr[l],arr[i]);
      Min(res,cal(l,i)+dfs(0,0,l+1,i-1)+dfs(1,arr[i],i,r));
      swap(arr[l],arr[i]);
      }

    if((f==0||f==2)&&arr[i]!=r+1){
      swap(arr[i],arr[r]);
      Min(res,cal(i,r)+dfs(2,arr[i],l,i)+dfs(0,0,i+1,r-1));
      swap(arr[i],arr[r]);
    }
  }

  for(int i=l;i<r;i++){
    if(f==1)Min(res,dfs(1,num,l,i)+dfs(0,0,i+1,r));
    else if(f==2)Min(res,dfs(0,0,l,i)+dfs(2,num,i+1,r));
    else Min(res,dfs(0,0,l,i)+dfs(0,0,i+1,r));
  }

  return mem[f][num][l][r]=res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>arr[i];
  memset(mem,-1,sizeof(mem));
  cout<<dfs(0,0,0,n-1)<<endl;
}

Measured memory_bytes: 15192
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n;

int fir[maxn], nxt[2 * maxn], to[2 * maxn], e = 0;
void add(int x, int y) {
	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;
	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;
}

int dp[maxn];
int dfs(int pos, int f) {
	int y, z, rs = pos, d;
	for (y = fir[pos]; y; y = nxt[y]) {
		if((z = to[y]) == f) continue;
		dp[z] = dp[pos] + 1;
		d = dfs(z, pos);
		if(dp[d] > dp[rs]) rs = d;
	}
	return rs;
}

int main() {
	scanf("%d", &n);
	int x, y;
	for (int i = 1; i < n; ++i) {
		scanf("%d%d", &x, &y);
		add(x, y);
	}
	dp[1] = 0;
	x = dfs(1, 0);
	dp[x] = 0;
	y = dfs(x, 0);
	//printf("%d %d\n", x, y);
	if(dp[y] % 3 == 1) printf("Second\n");
	else printf("First\n");
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout << b;
    }
    cout << endl;
  }else{
    for(int i=0;i<b;i++){
      cout << a;
    }
    cout << endl;
  }
  return 0;
}
    
    

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

int main(){
    int N;  cin >> N;
    map<ll, int> mp;
    for(int i=0; i<N; i++){
        ll a;  cin >> a;
        mp[a]++;
    }
    vector<pair<ll, int>> P;
    for(auto p : mp){
        if(p.second >= 2){
            P.push_back(p);
        }
    }

    int n = P.size();
    if(n < 2){
        cout << 0 << endl;
    }else{
        sort(P.begin(), P.end());
        if(P[n-1].second >= 4){
            cout << P[n-1].first * P[n-1].first << endl;
        }else{
            cout << P[n-1].first * P[n-2].first << endl;
        }
    }
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a[5];
	for(int i=0;i<5;i++) cin >> a[i];
	sort(a, a+5, greater<int>());
	cout << a[0];
	for(int i = 1; i<5; i++ ) cout << " " << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
import sys

n, *ab = map(int, sys.stdin.read().split())
ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])

def main():
    t = 0
    for a, b in ab:
        t += a
        if t > b:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main() {
  int S;
  cin >> S;
  
  if(S/100 <= 12 && S/100 >= 1){
    if(S%100 <= 12 && S%100 >= 1)
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  }
  else if(S%100 <= 12 && S%100 >= 1)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<cmath>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
long long cnt;
int l;
int a[1000000];
int n;
vector<int>g;
void insertionSort(int a[],int n,int g){
for(int i=g;i<n;i++){
int v = a[i];
int j = i - g ;
while (j >= 0 && a[j] > v){
a[j+g] = a[j];
j = j - g;
cnt++;
}
a[j+g] = v;
}
}

void shellSort(int a[],int n){
for(int h=1; ;){
if(h>n) break;
g.push_back(h);
h=3*h+1;
}
for(int i=g.size()-1;i>=0;i--){
insertionSort(a,n,g[i]);
}
}
int main(){
cin>>n;
for(int i=0;i<n;i++) scanf("%d",&a[i]);
cnt=0;
shellSort(a,n);
cout<<g.size()<<endl;
for(int i=g.size()-1;i>=0;i--){
    printf("%d",g[i]);
    if(i) printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for(int i=0;i<n;i++) printf("%d\n",a[i]);
return 0;
}

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

        int main() {
            
            long long int a,b,c,k;
            cin >> a >>b >>c>>k;
            
        if(a==k)
            cout<< a;
        
        else if(a>k)
            cout<< k;
        
        else{
            
            if(a+b==k)
               cout<< a;
            
            else if(a+b+c>=k){
                int ans =0;
                for(int i=0; i<k-a-b; i++){
                ans+=-1;
                }
            cout << a+ans;

            }
      }
            return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;

int main(){
    int n;
    double ans,s;

    cin >> n;

    REP(i,n){
        cin >> s;
        ans += 1.0/s;
    }

    cout << 1.0/ans << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> vec(n+1, 0);
    rep(i, m){
        int a;
        cin >> a;
        vec[a] ++;
    } 
    int cnt1=0, cnt2=0;
    for (int i=0; i<x; i++){
        cnt1 += vec[i];
    }
    for (int i=x; i<=n; i++){
        cnt2 += vec[i];
    }
    out(min(cnt1, cnt2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 0, n){
        cin >> h[i];
    }
    int ans = 0;
    vector<P> t;
    t.push_back({0, n});
    while(1){
        bool f = false;
        vector<P> nxt;
        rep(i, 0, n) if(h[i] != 0) f = true;
        rep(i, 0, t.size()){
            if(t[i].first >= n) continue;
            int MIN = *min_element(h.begin() + t[i].first, h.begin() + t[i].second);
            ans += MIN;
            rep(j, t[i].first, t[i].second){
                h[j] -= MIN;
            }
            int l = t[i].first;
            rep(j, t[i].first, t[i].second){
                if(h[j] == 0){
                    nxt.push_back({l, j});
                    l = j + 1;
                }
            }
            nxt.push_back({l, t[i].second});
        }
        if(!f) break;
        t = nxt;
    }
    cout << ans << endl;
}

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


using namespace std;

int a[3];


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int tmp = a;
    while(tmp >= a && tmp <= b && tmp <= (a + c - 1))
        cout << tmp++ << endl;
    tmp = (b - c + 1);
    if(tmp <= (a+c-1)) tmp = (a + c);
    while(tmp > a  && tmp <= b)
        cout << tmp++ << endl;
}


Measured memory_bytes: 256
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
float Float(){float x ; scanf("%f",&x) ; return x ;}
double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     Int         Int()
#define     Long        Long()
#define        Float         Float()
#define     Double         Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/



int main(){
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    int a, b , c;
    while(test--){
        a = Int;
        b = Int;
        c = Int;
        if(a+b+c >= 22)
            printf("bust\n");
        else
            printf("win\n");
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/


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

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<int> size;
	
	UnionFind(int n){
		par.resize(n);
		rank.resize(n);
		size.resize(n);
		for(int i=0; i<n; i++){
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			size[y] += size[x];
		}else{
			par[y] = x;
			size[x] += size[y];
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(){
	int N, M, ans = 0; cin >> N >> M;
	vector<int> p(N+1), q(N+1);
	for(int i=1; i<=N; i++){
		cin >> p[i];
		q[p[i]] = i;
	}
	UnionFind uf(N+1);
	for(int i=0; i<M; i++){
		int x, y; cin >> x >> y;
		uf.unite(x, y);
	}
	for(int i=1; i<=N; i++){
		if(uf.same(i, q[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {

  int w,h;

  while(1) {
  cin >> w >> h;
  if(w == 0 && h == 0) break;

  string com;

  int dir = 200000;
  int x,y;
  x = y = 1;
  while(1) {
    cin >> com;
    if(com == "STOP") break;

    if(com == "RIGHT") dir++;
    if(com == "LEFT") dir--;

    if(com == "FORWARD" || com == "BACKWARD") {
      int flg = 1;
      if(com == "BACKWARD") flg = -1;
      int n;
      cin >> n;
      n*=flg;
      if(dir % 4 == 0)y += n;
      else if(dir % 4 == 1) x += n;
      else if(dir % 4 == 3) x -= n;
      else if(dir % 4 == 2) y -= n;
      if(x > w) x = w;
      if(y > h) y = h;
      if(x < 1) x = 1;
      if(y < 1) y = 1;
    }
  }
  cout << x <<" "<<y << endl;

  }

  return 0;
}

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

int main()
{
    int month, day;
    cin >> month >> day;
    if (month < 4 || day < 22)
    {
        cout << 0 << endl;
        return 0;
    }

    int counter=0;
    for (int d = 22; d <=day; d++) {
        int d1 = d % 10;
        int d2 = d / 10;
        if(d1>=2 && d2>=2 && d1*d2<=month) {
            counter++;
        }
    }
    cout << counter << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int x,y,a,b;
int main()
{
	cin>>x>>y;
	for (a=0;a<=x;++a)
	{
		b=x-a;
		if (a*2+b*4==y)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3620
N = int(input())
cnt = 0
S = ''
Q = [[0, 0, 0, S]]
while Q:
  q0 = Q[0]
  Q = Q[1:]
  for i, s in enumerate(['3', '5', '7']):
    q = [q for q in q0]
    q[i] += 1
    q[3] += s
    if int(q[3]) <= N:
      Q.append(q)
      if q[0] and q[1] and q[2]:
        cnt += 1
print(cnt)

Measured memory_bytes: 139444
#include<iostream>
main(){for(float a,b,c,d,e,f,g,h;std::cin>>a>>b>>c>>d>>e>>f>>g>>h;)if((((e>g?e:g)-(a<c?a:c))*((a>c?a:c)-(e<g?e:g))<0)||(((f>h?f:h)-(b<d?b:d))*((b>d?b:d)-(f<h?f:h))<0))std::cout<<"NO\n";else std::cout<<"YES\n";}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
void solve(){
    int x;
    cin>>x;
    cout<<1-x<<endl;

}
int main()
{
   int t=1;
   //int t;
   //cin>>t;
    while(t--)
        solve();
     
   return 0;   
}


 

Measured memory_bytes: 3616
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))

ans=0
p.sort()
v=0
x=0
z=0
for i in range(len(p)):
    if p[i]<=a:
        v+=1
    elif a<p[i]<=b:
        x+=1
    else:
        z+=1

print(min(v,x,z))

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	int x;
	cin>>x;
	cout<<(x>=30 ? "Yes" : "No") << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
import math
n = int(input())
candidate = n / 1.08
x = math.floor(candidate)
flg = False
for i in range(x - 1, x + 2):
    if math.floor(i * 1.08) == n:
        flg = True
        break
if flg:
    print(i)
else:
    print(":(")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t, u;
    cin >> s >> t >> u;

    cout << "A" << t[0] << "C" << endl;
}

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

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

#define out(v) cout<<v<<"\n"

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

  int A = 0, B = 0, AB = 0;
  int count1 = 0, count2 = 0, count3 = 0;
  rep(i, N) {
    string s;
    cin >> s;
    if (s.front() == 'B' && s.back() == 'A') ++count1;
    if (s.front() == 'B' && s.back() != 'A') ++count2;
    if (s.front() != 'B' && s.back() == 'A') ++count3;
    rep(j, s.size()-1) {
      if (s[j] == 'A' && s[j+1] == 'B')
        ++AB;
    }
  }
  if (count1 == 0)
    out(AB + min(count2, count3));
  else {
    if (count2 + count3 == 0)
      out(AB + count1 - 1);
    else
      out(AB + count1 + min(count2, count3));
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



int main() {
	int N;
	ll K;
	cin >> N >> K;
	vector <ll>A(N);
	rep(i, 0, N)cin >> A[i];

	ll res = 0;
	for (int d = 60; d >= -1; d--) {
		if (d != -1 && !(K & (1LL << d)))continue;

		ll temp = 0;
		for (int e = 60; e >= 0; e--) {
			ll mask = 1LL << e;

			int num = 0;
			rep(i, 0, N)if (mask & A[i])num++;


			if (e > d) {
				if (K & mask)temp += mask * (N - num);
				else temp += mask * num;
			}
			else if (e == d) {
				temp += mask * num;
			}
			else {
				temp += mask*max(num,N-num);
			}
		}
		res = max(res,temp);
	}




	cout << res << endl;

	return 0;
}

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

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

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
    ll a,b,i; cin>>a>>b;
    for(i=1;i<=1001;i++)
    {
        if (i*8/100==a&&i/10==b) {cout<<i; return 0;}
    }
    cout<<-1;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0, c = a + b;
    ans = n / c * a;
    ans += min(n % c, a);
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;

int main(){
  ll l;
  cin>>l;
  double l1=(double)l;
  double l2=(double)27;
  double ans=(l1*l1*l1)/l2;
  printf("%0.12lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,i,j,k=0;
    string s;
    cin >> s;
    for(i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            if(s[i]=='0')
                s[i]='1';
            else
                s[i]='0';
            k++;
        }
    }
    cout << k << endl;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

map<ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ll N, P; cin >> N >> P;
  map< ll, int > ret;
  for(ll i = 2; i * i <= P; i++) {
    ll n = P;
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  ret[1] = N;
  ret[P] = 1;

  ll retval = 1;
  for (auto p:ret){
    ll tmp = 1;
    rep(i,p.second/N) tmp *= p.first;
    retval = max(retval, tmp);
  }
  cout << retval << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(void){
  float A,B,T;
  int i;
  float j;
  cin >> A;
  cin >> B;
  cin >> T;
  
  T = T + 0.5;
  i = T / A;
  j = i * B;

  cout << j <<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DDight(N) (int)(log10((int)N) + 1)
int SumDDight(long long N)
{
    int ans  = 0;
    long long n = N;
    for(int i = 0;i < DDight(N);i++)
    {
        ans += n % 10;
        n /= 10;
    }
    return ans;
} 
int main()
{
    long long n;
    cin >> n;
    cout << (n % SumDDight(n) == 0 ? "Yes" : "No") << '\n';  
}
 

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll dp[81];
int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    dp[0] = 1000;
    
    rep(i, 1, n) {
        dp[i] = dp[i-1];
        rep(j, 0, i) {
            ll v = dp[j] / a[j];
            ll w = dp[j] + (a[i]-a[j])*v;
            dp[i] = max(dp[i], w);
        }
    }
    cout << dp[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 5960
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN = 305;
int A, B, D[15][15], F[105][105];
int S, T, M;
int main()
{
	scanf("%d%d", &A, &B);
	for(int I = 1; I <= A; ++I)
		for(int J = 1; J <= B; ++J)
			scanf("%d", &D[I][J]);
	for(int numX = 0; numX <= 100; ++numX)
		for(int numY = 0; numY <= 100 && numX + numY <= 100; ++numY)
			for(int X = 1; X <= A; ++X)
				for(int Y = 1; Y <= B; ++Y)
					F[numX][numY] = max(F[numX][numY], D[X][Y] - numX * X - numY * Y);
	M = 200 + 101 * 101;
	S = 1, T = 202;
	for(int X = 1; X <= A; ++X)
		for(int Y = 1; Y <= B; ++Y){
			int minDis = 0x3f3f3f3f;
			for(int numX = 0; numX <= 100; ++numX)
				for(int numY = 0; numY <= 100 && numX + numY <= 100; ++numY)
				{
					minDis = min(minDis, X * numX + Y * numY + F[numX][numY]);
				}
			if(minDis != D[X][Y]){
				puts("Impossible");
				return 0;
			}
		}
	puts("Possible");
	cout<<202<<" "<<M<<endl;
	for(int I = 1; I <= 100; ++I)
		printf("%d %d X\n", I, I + 1);
	for(int I = 102; I <= 201; ++I)
		printf("%d %d Y\n", I, I + 1);
	for(int I = 0; I <= 100; ++I)
		for(int J = 0; J <= 100; ++J)
			printf("%d %d %d\n", 1 + I, 102 + J, F[I][100 - J]);
	cout<<S<<" "<<T<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n ; cin>> n;
    if(n<=1) cout << 1 << endl;
    else if(n<=3) cout << 2 << endl;
    else if(n<=7) cout << 4 << endl;
    else if (n<=15) cout << 8 << endl;
    else if (n<=31) cout << 16 << endl;
    else if (n<=63) cout << 32 << endl;
    else cout << 64 << endl;
    return 0 ;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main(){
	cin>>a>>b>>c>>d;
	if(abs(c-a)<=d) return cout<<"Yes", 0;
	if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  string s;

  map<string,int> dict;
  cin >> n >> k;
    REP(i,n){
        cin >> s;
        if (dict.count(s)==0)dict.emplace(s,0);
        dict[s]++;
    }
    // for(auto x : dict) {
    //     cout << x.first << " "<<x.second << endl;
    // }
    vector<int> vec;
    for(auto x : dict) {
        vec.push_back(x.second);
    }
    SORT(vec);
    // for (auto it = vec.begin(); it!=vec.end();it++)
    // cout << *it << endl;
    int ans = 0;
    int r = max(0,(int) vec.size()-k);
    REP(i,r){
        ans += vec[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 23288