akhauriyash/Code-Regression huggingface dataset:
unittest
{
	assert( [ "1" ].solve == 0 );
	assert( [ "0" ].solve == 1 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	
	return ( x + 1 ) % 2;
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
int main(){FAST;
cin>>n;
ll x = n;
ll ct = 0;
while(x){
	ct++;
	x/=10;
}
ll p = 1;
ll ans = 0;
for(ll i=1;i<ct;i++){
	if(i&1)ans+=p*9;
	p*=10;
}
if(ct&1){
	ans+=(n-p+1);
}
cout<<ans;
return 0;
}

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

using namespace std;

#define U unsigned
#define L long
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
	
int main(){
	unsigned long long int n, sum = 0;

	cin >> n;

	for(int i = 1; i <=  n; i++){
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}

	cout << sum;
}

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


signed main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans;
    if(a+b <= 2*c){
        ans = x*a + y*b;
    }else{
        if(x > y){
            int ans1 = 2*c*y + a*(x-y);
            int ans2 = 2*c*x;
            ans = min(ans1, ans2);
        }else{
            int ans1 = 2*c*x + b*(y-x);
            int ans2 = 2*c*y;
            ans = min(ans1, ans2);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

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

template<class T>void byebye(T _rpl){cout<<_rpl<<endl;exit(0);}
int nextint(){int x;scanf("%d",&x);return x;}
ll nextll(){ll x;scanf("%lld",&x);return x;}

int read(){
	int f=1,ret=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ret=ret*10+(c-'0');c=getchar();}
	return ret*f;
} 

int n,k,a[2005],cnt[2005];
const ll mod=1000000007;
ll ans=0;

int main(){	
	n=read(),k=read();
	ll mul=ll(k)*ll(k-1)/2ll;
	mul%=mod;
	for(int i=0;i<n;++i){a[i]=read();}
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){if(a[j]<a[i])cnt[i]++;}
		ll res=0;
		for(int j=i+1;j<n;++j){if(a[j]<a[i])res+=k,res%=mod;}
		res+=mul*cnt[i];
		res%=mod;
		ans+=res;
	//	cerr<<res<<endl;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s + n);
    int res = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i - 1] != s[i])
            res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9844
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;

string ans;
char can;

void prt(int n, char can)
{
    for (char ch = 'a'; ch <= can; ch++)
    {
        ans[n] = ch;
        if (n + 1 < N)
        {
            char ch2 = ch + 1;
            prt(n + 1, max(ch2, can));
        }
        else
        {
            cout << ans << endl;
        }
    }
}

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        ans += 'a';
    }
    can = 'a';
    prt(0, 'a');
}

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

int main(){
  int64_t N;
  int64_t count=0;
  cin>>N;
  int64_t sum=100;
  while(sum<N){
    int64_t r=sum/100;
    sum+=r;
    count++;
  }
  cout<<count<<endl;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  long H, W, M;
  cin >> H >> W >> M;
  vector<long> T(M);
  for (int i = 0; i < M; i++) {
    int h, w;
    cin >> h >> w;
    h--;
    w--;
    T[i] = h * W + w;
  }
  vector<long> cntT(H, 0), cntY(W, 0);  // count per tate yoko

  for (int i = 0; i < M; i++) {
    cntT[T[i] / W]++;
    cntY[T[i] % W]++;
  }

  long maxTval = cntT[0], maxYval = cntY[0];  // value of tate yoko

  for (int i = 1; i < H; i++) {
    maxTval = max(cntT[i], maxTval);
  }

  for (int i = 1; i < W; i++) {
    maxYval = max(cntY[i], maxYval);
  }

  set<int> maxTs, maxYs;

  for (int i = 0; i < H; i++) {
    if (cntT[i] == maxTval) maxTs.insert(i);
  }
  for (int i = 0; i < W; i++) {
    if (cntY[i] == maxYval) maxYs.insert(i);
  }

  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (maxTs.find(T[i] / W) != maxTs.end() &&
        maxYs.find(T[i] % W) != maxYs.end())
      cnt++;
  }

  if (cnt < maxTs.size() * maxYs.size()) {
    cout << maxTval + maxYval << endl;
  } else {
    cout << maxTval + maxYval - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 38276
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
    int n;
    int sgn = 1;

    string ans = "";

    cin >> n;

    if (n == 0) {
        cout << "0" << endl;
        return 0;
    }

    while (n != 0) {
        if (n % 2 != 0) {
            n -= sgn;
            ans += '1';
        } else {
            ans += '0';
        }

        n >>= 1;
        sgn *= -1;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	int N;
	int M = 0;
	cin>>N;
	int summ = 0;
	rep1(i,N+2){
		summ+=i;
		if(summ>=N){
			M = i;
			break;
		}
	}
	rep1(i,M+1){
		if(i == summ-N)continue;
		cout<<i<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
      
        int n;
        cin >> n;
        int i,j;
        int ans=0;
        for(i=1; i<=n; i++){
            int x=i;
            string y=to_string(x);
            if(y.size()%2){
                ans++;
            }
        }  
        cout << ans << '\n';
        

}

Measured memory_bytes: 256
s=input()
t=input()

lst=[]
for i in range(len(s)-len(t)+1):
  ss=s[i:i+len(t)]
  f=True
  for a,b in zip(ss,t):
    if a!=b and a!="?":
      f=False
      break
  if f:
    st=s[:i]+t+s[i+len(t):]
    lst.append(st.replace("?","a"))
if lst==[]:
  print("UNRESTORABLE")
else:
  lst.sort()
  print(lst[0])

Measured memory_bytes: 9020
//https://twitter.com/chokudai/status/1267093176973549571
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long N;
    long long A[1000000];
    long long sum = 1;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] == 0)
        {
            cout << "0" << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (sum * A[i] < sum || sum * A[i] > 1000000000000000000)
        {
            cout << "-1" << endl;
            return 0;
        }
        else
        {
            sum = sum * A[i];
        }
    }

    if (sum <= 1000000000000000000)
    {
        printf("%llu\n", sum);
        return 0;
    }
    else
    {
        cout << "-1" << endl;
        return 0;
    }
}

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

int solve(long long N, std::vector<long long> A)
{
    long long sum = A[0];
    for (int i = 1; i < N; i++)
    {
        sum = sum * A[i];
    }

    if (1000000000000000000 < sum)
    {
        cout << "-1" << endl;
    }
    else
    {
        printf("%lld\n", sum);
    }

    //cout << fixed << setprecision(20) << sum << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}
*/

Measured memory_bytes: 4552
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	int l[200010],r[200010];
	int now=0,cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='o'&&cnt==0){
			l[now]=i;
			now++;
			cnt=c;
		}else if(cnt>0){
			cnt--;
		}
	}
	now=k-1,cnt=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'&&cnt==0){
			r[now]=i;
			now--;
			if(now<0)break;
			cnt=c;
		}else if(cnt>0){
			cnt--;
		}
	}
	for(int i=0;i<k;i++){
		if(l[i]==r[i])cout<<l[i]+1<<endl;
	}
}


Measured memory_bytes: 4996
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L,i;
  cin>>N>>L;
  string ans="";

  string a[N];
  for (i=0;i<N;i++)cin>>a[i];
  sort(a,a+N);
  //reverse(a,a+N);
  
  for (i=0;i<N;i++){
    ans += a[i];
  }
  cout << ans << endl;
}

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

int main(){
    int N, T;
    cin >> N >> T;
    
    int A[N];
    int maxes[N];
    int B[N-1];
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        maxes[i] = 0;
    }
    maxes[N-1] = A[N-1];
    for(int i = N - 2; i >= 0; --i){
        maxes[i] = max(maxes[i+1], A[i+1]);
    }

    for(int i = 0; i < N - 1; ++i){
        B[i] = maxes[i] - A[i];
    }

    int temp = INT_MIN;
    for(int i = 0; i < N - 1; ++i){
        if(temp < B[i]){
            temp  = B[i];
        }
    }
    
    int ans = 0;
    for(int i = 0; i < N - 1; ++i){
        if(temp == B[i]){
            ans++;
        }
    }

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


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef double db;
const int maxn = 4e3 + 5;
const ll mod = 998244353;

int n;
char s[maxn];
ll dp[maxn][maxn];
int a[maxn], b[maxn];

template<class T>
void add(T &x, T &y){ x += y; if(x >= mod) x -= mod; }

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    rep(i, 1, n)
        a[i] = a[i-1] + 2 - (s[i] - '0'), b[i] = b[i-1] + s[i] - '0';
    dp[0][0] = 1;
    rep(i, 0, 2 * n)
        rep(j, 0, i)
            if(dp[i][j]){
                if(a[min(i + 1, n)] > j)
                    add(dp[i+1][j+1], dp[i][j]);
                if(b[min(i + 1, n)] > i - j)
                    add(dp[i+1][j], dp[i][j]);
            }
    printf("%lld\n", dp[2*n][a[n]]);
    return 0;
}


Measured memory_bytes: 123520
#include <bits/stdc++.h>
#define SZ(v) ((int)((v).size()))
using namespace std;
using ll = long long;

template<typename T>
vector<T> compress(vector<T> vec) {
	vector<pair<T, int>> util(SZ(vec));
	for (int i = 0; i < SZ(vec); ++i) {
		util[i] = {vec[i], i};
	}
	sort(util.begin(), util.end());
	vector<int> res = vec;
	int pos = 0;
	for (int i = 0; i < SZ(vec); ++i) {
		if (i > 0 && util[i].first > util[i-1].first) ++pos;
		res[util[i].second] = pos;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	a = compress(a);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (i%2 != a[i]%2) ++cnt;
	}
	cout << cnt/2 << "\n";
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

ll cnt = 0; 

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 

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

  priority_queue<ll> pq;

  ll tmp;
  rep(i,n){
    cin>>tmp;
    pq.push(tmp);
  }

  rep(i, m){
    tmp = pq.top();
    pq.pop();
    pq.push(tmp/2);
  }

  ll ans = 0;
  rep(i, n){
    tmp = pq.top();
    pq.pop();
    ans += tmp;
  }

  cout << ans << endl;
 
  
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, P;
	cin >> N >> P;
	int res;
	if (N == 1) {
		res = P;
	}
	else {
		res = 1;
		for (int i = 2; i*i <= P; i++) {
			if (P%i == 0) {
				int c = 0;
				while (P % i == 0) {
					P /= i;
					c++;
				}
				int z = c / N;
				for (int j = 0; j < z; j++) {
					res *= i;
				}
			}
		}
	}
	cout << res << endl;
}

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

int n,p[101],q[101],r[101],b[101];
bool flg[101];

int gcd(int a,int b){
	return b == 0 ? a : gcd(b,a%b);
}

int lcm(int a,int b){
	return a / gcd(a,b) * b;
}

int solve(int idx){
	int res = 0;

	int rcost = r[idx] ? solve(r[idx]) : 1;
	int bcost = b[idx] ? solve(b[idx]) : 1;
	int l = lcm(p[idx] * rcost, q[idx] * bcost);

	return l / p[idx] + l / q[idx];
}

int main(void){
	while(cin>>n, n){
		memset(flg,0,sizeof(flg));
		for(int i=1;i<=n;i++){
			cin>>p[i]>>q[i]>>r[i]>>b[i];
			flg[r[i]] = flg[b[i]] = true; //ã©çÂé³êÄ¢é_ðtrueÉ·é
		}

		for(int i=1;i<=n;i++){
			//ã©çÂé³êÄ¢È¢_ÈçÎ, [gm[h
			if(!flg[i]){
				cout<<solve(i)<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

const int mxn = 1e5 + 5;
int n, m;
vector<int> G[mxn];

int vis[mxn], dp[mxn];

int dfs( int u ) {
	if( ~dp[u] ) return dp[u];
	dp[u] = 0;
	vis[u] = 1;

	for(auto& v : G[u]) {
		if( !vis[v] ) {
			dp[v] = dfs( v );
		}
		dp[u] = max(dp[u], dp[v] + 1);
	}
	return dp[u];
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		G[u].push_back(v);
	}

	int res = 0;
	memset(dp, -1, sizeof dp);
	for(int i = 1; i <= n; i++) {
		res = max(res, dfs( i ));
	}

	cout << res << "\n";
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    ll s=n+m;
    if(n%3==0||m%3==0||s%3==0)
    {
        cout<<"Possible"<<endl;
    }
    else
        cout<<"Impossible"<<endl;
    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> zAlgorithm(string s) {
    int n = s.size();
    vector<int> ret(n,0);
    ret[0] = n;
    int i = 1,j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) {
            ++i;
            continue;
        }
        int k = 1;
        while (i+k < n && k+ret[k] < j) {
            ret[i+k] = ret[k];
            ++k;
        }
        i += k;
        j -= k;
    }
    return ret;
}

int main() {
    string s,t,u;
    cin >> s >> t;
    int n = s.size(),m = t.size(),x,ans = 0;
    u = t;
    for (int i = 0;i < m/n+2;++i) u += s;
    x = u.size();
    vector<int> a = zAlgorithm(u);
    vector<bool> b(n,false),used(n,false);
    for (int i = m;i < m+n;++i) {
        if (a[i] < m) continue;
        b[i-m] = true;
    }
    for (int i = 0;i < n;++i) {
        if (!b[i]) used[i] = true;
        if (b[((i-m)%n+n)%n]) continue;
        int ret = 0,f = i;
        while (b[f]) {
            used[f] = true;
            (f += m) %= n;
            ret++;
        }
        ans = max(ans,ret);
    }
    for (int i = 0;i < n;++i) if (!used[i]) {
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13108
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(double, a);
    make(double, b);
    cout << (int)(a * b);
    return 0;
}

Measured memory_bytes: 3752
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int solve(const string &a, const string &b, const string &c) {
  int x = a.length(), y = b.length(), z = c.length();
  vector<bool> ab(x), bc(y), ac(x);
  REP(i, x) {
    int j = i;
    while (j < x && j - i < y && (a[j] == '?' || b[j - i] == '?' || a[j] == b[j - i])) ++j;
    ab[i] = j == x || j - i == y;
  }
  REP(i, y) {
    int j = i;
    while (j < y && j - i < z && (b[j] == '?' || c[j - i] == '?' || b[j] == c[j - i])) ++j;
    bc[i] = j == y || j - i == z;
  }
  REP(i, x) {
    int j = i;
    while (j < x && j - i < z && (a[j] == '?' || c[j - i] == '?' || a[j] == c[j - i])) ++j;
    ac[i] = j == x || j - i == z;
  }
  int ans = INF;
  REP(i, x + 1) FOR(j, i, x + y + 1) {
    if ((x <= i || ab[i]) && (i + y <= j || bc[j - i]) && (x <= j || ac[j])) {
      // cout << a << ' ' << b << ' ' << c << " : " << i << ' ' << j << " : " << max({x, i + y, j + z}) << '\n';
      chmin(ans, max({x, i + y, j + z}));
    }
  }
  return ans;
}

int main() {
  vector<string> a(3); REP(i, 3) cin >> a[i];
  int ans = INF;
  REP(i, 3) REP(j, 3) REP(k, 3) {
    if (i != j && j != k && k != i) chmin(ans, solve(a[i], a[j], a[k]));
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;

const double EPS = 1e-9;

bool equal(double a, double b) {
  return abs(a - b) < EPS;
}

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double S = (double)W * H / 2.0;
  int multi = 0;
  if (equal((double)W / 2.0, (double)x) && equal((double)H / 2.0, (double)y)) multi = 1;
  else multi = 0;
  printf("%.9f %d\n", S, multi); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X,Y;
  cin >> X >> Y >> A >> B >> C;
  vector<long long> P(A);
  vector<long long> Q(B);
  vector<long long> R(C);
  for(int i=0;i<A;i++){
    cin >> P.at(i);
  }
  for(int i=0;i<B;i++){
    cin >> Q.at(i);
  }
  for(int i=0;i<C;i++){
    cin >> R.at(i);
  }
  sort(P.begin(),P.end());
 reverse(P.begin(),  P.end());
  sort(Q.begin(),Q.end());
 reverse(Q.begin(),Q.end());
  vector<long long> KIYO(X+Y+C);
  
  
  
  for(int i=0;i<X;i++){
    KIYO.at(i)=P.at(i);
  }
  for(int i=0;i<Y;i++){
    KIYO.at(i+X)=Q.at(i);
  }
  for(int i=0;i<C;i++){
    KIYO.at(i+X+Y)=R.at(i);
  }
  sort(KIYO.begin(),KIYO.end());
reverse(KIYO.begin(),KIYO.end());
  long long sum=0;
  for(int i=0;i<X+Y;i++){
    sum+=KIYO.at(i);
  
 }
  cout << sum << endl; 
}

Measured memory_bytes: 4736
#4.2
a = list(input().split())

stack = [0] * 1000
stackIndex = -1

for ele in a:
    if ele != '+' and ele != '-' and ele != '*':
        stackIndex += 1
        stack[stackIndex] = ele
    else:
        num2 = int(stack[stackIndex])
        stackIndex -= 1
        num1 = int(stack[stackIndex])
        stackIndex -= 1
        
        calcVal = 0
        if ele == '+':
            calcVal = num1 + num2
        elif ele == '-':
            calcVal = num1 - num2
        elif ele == '*':
            calcVal = num1 * num2
        
        stackIndex += 1
        stack[stackIndex] = calcVal

print(stack[stackIndex])
            

Measured memory_bytes: 7648
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h, w, k, sy, sx, gy, gx;
    cin >> h >> w >> k >> sy >> sx >> gy >> gx;

    --sy;
    --sx;
    --gy;
    --gx;

    vector<string> mat(h);

    rep(i,h){
        cin >> mat[i];
    }

    auto inside = [&](int y, int x){
        return (0 <= y && 0 <= x && y < h && x < w);
    };

    vector<vector<int> > min_cost(h, vector<int>(w, LINF));
    //queue<pair<int, int> > que;
    min_heap<tuple<int, int, int> > pq;
    min_cost[sy][sx] = 0;
    //que.emplace(sy, sx);
    pq.emplace(0, sy, sx);

    while(!pq.empty()){
        //auto [y, x] = que.front();
        auto [v, y, x] = pq.top();
        //que.pop();
        pq.pop();
        if(min_cost[y][x] < v) continue;
        rep(i,4){
            int ny = y, nx = x;
            rep(j,k){
                ny += dy[i];
                nx += dx[i];
                if(inside(ny, nx) && mat[ny][nx] != '@'){
                    if(chmin(min_cost[ny][nx], min_cost[y][x] + 1)){
                        pq.emplace(min_cost[ny][nx], ny, nx);
                    }else if(min_cost[ny][nx] != min_cost[y][x] + 1){
                        break;
                    }
                }else{
                    break;
                }
            }
        }
    }

    if(min_cost[gy][gx] == LINF){
        cout << -1 << '\n';
    }else{
        cout << min_cost[gy][gx] << '\n';
    }

    return (0);
}


Measured memory_bytes: 19788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll a;
	float b;
	cin >> a >> b;
	int intb = round(b*100);
	cout << a*intb/100 << endl;
	return 0;
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii; typedef pair<ll,ll> pll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, K, C;
	string S;

	cin >> N >> K >> C;
	cin >> S;

	pii dp[200005] = {};
	int mx = 0;
	rep(i,N){
		if(i-C-1 >= 0) chmax(mx, dp[i-C-1].X);
		if(S[i] == 'o') chmax(dp[i], pii(mx + 1, -i));
		chmax(dp[i+1], dp[i]);
	}
	// rep(i,N) cout << dp[i] << " "; cout << endl;

	int dpR[500005] = {};
	mx = 0;
	rrep(i,N){
		if(i+C+1 < N) chmax(mx, dpR[i+C+1]);
		if(S[i] == 'o') chmax(dpR[i], mx + 1);
		chmax(dpR[i], dpR[i+1]);
	}
	// rep(i,N*2) cout << dpR[i] << " "; cout << endl;

	vector<int> ans;
	rep(i,N) if(S[i] == 'o') {
		// cout << i << ": ";
		int mx = 0;
		if(i > 0){
			int l = dp[i-1].X;
			int k = -dp[i-1].Y;
			if(k+C+1 > i) chmax(mx, l + dpR[k+C+1]);
			else chmax(mx, l + dpR[i+1]);
			// cout << l << " " << k << " " << mx << ",";
			if(k-1 >= 0){
				int l2 = dp[k-1].X;
				int k2 = -dp[k-1].Y;
				if(k2+C+1 > i) chmax(mx, l2 + dpR[k2+C+1]);
				else chmax(mx, l + dpR[i+1]);
				// cout << l2 << " " << k2 << " " << mx << ",";
			}
		}
		chmax(mx, dpR[i+1]);
		if(mx < K) ans.push_back(i+1);
		// cout << mx << endl;
	}

	for(auto t: ans) cout << t << endl;

	return 0;
}

Measured memory_bytes: 6156
n, m = [int(x) for x in input().split()]
sc = [[int(x) for x in input().split()] for i in range(m)]
r = [-1] * n
def solution():
    for s, c in sc:
        if s == 1 and c == 0 and n != 1:
            return '-1'
        if r[s - 1] >= 0 and r[s - 1] != c:
            return '-1'
        r[s - 1] = c
    for i in range(n):
        if r[i] < 0:
            if i == 0 and n != 1:
                r[i] = 1
            else:
                r[i] = 0
    return ''.join(str(r[i]) for i in range(n))

print(solution())

Measured memory_bytes: 3064
from math import fabs

N = int(input())
A = list(map(int, input().split()))

fu_count = 0
for i in range(N):
    if A[i] < 0:
        fu_count += 1

goukei = sum(fabs(a) for a in A)

if fu_count % 2 == 1:
    goukei -= 2 * min(fabs(a) for a in A)
print(int(goukei))


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

class TV{
public:
	ll s,t,c;
	TV(){}
};


signed main(){
	ll N,C;
	cin>>N>>C;
	vector<TV> tv(N);
	ll endtime=0;
	rep(i,N){
		cin>>tv[i].s>>tv[i].t>>tv[i].c;
		chmax(endtime,tv[i].t);
	}

	sort(tv.begin(), tv.end(), [](const TV &x, const TV &y) {
		return x.s < y.s;
	});

	map<ll,ll> endmap;
	map<ll,ll> indexmap;
	repeq(i,C){
		endmap[i]=-1;
		indexmap[i]=-1;
	}
	vector<ll> removeindex;
	rep(j,tv.size()){
		ll end=endmap[tv[j].c];
		ll index=indexmap[tv[j].c];
		if(tv[j].s==end){
			removeindex.push_back(j);
			tv[index].t=tv[j].t;
		}else{
			indexmap[tv[j].c]=j;
		}
		endmap[tv[j].c]=tv[j].t;
	}

	for(ll j=removeindex.size()-1;j>=0;j--)tv.erase(tv.begin()+removeindex[j]);

	vector<ll> a(2+endtime,0);
	rep(i,tv.size()){
		a[tv[i].s]++;
		a[tv[i].t+1]--;
	}
	
	ll maxval=0;
	repeq(i,1+endtime){
		a[i]+=a[i-1];
		chmax(maxval,a[i]);
	}
	p(maxval);

	return 0;
}



Measured memory_bytes: 4344
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int windowLength = sc.nextInt();
    int cartainLength = sc.nextInt();
    int len = windowLength - (cartainLength*2);

    if(len > 0)
        System.out.println(len);
    else
        System.out.println(0);
    }
}

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

using namespace std;

long long n,a[1000005],cnt = 1,pos=-1;

int main () {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		if(a[i] == cnt && pos < i) {
			pos = i;
			cnt++;
//			cout << pos << " ";
		}
	}
	if(cnt == 1) {
		cout << -1;
		return 0;
	}
	cout << n - cnt + 1;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
 
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
 
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m, q;
  cin >> n >> m >> q;
  vector<pair<int, int>> vp(m);
  vector<vector<int>> co(n, vector<int>(n, 0));
  rep(i, m){
    int l, r;
    cin >> l >> r;
    l--; r--;
    co.at(l).at(r)++;
  }
  vector<vector<int>> sum(n, vector<int>(n+1, 0));

  rep(i, n){
    rep(j, n){
      sum.at(i).at(j+1) = sum.at(i).at(j) + co.at(i).at(j);
    }
  }


  // rep(i, n){
  //   rep(j, n+1){
  //     cout << sum.at(i).at(j) << " ";
  //   }
  //   cout << endl;
  // }
  
  rep(__, q){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    rep2(i, l-1, r){
      ans += sum.at(i).at(r) - sum.at(i).at(l-1);
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define p(x) cout << x << endl
#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	int a, b;
	cin >> a >> b;
	//cout << (a + b < 10 ? a + b : "error") << endl;
	if (a + b < 10) cout << (a + b) << endl;
	else cout << "error" << endl;
}

int main() {
	solve();
	return 0;
}

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

const lli MAXN = 100005;
const lli LG_NMAX = 64;

lli N;
lli par[MAXN][LG_NMAX];
vector<lli> child[MAXN];
lli depth[MAXN];

void init() {
  for (lli k = 1; k < LG_NMAX; ++k) {
    for (lli i = 0; i < N; ++i) {
      par[i][k] = par[par[i][k-1]][k-1];
    }
  }
  memset(depth, -1, sizeof(depth));
  depth[0] = 0;
  for (lli i = 1; i < N; ++i) {
    if (depth[i] != -1) continue;
    vector<lli> v(1, i);
    while (depth[par[v.back()][0]] == -1) {
      v.push_back(par[v.back()][0]);
    }
    while (v.size()) {
      depth[v.back()] = depth[par[v.back()][0]] + 1;
      v.pop_back();
    }
  }
}

lli lca(lli a, lli b) {
  if (depth[a] != depth[b]) {
    if (depth[a] > depth[b]) swap(a, b);
    for (lli i = LG_NMAX - 1; i >= 0; --i) {
      if (depth[a] <= depth[par[b][i]]) {
        b = par[b][i];
      }
    }
  }
  if (a == b) return a;
  for (lli i = LG_NMAX - 1; i >= 0; --i) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}

int main() {
  while (cin >> N) {
    fill(child, child + MAXN, vector<lli>());
    par[0][0] = 0;
    for (lli i = 1; i < N; ++i) {
      cin >> par[i][0];
      par[i][0]--;
      child[par[i][0]].push_back(i);
    }
    for (lli i = 0; i < N; ++i) {
      sort(child[i].begin(), child[i].end());
    }

    init();

    lli res = 0, prev = 0;
    queue<lli> que;
    que.push(0);
    while (que.size()) {
      const lli v = que.front();
      que.pop();
      res += depth[prev] + depth[v] - depth[lca(prev, v)] * 2;
      prev = v;
      for (lli i = 0; i < child[v].size(); ++i) {
        que.push(child[v][i]);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 57472
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

char tmp[4] = {'A', 'C', 'G', 'T'};

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

	int ans = 0;
	string S;
	cin >> S;

	for(int i = 0; i < S.size(); i++)
	{
		int cnt = 0;
		for(int j = i; j < S.size(); j++)
		{
			bool flg = false;
			for(int k = 0; k < 4; k++)
			{
				if(S[j]==tmp[k]){
					flg=true;
				}
			}
			if(flg){
				cnt++;
			}else{
				break;
			}
			
		}
		ans = max(cnt, ans);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
A,B = (int(x) for x in input().split())
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = a & b
count = 1
if 2 in c:
    count += 1
for x in c:
    if x % 2 == 1:
        if len(make_divisors(x)) == 2:
            count += 1
print(count)

Measured memory_bytes: 5116
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	int a = 1;
	for (int i = 1; i <= sqrt(n)+1; i++){
		if (n % i == 0) a = max(a, i);
	}

	cout << a + n/a - 2 << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N,A,B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++){
        int N0 = i%10;
        int N1 = (i/10)%10;
        int N2 = (i/100)%10;
        int N3 = (i/1000)%10;
        int N4 = (i/10000)%10;
        int sum = N0+N1+N2+N3+N4;
        if (sum >= A && sum <=B){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256