akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

class SegmentTree{
public:
	int n = 1;
	vector<P> seg[2];
	//m要素のセグメントツリー作成
	void init(int m){
		while(n < m)n *= 2;
		rep(i,2)seg[i].resize(2*n);
		fill(all(seg[0]), P(-INF, -1));
		fill(all(seg[1]), P(INF, -1));
	}
	//kの値をxに変更
	void update(int k, int x){
		k += n-1;
		seg[0][k] = seg[1][k] = P(x, k-(n-1));
		while(k > 0){
			k = (k-1)/2;
			seg[0][k] = max(seg[0][k*2+1], seg[0][k*2+2]);
			seg[1][k] = min(seg[1][k*2+1], seg[1][k*2+2]);
		}
	}
	P calc_max(int a, int b, int k, int l, int r){
		if(b <= l || r <= a)return P(-INF, -1);
		if(a <= l && r <= b)return seg[0][k];
		P vl = calc_max(a, b, k*2+1, l, (l+r)/2);
		P vr = calc_max(a, b, k*2+2, (l+r)/2, r);
		return max(vl, vr);
	}
	P calc_min(int a, int b, int k, int l, int r){
		if(b <= l || r <= a)return P(INF, -1);
		if(a <= l && r <= b)return seg[1][k];
		P vl = calc_min(a, b, k*2+1, l, (l+r)/2);
		P vr = calc_min(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
	//[a,b)の最大値を求める
	P get_max(int a, int b){return calc_max(a, b, 0, 0, n);}
	//[a,b)の最小値を求める
	P get_min(int a, int b){return calc_min(a, b, 0, 0, n);}
};

int a[400000];
vector<P> ans;
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	
	SegmentTree seg[2];
	rep(i,2)seg[i].init(n+2);
	rep(i,n){
		if(i%2 == 0)seg[0].update(i, a[i]);
		else seg[1].update(i, a[i]);
	}
	
	priority_queue<PP, vector<PP>, greater<PP> > q;
	q.push(PP(0, P(0, n)));
	while(!q.empty()){
		PP pp = q.top();P res[2], t;q.pop();
		int l = pp.se.fi, r = pp.se.se;
		int f = l%2;
		res[0] = seg[f].get_min(l, r);
		res[1] = seg[!f].get_min(res[0].se, r);
		ans.push_back(P(res[0].fi, res[1].fi));
		if(res[0].se-l >= 2){
			t = seg[l%2].get_min(l, res[0].se);
			q.push(PP(t.fi, P(l, res[0].se)));
		}
		if(res[1].se-(res[0].se+1) >= 2){
			t = seg[(res[0].se+1)%2].get_min(res[0].se+1, res[1].se);
			q.push(PP(t.fi, P(res[0].se+1, res[1].se)));	
		}
		if(r-(res[1].se+1) >= 2){
			t = seg[(res[1].se+1)%2].get_min(res[1].se+1, r);
			q.push(PP(t.fi, P(res[1].se+1, r)));
		}
		//printf("%lld %lld\n", res[0].fi, res[1].fi);
	}
	
	rep(i,n/2){
		printf("%lld %lld%c", ans[i].fi, ans[i].se, i == n/2-1 ? '\n' : ' ');
	}
	return 0;
}





Measured memory_bytes: 38560
#include<iostream>
typedef long long ll;
using namespace std;

ll XOR(ll n){
    if(n%4 == 0) return n;
    if(n%4 == 1) return 1;
    if(n%4 == 2) return n+1;
    else return 0;
}

int main() {
    ll n,m;
    cin >> n >> m;
  	ll ans = XOR(n-1)^XOR(m);
  	cout << ans << endl;
    return 0;
}


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

int comp(const void *a, const void *b){
	return *(int *)b - *(int *)a;
}

int main(void)
{
	int i, n[5];

	for(i=0; i<5; i++){ scanf("%d", &n[i]); getchar; }
	qsort(n, 5, sizeof(int), comp);

	for(i=0; i<4; i++){ printf("%d ", n[i]); }
	printf("%d\n", n[4]);
	return 0;
}

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

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

    for (int i = 1; i < n; i++) {
        int h; cin >> h;
        if (h > pre) pre = h - 1;
        else if (h == pre) pre = h;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
k = int(input())

# k番目の文字と異なる文字をすべて*で置き換える
t = s[k-1]
r = ""
for i in s:
  if i not in t:
    r = r + "*"
  else:
    r = r + i
    
print(r)

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

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

    char S[N];
    for (int i = 0; i < N; i++){
        cin >> S[i];
    }

    int cnt = 0;

    for (int j = 0; j < N-2; j++){
        if(S[j] == 'A'){
            if(S[j+1] == 'B'){
                if(S[j+2] == 'C'){
                    cnt++;
                }
            }
        }
    }
 
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

// #define TEST

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int N; cin >> N;
	vector<pair<int, int>> A_idx(N);
	for (int i = 0; i < N; ++i) {
		int ai; cin >> ai;
		A_idx[i] = pair<int, int>(ai, i);
	}
	// (Ai,i)を降順ソート
	sort(
		A_idx.begin(), A_idx.end(),
		[&](auto& a, auto& b) {
			return a >= b;
		}
	);
#ifdef TEST
	cout << "-----sorted A_idx-----" << endl;
	for (auto& p : A_idx)
		cout << p.first << " " << p.second << endl;
#endif
	// DP[i][j] := 大きいほうからi個をj番目までに割り当てるときのmax
	vector<vector<ll>> DP(N + 1, vector<ll>(N + 1, 0));
	for (int i = 1; i <= N; ++i) {
		int idx = A_idx[i - 1].second;
		int ai = A_idx[i - 1].first;
		for (int j = 0; j <= i; ++j) {
			if (j == 0)
				DP[i][j] = DP[i - 1][j] + (ll)ai * abs(idx - (N - i + j));
			else if (j == i)
				DP[i][j] = DP[i - 1][j - 1] + (ll)ai * abs(idx - (j - 1));
			else {
				ll tmp1 = DP[i - 1][j] + (ll)ai * abs(idx - (N - i + j));
				ll tmp2 = DP[i - 1][j - 1] + (ll)ai * abs(idx - (j - 1));
				DP[i][j] = max(tmp1, tmp2);
			}
		}
	}
#ifdef TEST
	cout << "-----DP-----" << endl;
	for (int j = 0; j <= N; ++j) {
		for (int i = 0; i <= N; ++i)
			cout << DP[i][j] << " ";
		cout << endl;
	}
	cout << "-----answer-----" << endl;
#endif
	ll res = 0;
	for (int j = 0; j <= N; ++j)
		res = max(res, DP[N][j]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 34680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, a, b, c, res = 0;
	cin >> a >> b >> c >> n;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
		{
			int tmp = a * i + b * j;
			tmp = n - tmp;
			if (tmp >= 0 && tmp % c == 0) res++;
		}
	cout << res << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int wCnt[n];
	int bCnt[n];
	wCnt[n-1] = ((s[n-1] == '.')?1:0);
	FORR(i,n-2,0){
		wCnt[i] = wCnt[i+1];
		if(s[i] == '.')wCnt[i]++;
	}
	bCnt[0] = ((s[0] == '#')?1:0);
	FOR(i,1,n){
		bCnt[i] = bCnt[i-1];
		if(s[i] == '#')bCnt[i]++;
	}
	int ans = min(wCnt[0], bCnt[n-1]);
	FOR(i,0,n-1){
		ans = min(ans, wCnt[i+1] + bCnt[i]);
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 2180
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,k,tot,res,tmp,ck[100005],sum[100005];
long long ans;
char s[10000005];
int main(){
	scanf("%s%d",s,&k);
	n=strlen(s);
	for(int i=n;i<n*100000;i++){
		s[i]=s[i%n];
	}
	memset(ck,-1,sizeof(ck));
	for(int i=0;i<100000;i++){
		for(int j=i*n;j<(i+1)*n;j++){
			if(s[j]==s[j-1]){
				s[j]='a';
				while((!j||s[j]==s[j-1])||s[j]==s[j+1]){
					s[j]++;
				}
				tot++;
			}
		}
		sum[i]=tot;
		if(ck[(int)s[(i+1)*n-1]]!=-1){
			tmp=ck[(int)s[(i+1)*n-1]];
			res=i;
			break;
		}
		ck[(int)s[(i+1)*n-1]]=i;
	}
	ans=sum[tmp];
	k-=tmp+1;
	ans+=1LL*(sum[res]-sum[tmp])*k/(res-tmp);
	k%=(res-tmp);
	ans+=sum[tmp+k+1]-sum[tmp+1];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
using namespace std;
int main(){
    int N; int cnt[2] = {0, 0};
    for(int i = 0; i < 3; i++) {
        cin >> N;
        if(N == 5) cnt[0]++;
        else if(N == 7) cnt[1]++;        
    }
    if(cnt[0] == 2 && cnt[1] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,count=0;
  cin >> N;
  if(N<=2){
    cout << 0 << endl;
    return 0;
  }
  vector<long long> L(N);
  for(int i=0;i<N;i++) cin >> L.at(i);
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        //cout << i << j << k << endl;
        //if(i>=j||j>=k) break;
        if(L.at(i)==L.at(j)||L.at(j)==L.at(k)||L.at(k)==L.at(i))
          continue;
        long long max3 = max(L.at(i),max(L.at(j),L.at(k)));
        //cout << "point1" << endl;
        if(L.at(i)+L.at(j)>max3&&L.at(j)+L.at(k)>max3&&L.at(k)+L.at(i)>max3){
          count++;
          //cout << count << endl;
        }
      }
    }
  }
  cout << count << endl;
        
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  Int ans = (1000 - N%1000) % 1000;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 3648
function main(input) {
  let [a,b,c,d] = input.split(' ').map(Number)
  let i = 0
  let str = ''
  while(a > 0 && c > 0) {
    if (i % 2 === 0) {
      c = c - b
      str = 'Yes'
    } else {
      a = a - d
      str = 'No'
    }
    i++
  }
  console.log(str)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 29564
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, A, B;
  cin >> N >> A >> B;

  if (A + B - 1 <= N and A * B >= N) {
    if (B == 1) {
      rep(i, 0, N) { cout << i + 1 << (i + 1 == N ? '\n' : ' '); }
    } else {

      vector<int> v;
      v.push_back(A);
      int r = (N - A) % (B - 1);
      int q = (N - A) / (B - 1);
      loop(r) { v.push_back(q + 1); }
      loop(B - 1 - r) { v.push_back(q); }

      int m = N;
      vector<int> ans;
      rep(i, 0, v.size()) {
        rep(j, m - v[i], m) { ans.push_back(j); }
        m -= v[i];
      }

      rep(i, 0, ans.size()) {
        cout << ans[i]+1 << (ans.size() == i + 1 ? '\n' : ' ');
      }
    }
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 7536
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
    
int main(){
    string hitachi;
    cin >> hitachi;
    bool flag=true;
    if(hitachi.size()%2==1){
        cout << "No";
    }
    else{
        for (int i = 0; i < hitachi.size()-1; i+=2){
            if(hitachi[i]=='h'&&hitachi[i+1]=='i'){
                continue;
            }
            else{
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
        
    }
}



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

int main(){
    long long int A, B;

    cin >> A >> B;

    double S = ceil((double)A / 0.08);
    double V = B * 10;

    if((int)(S * 0.1) == B) {
        cout << S << endl;
        return 0;
    }
    else if((int)(V * 0.08) == A){
        cout << V << endl;
        return 0;
    }
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (void) {
    int64_t N, K;
    cin >> N >> K;
    int64_t min = N;

    if (K == 1) {
        cout << 0 << endl;
        return 0;
    } else {
        N %= K;
        while (1) {
            N = abs(N - K);
            if (min < N) break;
            
            min = N;
        }
    }
    cout << min << endl;
    
}

Measured memory_bytes: 3596
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

const int mod = 998244353;
int m[3];
int g[3][100000];
int p[3];
long long sum[3][100000];
vector <int> v[3][100000];

long long powmod(long long x, long long y) {
    long long ans = 1;
    
    while (y > 0) {
        if (y & 1) ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    
    return ans;
}

int main() {
    int n, i, j, k;
    long long ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < 3; i++) {
        scanf("%d", &m[i]);
        
        for (j = 0; j < m[i]; j++) {
            int x, y;
            
            scanf("%d %d", &x, &y);
            
            x--;
            y--;
            
            if (x > y) swap(x, y);
            
            v[i][x].push_back(y);
        }
    }
    
    for (i = 0; i < 3; i++) {
        for (j = n - 1; j >= 0; j--) {
            set <int> s;
            
            for (k = 0; k < v[i][j].size(); k++) s.insert(g[i][v[i][j][k]]);
            
            for (k = 0; ; k++) {
                if (!s.count(k)) {
                    g[i][j] = k;
                    break;
                }
            }
            
            p[i] = max(p[i], g[i][j]);
            sum[i][g[i][j]] += powmod(10, 18 * (j + 1));
            if (sum[i][g[i][j]] >= mod) sum[i][g[i][j]] -= mod;
        }
    }
    
    for (i = 0; i <= p[0]; i++) {
        for (j = 0; j <= p[1]; j++) {
            int x = i ^ j;
            
            if (x <= p[2]) ans += sum[0][i] * sum[1][j] % mod * sum[2][x] % mod;
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define popb pop_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
// #define int long long

const int N = 2e5+1;

using namespace std;

// bool vis[N];
// vector <int> adj[N];

void solve(){
	string str;
	cin >> str;
	int count = 0;
	rep0(i,str.size()){
		if(str[i]=='o') count++;
	}
	if(15-str.length()+count>=8) cout << "YES";
	else cout << "NO";

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
from decimal import *
getcontext().prec = 7000
#import numpy as np

a, b, c = map(float, input().split())

##print(a**0.5, b**0.5, c**0.5)
if Decimal(a).sqrt()+ Decimal(b).sqrt() < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x, t;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> t;
	cout << max(0, x - t) << "\n";
	return 0;
}

Measured memory_bytes: 256
/*
000000000011111111112222222222333333333344444444
012345678901234567890123456789012345678901234567
TfefirstemampleistrivivlTfefirstemampleistrifivl
                                   .        . .
len = 18 sp = 3
len = 15 sp = 11
len = 12 sp = 22
len = 12 sp = 35
mfv
 
000000000011111111112222222222
012345678901234567890123456789
aabbccbbccaabbaacceeddffccaabb
       . ..
 
len = 4 sp = 1
 
abc
 
*/
 
#include<set>
#include<iostream>
#include<cmath>
#include<cstdio>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
 
using namespace std;
 
void compute(string text,string S)
{
  int nt = text.size(),nS = S.size();
  int mlen = inf;
  string ans;
  set<string> all;
  bool found[nS];
  int CNT = 0;
  int fpos[nS];
  rep(i,nS)found[i] = false;
 
  rep(i,nt)
    {
      bool update = false;
      int cnt = 0,mn,mx;
      mn = inf,mx = -inf;
      rep(j,nS)
	{
	  if(S[j] == text[i])
	    {
	      update = true;
	      found[j] = true;
	      fpos[j] = i;
	    }
	  if(found[j])
	    {
	      cnt++;
	      mn = min(mn,fpos[j]);
	      mx = max(mx,fpos[j]);
	    }
	}
      if(cnt == nS)
	{
	  int cost = mx - mn + 1;
	  if(cost < mlen)
	    {
	      mlen = cost;
	      ans = text.substr(mn,cost);
	      all.clear();
	      CNT = 1;
	      all.insert(text.substr(mn,cost));
	    }
	  else if(cost == mlen)
	    {
	      if(update)CNT++;
	      all.insert(text.substr(mn,cost));
	    }
	}
    }
  cout << CNT << endl << endl;
  //printf("%d\n\n",(int)all.size());
  
  if(all.empty())
    {
      return;
    }

  rep(i,ans.size())
    if((i+1)%72 == 0 && i != 0)
      printf("%c\n",ans[i]);
    else
      printf("%c",ans[i]);
  if(ans.size()%72 != 0)puts("\n");
  else puts("");
}
 
int main()
{
  string blank;
  while(getline(cin,blank))
    {
      string text,S;
      text += blank;
      while(getline(cin,blank))
	{
	  if(blank.empty())break;
	  text += blank;
	}
      if(text.empty())goto Fin;
      while(getline(cin,blank))
	if(blank.empty())break;
	else S += blank;
      compute(text,S);
    }
 Fin:;
  return 0;
}

Measured memory_bytes: 2656
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // max()
    func max() -> Element? {
        guard self.count > 0 else { return nil }
        return self.reduce(self.first!) { return Swift.max($0, $1) }
    }
}
extension String {
    // Sequence#enumerated()
  	// public func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>
    func enumerated() -> EnumerateSequence<[Character]> {
        return Array(self.characters).enumerate()
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}

/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let P = input[0]
let Q = input[1]
let R = input[2]

print(min(P + Q, Q + R, R + P))


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int m, d;
	cin >> m >> d;
	int ans = 0;
	rep (i, 2, 9) {
		rep (j, 2, 9) {
			if (i * 10 + j <= d && i * j <= m) ++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    char a,b;
    cin>>a>>b;
   if(a>b){
    cout<<">";
   }
   if(b>a){
    cout<<"<";
   }
   if (a==b){
    cout<<"=";
   }
    return 0;
}


Measured memory_bytes: 256
c = []
for i in range(3):
  c.append(list(map(int,input().split())))
diff1 = [c[0][0]-c[1][0],c[0][1]-c[1][1],c[0][2]-c[1][2]]
diff2 = [c[0][0]-c[2][0],c[0][1]-c[2][1],c[0][2]-c[2][2]]
if diff1[0] == diff1[1] and diff1[2] == diff1[1] and diff2[0] == diff2[1] and diff2[2] == diff2[1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<50);
const int mod=1000000007;
inline int gcd(int a,int b) { return b ? gcd(b, a % b) : a; }
int main(void){
	long long int x,y;
	scanf("%lld %lld",&x,&y);
	if(abs(x-y)<=1){printf("Brown\n");}
	else{printf("Alice\n");}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  ans += (ll)pow(N/K, 3);
  if (K%2 == 0) {
    ans += (N%K < K/2 ? (ll)pow(N/K, 3) : (ll)pow(N/K+1, 3));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

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

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

    if(x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
	int N;
	cin>>N;
	int t[100];
	string chr="abcdefghijklmnopqrstuvwxyz";
	for(int i=0;i<100;++i)t[i]=100000;

	for(int i=0;i<N;++i){
		string str;
		cin>>str;
		int t2[100]={};
		for(int j=0;j<str.length();++j){
			if(str[j]=='a')++t2[0];
			if(str[j]=='b')++t2[1];
			if(str[j]=='c')++t2[2];
			if(str[j]=='d')++t2[3];
			if(str[j]=='e')++t2[4];
			if(str[j]=='f')++t2[5];
			if(str[j]=='g')++t2[6];
			if(str[j]=='h')++t2[7];
			if(str[j]=='i')++t2[8];
			if(str[j]=='j')++t2[9];
			if(str[j]=='k')++t2[10];
			if(str[j]=='l')++t2[11];
			if(str[j]=='m')++t2[12];
			if(str[j]=='n')++t2[13];
			if(str[j]=='o')++t2[14];
			if(str[j]=='p')++t2[15];
			if(str[j]=='q')++t2[16];
			if(str[j]=='r')++t2[17];
			if(str[j]=='s')++t2[18];
			if(str[j]=='t')++t2[19];
			if(str[j]=='u')++t2[20];
			if(str[j]=='v')++t2[21];
			if(str[j]=='w')++t2[22];
			if(str[j]=='x')++t2[23];
			if(str[j]=='y')++t2[24];
			if(str[j]=='z')++t2[25];
		}
		for(int j=0;j<26;++j)t[j]=min(t[j],t2[j]);
	}

	string R="";
	for(int i=0;i<26;++i){
		for(int j=0;j<t[i];++j)R+=chr[i];
	}

	cout <<R <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int debt_amount(int, int);

int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", debt_amount(100000, n));
	return 0;
}

int debt_amount(int a, int x){
	if(x >= 1){
		a = (a + a*0.05 + 999)/1000;
		a = a*1000;
		return debt_amount(a, x-1);
	}else{
		return a;
	}
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main(void) {
    int a, b, k;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> k;
    FOR(i, a, min(b, a + k - 1) + 1) {
        cout << i << "\n";
    }
    FOR(i, max(b - k + 1, a + k), b + 1) {
        cout << i << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main()
{
    int x,y,z;
	cin>>x>>y>>z;
	if(x-y==y-z)
	cout<<"YES"<<endl; 
	if(x-y!=y-z)
	cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const ll mod = 998244353;

ll fac[200005];
ll rfac[200005];

ll f(ll a, ll x)
{
    ll res = 1;

    while (x > 0)
    {
        if (x & 1)
            res = a * res % mod;

        a = a * a % mod;
        x >>= 1;
    }

    return res;
}
int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    ll ans = 0;

    fac[0] = rfac[0] = 1;

    for (int i = 1; i <= max(n, m); i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        rfac[i] = f(fac[i], mod - 2);
    }

    for (ll i = 0; i <= k; i++)
    {
        ll tmp = m * f(m - 1, n - i - 1) % mod * fac[n - 1] % mod * rfac[n - i - 1] % mod * rfac[i] % mod;
        ans = (ans + tmp) % mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};

int main(){
  string s,t,ss;
  int i,j,k,l,n,ans=0,m=0;
  vector<string> vs;
  vector<int> v[26];
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq

  
  cin >> s;
  cin >> t;
  
  rep(i,0,2){
    if(s[i] == t[i])++ans;
  }

  cout << ans << endl;
  return 0;

}

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

using namespace std;

int main(){
    unsigned long long X,Y,val,count;
    cin >> X >> Y;
    val = X;
    count = 1;
    while(1){
        val *= 2;
        if (Y < val) break;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;
 
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}
 
int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int a,b;
  cin >>a >>b;
  if(a<=12 && a>=6){
    b = b/2;
  }
  else if(a<6){
    b=0;
  }

  cout <<b<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dp[18][301];

int main() {
  
  for(int i=1; i<=17; i++) {
    for(int j=0; j<=300; j++) {
      if(i == 1) {
	if(j == 0) dp[1][0] = 1;
	else dp[i][j] = 1;
      }
      else if(j == 0) dp[i][j] = 1;
      else {
	dp[i][j] = dp[i-1][j];
	if(j-i*i>=0) dp[i][j] += dp[i][j-i*i];
      }
    }
  }
  /*
  for(int i=0; i<=17; i++) {
    for(int j=0; j<=19; j++) printf("%3lld", dp[i][j]);
    cout << endl;
  }
  
  for(int i=0; i<=17; i++) {
    for(int j=20; j<=30; j++) printf("%3lld", dp[i][j]);
    cout << endl;
  }
  */

  int n;  
  
  while(cin>>n, n) {
    cout << dp[17][n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
};
node a[101],b[101];
int dist(node da,node db){
	return abs(da.x-db.x)+abs(da.y-db.y);
}
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
	} 
	for(j=1;j<=m;j++){
		cin>>b[j].x>>b[j].y;
	} 
	
	int  mind,id;
	for(i=1;i<=n;i++){
		mind=dist(a[i],b[1]);
		id=1;
		for(j=2;j<=m;j++){
			int tmp=dist(a[i],b[j]);
			if(tmp<mind){
				mind=tmp;
				id=j;
			}
		}
		cout<<id<<endl;
		
	} 
	
	
	
	return 0;
}
/*
2 2
2 0
0 0
-1 0
1 0
*/

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

#define INF 1000000007

int main(void){
  vector<int> v;
  int n,q,b,e,d,t;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int t; cin >> t;
    v.push_back(t);
  }
  cin >> q;
  for (int i=0; i<q; i++){
    cin >> b >> e >> d;
    for (int j=0; j<e-b; j++){
      t = v[b+j]; v[b+j] = v[d+j]; v[d+j] = t;
    }
  }
  cout << v[0];
  for (int i=1; i<v.size(); i++){
    cout << " " << v[i];
  } cout << endl;
  return 0;
}
  
  



Measured memory_bytes: 3156
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		int b=0,c=0;
		String ans;
		if(Character.getNumericValue(a.charAt(0))!=0){
			b+=Character.getNumericValue(a.charAt(0))*10;
		}b+=Character.getNumericValue(a.charAt(1));
		if(Character.getNumericValue(a.charAt(2))!=0){
			c+=Character.getNumericValue(a.charAt(2))*10;
		}c+=Character.getNumericValue(a.charAt(3));
		if(b>=1&&b<=12&&c>=1&&c<=12){
			ans="AMBIGUOUS";
		}else if(b>=1&&b<=12){
			ans="MMYY";
		}else if(c>=1&&c<=12){
			ans="YYMM";
		}else{
			ans="NA";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 20564
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

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

	ll ans = 0;

	for(int i = 1;i <= n;i++){
		while(s[i] == s[i-1]) i++;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll n;
pair<ll,ll> a[ARRS];

int main(){
	ll n;
	cin>>n;
	for(int i=0; i<(1<<n); i++){
		cin>>a[i].fr;
	}
	for(int i=0; i<18; i++){
		for(int j=0; j<(1<<n); j++){
			if(!((j>>i)&1)){
				ll f=j,t=j|(1<<i);
				if(a[t].fr<a[f].fr){
					swap(a[t].fr,a[t].sc);
					a[t].fr=a[f].fr;
				}
				else if(a[t].sc<a[f].fr)
					a[t].sc=a[f].fr;
			
				if(a[t].fr<a[f].sc){
					swap(a[t].fr,a[t].sc);
					a[t].fr=a[f].sc;
				}
				else if(a[t].sc<a[f].sc)
					a[t].sc=a[f].sc;
			}
		}
	}
	for(int i=1; i<(1<<n); i++){
		ll x=i;
		ll pas=0;
		while(x){
			pas=max(pas,a[x].fr+a[x].sc);
			pas=max(pas,a[x-1].fr+a[x-1].sc);
			x=x&(x-1);
		}
		cout<<pas<<endl;
	}
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    if(n == 25) cout << "Christmas" << endl;
    else if(n == 24) cout << "Christmas Eve" << endl;
    else if (n == 23) cout << "Christmas Eve Eve" << endl;
    else if (n == 22) cout << "Christmas Eve Eve Eve" << endl; 
}


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

struct Card{char suit,value;};

void bubble(struct Card A[],int N){
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=i;j--){
      if(A[j].value<A[j-1].value){
	Card t=A[j];A[j]=A[j-1];A[j-1]=t;
      }
    }
  }
}

void selection(struct Card A[],int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j].value<A[minj].value) minj=j;
    }
    Card t=A[i];A[i]=A[minj];A[minj]=t;
  }
}

void print(struct Card A[],int N){
  for(int i=0;i<N;i++){
    if(i>0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
  for(int i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N;
  char ch;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> C1[i].suit >> C1[i].value;
  }

  for(int i=0;i<N;i++) C2[i]=C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }

  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
#define maxn 300002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 __y0
#define y1 __y1
#define x0 __x0
#define x1 __x1
#define next __next
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const ll inf = 1e18;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}
 
int n, a[maxn];
ll ps[maxn], Left[maxn], Right[maxn];
priority_queue<int, vector<int>, greater<int> > pq;
 
int main() {
    //freopen("num3N.inp", "r", stdin);
    //freopen(".out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    FOR(i, 1, 3*n) cin >> a[i];
    ll s = 0;
    FOR(i, 1, 3*n) {
        if (int(pq.sz())<n) {
            s += a[i];
            pq.push(a[i]);
        }
        else if (pq.top()<a[i]) {
            s -= pq.top(); pq.pop();
            s += a[i]; pq.push(a[i]);
        }
        Left[i] = s;
    }
    s = 0;
    while (pq.sz()) pq.pop();
    FORD(i, 3*n, 1) {
        if (int(pq.sz())<n) {
            s -= a[i];
            pq.push(-a[i]);
        }
        else if (pq.top()<-a[i]) {
            s -= pq.top(); pq.pop();
            s -= a[i]; pq.push(-a[i]);
        }
        Right[i] = s;
    }
    ll res = -inf;
    FOR(i, n, 2*n) {
        res = max(res, Left[i] + Right[i+1]);
    }
    cout << res;
}

Measured memory_bytes: 8952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

static const int MAXV = 1000000;
const int mod = 1000000007;
long long fac[MAXV], finv[MAXV], inv[MAXV];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXV; 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;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    int x, y, a, b; sc(x), sc(y);
    COMinit();
    if ((2*x - y) % 3 != 0) cout << 0 << endl;
    else{
        b = (2*x - y) / 3;
        a = x - 2*b;
        cout << COM(a+b, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 23808
import math

def koch(n,p1,p2):
	if n==0:
		return
	s=[0 for i in range(2)]
	t=[0 for i in range(2)]
	u=[0 for i in range(2)]
	
	s[0]=(2*p1[0]+1*p2[0])/3
	s[1]=(2*p1[1]+1*p2[1])/3
	t[0]=(1*p1[0]+2*p2[0])/3
	t[1]=(1*p1[1]+2*p2[1])/3
	
	rad=math.radians(60)
	
	u[0]=(t[0]-s[0])*math.cos(rad)-(t[1]-s[1])*math.sin(rad)+s[0]
	u[1]=(t[0]-s[0])*math.sin(rad)+(t[1]-s[1])*math.cos(rad)+s[1]
	
	koch(n-1,p1,s)
	print(*s)	
	
	koch(n-1,s,u)
	print(*u)
	
	koch(n-1,u,t)
	print(*t)
	
	koch(n-1,t,p2)
	
n=int(input())
p1=[0,0]
p2=[100,0]

print(*p1)
koch(n,p1,p2)
print(*p2)


Measured memory_bytes: 5796
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    cout << a[n - 1] << " ";
    auto itr = lower_bound(all(a), a[n - 1] / 2);
    int x = *itr;
    int y = *(--itr);
    if (abs(a[n - 1] / 2 - x) <= abs(a[n - 1] / 2 - y) && x != a[n - 1])
        cout << x << endl;
    else
        cout << y << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; ++i)
    {
        int li, ri;
        cin >> li >> ri;
        ans += ri - li + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1016
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int X=0;
  cin >> X;
  if((X==7)||(X==5)||(X==3)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    int max;
    int min;
    int mid;

    if(a>=b){
        if(a>=c){
            max=a;
        }else{
            max=c;
        }
    }else{
        if(b>=c){
            max=b;
        }else{
            max=c;
        }
    }

    if(a<=b){
        if(a<=c){
            min=a;
        }else{
            min=c;
        }
    }else{
        if(b<=c){
            min=b;
        }else{
            min=c;
        }
    }

    if(max==a){
        if(min==b){
            mid=c;
        }else if(min==c){
            mid=b;
        }
    }else if(max==b){
        if(min==a){
            mid=c;
        }else if(min==c){
            mid=a;
        }
    }else if(max==c){
        if(min==a){
            mid=b;
        }else if(min==b){
            mid=a;
        }
    }

    if(max==(min+mid)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

using namespace std;

#define sz(a) int(a.size())

const int MOD = 1e9+7;
const int MAX_N = 100'010;
int res[MAX_N][2];
vector <int> adj [MAX_N];

int dp(int u, int pc, int p = -1) {
	if (res[u][pc] != -1) return res[u][pc];
	int w0 = 1, w1 = !pc;
	for (int v : adj[u]) {
		if (v != p) {
			w0 = (1LL*w0*dp(v, 0, u))%MOD;
			if (!pc) w1 = (1LL*w1*dp(v, 1, u))%MOD;
		}
	}
	return res[u][pc] = (w0+w1)%MOD;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(res, -1, sizeof(res));
	cout << dp(0, 0) << endl;
}


Measured memory_bytes: 13440
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b; cin>>n>>a>>b;
    ll c,d;
    c=n/(a+b);
    d=n%(a+b);
    if(d>a){
        cout<<c*a+a<<endl;
    }else{
        cout<<c*a+d<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 500000;
int N;
ll A, B, C, D;

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  
  cin >> N >> A >> B >> C >> D;

  ll ma = A + (N-1) * D;
  ll mi = A - (N-1) * D;

  ll period = (N-1)*(D-C);
  ll dist = N*C - (N-2)*D;
  dist = max(dist, 0ll);

  if (B < mi || B > ma) {
      cout << "NO" << endl;
      return 0;
  }
  
  if (dist == 0) {
      cout << "YES" << endl;
  } else {
      ll k1 = (B-mi)/(period+dist);
      ll k2 = (B-mi-period+period+dist-1)/(period+dist);
      if (k1 == k2) cout << "YES" << endl;
      else cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll N,M;

int main(){
  cin >> N;
  vector<ll> A(N);
  rep(i,N)cin >> A[i];
  sort(A.begin(),A.end());
  ll ans = 1;
  ll max = 1e18;
  rep(i,N){
    if(max/ans < A[i]){
      ans = -1;
      break;
    }
    ans *= A[i];
    if(ans == 0)break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char x[1001];
    int i;
    int sum;
  
  while(1){      
      scanf("%s", &x);
      sum = 0;

      if (x[0] == '0'){
          break;
      }else {
          for(i = 0; i < strlen(x); i++){
              sum += x[i] - '0';
          }

          printf("%d\n", sum);
      }

  }
  return (0);
}



Measured memory_bytes: 2688
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,k;
    cin>>k>>a>>b;
    bool f=0;
    for(int i=a;i<=b;i++){
        if(i%k==0) f=1;
    }
    cout<<(f?"OK":"NG")<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3656