akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N, A;
    cin >> N >> A;
    int x[N];
    REP(i,N) cin >> x[i];

    int y[N];
    REP(i,N) y[i] = x[i] - A;

    int X = abs(x[0]);
    FOR(i,1,N) chmax(X, abs(x[i]));

    ll dp[N+1][2*N*X+1]; // dp[i][j] : i個目までのカードのうち0個以上を選び, 合計がj-NXとなる選び方の総数
    REP(i,N+1)REP(j,2*N*X+1) dp[i][j] = 0;
    REP(i,N+1) dp[i][N*X] = 1;

    FOR(i,1,N+1)FOR(j,1,2*N*X+1){
        if(j-y[i-1] >= 0 && j-y[i-1] <= 2*N*X) dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i-1]];
        else dp[i][j] = dp[i-1][j];
    }

    cout << dp[N][N*X]-1 << endl;;

    return 0;
}

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

int main() {
	int a,b,wa,wb;
	string sa="",sb="";
	cin>>a>>b;
	for(int i=0;i<a;i++){
		sa=sa+"1";
	}
	for(int i=0;i<b;i++){
			sb=sb+"1";
	}
	wa=stoi(sa);
	wb=stoi(sb);
	a=a*wb;
	b=b*wa;
	sa=to_string(a);
	sb=to_string(b);
	cout<<min(sa,sb)<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a < b)swap(a, b);
	if (b < c)swap(b, c);
	if (a < b)swap(a, b);
	cout << a - c << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc153/tasks/abc153_d

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

long rec(long h)
{
    if (h == 1)
    {
        return 1;
    }
    else
    {
        return rec(h / 2) * 2 + 1;
    }
}

int main()
{
    long h;
    cin >> h;
    cout << rec(h) << endl;
    return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int n;
    cin>>n;
    int k;
    cin>>k;
    vec a(n);
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int aa;
            cin>>aa;
            aa--;
            a[aa]++;
        }
    }
    int cnt=0;
    rep(i,n) if(a[i]==0) cnt++;
    cout<<cnt<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7788
#include <stdio.h>

int main(){
	
	int m[1000],f[1000],r[1000];
	
	int i=0;
	
	while(1){
		
		if(i!=0)
		
			scanf("%*c");
		
		scanf("%d %d %d",&m[i],&f[i],&r[i]);
		
		if(m[i]==-1&&f[i]==-1&&r[i]==-1)
			
			break;
		
		i++;
	}
	
	int t;

	for(t=0;t<=i-1;t++){
		
		
		if(m[t]==-1||f[t]==-1){
			
			printf("F\n");
			
		}
		
		else if(m[t]+f[t]>=80){
			
			printf("A\n");
			
		}
		
		else if(m[t]+f[t]>=65){
			
			printf("B\n");
			
		}
		
		else if(m[t]+f[t]>=50){
			
			printf("C\n");
			
		}
		
		else if(m[t]+f[t]>=30&&r[t]>=50){
			
			printf("C\n");
			
		}
		
		else if(m[t]+f[t]>=30){
			
			printf("D\n");
			
		}
		
		else{
			
			printf("F\n");
			
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ll long long
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void  solve(){
  ll n,k;
     cin>>n>>k;
     ll a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     int ct[60];
     memset(ct,0,sizeof(ct));
     for(int i=0;i<n;i++){
          ll t=a[i];
          for(int j=0;j<50;j++){
               ct[j]+=t%2;
               t/=2;
          }
     }
     ll res=0LL,tmp=0LL;
     for(int j=59;j>=0;j--){
          int count1=ct[j];
          if(count1>=n-count1){
               res+=count1*(1LL<<j);
          }
          else{
               ll ty=(tmp+(1LL<<j));
               if(ty<=k){
                    tmp=ty;
                    res+=(n-count1)*(1LL<<j);
               }
               else{
                    res+=(count1)*(1LL<<j);
               }
          }
     }
     cout<<res;
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 4332
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	int n; cin >> n;
	vector<int> aa(n);
	rep(i, n) cin >> aa[i];
	sort(aa.begin(), aa.end());
	cout << aa[n / 2] - aa[n / 2-1];
}


Measured memory_bytes: 3756
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

int main() {
	char str[1000];
	scanf("%s",str);
	for(int i=0;str[i];i++) {
		if(str[i]<'D') str[i]='Z'-('C'-str[i]); else str[i]-=3;
	}
	printf("%s\n",str);
}

Measured memory_bytes: 952
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int n,q;
hei(ll) seg, lazy;

void aaa(int k) {
	if (lazy[k] == 0)return ;
	if (k < n - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	seg[k] += lazy[k];
	lazy[k] = 0;
}

void update(int a, int b, ll x,int k,int l,int r) {
	aaa(k);
	if (a<=l && b>=r) {
		lazy[k] += x;
		aaa(k);
	}
	else if(a<r&&l<b){
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		seg[k] = seg[k * 2 + 1]+seg[k * 2 + 2];
	}
}

ll query(int a,int b,int k,int l,int r){
	aaa(k);
	if (l >= b || r <= a)return 0;
	if (a <=l  && b >= r) {
		return seg[k];
	}
	ll v1 = query(a, b, k*2+1, l, (l + r) / 2);
	ll v2 = query(a, b, k*2+2, (l + r) / 2, r);
	return v1 + v2;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	string s;
	cin >> s;
	int g = 0;
	int p = 0;
	int ans = 0;
	rep(i, 0, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'p')ans--;
		}
		else {
			if (s[i] == 'g')ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

int table[50000];
vector<int> prime;

int main() {
    for (int i = 2; i < 50000; i++) {
        if (table[i] == 0) {
            prime.push_back(i);
            for (int j = i; j < 50000; j += i) {
                table[j] = 2;
            }
            table[i] = 1;
        }
    }
    int n, size = prime.size();
    while (cin >> n && n != 0) {
        int ans = 0, num1, num2;
        for (int i = 0; i < size; i++) {
            num1 = prime[i];
            num2 = n - num1;
            if (num2 <= 0) {
                break;
            }
            if (num1 <= num2 && table[num2] == 1) {
                ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1468
#include <cstdio>

int main(){
	int T,D,L,x;	
	while(scanf("%d%d%d",&T,&D,&L), T != 0){
		int ans = 0, cont = -1;
		for(int i = 0; i < T; i++){
			scanf("%d",&x);
			if(cont >= i){
				ans++;
			}
			if(x >= L){
				cont = i + D;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 2672
a,b,h,m = map(int, input().split())

import math

hd = h * 30
md = (m / 5) * 30
hd += (m / 60) * 30
d = hd-md
d = min(d, abs(360-d))
cs = math.radians(d)
c = math.sqrt(a**2+b**2-2*a*b*math.cos(cs))
print(c)

Measured memory_bytes: 62252
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	int n;
	cin >> n;
	map<string, int> dic;
	for (int i = 0; i < n; i++)
	{
		string command;
		string str;
		cin >> command >> str;
		if (command == "insert")
		{
			dic[str]++;
		}
		else if (command == "find")
		{
			if (dic.count(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 36476
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <unordered_set>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
const double PI=3.14159265358979323846;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
// vector<ll> height(max_n, -1);
// vector<pair<ll,ll>> edge_list(max_n);

ll N, M, Q;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    lf A, B, H, M;
    slf(A);
    slf(B);
    slf(H);
    slf(M);

    lf diff_rad = 2 * PI * (H / 12. + M / (12. * 60.) - M / 60.);
    // lf diff_rad = diff / 180. * PI;
    // cout << "diff " << diff << endl;
    // cout << "radian " << diff_rad <<endl;
    lf ans = sqrt(A*A + (B*B - 2*A*B*cos(diff_rad)));

    cout << setprecision(20) << ans <<endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

ll n;
string s = "";
char c = 'a';
vector<string> ans;
void dfs(string s, char c){
  if(sz(s) == n){
    cout << s << endl;
  }else{
    for(char a = 'a'; a <= c; a++){
      dfs(s+a, ((a==c)?(char)(c+1):c));
    }
  }
  return;
}

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

  cin >> n;
  dfs(s, c);
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
struct edge{int u,v;ll w;}e[2010];
int fa[2010],n,m;
ll p[2010],K,f[2010];
int find(int x){return fa[x]= fa[x]==x?x:find(fa[x]);}
ll kruskal(int x=0,int y=0){
	for(int i=1;i<=n;i++) fa[i]=i;
	if(x&&y) fa[x]=y;
	ll ans=0;
	for(int i=1;i<=m;i++){
		int x=e[i].u,y=e[i].v;
		x=find(x);y=find(y);
		if(x==y) continue;
		ans+=e[i].w;
		fa[x]=y;
	}
	return ans;
}
int main(){
	cin>>n>>m;
	p[0]=1;
	for(int i=1;i<=m;i++) p[i]=p[i-1]*2%mod;
	cin>>K;
	for(int i=1;i<=m;i++)
		cin>>e[i].u>>e[i].v>>e[i].w;
	sort(e+1,e+m+1,[](edge a,edge b){
		return a.w<b.w;
	});
	ll mn=kruskal();
	if(mn>K){puts("0");return 0;}
	for(int i=1;i<=m;i++)
		f[i]=kruskal(e[i].u,e[i].v)+e[i].w;
	if(mn==K){
		int S=0;
		for(int i=1;i<=m;i++)
			S+=f[i]==mn;
		cout<<(1ll*(p[S]-2)*p[m-S]%mod+mod)%mod<<'\n';
		return 0;
	}
	int S1=0,S2=0;
	for(int i=1;i<=m;i++){
		S1+=f[i]<K;
		S2+=f[i]==K;
	}
	cout<<((2ll*p[S2]-2)*p[m-S1-S2]%mod+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(2 * n),b(2 * n,0);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    for(int i=n; i>=1; i--)
    {
        int ans=0;
        for(ll j = i; j <= n; j += i){
            ans += b[j];
        }
        if(ans % 2 != a[i])
            b[i] = 1;
    }
    int cnt = 0;
    for(int i=1; i<=n; i++)
        if(b[i] > 0){
            cnt++;
        }
    cout << cnt << endl;
    ll k = 0;
    for(ll i = 1; i <= n; i++)
    {
        if(b[i] && k==0)
        {
            cout << i << endl;
            k++;
        }
        else if(b[i]){
            cout << i << endl;
        }
    }

}


Measured memory_bytes: 7168
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  long double A, B;
  cin >> A >> B;
  if(A > B) cout << "GREATER" << endl;
  else if(A == B) cout << "EQUAL" << endl;
  else cout << "LESS" << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000)

cm = None
cM = None
def m(a, n, i, w):
    if w in cm[i]: return cm[i][w]
    m = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        m = min(m, abs(M(a, n, k + 1, a[k])))
    cm[i][w] = m
    return m

def M(a, n, i, w):
    if w in cM[i]: return cM[i][w]
    M = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        M = max(M, abs(m(a, n, k + 1, a[k])))
    cM[i][w] = M
    return M

n, z, w = map(int, raw_input().split())
a = map(int, raw_input().split())
cm = [dict() for _ in range(n)]
cM = [dict() for _ in range(n)]
print M(a, n, 0, w)


Measured memory_bytes: 37532
#include<iostream>

using namespace std;

int main(){
	int n, q;
	int date[101];
	int i,j;
	int m, temp;
	int max;

	while (1){

		max = 0;
		for (i = 0; i <= 100; i++){
			date[i] = 0;
		}



		cin >> n >> q;
		if (n == 0 && q == 0){
			break;
		}
		
		for (i = 1; i <= n; i++){
			cin >> m;
			for (j = 0; j < m; j++){
				cin >> temp;
				date[temp]++;
			}
		}

		for (i = 1; i <= 100; i++){
			if (date[i]>date[max]){
				max = i;
			}
		}

		if (date[max] < q){
			cout << 0 << endl;
		}else{
			cout << max << endl;
		}


		
	}

}

Measured memory_bytes: 1160
import copy

import numpy as np


def main():
    N = int(input())
    X = np.array(list(map(int, input().split())))
    m = np.median(X)

    XX = copy.deepcopy(X)
    mm = np.argmin(X)
    XX = np.delete(XX, mm)
    m0 = int(np.median(XX))

    XX = copy.deepcopy(X)
    mm = np.argmax(X)
    XX = np.delete(XX, mm)
    m1 = int(np.median(XX))

    for x in X:
        if x <= m:
            print(m0)
        else:
            print(m1)


main()


Measured memory_bytes: 34148
N, M = map(int, input().split())
A = list(map(int, input().split()))
numbers = [0,2,5,5,4,5,6,3,7,6]


dp = ["-" for i in range(11000)]
dp[0] = ""

def cal(x, y):
  lenx = len(x)
  leny = len(y)
  
  if lenx > leny:
    return x
  if leny > lenx:
    return y
  
  return max(x, y)

for i in range(N):
  if dp[i] == "-": 
    continue

  for j in range(M):
    num = numbers[A[j]]
    dp[i+num] = cal(dp[i] + str(A[j]), dp[i+num])

print(dp[N])

Measured memory_bytes: 30196
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll dp[60][60][2510];

int main(int argc, const char * argv[]) {
  int n, a;
  cin >> n >> a;
  
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 2510; k++) {
        if (dp[i][j][k] == 0) {
          continue;
        }
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }
  
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * a];
  }
  cout << ans << endl;
  return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, d, a; std::cin >> n >> d >> a;
  vector<pi> points(n);
  rep(i, n) {
    std::cin >> points[i].fi >> points[i].se;
  }
  sort(rng(points));
  d *= 2;
  queue<pi> que;
  ll tot = 0, ans = 0;
  rep(i, n) {
    while (que.size() > 0 && que.front().fi < points[i].fi) {
      tot -= que.front().se;
      que.pop();
    }
    points[i].se -= tot;
    if (points[i].se > 0) {
      pi p;
      p.fi = points[i].fi + d;
      p.se = (points[i].se + a - 1) / a;
      ans += p.se, p.se *= a;
      tot += p.se;
      que.push(move(p));
    }
  }
  std::cout << ans << "\n";
}


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

const int MOD = 1000000007;
int N, M;
vector<int> A, B;

long long solve() {
    long long res = 1;
    int biggerX_a = 0, biggerX_b = 0; // A, B で x より大きいのが何個あるか
    for (int x = N*M; x >= 1; --x) {
        if (A[biggerX_a] > x) return 0;
        if (B[biggerX_b] > x) return 0;
        
        long long tmp = 1;
        if (A[biggerX_a] == x && B[biggerX_b] == x) {
            tmp = 1;
            ++biggerX_a, ++biggerX_b;
        }
        else if (A[biggerX_a] == x) {
            tmp = biggerX_b;
            ++biggerX_a;
        }
        else if (B[biggerX_b] == x) {
            tmp = biggerX_a;
            ++biggerX_b;
        }
        else {
            tmp = biggerX_a * biggerX_b - (N * M - x);
            if (tmp <= 0) return 0;
        }
        res = (res * tmp) % MOD;
    }
    return res;
}

int main() {
    cin >> N >> M;
    A.resize(N + 1); B.resize(M + 1);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) cin >> B[i];
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    cout << solve() << endl;
}

Measured memory_bytes: 256
import sys
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


class SegTree:

    def __init__(self, init_val, segfunc, ide_ele):

        n = len(init_val)
        self.ide_ele = ide_ele
        self.segfunc = segfunc
        self.num = 2**(n - 1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num

        for i in range(n):
            self.seg[i + self.num - 1] = init_val[i]

        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, k, x):
        k += self.num - 1
        self.seg[k] += x
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])

    def query(self, p, q):
        if q <= p:
            return self.ide_ele
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q & 1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res


def main():

    N, D, A = in_nn()
    XH = sorted(in_nl2(N))
    X = [0] * N
    H = [0] * N

    for i in range(N):
        x, h = XH[i]
        X[i] = x
        H[i] = h

    seg = SegTree([0] * N, segfunc=lambda a, b: a + b, ide_ele=0)

    ans = 0
    for i in range(N):

        x, h = X[i], H[i]
        j = bisect.bisect_right(X, x + 2 * D)
        cnt_bomb = seg.query(0, i + 1)

        h -= A * cnt_bomb
        if h <= 0:
            continue

        cnt = -(-h // A)
        ans += cnt
        seg.update(i, cnt)

        if j < N:
            seg.update(j, -cnt)

        # print(i, j)
        # print(seg.seg)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 110420
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 1700;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
int SUM = 0;
array<array<int, SZ>, D> S;

struct State {
	array<short, SZ> last = {};
	array<char, D> ans;
	int score = 0, sum = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		sum -= C[t] * (d + 1 - last[t]);
		last[t] = d + 1;
		sum += SUM;
		score -= sum;
	}

	int next_eval(int d, int t){
		int res = score;
		res += S[d][t];
		rep(i, SZ){
			if (i != t) res -= C[i] * (d + 1 - last[i]);
		}
		return res;
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.update_score(d, t);
		return res;
	}

	array<char, D> answer() {
		return ans;
	}
};

array<char, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.next_eval(d, t) > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, SZ) SUM += C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (char i : ans) cout << (int)i + 1 << endl;

	return 0;
}


Measured memory_bytes: 5000
#include <iostream>
#include <stdlib.h>
using namespace std;

int find(long k,long* A,int n);

int main(void){
  int n;
  cin>>n;
  long A[n];
  for(long i=0;i<n;i++){
    cin>>A[i];
  }

  int q;
  cin>>q;
  long k;
  for(int i=0;i<q;i++){
    cin>>k;
    cout<<find(k,A,n)<<endl;;
  }
  return 0;
}

int find(long k, long* A,int n){
  long low = 0;
  long high = n-1;
  long mid;
  while (high-low>10){
    mid = (high+low)/2;
    if(A[mid]>=k){
      high=mid;
    }
    else{
      low=mid;
    }
  }

  for(long i=low;i<=high;i++){
    if(A[i]>=k){
      return i;
    }
  }
  return n;
}



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

    int D, G;
    cin >> D >> G;

    vector<int> p(D);
    vector<int> c(D);

    for(int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    int ans = 1000000;

    for(int bit = 0; bit < (1 << D); bit++) {
        int count = 0;
        int sum = 0;
        int m = -1;
        for(int i = 0; i < D; i++) {
            if(bit & (1 << i)) {
                count += p[i];
                sum += p[i] * 100 * (i + 1);
                sum += c[i];
            } else {
                m = i;
            }
        }

        if(sum - G >= 0) {
            ans = min(ans, count);
            continue;
        }

        if(m != -1) {
            int x = (G - sum) / (100 * (m + 1));
            if((G - sum) % (100 * (m + 1))) {
                x++;
            }
            if(x <= p[m]) {
                count += x;
                ans = min(ans, count);
            }
        }
    }

    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[200001];
  for(int i=0;i<N;i++) cin>>A[i];
  sort(A,A+N);
  int B[1000001];
  for(int i=0;i<=1000000;i++) B[i]=0;
  for(int i=0;i<N;i++){
    B[A[i]]++;
    if(i==N-1||(i!=N-1&&A[i+1]!=A[i])){
      for(int j=2;j*A[i]<=1000000;j++) B[j*A[i]]=B[A[i]];
    }
  }
  int answer=0;
  for(int i=0;i<N;i++){
    if(B[A[i]]<=1) answer++;
  }
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 8300
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = input()
t = input()

ans = float('inf')

for i in range(len(s)):
    temp = s[i:]
    if len(temp) < len(t):
        break
    cnt = 0
    for j in range(len(t)):
        if temp[j] != t[j]:
            cnt += 1
    ans = min(cnt, ans)
print(ans)

Measured memory_bytes: 67752
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1000000007;
string s;
int l,r,ans;

int main(){
    fastIO;
    cin>>s;
    int n = 3;
    while(r<n){
        if(s[l] == s[r] && s[r] == 'R'){
            ans = max(ans,r-l+1);
        }
        else{
            l++;
        }
        r++;
    }
    cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=1e6+10;

char s[N];
int n;
int solve(){
	int res=0;
	for (int i=0; i<n; ++i){
		// calc bionomial(n,i) % 2 using lucas
		int j=1;
		for (int k=0;(1<<k)<n;++k)
			if ( ((n-1)>>k&1) < (i>>k&1)){
				j=0;break;
			}
		res ^= j*s[i];
	}
	return res;
}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%s", &n,s);
	int cnt[3] = {0,0,0};
	for (int i=0;i<n;++i){
		--s[i];
		++cnt[s[i]-'0'];
	}

	if (cnt[1]==0){
		for (int i=0; i<n; ++i) s[i] = (s[i]>'0');
		printf("%d\n", solve()*2);
	}	else{
		for (int i=0; i<n; ++i) s[i] = (s[i]-'0')%2;
		printf("%d\n", solve());
	}
	return 0;
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

long long gcd(long long x, long long y){return x % y == 0 ? y : gcd(y, x%y);}
long long lcm(long long a, long long b){return a / gcd(a,b) * b;}

int main(void){
    ll A,B,C,D; cin >> A >> B >> C >> D;

    ll nC = B/C - (A-1)/C, nD = B/D - (A-1)/D, nCD = B/lcm(C,D) - (A-1)/lcm(C,D);
    cout << B-(A-1)-(nC+nD-nCD) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string.h>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define lriii(a,b,c) lrii(a,b),lri(c)
#define pb push_back
#define _1 first
#define _2 second
#define ALL(s) s.begin(),s.end()
#define SZ(x) int((x).size())

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int alphabet = 26;
const double PI = 3.1415926535;
const int MAXINT = 1e5+1;

int main(){
	int n, W; rii(n,W);
	vector<int> w(n), v(n);
	FOR(i,0,n) rii(w[i],v[i]);

	int sum[MAXINT], prevSum[MAXINT];
	FOR(i,0,MAXINT) sum[i] = INF;
	sum[0] = 0;

	FOR(i,0,n){
		FOR(j,0,MAXINT) prevSum[j] = sum[j];

		FOR(j,0,MAXINT) if(prevSum[j] + w[i] <= W){
			sum[ j + v[i] ] = min( sum[ j + v[i] ], prevSum[j] + w[i] );
		}
	}

	ROF(i,MAXINT-1,-1) if( sum[i] != INF ){
		printf("%d\n", i); break;
	}
	return 0;
}
/*

*/  



Measured memory_bytes: 4572
#include<stdio.h>

int main(void){

    long int N,i,num = 1,save_block,a[200001],ans;

    scanf("%ld",&N);
    for(i = 0;i < N;i++){
        scanf("%ld",&a[i]);
    }

    save_block = 0;
    for(i = 0;i < N;i++){
        if(a[i] == num){
            num++;
            save_block++;
        }
    }

    (save_block == 0) ? (ans = -1) : (ans = N - save_block);

    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
int comp(string s, string t) {
    REP(i, min(s.size(), t.size())) {
        if (s[i] != t[i]) return i;
    }
    return min(s.size(), t.size());

}
int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s ){
        string t = s;
        reverse(ALL(t));
        cout << (comp(s, "keyence") + comp(t, "ecneyek") >= 7 ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i=0
k=0
ans=0
for j in range(n):
    while i<n and a[i]<b[j]:
        i+=1
    while k<n and c[k]<=b[j]:
        k+=1
    cnti=0
    cntk=0
    if i==n:
        cnti+=n
    else:
        cnti+=(i)
    if k<n:
        cntk+=(n-1-k+1)
    ans+=cnti*cntk
print(ans)




Measured memory_bytes: 23204
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(string S) {
  int cnt = 0;
  for (auto c : S) {
    if (c == '0') cnt++;
  }
  cout << min((int)S.size() - cnt, cnt) * 2 << endl;
}

int main() {
  cout << setprecision(10);
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

vector<ll> a;
vector<ll> neg;
vector<ll> pos;
ll n, k;

ll count_below(ll x, int ind) {
    int lo = 0, hi = n+1;
    while (lo<hi) {
        int mid = (lo+hi)/2;
        if (a[mid] <= x) {
            lo = mid+1;
        } else {
            hi = mid;
        }
    }
    --lo;

    return lo - (lo>=(ind));
}

ll count_above(ll x, int ind) {
    int lo=0, hi=n+1;
    while (lo<hi) {
        int mid = (lo+hi+1)/2;
        if (a[mid] >= x) {
            hi = mid-1;
        } else {
            lo = mid;
        }
    }
    ++lo;
    ////cerr << " INDEX " << lo << endl;
    return n-lo - (lo<=(ind)) + 1;
}

ll civv(ll x, ll y) {
    ////cerr << " Civv " << x << " " << y << endl;
    assert (y != 0);
    if ((x<0) == (y<0)) {
        if (y<0) {
            x*= -1;
            y*= -1;
        }
        return (x+y-1)/y;   
    }
    if (y<0) {
        x*=-1;
        y*=-1;
    }
    ////cerr << " X Y " << x << " " << y << endl;
    assert (y>0);
    return (x)/y;
}

ll divv(ll x, ll y) {
    assert (y != 0);
    if ((x<0) == (y<0)) {
        if (y<0) {
            x *= -1;
            y *= -1;
        }
        return x/y;
    }
    if (y<0) {
        x*=-1;
        y*=-1;
    }
    assert (y>0);
    return (x-y+1)/y;
}

ll check(ll x) {
    ll leq = 0;
    ll zeros = 0;
    for (int i=1; i<=n; ++i) {
        ll y = a[i];
        if (y == 0) {
            if (x >= 0) {
                ++ zeros;
                leq += n-1;
            }
        } else if (y < 0) {
            ll thresh = civv(x, y);
            ////cerr << " " << i << " " << count_above(thresh, i) << " ABOVE " << thresh << " :: " << y << endl;
            leq += count_above(thresh, i);
        } else if (y > 0) {
            ll thresh = divv(x, y);
            ////cerr << " " << i << " " << count_below(thresh, i) << " BELOW " << thresh << endl;
            leq += count_below(thresh, i);
        }
    }
    return leq;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k;
    for (int i=1; i<=n; ++i) {
        ll x;
        cin >> x;
        a.push_back(x);
        if (x>=0) {
            pos.push_back(x);
        } else {
            neg.push_back(x);
        }
    }
    a.push_back(-1e18-1e17);
    a.push_back(1e18+1e17);
    sort(a.begin(), a.end());
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

#ifdef DEBUG
    vector<ll> v;
    for (int i=1; i<=n; ++i) {
        for (int j=i+1; j<=n; ++j) {
            v.push_back(a[i]*a[j]);
        }
    }
    sort(v.begin(), v.end());
    for (int i=0; i<v.size(); ++i) {
        //cerr << " " << i << "  : " << v[i] << endl;
    }
#endif

    ll lo = -1e18, hi = 1e18;
    ll off = 1e18;
    lo += off;
    hi += off;
    while (lo < hi) {
        ll mid = (lo+hi)/2;
        ll ch = mid-off;
        ll leq = check(ch);
        //cerr << "GUESS " << ch << " GET " << leq << endl;
        if (leq >= k*2) {
            hi = mid;
        } else {
            lo = mid+1;
        }
    }

    lo -= off;
    cout << lo << "\n";
    
    return 0;
}

Measured memory_bytes: 4452