akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>

void print(int a[], int n){
    for(int i = 0; i < n - 1; i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[n-1]);
}

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

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

    print(a, n);

    for(int i = 1; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        print(a, n);
    }
}


Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf = 1e14;

class min_cost_flow{
private:
    int N;
    struct edge{int to; ll cap,cost; int rev; bool is_rev;};
    vector<vector<edge>> G;
    vector<ll> h,dist,prevv,preve;
public:
    min_cost_flow(int n){
        N = n;
        G = vector<vector<edge>>(N);
        h = dist = prevv = preve = vector<ll>(N,0);
    }
    void add_edge(int from,int to,ll cap,ll cost){
        G[from].push_back((edge){to,cap,cost,(int) G[to].size(),false});
        G[to].push_back((edge){from,0,-cost,(int) G[from].size()-1,true});
    }
    ll answer(int s,int t,ll f){
        ll res = 0;
        fill(h.begin(),h.end(),0);
        while(f>0){
            priority_queue<P,vector<P>,greater<P>> Q;
            fill(dist.begin(),dist.end(),inf);
            dist[s] = 0;
            Q.push(P(0,s));
            while(!Q.empty()){
                P p = Q.top(); Q.pop();
                int v = p.second;
                if(dist[v]<p.first) continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e = G[v][i];
                    if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                        dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        Q.push(P(dist[e.to],e.to));
                    }
                }
            }
            if(dist[t]==inf) return -1;
            for(int v=0;v<N;v++) h[v] += dist[v];
            ll d = f;
            for(int v=t;v!=s; v=prevv[v]){
                d = min(d,G[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += d*h[t];
            for(int v=t;v!=s;v=prevv[v]){
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= d;
                G[v][e.rev].cap += d;
            }
        }
        return res;
    }
};

int N,M,F;

int main(){
    cin >> N >> M >> F;
    min_cost_flow flow(N+1);
    int u,v,c,d;
    for(int i=0;i<M;i++){
        cin >> u >> v >> c >> d;
        flow.add_edge(u,v,c,d);
    }
    cout << flow.answer(0,N-1,F) << endl;
}


Measured memory_bytes: 3244
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n + 1), b(m + 1);
    vector<int> s(m + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        s[i] = s[i - 1] + b[i];
    }
    int sum = 0;
    for (int i = 0; i <= n; i++) {
        sum += a[i];
        if (x - sum < 0) break;
        auto it = max(0ll, upper_bound(all(s), x - sum) - s.begin() - 1ll);
        ans = max(ans, i + it);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7948
/*A - Sheep and Wolves*/
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int wolves;
	int sheep;

	cin >> sheep >> wolves;

	if(wolves >= sheep)
		cout << "unsafe";
	else
		cout << "safe";
	
	return 0;
}

Measured memory_bytes: 3628
N,Y = map(int,input().split())
flag = False
for i in range(N+1):
    for j in range(N+1-i):
        x = N - i - j
        if x*1000 + j*5000 +i*10000 == Y:
            print(i,j,x)
            flag = True
            break
    if flag == True:
        break


if flag == False:
    print('-1 -1 -1')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int n, k;
string s;
int ans, ta, rin;
vector<int> wa;
vector<char> iku;
queue<int> que;

signed main() {
	cin >> n >> k >> s;
	rep(i, s.size()) {
		iku.push_back(s[i]);
		wa.push_back(iku[i] - '0');
	}
	for (int i = 1; i < n; i++) {
		if (wa[i] == 0 && wa[i - 1] == 1) {
			if (ta == k) {
				ans = max(ans, i - rin);
				rin = que.front();
				que.pop();
			}
		}
		else if (wa[i] == 1 && wa[i - 1] == 0) {
			ta = min(ta + 1, k);
			que.push(i);
		}
	}
	ans = max(ans, n - rin);
	cout << ans << endl;
}

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

ll gcd(ll i, ll j, ll k){
	return __gcd(i,__gcd(j,k));
}
void solve(){
	ll k;
	cin>>k;
	ll ans = 0;
	for(ll i=1;i<=k;++i){
		for(ll j=1;j<=k;++j){
			for(ll h = 1;h<=k;++h){
				ans += gcd(i,j,h);
			}
		}
	}
	cout<<ans<<endl;
}
int main()
{

  solve();

return 0;
}



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

using namespace std;

#define ll long long
#define pii pair<int,int>
vector<int> parent(200005);
vector<int> s(200005);

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void union_sets(int a,int b)
{
	a = find_set(a);
	b = find_set(b);
	if(a != b)
	{
		if(s[a] < s[b])
			swap(a,b);
		parent[b] = a;
		s[a] += s[b];
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	int x,y;
	for(int i=1;i<=n;i++)
	{
		s[i] =1;
		parent[i] =i;
	}
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		union_sets(x,y);
	}
	int nax = INT_MIN;
	for(int i=1;i<n+1;i++)
	{
		nax = max(nax,s[i]);
	}
	cout<<nax<<endl;
}

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

bool check(vector<vector<char>>a,int y,int x,int h,int w) {
	bool hor(true), ver(true);
	for (int i(0); i < h; i++) {
		if (a[i][x] == '#')ver=false;
	}
	for (int i(0); i < w; i++) {
		if (a[y][i] == '#')hor=false;
	}
	if (ver == true || hor == true)return true;
	else return false;
}

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<vector<char>>a;
	for (int i(0); i < h; i++) {
		vector<char>b;
		for (int j(0); j < w; j++) {
			char tmp;
			cin >> tmp;
			b.push_back(tmp);
		}
		a.push_back(b);
	}
	for (int i(0); i < h; i++) {
		int cnt(0);
		for (int j(0); j < w; j++) {
			if (!(check(a, i, j, h, w))) {
				cout << a[i][j];
				cnt++;
			}
		}
		if (cnt>0)cout << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, a[100] = { 0 }, maxv = 0;
    while (cin >> n) {
        a[n - 1]++;
        maxv = max(maxv, a[n - 1]);
    }
    for (int i = 0; i < 100; i++) {
        if (a[i] == maxv) {
            cout << i + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
import collections
n = int(input())
a = list(map(int, input().split()))

a.sort()
a = collections.deque(a)
counter = 0
for i in range(1, n+1):
    while len(a) != 0:
        if i != a[0]: 
            break
        counter += 1
        a.popleft()    
    print(counter)
    counter = 0
    


Measured memory_bytes: 92404
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int h[100005];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int dp[100005];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=1e9;
        for(int j=1;j<=k&&i-j>=0;j++)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    printf("%d\n",dp[n-1]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
vector<int> g[100100];
int N,M;
int p[100100];
int x[100100],y[100100];
bool used[100100];
vector<int> vec;
set<int> s;
void dfs(int v){
	used[v]=true;
	vec.pb(v);
	s.insert(p[v]);
	for(int i=0;i<g[v].size();i++){
		if(used[g[v][i]])continue;
		dfs(g[v][i]);
	}
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		scanf("%d",&p[i]);
		p[i]--;
	}
	for(int i=0;i<M;i++){
		scanf("%d %d",&x[i],&y[i]);
		x[i]--;y[i]--;
		g[x[i]].pb(y[i]);
		g[y[i]].pb(x[i]);
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(used[i])continue;
		vec.clear();
		s.clear();
		dfs(i);
		for(int j=0;j<vec.size();j++){
			if(s.find(vec[j])!=s.end())ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    if (n < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;

    return 0;
}



Measured memory_bytes: 3632
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 

vector<int> v[100001];
int vis[100001];
int res[100001];
int main()
{
    fast;
 	int n;cin>>n;
 	int m;cin>>m;
 	rep(i,m)
 	{
 		int x,y;cin>>x>>y;
 		v[x].p_b(y);
 		v[y].p_b(x);
 	}

 	queue<int> q;
 	q.push(1);
 	vis[1]=1;
 	int count=0;
 	res[1]=0;
 	while(!q.empty())
 	{
 		int x=q.size();
 		count++;
 		for(int i=0; i<x; i++)
 		{
 			int t=q.front();
 			q.pop();
 			for(int j=0; j<v[t].size(); j++)
 			{
 				if(vis[v[t][j]]==0)
 				{
 					vis[v[t][j]]=1;
 					q.push(v[t][j]);
 					res[v[t][j]]=t;
 				}
 			}
 		}
 	}
 	vector<int> ans;
 	int f=0;
 	for(int i=2; i<=n; i++)
 	{
 		if(res[i]==0)
 		{
 			f=1;
 		}
 		else
 		{
 			ans.p_b(res[i]);
 		}
 	}
 	if(f==0)
 	{
 		cout<<"Yes"<<"\n";
 		for(auto i:ans)
 			cout<<i<<"\n";
 	}
 	else
 		{cout<<"No"<<"\n";}



}





Measured memory_bytes: 11188
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int X, A;

int main(int argc, const char * argv[]) {
    cin >> X >> A;
    if (X < A) {
        output(0);
    } else {
        output(10);
    }

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    
    sort(s.begin(),s.end());
    int kw = 0;
    REP(i,s.size()-1){
        if(s[i] != s[i+1]) kw++;
    }
    if(kw==1) cout<<"Yes"<<endl; else cout<<"No"<<endl;

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

Measured memory_bytes: 256
from sys import stdin


def get_result(data):
    N = data[0][0]
    A = data[1]
    ans = [0 for _ in range(N)]
    for val in A:
        ans[val-1] += 1
    for val in ans:
        print(val)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)


Measured memory_bytes: 32292
#include <stdio.h>

int main()
{
    long long n,h[100000],l = 0,j = 0,maxl = 0;

    scanf("%lld",&n);
    for (long long  i = 0; i < n; i++)
    {
        scanf("%lld",&h[i]);
    }

    for (long long i = 0; i < n - 1; i++)
    {
        if(h[i] >= h[i + 1])
        {
            l ++;
        }
        else
        {
            if(maxl < l)
            {
                maxl = l;
            }
            l = 0;
        }
    }
    if(maxl < l)
    {
        maxl = l;
    }
    printf("%lld",maxl);
}


Measured memory_bytes: 896
a=input()
b=len(a)
c=int(a)
if b==1:
    print(c)
elif b==2:
    print(9)
elif b==3:
    d=c-99+9
    print(d)
elif b==4:
    print(909)
elif b==5:
    e=c-9999+909
    print(e)
else:
    print(90909)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, m;
    cin>>n>>m;
    int i;
    int sum = 0;
    FOR0(i, m)
    {
        int temp;
        cin>>temp;
        sum += temp;
    }
    int ans = MAX2(n-sum, -1);
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

const int N = (int) 2e5 + 7;
const long long MOD = (long long) 1e9 + 7ll;

int n;
long long a[N], p[N];

void add(long long &ans, long long val) {
	ans = (ans + val) % MOD;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (i == 0) {
			p[i] = a[0] % MOD;
		} else {
			p[i] = (p[i - 1] + a[i]);
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		add(ans, (a[i] * ((p[n - 1] - p[i]) % MOD)) % MOD);
	}
	cout << ans;
}

Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    ll c = abs(b - a);
    if(c % 2) cout << "IMPOSSIBLE" << endl;
    else{
        ll res = min(a, b) + c / 2;
        cout << res << endl;
    }
    return 0;
}

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

int n,Q[4],a[10],ans=1e9;

void DFS(int x,int S,int v)
{
	if (x==4)
	{
		if (!v)
		{
			cout<<"";
		}
		ans=min(ans,v);
		return;
	}
	for (int i=1; i<(1<<n); ++i)
	{
		if (i&S) continue;
		int cnt=0,sum=0;
		for (int j=0; j<n; ++j)
			if (i&(1<<j)) cnt++, sum+=a[j];
		DFS(x+1,S|i,v+abs(sum-Q[x])+(cnt-1)*10) ;
	}
}


int main()
{
	cin>>n>>Q[1]>>Q[2]>>Q[3];
	for (int i=0; i<n; ++i) cin>>a[i];
	DFS(1,0,0); cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int n, tmp, max = 0;
    cin >> n;
    vector<int> c(n), v(n),s(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        s[i] = v[i] - c[i];
    }

    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { 
                S.push_back(s[i]);
            }
        }
        for (int i = 0; i < (int)S.size(); ++i) {
            tmp += S[i];
             if(max < tmp) {
                max = tmp;
            }
        }
       
        tmp = 0;
    }

    cout << max << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static double max = 0;
    static void Main(string[] args)
    {
        string n = Console.ReadLine();
        Console.WriteLine(n.IndexOf("7") >= 0 ? "Yes" : "No");


    }


}



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

#define endl "\n"

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, n;
    cin >> k >> n;
    int a[n], dis[n], sum = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    for (int i = 0; i < n - 1; ++i)
        dis[i] = a[i + 1] - a[i];
    dis[n - 1] = k + a[0] - a[n - 1];

    int max_d = -1;
    for (int i = 0; i < n; ++i)
        max_d = max(max_d, dis[i]);

    cout << k - max_d << endl;
    // if (a[0] == 0) {
    //     sum = k - max_d;
    // } else {
    //     sum = a[n - 1] - a[0];
    // }
    // cout << sum << endl;

    return 0;
}

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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    ll a2=a-1;

    ll aa,bb;
    ll l=(c*d)/__gcd(c,d);

    bb=b-b/c-b/d+b/l;
    aa=a2-a2/c-a2/d+a2/l;

    cout<<bb-aa<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    int ans = 700;
    rep(i, s.size()) if(s[i] == 'o') ans += 100;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> W(N);
  rep(i, 0, N) cin >> W[i];
  int tot = accumulate(W.begin(), W.end(), 0);
  int ans = tot;
  int t = 0;
  rep(i, 0, N-1) {
    t += W[i];
    int dif = tot - t;
    ans = min(ans, abs(t - dif));
  }
  cout << ans << endl;
  return 0;
}


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

#define int long long
#define double long double

double EPS = (1e-8);

struct Point {
  double x, y;
};

struct Circle {
  Point p;
  double r;
  int id;
};

bool intersect(Circle a, Circle b) {
  double x1 = a.p.x, y1 = a.p.y;
  double x2 = b.p.x, y2 = b.p.y;  
  double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);

  if ( d - (a.r+b.r)*(a.r+b.r) >= -EPS ) return false;  
  else return true;
}

vector<Circle> C[4];
vector<Circle> circles;
int N;
unordered_map<int, int> dp;

int dfs(int bit) {
  //cout << bit << endl;
  if ( bit == (1<<N)-1 ) return 0;
  if ( dp[bit] ) return dp[bit];

  int ret = 0;
  int n;
  for ( int i = 0; i < 4; i++ ) {
    n = C[i].size();
    for ( int a = 0; a < n; a++ ) {
      Circle c1 = C[i][a];
      int i1 = c1.id;
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      if ( bit & (1<<i1) ) continue;
      bool flag = true;	
      for ( int j = 0; j < i1; j++ ) {
	if ( !(bit & (1<<j)) && intersect(circles[j], c1) ) {
	  flag = false;
	  break;
	}
      }
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      if ( !flag ) continue;
      //if ( bit == 9 && i1 == 1 ) cout << 'a' << endl;
      for ( int b = a+1; b < n; b++ ) {
	Circle c2 = C[i][b];
	int i2 = c2.id;
	//if ( i1 == 1 && i2 == 2 ) cout << 'a' << endl;
	if ( bit & (1<<i2) ) continue;       	
	for ( int j = 0; j < i2; j++ ) {
	  if ( !(bit & (1<<j)) && intersect(circles[j], c2) ) {	    
	    flag = false;
	    break;
	  }
	}
	if ( flag ) {
	  ret = max(ret, dfs(bit|(((1<<i1)+(1<<i2))))+2);	  
	} else {
	  flag = true;
	}
      }
    }
  }
  
  return dp[bit] = ret;  
}

signed main() {
  while ( cin >> N, N ) {
    for ( int i = 0; i < 4; i++ ) C[i].clear();
    circles.clear();
    dp.clear();    
    
    for ( int i = 0; i < N; i++ ) {
      Circle in;
      double x, y, r;
      int c;      
      cin >> x >> y >> r >> c;
      c--;
      in.p = Point{x, y};      
      in.r = r;
      in.id = i;      
      C[c].push_back(in);
      circles.push_back(in);      
    }
    
    cout << dfs(0) << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 43948
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  bool c = false, f = false;
  re(i, s.size()){
    if(s[i]=='C') c = true;
    if(c&&s[i]=='F') f = true;
  }
  std::cout << (c&&f?"Yes":"No") << '\n';
}


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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt(), x = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}
	sort(all(a));
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (x >= a[i]) {
			x -= a[i];
			++ans;
		}
	}
	if (ans == n && x) {
		--ans;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    a, b = map(int, input().split())
    print(a * b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65224
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
#define tc(w) ll w;cin>>w;while(w--)

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

ll lcm1(ll a,ll b){
	return (a*b)/(__gcd(a,b));
}
int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);
    	ll k;
    	string s;
    	cin>>k>>s;
    	if(s.size()>k){
    		string str = s.substr(0,k);
    		cout<<str<<"..."<<endl;
    	}else{
    		cout<<s;
    	}
	return 0;
}


Measured memory_bytes: 3644
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
mod = 10**9 + 7

#maincode-------------------------------------------------

a,b,c,d = inm()
x = [a,b]
y = [c,d]
ans = a*c
for i in x:
    for j in y:
        ans = max(ans,i*j)

print(ans)

Measured memory_bytes: 9344
#include<stdio.h>
int main()
{
    int x,a,b,c,d;
    scanf("%d",&x);
    a=x%10;
    x/=10;
    b=x%10;
    x/=10;
    c=x%10;
    x/=10;
    d=x%10;
    if(a==b&&b==c || b==c&&c==d)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

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

int main(){
  int64_t Q,H,S,D;
  cin >> Q >> H >> S >> D;
  int64_t N;
  cin >> N;
  H=min(H,Q*2);
  S=min(S,H*2);
  D=min(D,S*2);
  int64_t s,d;
  d=N/2;
  N%=2;
  s=N;
  cout << d*D+s*S << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		int k = (A + B) / 2;
		System.out.println((A + B) % 2 == 0 ? String.valueOf(k) : "IMPOSSIBLE");
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

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

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int A, B; cin >> A >> B;
    if(A>=13){
        cout << B << endl;
    }else if(A<=5){
        cout << 0 << endl;
    }else{
        cout << B/2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, cnt = 0;
	cin >> N;
	for (int i = 1; i < N + 1; i++) {
		if (to_string(i).size() % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := oneInt()
	as := scanNums(n)

	ans := calc(as)

	fmt.Println(ans)
}

func calc(as []int) int64 {
	var minusCount int
	for _, ai := range as {
		if ai < 0 {
			minusCount++
		}
	}
	var answer int64
	if minusCount%2 == 0 {
		for _, ai := range as {
			answer += int64(abs(ai))
		}
	} else {
		s := []int{}
		for _, ai := range as {
			s = append(s, abs(ai))
			answer += int64(abs(ai))
		}
		sort.Ints(s)
		answer += int64(s[0] * -2)
	}
	return answer
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func nextWord(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanNums(n int) (nums []int) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		s := nextWord(sc)
		num, _ := strconv.Atoi(s)
		nums = append(nums, num)
	}
	return nums
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 7680
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;

signed main(){
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

using namespace std;

long long a[10];

int main()
{
  for (int i = 1; i <= 7; i++)
    cin >> a[i];
  long long ans = 2 * a[2];
  if (a[1] % 2 + a[4] % 2 + a[5] % 2 >= 2 && a[1] && a[4] && a[5]) {
    ans += 6;
    a[1]--;
    a[4]--;
    a[5]--;
  }
  ans += 4 * (a[1] / 2);
  ans += 4 * (a[4] / 2);
  ans += 4 * (a[5] / 2);
  cout << ans / 2;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,k; cin >> n >> k;
  str s; cin >> s;
  vector<ll> rv, st;
  if(s[0]=='0') rv.push_back(0);
  bool state = (s[0]=='0') ? false : true;
  int cnt = 0;
  REP(i,n){
      if((state&&s[i]=='0')||(!state&&s[i]=='1')){
        if(state){
          rv.push_back(cnt);
        }else{
          st.push_back(cnt);
        }
        cnt = 1;
        state=!state;
      }else{
        cnt++;
      }
  }
  if(state){
    rv.push_back(cnt);
  }else{
    st.push_back(cnt);
  }
  if(s.back()=='0') rv.push_back(0);
  /*for(ll k : rv) cout << k;
  cout << endl;
  for(ll k : st) cout << k;
  cout << endl;*/

  if(rv.size()==1) rv.push_back(0), st.push_back(0);
  if(k>=st.size()){
    ll ans = 0;
    for(ll l : rv) ans += l;
    for(ll l : st) ans += l;
    cout << ans << endl;
    return 0;
  }
  ll sum = 0;
  REP(i,k+1) sum += rv[i];
  REP(i,k) sum += st[i];
  ll ans = sum;
  REP(i,st.size()-k){
    sum = sum + rv[k+1+i] + st[k+i] - rv[i] - st[i];
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, k = 0, s = 0;
    cin >> n;
    long long a[n], p[n];
    for (long long i = 0; i < n; i++) 
    {
        cin >> a[i];
        p[i] = 0;
    }
    p[0] = 1;
    sort(a, a + n);
    for (long long i = 1; i < n; i++)
    {
        bool increase = false;
        if (a[i] != a[i - 1])
        {
            increase = true;
            if (p[k] < a[i - 1]) s = s + p[k];
            if (p[k] > a[i - 1]) s = s + p[k] - a[i - 1];
            k++;
            p[k] = 1;
        }
        else p[k]++;
        if (i == n - 1 && increase == false)
        {
            if (p[k] < a[i - 1]) s = s + p[k];
            if (p[k] > a[i - 1]) s = s + p[k] - a[i - 1];
        }
    }
    if (p[k] == 1)
    {
        if (p[k] < a[n - 1]) s = s + p[k];
        if (p[k] > a[n - 1]) s = s + p[k] - a[n - 1];
    }
    if (n == 1 && a[0] != 1) cout << '1';
    else cout << s;
}

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

void monster_kill(long long &ans,long long &number,long long &health){
	if(health == 0) return;	

	ans += number;

	number *= 2;

	health /= 2;

	monster_kill(ans,number,health);
	
}

int main(){
	long long h,ans,number;
	cin >> h;
	ans = 0;
	number = 1;
	monster_kill(ans,number,h);

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

	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n, k, c = 0;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  rep(i, 0, n) {
    c += min(v[i], abs(k-v[i]))*2;
  }
  cout << c;
}

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

using namespace std;

int main() {

  string realN;
  int n = 0, nsum = 0;
  cin >> realN;
  for(int i = 0;i < realN.size();i++){
    n = n * 10 + realN[i] - '0';
    nsum += realN[i] - '0';
  }
  //cerr << n;
  if(n % nsum == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

ll r[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; ll a, b; cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
		cin >> r[i];
	ll ans = 0;
	for (int i = 1; i < n; i++)
		ans += min((r[i] - r[i - 1]) * a, b);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vector<bool> go(n+1,false);
    vector<int> dp(n+1,inf);
    for(int i=0;i<=n;i++){
	if( s[i] == '0' ){
	    go[i] = true;
	}
    }

    int now = n ;
    vector<int> st;
    while( now != 0 ){
	st.push_back( now );
	bool flag = false;
	for(int i =min( m , now ); i>0 ;i--)if( go[now-i] ){
	    flag = true;
	    now = now-i;
	    break;
	}
	if( !flag )break;
    }
    if( now == 0 ){
	st.push_back( now );
	for(int i=st.size()-2;i>=0;i--){
	    cout<<st[i]-st[i+1];
	    if( i == 0 )cout<<endl;
	    else cout<<' ';
	}
    }else{
	cout<<-1<<endl;
    }

    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

ll x[MAX_N], v[MAX_N], a[MAX_N], b[MAX_N], sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll C;
    cin >> n >> C;
    rep(i,n){
        cin >> x[i+1] >> v[i+1];
        sm[i+1] = sm[i] + v[i+1];
    }
    x[n+1] = C, v[n+1] = 0, sm[n+1] = sm[n];
    a[n+1] = b[n+1] = (1LL << 62);
    for(int i = n; i >= 0; --i){
        a[i] = min(a[i+1], sm[i] - x[i+1]);
        b[i] = min(b[i+1], sm[i] - 2 * x[i+1]);
    }
    ll ans = 0;
    rep(i,n+1){
        cmx(ans, sm[n] - C + sm[i] - x[i] - min(x[i] + a[i], C + b[i]));
    }
    cout << ans << "\n";
    return 0;
}

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

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

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

  ll n, c, k; cin >> n >> c >> k;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  sort(t.begin(), t.end());

  ll ans = 1, cnt = 1, time = t[0]+k;
  rep(i, n-1) {
    if(cnt == c || t[i+1] > time) {
      ans++;
      cnt = 1;
      time = t[i+1]+k;
    } else {
      cnt++;
    }
  }

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


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

typedef long long LL;

using namespace std;

int N,M,x[100010],y[100010];
int cnt[100010];
bool ok[100010];

int main()
{
    scanf("%d%d",&N,&M);
    for (int i=1;i<=M;i++)scanf("%d%d",&x[i],&y[i]);
    for (int i=1;i<=N;i++)cnt[i] = 1;
    ok[1] = true;
    for (int i=1;i<=M;i++)
    {
        ok[y[i]] |= ok[x[i]];
        cnt[y[i]]++;
        cnt[x[i]]--;
        if (cnt[x[i]] == 0) ok[x[i]] = false;
    }
    int ans = 0;
    for (int i=1;i<=N;i++)ans+=ok[i];
    printf("%d\n",ans);
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL
//						999999999999999989
//	O(1e7) O(1e8)

void Main()
{
	int N,K;
	cin>>N>>K;
	vec(A,N);
	int longer=-1;
	rep(i,N){
		cin>>A[i];
		longer = max(longer, A[i]);
	}

	int l=0, r=longer+1;
	while(abs(l-r)>1){
		int mid=(l+r)/2;
		if(mid==0) mid=1;
		ll ans=0;
		rep(i,N){
			ans += (A[i]-1)/mid;
		}
		if(ans<=K)r=mid;
		else l=mid;
	}

	cout<<r<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3964
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var line;
while (line = lines.shift()) {
	if (line == '0')
		break;

	cnt2 = 0;
	cnt5 = 0;
	var n = +line;
	for (var i = 1; i <= n; i++) {
		var tmp = i;
		while (tmp % 2 == 0) {
			tmp /=2;
			cnt2++;
		}
		while (tmp % 5 == 0) {
			tmp /= 5;
			cnt5++;
		}
	}
	console.log(Math.min(cnt2, cnt5));
}

Measured memory_bytes: 8692