akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
vector<vector<int>> G;
vector<int> K;
int main() {
	int N, M;
	cin >> N >> M;
	double v;
	priority_queue<double> A;
	rep(i, 0, N)cin >> v, A.push(v);
	rep(i, 0, M) {
		double v = A.top();
		A.pop();
		A.push(v / 2);
	}
	ll S = 0;
	while (!A.empty()) {
		S += (ll)A.top();
		A.pop();
	}
	printf("%lld\n", S);
	return 0;
}

Measured memory_bytes: 1400
s = input()
t = []
cnt = 0
for a in s:
    t.append(a)
    cnt += 1
    if cnt >= 2:
        if t[-2] == 'S' and t[-1] == 'T':
            cnt -= 2
            for i in range(2):
                t.pop(-1)
print(cnt)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K, C;
string S;

int cnt[int(2e5+5)][2];

int main(){
  cin >> N >> K >> C;
  cin >> S;

  int now = 0, day = 0;
  while (now < K){
    if (S[day] == 'o'){
      cnt[now][0] = day + 1;
      day += C+1; now++;
    }else{
      day++;
    }
  }
  now = K - 1; day = N - 1;
  while (now >= 0){
    if (S[day] == 'o'){
      cnt[now][1] = day + 1;
      day -= C+1; now--;
    }else{
      day--;
    }
  }


  for (int i = 0; i < K; i++){
    if (cnt[i][0] == cnt[i][1]) cout << cnt[i][0] << endl;
  }

  return 0;
}


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

int M, W;
int bm[12], bw[12];
int dp[15][(1 << 12)];

int calcPower(int a, int b) {
	int num = ((a - b) >= 0) ? (a - b) : (b - a);
	return num * (num - 30) * (num - 30);
}

int main() {
	while (cin >> M >> W, M, W) {
		// input
		for (int i = 0; i < M; i++) {
			cin >> bm[i];
		}
		for (int i = 0; i < W; i++) {
			cin >> bw[i];
		}

		if (M > W) {
			swap(M, W);
			swap(bm, bw);
		}

		// initialize
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < (1 << W); j++) {
				dp[i][j] = -1;
			}
		}
		for (int i = 0; i < W; i++) {
			dp[0][(1 << i)] = calcPower(bm[0], bw[i]);
		}

		// solve
		for (int i = 0; i < M - 1; i++) {
			for (int j = 1; j < (1 << W); j++) {
				if (dp[i][j] == -1) {
					continue;
				}

				for (int k = 0; k < W; k++) {
					if ((j & (1 << k))) {
						continue;
					}

					int next = ((j | (1 << k)));
					int cost = dp[i][j] + calcPower(bm[i + 1], bw[k]);
					dp[i + 1][next] = max(dp[i + 1][next], cost);
				}
			}
		}

		int ans = -1;
		for (int i = 0; i < (1 << W); i++) {
			ans = max(ans, dp[M - 1][i]);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3252
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum_c = 0

for i in range(n-1):
    if a[i]+1 == a[i+1]:
        sum_c += c[a[i]-1]

print(sum(b) + sum_c)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long a,b,c,d;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	int a,b,c;
	int k;
	cin>>a>>b>>c>>k;
	bool ok=false;
	for (int mask = 0; mask < pow(3, k); ++mask){
        int tmp = mask;
		int ta=a,tb=b,tc=c;
        for (int pos = 1; pos <= k; ++pos){//数字1~kが何文字分か仮定する
			int dig=tmp % 3 + 1;
            if(dig==1){
				ta*=2;
			}else if(dig==2){
				tb*=2;
			}else{
				tc*=2;
			}
            tmp /= 3;
        }
		if(ta<tb&&tb<tc){
			ok=true;
		}
    }	
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

int main(){
    int D = 0,N = 0;
    cin >> D >> N;
    int dh = 1;
    for(int i = 0; i < D ; i++){
        dh *= 100;

    }

    if(N == 100){
        cout << N*dh + dh << endl;
    }else{
     cout << N*dh << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    max_bin_digits = len(bin(max(A))[2:])
    ans = 0
    for i in range(max_bin_digits):
        cnt = 0
        m = 1 << i
        for a in A:
            if m & a:
                cnt += 1
        
        ans += cnt * (N - cnt) * m
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 44204
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const int mod = 998244353;
//const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
int mygcd(int a, int b){
	if(b == 0){
		return a;
	}
	return mygcd(b, a % b);
}
int mypow(int a, int b, int mod) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}
void solve(){
	int n;
	cin >> n;
	vector<vi> mat(n, vi(3));
	vector<vi> hap(n, vi(3));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> mat[i][j];
		}
	}
	hap[0] = mat[0];
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(k != j){
					hap[i][j] = max(hap[i][j], hap[i - 1][k] + mat[i][j]);
				}
			}
		}
	}
	cout << *max_element(all(hap[n - 1]));

}
signed main(){
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

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

int A,B,C;

int main(){
  cin >> A >> B >> C;
  vector<int> v = {A,B,C};
  sort(v.begin(), v.end());
  
  cout << v[0]+v[1]+v[2]*10 << endl;
  return 0;
  
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll mod = 1000000007LL;
	ll N;
	cin >> N;

	vector<ll> Cs(N);
	for (ll i = 0; i < N; ++i) {
		cin >> Cs[i];
	}
	map<ll, vector<ll>> pos;
	for (ll i = 0; i < N; ++i) {
		if (pos.count(Cs[i]) == 0) {
			pos[Cs[i]] = vector<ll>();
		}
		pos[Cs[i]].emplace_back(i);
	}

	vector<ll> dps(N + 1);
	dps[0] = 1;
	for (ll i = 0; i < N; ++i) {
		auto idx = distance(pos[Cs[i]].begin(), lower_bound(pos[Cs[i]].begin(), pos[Cs[i]].end(), i));
		if (idx == 0 || pos[Cs[i]][idx - 1] == i - 1) {
			dps[i + 1] = dps[i];
		}
		else {
			dps[i + 1] = (dps[i] + dps[pos[Cs[i]][idx - 1] + 1]) % mod;
		}
	}

	cout << dps[N] << endl;

	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int> k(m), p(m);
	vector<vector<int>> s(m);
	rep(i, m) {
		cin >> k[i];
		rep(j, k[i]) {
			int a; cin >> a;
			a--;
			s[i].emplace_back(a);
		}
	}
	rep(i, m) cin >> p[i];

	int ans = 0;

	for (int bit = 0; bit < (1 << n); ++bit) {
		int sol = 0;
		for (int i = 0; i < m; ++i) {
			int res = 0;
			rep(j, k[i]) {
				if (bit & (1 << s[i][j])) res++;
			}
			if (res % 2 == p[i]) sol++;
		}
		if (sol == m) ans++;
	}

	dunk(ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
int N, Q;
vector <int> Ans;
////////////

int main()
{
	int N;
	cin >> N;
	for (k = 0; k < N; k++) {
		vector<vector<int> >dp(1001, vector<int>(1001, 0));
		int ans = 0;
		string s1, s2;
		cin >> s1 >> s2;
		s1 = ' ' + s1;
		s2 = ' ' + s2;
		for (i = 0; i < s1.size(); i++) { dp[i][0] = 0; }
		for (i = 1; i < s2.size(); i++) { dp[0][i] = 0; }
		for (i = 1; i < s1.size(); i++) {
			for (j = 1; j < s2.size(); j++) {
				if (s1[i] == s2[j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
				ans = max(ans, dp[i][j]);
			}
		}
		Ans.push_back(ans);
	}
	for (i = 0; i < Ans.size(); i++) {
		cout << Ans[i] << endl;
	}
}


Measured memory_bytes: 6828
NM_list = input().split(" ")
N = int(NM_list[0])
M = int(NM_list[1])
a_list = [int(num) for num in input().split(" ")]
a_list.sort(reverse = True)
sum_vote = 0
for i in a_list:
    sum_vote += i

for i in range(M):
    if a_list[i]*4*M<sum_vote:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919810
typedef pair<int, int> P;
int a[200];
signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2])puts("Yes");
	else if (s[1] == s[2] && s[2] == s[3])puts("Yes");
	else puts("No");
}

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

int main() {
  
  int a;
  cin >> a;
  int b;
  cin >> b;
  int c;
  cin >> c;
  
  if (a+b==c || b+c==a || c+a==b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
inline int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
int32_t main() 
{ 
  fast;
  int x,y;
  cin >>   x >> y;
  if(y%2 == 0) {
    int k = y/2;
    if(k>= x && 2*x-k >=0 ) cout << "Yes\n";
    else cout << "No\n";
  }
  else cout << "No\n";
  return 0; 
}

// 2*a + 4*b = Y
// a+b = X
// a = x-b
// 2x - 2b + 4b = y
// 2x +2b = y
//(y/2)-x;

Measured memory_bytes: 3632
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto S = rs;
	writeln(S[0..K-1] ~ f(S[K-1]) ~ S[K..$]);
}

char f(char x) {
	switch (x) {
		case 'A': return 'a';
		case 'B': return 'b';
		case 'C': return 'c';
		default: return '1';
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int p(0);
  for (int i(0);i<n;i++){
    if (s[i]=='p') p++;
  }
  cout << n/2-p << endl;
}



Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
ans = 0
befor = a[0]
for i in range(1,n-1):
    after = a[i+1]
    if a[i] == befor:
        ans += 1
        for j in range(1,10001):
            if j != after:
                a[i] = j
                break
    befor = a[i]
if befor == a[-1]:
    ans += 1
print(ans)


Measured memory_bytes: 38256
from collections import deque

n, q = [int(i) for i in input().split()]

tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = [int(i) for i in input().split()]
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * (n+1)
for _ in range(q):
    p, x = [int(i) for i in input().split()]
    counter[p] += x

queue = deque([[0,1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])

print(*counter[1:])


Measured memory_bytes: 65272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll n, m, q;
vector<ll> a, b, c, d;
ll ans = 0;
map<vector<ll>, bool> mp;
void solve(vector<ll> &v) {
	mp[v] = true;
	ll subans = 0;
	for (ll i = 0; i < q; i++) {
		if (v[b[i]] - v[a[i]] == c[i]) subans += d[i];
	}
	ans = max(ans, subans);
	for (ll i = 0; i < n - 1; i++) {
		if (v[i] < v[i + 1]) {
			v[i]++;
			if (!mp[v]) solve(v);
			v[i]--;
		}
	}
	if (v[n - 1] < m) {
		v[n - 1]++;
		if (!mp[v]) solve(v);
		v[n - 1]--;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;


	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for (ll i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	vector<ll> v(n, 1);
	solve(v);
	cout << ans << endl;
}

Measured memory_bytes: 19468
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;


int main() {
  ll n;
  cin >> n;
  vector<ll> a;
  for(ll i = 1; i*i <=n; i++) {
    if(i*i==n) a.push_back(i);
    else if(n%i==0) {
      a.push_back(i);
      a.push_back(n/i);
    }
  }
  ll ans = 0;
  for(auto p : a) {
    p--;
    if(p!=0&&n/p==n%p) ans += p;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int h,n,count,i;
    cin>>h>>n;

    int a;
    for(i=0;i<n;i++)
    {
        cin>>a;
        h-=a;
    }

    if(h<=0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;
using namespace boost::multiprecision;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> p(n);
    vector<pair<pair<int, int>, int>> p2(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        p[i] = {{x, y}, i};
        p2[i] = {{y, x}, i};
    }
    sort(all(p));
    dsu d(n);
    {
        priority_queue<pair<pair<int, int>, int>> pq; // y, x, i
        rep(i, n) {
            while (!pq.empty() && -pq.top().first.first < p[i].first.second) {
                d.merge(p[i].second, pq.top().second);
                pq.pop();
            }
            pq.push({{-p[i].first.second, p[i].first.first}, p[i].second});
        }
    }
    reverse(all(p));
    {
        priority_queue<pair<pair<int, int>, int>> pq; // y, x, i
        rep(i, n) {
            while (!pq.empty() && pq.top().first.first > p[i].first.second) {
                d.merge(p[i].second, pq.top().second);
                pq.pop();
            }
            pq.push({{p[i].first.second, p[i].first.first}, p[i].second});
        }
    }
    
    sort(all(p2));
    {
        priority_queue<pair<pair<int, int>, int>> pq; // y, x, i
        rep(i, n) {
            while (!pq.empty() && -pq.top().first.first < p2[i].first.second) {
                d.merge(p2[i].second, pq.top().second);
                pq.pop();
            }
            pq.push({{-p2[i].first.second, p2[i].first.first}, p2[i].second});
        }
    }
    reverse(all(p2));
    {
        priority_queue<pair<pair<int, int>, int>> pq; // y, x, i
        rep(i, n) {
            while (!pq.empty() && pq.top().first.first > p2[i].first.second) {
                d.merge(p2[i].second, pq.top().second);
                pq.pop();
            }
            pq.push({{p2[i].first.second, p2[i].first.first}, p2[i].second});
        }
    }
    rep(i, n) cout << d.size(i) << endl;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 9712
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  a = new Array(n).fill(0);
  b = new Array(n).fill(0);
  tmpa = input[1].split(" ");
  tmpb = input[2].split(" ");
  var suma=0;
  var sumb=0;
  var dif=0;
  var difp=0;
  var difm=0;

  for(i=0;i<n;i++){
    a[i]=parseInt(tmpa[i]);
    suma += a[i];
    b[i]=parseInt(tmpb[i]);
    sumb += b[i];
    dif+=Math.abs(a[i]-b[i]);
    difp+=Math.floor(Math.max(0,b[i]-a[i])/2);
    difm+=Math.max(0,a[i]-b[i]);
  }
  var ans ="No";
  if(difm<=difp){
    ans="Yes";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 13760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y>>z;
  repone(i,x+1){
    m=i;
    while(m>0){
      n+=m%10;
      m/=10;
    }
    if(n>=y&&n<=z)w+=i;
    n=0;
  }
  std::cout << w << '\n';
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <queue>
namespace Program
{
    using namespace std;
    class Solver
    {
    private:
        int N, K;
        int a;

        queue<int> qi;
        vector<long long int> viA;
        vector<long long int> viB;

        long long int sumTotal = 0LL;
        long long int sumA = 0LL;
        long long int sumB = 0LL;

    public:
        Solver()
        {
            cin.tie(0);
            ios::sync_with_stdio(false);

            cin >> N >> K;

            for (int i = 0; i < N; i++)
            {
                cin >> a;

                qi.push(a);

                sumA += a;
                sumTotal += a < 0 ? 0 : a;

                if (i >= K - 1)
                {
                    viA.push_back(sumA);
                    long long int qf = qi.front();
                    sumA = sumA - qf;
                    qi.pop();

                    sumB += qf < 0 ? 0 : qf;
                    viB.push_back(sumB);
                }
                else
                {
                    viA.push_back(0);
                }
            }

            while (!qi.empty())
            {
                sumB += qi.front() < 0 ? 0 : qi.front();
                viB.push_back(sumB);
                qi.pop();
            }
        }

        void Solve()
        {
            long long int score = 0LL;
            for (int i = K - 1; i < N; i++)
            {
                long long int b = i - K >= 0 ? viB[i - K] : 0;

                // 最後に白く塗る
                long long int shiro = b + sumTotal - viB[i];
                score = max(shiro, score);

                // 最後に黒く塗る
                long long int kuro = shiro + viA[i];
                score = max(kuro, score);
            }

            cout << score << endl;
        }
    };
}

int main()
{
    // メモリリーク検出
    //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
    //    | _CRTDBG_DELAY_FREE_MEM_DF
    //    | _CRTDBG_CHECK_ALWAYS_DF
    //    | _CRTDBG_LEAK_CHECK_DF);

    // メンバ関数ポインタ取得
    void (Program::Solver::*pSolve)() = &Program::Solver::Solve;

    // コンストラクタ呼び出し
    Program::Solver obj;

    // .*演算子でアクセス
    (obj.*pSolve)();
    return 0;
}


Measured memory_bytes: 2932
N, M = map(int, input().split())
A = [[] for _ in range(N)]
ac_cnt, wa_cnt = 0, 0
for _ in range(M):
    p, s = input().split()
    if s == "AC":
        A[int(p) - 1].append(1)
    else:
        A[int(p) - 1].append(0)

for x in A:
    if x.count(1) >= 1:
        ac_cnt += 1
        wa_cnt += len(x[0:x.index(1)])
print(ac_cnt, wa_cnt)

Measured memory_bytes: 14768
#include <iostream>
#include <cmath>
using namespace std;
#define PI 3.14159265
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n , n != -1){
		double x = 1.0 , y = 0.0 , degree = PI;
		
		rep(i,n-1){
			degree -= PI / 2.0;
			x += cos(degree);
			y += sin(degree);
			
			double d = max(x,y);
			degree = atan2(y,x) + PI;
		}
		printf("%.2lf\n%.2lf\n",x,y);
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

const ll M=(1<<20);

ll n;
ll a[500010],s[500010];
ll sz[500010];
vector<ll> b[M];

ll cntz(ll l,ll r){
  return sz[r]-sz[l];
}

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

  cin>>n;
  rep(i,n){
    cin>>a[i];
    s[i+1]=s[i]^a[i];
  }

  rep(i,n+1){
    b[s[i]].push_back(i);
    sz[i+1]=sz[i]+(s[i]==0);
  }

  ll res=0;
  repl(i,1,M){
    if(b[i].size()==0)continue;
    ll m=b[i].size();
    vector<vector<ll>> dp(m+1,vector<ll>(2,0));
    dp[1][0]=1; dp[1][1]=1;
    repl(j,1,m){
      (dp[j+1][0]+=dp[j][0])%=mod;
      (dp[j+1][0]+=dp[j][1]*cntz(b[i][j-1],b[i][j])%mod)%=mod;

      (dp[j+1][1]+=dp[j][0])%=mod;
      (dp[j+1][1]+=dp[j][1])%=mod;
      (dp[j+1][1]+=dp[j][1]*cntz(b[i][j-1],b[i][j])%mod)%=mod;
    }

    if(b[i][m-1]==n){
      res+=(dp[m][1]-dp[m-1][1]+mod)%mod;
      res%=mod;
    }
    if(s[n]==0){
      res+=dp[m][1]%mod;
      res%=mod;
    }
  }

  if(s[n]==0)(res+=mod_pow(2,cntz(1,n)))%=mod;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 57672
#include<stdio.h>
 
int main(void)
{
 int a,b,c,d,e,f,A;
 for(;scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF; A = (a*e-b*d),printf("%.3f %.3f\n",(double)(c*e-b*f)/A+0,(double)(a*f-c*d)/A+0));
 return 0;
}

Measured memory_bytes: 0
def euclid(a, b):
  if b == 0:
    gcdr = a
  else:
    gcdr = euclid(b, a%b)
  return gcdr

N = int(input())
A ,*B= map(int,input().split())
for i in B:
    A = euclid(A,i)
print(A)


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

Measured memory_bytes: 256
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll turn=1;
    while(a>0 && c>0){
        if(turn){
            c-=b;
        }else{
            a-=d;
        }
        turn^=1;
    }
    if(turn){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
}

int main(ll argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


bool is_palin(string s){
  string t(RALL(s));
  return s == t;
}


int main(){
  string s;

  while(cin >> s){
    int n = s.size();
    string a = s.substr(0, n/2);

    dump(a);
    if(is_palin(s) and is_palin(a)){
      puts_all("Yes");
    }else{
      puts_all("No");
    }

    
  }


  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, d;
    cin >> n >> d;
    double a, b;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;        
        double sq = sqrt(pow(a,2) + pow(b,2));
        if (sq <= d) {
            sum += 1;
        }
    }
    cout << sum;
}


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();

		int ans = 0;
		for(int a=1; a<=K; a++) {
			for(int b=1; b<=K; b++) {
				for(int c=1; c<=K; c++) {
					ans += gcd_triple(a, b, c);
				}
			}
		}

		System.out.println(ans);
	}

	static int gcd_triple(int a, int b, int c) {
		return gcd(gcd(a, b) , c);
	}

//	static int gcd(long m, long n) {
//	    if(m < n) return gcd(n, m);
//	    if(n == 0) return m;
//	    return gcd(n, m % n);
//	}
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

}


Measured memory_bytes: 35768
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
cum_sum = [0] * (n+1)
for i in range(n):
    cum_sum[i+1] = cum_sum[i] + A[i]
C = Counter(cum_sum[1:])
ans = 0
for k, v in C.items():
    if k == 0:
        ans += v + (v*(v-1)//2)
    else:
        ans += (v*(v-1)//2)
print(ans)


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int par[100001];
int weight[100001];

int find(int x) {           //親探し
	if (par[x] == x) {
		return x;
	}
	else {
		int z = find(par[x]);
		weight[x] += weight[par[x]];
		par[x] = z;
		return z;
	}
}

bool  unit(int x, int y, int w) {


	int xpar = find(x);
	int ypar = find(y);

	w += weight[x];
	w -= weight[y];

	if (xpar == ypar) { return false; }   //すでに結合済み

	if (weight[x]<weight[y]) {
		swap(xpar, ypar);
		w = -w;
	}

	par[ypar] = xpar;
	weight[ypar] += w;

	return true;
}

int getWeight(int x, int y) {
	return weight[y] - weight[x];
}

bool isSame(int x,int y) {
	return find(x) == find(y);
}

int main()
{
	int N, M;
	cin >> N >> M;
	fx(N) {
		par[x] = x;
		weight[x] = 0;
	}
	fw(M) {
		int L,R,D;
		cin >> L >> R >> D;
	
		if (isSame(L,R)) {
			if (getWeight(L,R)!=D) {
				cen;
				return 0;
			}
		}
		else {
			unit(L, R, D);
		}

	}
	cey;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=0;i<=b;i++){
        if ((a*i)%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#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(x) (x).begin(), (x).end()
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int main(){
    // 入力
    ll n,x,y;
    scanf("%lld %lld %lld",&n,&x,&y);

    ll result[n-1];
    rep(i,n){
        result[i] = 0;
    }

    ll temp;

    rep1(i,n-1)for(ll j=i+1;j<=n;j++){
        // printf("%d %lld\n",i,j);
        temp = min(j-i,llabs(x-i)+1+llabs(j-y));
        temp = min(temp,llabs(y-i)+1+llabs(j-x));
        result[temp-1]++;
        // printf("%lld\n",temp-1);
    }

    rep(i,n-1){
        printf("%lld\n",result[i]);
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

#n,k=[int(i) for i in input().split()]



n=int(input())


ok=0
for i in range(100):
    if n>=4*i and (n-4*i)%7 == 0:
        ok = 1
        break

if ok==0:
    print("No")
else:
    print("Yes")

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int A, B, C; cin >> A >> B >> C;
  if (A == B && B == C && A % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int count = 0;
  while (true) {
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
      cout << count << endl;
      return 0;
    }
    int a = (B + C) / 2;
    int b = (A + C) / 2;
    int c = (A + B) / 2;
    A = a;
    B = b;
    C = c;
    count++;
  }

  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 1000000 + 9;
ll n,ans,mod=1e9+7,mem[2009];

ll dp(int sum)
{
    if(!sum)return 1;
    ll&ret=mem[sum];
    if(~ret)return ret;

    ret=0;
    forr(j,3,n)
    {
        if(j<=sum)
         ret+=dp(sum-j),ret%=mod;
    }
    return ret;
}
 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n;
        memset(mem,-1,sizeof mem);
        cout<<dp(n)<<endl;




return 0;
}


Measured memory_bytes: 3668
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
flg = True

while flg:
    for i in range(N):
        if A[i] % 2:
            flg = False
            break
        else:
            A[i] >>= 1

    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
    string s;
    cin >> s;
    int g_count = 0, p_count = 0;
    each(c, s) {
        if (c == 'g') g_count++;
        if (c == 'p') p_count++;
    }
    int all = g_count + p_count;
    if (all % 2 == 0) {
        cout << min(all / 2, g_count) - min(all / 2, p_count) << endl;
    } else {
        cout << min((all - 1) / 2, g_count) - min((all - 1) / 2 + 1, p_count) << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1001001];
int n;
int k;
int minn=999999999;
int main()
{
	  cin>>n>>k;
	  for(int i=1;i<=n;i++)
	    cin>>a[i];
	  sort(a+1,a+1+n);
	  for(int i=k;i<=n;i++)
	    minn=min(minn,a[i]-a[i-k+1]);
	  cout<<minn;
	  return 0;
}

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

int main() {
  long N;
  cin>>N;
  bool flg=false;
  long k;
  for(int i=1;i<500;i++){
    if(i*(i+1)/2==N) flg=true,k=i;
  }
  if(!flg){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl<<k+1<<endl;
  if(k==1){
    cout<<1<<" "<<1<<endl;
    cout<<1<<" "<<1<<endl;
    return 0;
  }

  int h=(k+1),w=N*2/(k+1);
  //cout<<h<<" "<<w<<endl;
  vector<vector<long>> a(h,vector<long>(w));

  for(int i=1;i<=h-1;i++)for(int j=0;j<i;j++) a[i][j]=(i-1)*i/2+j+1;

  for(int i=0;i<=h-2;i++)for(int j=i;j<w;j++) a[i][j]=(j+1)*j/2+i+1;

  for(int i=0;i<h;i++){
    cout<<w<<" ";
    for(int j=0;j<w;j++){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 4600
def hit(bases):
    got_point = False
    if bases[2]:
        got_point = True
    bases[0], bases[1], bases[2] = 1, bases[0], bases[1]
    if got_point:
        return 1
    else:
        return 0

def homerun(bases):
    num_runner = bases.count(1)
    bases[0], bases[1], bases[2] = 0, 0, 0
    return num_runner + 1

for i in range(int(raw_input())):
    bases = [0, 0, 0]
    out_count = 0
    points = 0
    while out_count != 3:
        event = raw_input()
        if event == "HIT":
            points += hit(bases)
        elif event == "HOMERUN":
            points += homerun(bases)
        else:
            out_count += 1
    print points

Measured memory_bytes: 4248
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	VI a, b;
	rep(i, n) {
		int x; cin >> x;
		(i % 2 == 0 ? a : b).pb(x);
	}
	sort(all(a));
	sort(all(b));

	//number, element
	vector<PII> odd, even;
	int i = 0;
	while (i < n / 2) {
		int elem = a[i], cnt = 0;
		while (i < n / 2 && a[i] == elem) { cnt++; i++; }
		odd.pb(mp(cnt, elem));
	}
	i = 0;
	while (i < n / 2) {
		int elem = b[i], cnt = 0;
		while (i < n / 2 && b[i] == elem) { cnt++; i++; }
		even.pb(mp(cnt, elem));
	}
	sort(all(odd)); reverse(all(odd));
	sort(all(even)); reverse(all(even));

	int ans = n;
	rep(i, min(3, sz(odd)))rep(j, min(3, sz(even))) {
		if (odd[i].second == even[j].second) {
			continue;
		}
		else {
			ans = min(ans, n - odd[i].first - even[j].first);
		}
	}
	if (sz(odd) == 1 && sz(even) == 1 && odd[0].second == even[0].second)ans = n / 2;
	Cout(ans);
}

Measured memory_bytes: 1784
/*
"Won't stop until I'm Phenomenal."
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

ll binmodulo(ll x, ll y){
    x%=mod1;
    if(!x) return 0;
    ll res = 1;
    while(y){
        if(y&1){
            res = res*x%mod1;
        }
        y/=2;
        x = x*x%mod1;
    }
    return res;
}

ll ncrr(ll n, ll r){
    if(n - r < r)
        r = n-r;
    ll x = 1, y =1;
    for(int i = 1; i <= r; i++){
        x*=(n+1-i);
        x%=mod1;
        y*=i;
        y%=mod1;

    }
    return x*binmodulo(y,mod1-2)%mod1;
}

int main(){
    Shazam;
    ll n,a,b; cin>>n>>a>>b;
    ll tot = binmodulo(2LL,n);
    tot = (tot - ncrr(n,a) + mod1)%mod1;
    tot = (tot - ncrr(n,b) + mod1)%mod1;
    cout<<tot-1<<endl;
    return 0;
}

Measured memory_bytes: 3620
use contest::io::Scanner;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n = sc.next::<usize>();
    let m = sc.next::<usize>();
    let c = sc.next::<i32>();
    let mut b = vec![];
    for _ in 0..m {
        b.push(sc.next::<i32>());
    }

    let mut res = 0;
    for _ in 0..n {
        let mut v = c;
        for i in 0..m {
            let a = sc.next::<i32>();
            v += a * b[i];
        }
        if v > 0 {
            res += 1;
        }
    }
    println!("{}", res);
}
pub mod contest {
    pub mod io {
        /// Scanner
        ///
        /// # Example
        /// ```
        /// use contest::io::Scanner;
        /// let mut sc = Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
        /// assert_eq!("1".to_string(), sc.next::<String>());
        /// assert_eq!(2, sc.next());
        /// assert_eq!(3.5, sc.next());
        ///
        /// // To create a scanner from stdin:
        /// Scanner::new(std::io::stdin());
        /// ```
        use std;
        use std::io;
        use std::io::BufRead;

        pub struct Scanner<R: io::Read> {
            br: io::BufReader<R>,
            // Read tokens are stored in reversed order per line.
            buf: Vec<String>,
        }

        pub fn new<R: io::Read>(r: R) -> Scanner<R> {
            Scanner::new(r)
        }

        impl<R: io::Read> Scanner<R> {
            #[inline]
            pub fn new(r: R) -> Scanner<R> {
                Scanner {
                    br: io::BufReader::new(r),
                    buf: vec![],
                }
            }
            #[inline]
            pub fn next<T>(&mut self) -> T
            where
                T: std::str::FromStr,
                T::Err: std::fmt::Debug,
            {
                self.next_string()
                    .map(|s| s.parse::<T>().expect("Parse failed: "))
                    .expect("Unexpected EOF")
            }
            #[inline]
            pub fn next2<T1, T2>(&mut self) -> (T1, T2)
            where
                T1: std::str::FromStr,
                T2: std::str::FromStr,
                T1::Err: std::fmt::Debug,
                T2::Err: std::fmt::Debug,
            {
                (self.next(), self.next())
            }
            fn next_string(&mut self) -> Option<String> {
                self.buf.pop().or_else(|| match self.update() {
                    true => self.next_string(),
                    false => None,
                })
            }
            #[inline]
            fn update(&mut self) -> bool {
                let mut s = String::new();
                let res = self.br.read_line(&mut s);
                match res.expect("I/O error.") {
                    0 => false,
                    _ => {
                        self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                        true
                    }
                }
            }
        }

        #[test]
        fn test_next() {
            let mut sc = new("hoge".as_bytes());
            let s: String = sc.next();
            assert_eq!("hoge", s);
        }
    }
}


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

int main(){
    ll n; cin >> n;
    string name;
    while(n>0LL){
        ll tmp = n%26LL;
        if(tmp == 0LL) name = 'z' + name;   
        else name = (char)('a' + tmp - 1LL) + name;
        
        if(n == 26LL) break;
        else if(tmp == 0LL){
            n /= 26LL; n--;
        }
        else n/= 26LL;
        //if(n/26LL == 1LL) break;
        //else n/=26LL;
        //n /= 26LL;
        /*ll tmp2 = n/26LL;
        n = n-tmp2*26LL;
       if(n == 1LL) break;*/
    }
    
    cout << name << endl;
}

Measured memory_bytes: 3628