akhauriyash/Code-Regression huggingface dataset:
N,W,H = map(int,raw_input().split())
X,Y = [0]*(W+1),[0]*(H+1)
for loop in xrange(N):
    x,y,w = map(int,raw_input().split())
    X[max(0,x-w)] += 1
    X[min(W,x+w)] += -1
    Y[max(0,y-w)] += 1
    Y[min(H,y+w)] += -1
for i in xrange(1,W+1): X[i] += X[i-1]
for i in xrange(1,H+1): Y[i] += Y[i-1]
print "Yes" if min(X[:-1]) > 0 or min(Y[:-1]) > 0 else "No"

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
int n;
vector<vector<int>> tree(200010);
vector<int> gp(200010);
vector<int> parent(200010);
vector<set<int>> ntree(200010);
vector<int> color(200010);
int main(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 or w == 1){
        cout << 1 << endl;
    }
    else{cout << h * w / 2 + (h * w) % 2 << endl;}
    return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    int b;
    int c=1;
    cin>>a;
    for(int i=0;i<a;i++){
	cin>>b;
	if(b%2==0){
	    if(b%3!=0&&b%5!=0) c=0;
	}
    }
    if(c) cout<<"APPROVED";
    else cout<<"DENIED";
    cout<<"\n";
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;


mint comb(int32 n, int32 r){
  mint res = 1;
  r = min(r, n - r);
  REP(i,r){
    res *= (n-i);
    res /= (mint)(i+1);
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,a,b;
  cin >> n >> a >> b;

  mint ans = mint(2).pow(n) - 1;
  ans -= comb(n,a);
  ans -= comb(n,b);
  ANS(ans);
  return 0;
}

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


void solve(long long N){
    if (N%2==0)printf("%lld\n",N/2);
    else printf("%lld\n",N/2+1);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%s", $s);
    $array = str_split($s);
    $count = 0;
    for($i = 0; $i < count($array); $i ++){
      if($array[$i] == 1){
        $count += 1;
      }
    }
    echo $count;
  ?>

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

// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n){
  vector<pair<ll, ll>> res;
  for(ll p = 2; p * p <= n; p++){
    if(n % p != 0) continue;
    int num = 0;
    while(n % p == 0){ num++; n /= p;}
    res.push_back(make_pair(p, num));
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(){
  int n, m;
  COMinit();
  cin >> n >> m;
  auto v = prime_factorize(m);
  ll res = 1;
  for(auto &e : v){
    int k = e.second;
    res = (res * COM(n + k - 1, k)) % MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;

  if (k > (n - 1) * (n - 2) / 2)
  {
    cout << -1 << endl;
    return 0;
  }

  bool graph[110][110] = {};
  for (int i = 0; i < n; ++i)
  {
    graph[0][i] = graph[i][0] = true;
  }
  int res = (n - 1) * (n - 2) / 2 - k;
  cout << n - 1 + res << endl;

  for (int i = 1; i < n - 1; ++i)
  {
    if (res == 0)
      break;
    for (int j = i + 1; j < n; ++j)
    {
      if (res == 0)
        break;
      graph[i][j] = graph[j][i] = true;
      res--;
    }
  }

  for (int i = 0; i < n - 1; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      if (graph[i][j])
        cout << i + 1 << ' ' << j + 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		List<Integer> numbers = new ArrayList<Integer>();
		Scanner scan = new Scanner(System.in);
		for(;;){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			numbers.add(n);
		}

		int i = 0;
		for(Integer n : numbers){
			System.out.printf("Case %d: %d\n", ++i, n);
		}
	}
}

Measured memory_bytes: 67520
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>

using namespace std;


int main(int argc, const char * argv[]) {

    int N, K;
	cin >> N >> K;
  	char s[N];
    cin >> s;
    s[K-1] += 0x20;
  	cout << s <<endl;
    return 0;
}

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

class Timer {
	std::chrono::high_resolution_clock::time_point m_start;
public:
	Timer() 
	: m_start(std::chrono::high_resolution_clock::now()) {}

	~Timer() {
		auto end = std::chrono::high_resolution_clock::now();
  		auto duration_s = std::chrono::duration<double>(end - m_start).count();
  		cerr << "Completed in " << duration_s << endl;
  	}
};

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; }
	template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); }
	template < class c, class b > debug & operator <<(pair < b, c > d) {
	  return * this << "(" << d.first << ", " << d.second << ")";
	}
	template < class c > debug & operator <<(rge<c> d) {
	  *this << "[";
	  for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
	  return * this << "]";
	}
#else
	template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#include <iostream>

void solve() {
	ll n;
	cin >> n;
	vector<int> p(n);
	unordered_map<int, int> mp;

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

	ll sum = 0;

	if (is_sorted(p.begin(), p.end()) || is_sorted(p.rbegin(), p.rend())) {
		cout << n*(n - 1)*(2*n - 1)/6 << endl;
		return;
	}

	Timer timer;
	for (int i = 0; i < n; ++i) {
		ll a = 0, b = 0, c = 0, d = 0;
		bool ar = false, dr = false;
		int counter = i;
		while (--counter >= 0) {
			if (p[counter] > p[i]) {
				ar = true;
				break;
			}
			++a;
		}
		while (--counter >= 0) {
			if (p[counter] > p[i]) {
				break;
			}
			++b;
		}
		counter = i;
		while (++counter < n) {
			if (p[counter] > p[i]) {
				dr = true;
				break;
			}
			++c;
		}
		while (++counter < n) {
			if (p[counter] > p[i]) {
				break;
			}
			++d;
		}
		if (ar) {
			sum += (b+1)*(c+1) * ll(p[i]);
		}
		if (dr) {
			sum += (a+1)*(d+1) * ll(p[i]);
		}
	}

	

	cout << sum << endl;
	
}

int main() {
	FAST
	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i) {
		solve();
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e6+20;
const int M=1<<20;
ll n,a[N];
//µÚÒ»²¿·ÖS1µÄ·¶Î§Îª[n,2*n],Ã¶¾Ù¶Ïµãx ´¦Àí³öÇ°x¸öÑ¡n¸ö×î´óÖµ,ºó3n-x¸öÑ¡n¸ö×îÐ¡Öµ
//ÓÃÓÅÏÈ¶ÓÁÐÎ¬»¤¸öÊýÎªx¸öÖÐÇ°n´óµÄÊý Ô¤´¦Àí¼´¿É  
ll f[N],h[N];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll> p; 
int main()
{
	while(cin>>n)
	{
		ll ans=-2e17;
		for(int i=1;i<=3*n;i++)
			scanf("%I64d",&a[i]);
		
		ll s=0,mn=0;
		while(!p.empty())
			p.pop();
		while(!q.empty())
			q.pop();
		
		for(int i=1;i<=n;i++)
			q.push(a[i]),s+=a[i];
		f[1]=s;
		for(int i=n+1;i<=2*n;i++)
		{
			ll t=q.top();
			if(t<a[i])
				q.pop(),q.push(a[i]),s-=t,s+=a[i];
			f[i-n+1]=s;
		}		
		
		reverse(a+1,a+1+3*n);
		for(int i=1;i<=n;i++)
			p.push(a[i]),mn+=a[i];
		h[1]=mn;
		for(int i=n+1;i<=2*n;i++)
		{
			ll t=p.top();
			if(t>a[i])
				p.pop(),p.push(a[i]),mn-=t,mn+=a[i];
			h[i-n+1]=mn;
		}
		
		for(int i=n;i<=2*n;i++)
		{
	
			//[1~i] [i+1,3*n] ·Ö±ðÔ¤´¦Àí×îÖµ n<=1e3
			//n->1 ,3*n-i
			ans=max(f[i-n+1]-h[3*n-i-n+1],ans);
		}	
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 10868
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, i;
    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        int x=i;
        if (x%3==0) {
            printf(" %d", i);
            continue;
        }
        while (x>1) {
            if (x%10==3) {
                printf(" %d", i);
                break;
            }
            x/=10;
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int A[2][100];

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }

    int max = 0;
    for(int i = 0; i < N; i++)
    {
        int sum = 0;
        for(int j = 0, row = 0; j < N; j++)
        {
            sum += A[row][j];
            if(i==j)
            {
                row = 1;
                sum += A[row][j];
            }
        }

        if(max < sum)
        {
            max = sum;
        }

    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc075A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if (A == B)
                Console.WriteLine(C);
            else if (A == C)
                Console.WriteLine(B);
            else
                Console.WriteLine(A);
        }
    }
}


Measured memory_bytes: 13140
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


ll sum(ll mid2, const vector<ll>& vec)
{
    ll r = 0;
    rep(i, vec.size()) {
        r += (vec[i] * 2 + mid2 - 1) / mid2;
    }
    return r;
}

int main()
{
    ll n, k;
    cin >> n >> k; k += n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll left2 = 0 * 2, right2 = 1000000001 * 2;
    while (right2 - left2 > 1) {
        ll mid2 = (left2 + right2) / 2;
        ll s = sum(mid2, a);
        if (s > k) {
            left2 = mid2;
        } else {
            right2 = mid2;
        }
    }
    if (left2 == 0) {
        cout << "1" << endl;
    } else if (sum(left2, a) <= k) {
        cout << (left2 + 1) / 2 << endl;
    } else {
        cout << (right2 + 1) / 2 << endl;
    }
    return 0;
}


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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int>v(M);
  for(int i = 0; i < M; i++){
    cin >> v.at(i);
  }
  
  int count = 0;
  for(int i = 0; i < N; i++){
    int tmp_val = 0;
    for(int j = 0; j < M; j++){
      int tmp;
      cin >> tmp;
      tmp_val += tmp * v.at(j);
    }
    if(tmp_val + C > 0){
      count++;
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

map<string, int>dp;
int dir[4] = {1, -1, 4, -4};

void Swap(char &p, char &q)
{
	char t = q;
	q = p;
	p = t;
}

void bfs()
{
	int i, x, q;
	queue<string>que;
	que.push("01234567");
	dp["01234567"] = 0;
	while (!que.empty())
	{
		string p = que.front();
		que.pop();
		for (x = 0; x < 8; x++)
			if (p[x] == '0')
				break;
		for (i = 0; i < 4; i++)
		{
			q = x + dir[i];
			if (q >= 0 && q < 8 && !(x == 3 && i == 0) && !(x == 4 && i == 1))
			{
				string pp = p;
				Swap(pp[q], pp[x]);				
				if (dp.find(pp) == dp.end())
				{
					dp[pp] = dp[p] + 1;
					que.push(pp);
				}
			}
		}
	}
}

int main()
{
	bfs();
	string ss;
	char s[100];
	int i, j;
	while (gets(s) != NULL)
	{
		for (i = j = 0; s[i]; i++)
			if (s[i] >= '0' && s[i] <= '9')
				ss = ss + s[i];
		printf("%d\n", dp[ss]);
		ss.erase(ss.begin(), ss.end());
	}
	return 0;
}

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

using namespace std;

int main(){
    int k;
    string s;
    vector <string> V;

    cin >> s >> k;
    for(int i = 0; i < s.length(); i++){
        string temp;
        for(int j = i; j < s.length() && j < i + k; j++){
            temp += s[j];
            V.push_back(temp);
        }
    }
    sort(V.begin(), V.end());
    V.erase(unique(V.begin(), V.end()), V.end());
    cout << V[k-1] << endl;
    return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,ans=0,x;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            if(!(i%2) && x%2)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];

    string ans = "APPROVED";
    for (int i = 0; i < n; ++i)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
            {
                ans = "APPROVED";
            }
            else
            {
                ans = "DENIED";
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] h = in.nextIntArray(n);

            Arrays.sort(h);

            int d = h[k - 1] - h[0];
            for (int i = 1; i <= n - k; i++)
                d = Math.min(h[i + k - 1] - h[i], d);

            out.println(d);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}



Measured memory_bytes: 26516
N,Q=gets.split.map(&:to_i)
S=gets.chomp
lrs=$<.read.split.map(&:to_i).each_slice(2)

ps = []
pos = 0
while pos = S.index('AC',pos)
    ps << pos+1
    pos += 1
end
ps << 10**6

lrs.each do |l,r|
    i = ps.bsearch_index {|p| l <= p}
    unless i
        puts 0
        next
    end
    j = ps.bsearch_index {|p| r < p+1}
    puts j-i
end



Measured memory_bytes: 20220
#include <iostream>

using namespace std;

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

signed main() {
  int n;
  cin >> n;
  int s[n];
  rep(i,n) {
    char c;
    cin >> c;
    if(c == 'R') s[i] = 0;
    if(c == 'G') s[i] = 1;
    if(c == 'B') s[i] = 2;
  }
 
  int r[3][n+1];
  rep(i,3) rep(j,n+1) r[i][j] = 0;
  rep(i,3) rep(j,n) if(i == s[j]) r[i][j]++;
  rep(i,3) rep(j,n) r[i][n-1-j] = r[i][n-1-j] + r[i][n-j];
 
  int w = 0;
  rep(i,n) rep(j0,n-i-1) {
    int j = j0 + i + 1;
    if(s[i] != s[j]) {
      int k = 3 - s[i] - s[j], l = 2 * j - i;
      w += r[k][j+1];
      if(l < n && k == s[l]) w -= 1;
    }
  }
  cout << w << endl;
  return 0;
}

Measured memory_bytes: 3272
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int a = 0,b = 0;
		double x = 0;

		a = sc.nextInt();
		b = sc.nextInt();

		x = a * b;
		x = x % 2;

		if(x == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}

	}
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int arr[4];

long double dp[302][302][302];

int n;

long double func(int x, int y, int z)
{
	if(x<0 || y<0 || z<0) return 0;
	if(x+y+z == 0) return 0;
	if(dp[x][y][z]!=-1) return dp[x][y][z];
	dp[x][y][z]=n/(x+y+z+0.0);
	dp[x][y][z]+=(x/(x+y+z+0.0))*func(x-1,y,z);
	dp[x][y][z]+=(y/(x+y+z+0.0))*func(x+1,y-1,z);
	dp[x][y][z]+=(z/(x+y+z+0.0))*func(x,y+1,z-1);
	return dp[x][y][z];
}

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase;
	for(int i=0;i<=300;i++)
		for(int j=0;j<=300;j++)
			for(int k=0;k<=300;k++)
				dp[i][j][k]=-1;
	//cin >> tt;
	rep(tcase,1,tt)
	{
		cin >> n;
		for(int i=0;i<n;i++)
		{
			int val; cin >> val;
			arr[val]++;
		}
		cout << setprecision(10) << fixed << func(arr[1], arr[2], arr[3]) << "\n";
	}
	return 0;
}


Measured memory_bytes: 430336
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int n, m;
const int maxN = 305;
vector < pair < int, int > > f[maxN];
int dp[maxN][maxN];
int ndp[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        f[r].emplace_back(l, x);
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int a = 0; a <= i; a++) {
            for (int b = 0; b <= i; b++) {
                if (!dp[a][b]) continue;
                //add this
                ndp[a][b] = sum(ndp[a][b], dp[a][b]);
                // add a
                ndp[i][b] = sum(ndp[i][b], dp[a][b]);
                // add b
                ndp[a][i] = sum(ndp[a][i], dp[a][b]);
            }
        }
        for (int a = 0; a <= i; a++) {
            for (int b = 0; b <= i; b++) {
                if (!ndp[a][b]) continue;
                bool ok = true;
                for (auto it : f[i + 1]) {
                    int cnt = 1;
                    if (a >= it.first) cnt++;
                    if (b >= it.first) cnt++;
                    if (cnt != it.second) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) ndp[a][b] = 0;
            }
        }
        for (int a = 0; a <= i; a++) {
            for (int b = 0; b <= i; b++) {
                dp[a][b] = ndp[a][b];
                ndp[a][b] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            ans = sum(ans, dp[i][j]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split();
        //int input=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        Console.WriteLine(input[0][input[0].Length-1]==input[1][0]&&input[1][input[1].Length-1]==input[2][0]?"YES":"NO");
        Console.ReadLine();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  ll a[n+2];
  a[0]=a[n+1]=0;
  rep(i,n)cin>>a[i+1];
  ll sum=0;
  rep(i,n+1)sum+=abs(a[i+1]-a[i]);
  rep(i,n){
    ll dist=sum;
    dist-=(abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]));
    dist+=abs(a[i+2]-a[i]);
    cout<<dist<<"\n";
    }
  return 0;
  }

Measured memory_bytes: 2048
n, a, b = map(int, input().split())
s = input()

passed = 0
limit = a+b
b_rank = 1

ans_list = []
for w in s:
    if w == 'a':
        if passed < limit:
            ans_list.append('Yes')
            passed += 1
        else:
            ans_list.append('No')
    elif w == 'b':
        if passed < limit and b_rank <= b:
            ans_list.append('Yes')
            passed += 1
        else:
            ans_list.append('No')
        b_rank += 1
    else:
        ans_list.append('No')

for i in ans_list:
    print(i)

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

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (auto &i : a) cin >> i;

    long long ans = accumulate(a.begin(), a.end(), 0);
    cout << ans - n;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, z, w; cin >> n >> z >> w;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  if (n == 1) cout << abs(arr[0] - w) << endl;
  else cout << max(abs(arr[n-1] - arr[n-2]), abs(arr[n-1] - w)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;


ll check(ll a[],ll n,ll k,ll mid)
{
    ll i,j;
    ll res=0;
    for(i=0;i<n;i++)
    {
        res+=(((a[i]+mid-1)/mid)-1); 
    }
    if(res<=k)
    {
        return 1;
    }
    return 0;
}

void solve()
{
    ll n,k;
    ll i,j;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll maxi = *max_element(a,a+n);
    
    ll l=1,r=maxi;
    ll ans=maxi;
    while(l<r)
    {
        ll mid = l+(r-l)/2;
        
        if(check(a,n,k,mid))
        {
            ans=min(ans,mid);
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    cout<<ans<<"\n";

    

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5164
r, D ,x2000 = map(int,input().split())

def calc(r,d,x,i):    
    x_n = r*x-d
    print(x_n)
    if i == 9:    
        return 1
    else:
        return calc(r, d, x_n,i+1)


calc(r,D,x2000,0)
    

Measured memory_bytes: 38256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> II;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int r = -1, c, k;
		cin >> r >> c >> k;
		if (r < 0) return 0;
		map<II, LL> m;
		for (LL i = 0; i < k; ++i) {
			int a, b, c;
			cin >> a >> b >> c;
			m[II(a, b)] = c;
		}
		vector<vector<vector<LL>>> dp(2, vector<vector<LL>>(c + 1, vector<LL>(4)));
		for (int i = 1; i <= r; ++i) {
			int curr = i & 1, prev = curr ^ 1;
			for (int j = 1; j <= c; ++j) {
				dp[curr][j] = dp[curr][j - 1];
				dp[curr][j][0] = max(dp[curr][j][0], *max_element(dp[prev][j].begin(), dp[prev][j].end()));
				II key(i, j);
				if (m.find(key) != m.end()) {
					for (int k = 3; k > 0; --k) {
						dp[curr][j][k] = max(dp[curr][j][k], dp[curr][j][k - 1] + m[key]);
					}
				}
			}
		}
		LL ans = *max_element(dp[r & 1][c].begin(), dp[r & 1][c].end());
		cout << ans << endl;
	}
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int N, W;
int w[110], v[110];
//dp[i][j]:=i番目の品物を見て，重さがjのときの価値の最大値
ll dp[110][100010];

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

  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if (j+w[i+1] <= W)
        dp[i+1][j+w[i+1]] = max(dp[i+1][j+w[i+1]], dp[i][j] + v[i+1]);
    }
  }

  ll ans = 0;
  for (int i = 0; i <= W; i++) {
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79360
int main(){
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(32);
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(10);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, M;
int L[201010], R[201010];
ll D[201010];

int inedge[101010];
vector<pair<int, ll>> edge[101010];
ll c[101010];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N>>M;

    REP(i,0,M){
        cin>>L[i]>>R[i]>>D[i];
        inedge[R[i]-1]++;
        edge[L[i]-1].push_back(make_pair(R[i]-1, D[i]));
    }

    int cnt = M;
    set<int> st;
    REP(i,0,N){
        if(inedge[i] == 0) st.insert(i);
    }

    REP(i,0,N) c[i] = -1;

    while(!st.empty()){
        int n = *st.begin();
        st.erase(n);

        REP(i,0,edge[n].size()){
            cnt--;
            inedge[edge[n][i].first]--;

//            if(c[edge[n][i].first] != -1 && c[n]+edge[n][i].second != c[edge[n][i].first]){
//                cout<<"No"<<endl;
//                return 0;
//            }
            if(c[n] == -1) c[n] = 0;
            if(c[edge[n][i].first] != -1 ){
                if(c[n]+edge[n][i].second != c[edge[n][i].first]){
                    cout<<"No"<<endl;
                    return 0;
                }
            }else{
                c[edge[n][i].first] = c[n]+edge[n][i].second;
            }

            if(inedge[edge[n][i].first] == 0) st.insert(edge[n][i].first);

        }
    }

    if(cnt == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main(){
	int N;
	int tmp;
	vector<pair<int, int> >stu;
	cin>>N;
	for(int i=1; i<=N; i++){
		cin>>tmp;
		stu.push_back({tmp, i});
	}
	sort(stu.begin(), stu.end());
	for(auto p : stu){
		cout<<p.second<<" ";
	}
	return 0;
}

Measured memory_bytes: 1780
#include <algorithm>
#include <cstdio>

using namespace std;

long long n, list[200005], ps[200005], sf[200005], ans, a, b, l, r;

int main() {
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &list[i]);	
	}
	for(int i = 1; i <= n; i++) {
		ps[i] = ps[i - 1] + list[i];
	}
	for(int i = n; i >= 1; i--) {
		sf[i] = sf[i + 1] + list[i];
	}
	ans = 2000000001;
	for(int i = 1; i < n; i++) {
		ans = min(ans, abs(ps[i] - sf[i + 1]));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int a,b,c;
  string S;
  int d=0;
  int e=0;
  int i=0;
  cin>>a>>b>>c>>S;
  
  for(int i = 0; i <a; i++){
        switch(S[i]){
            case 'a' :
                if(d<b+c){
                    cout << "Yes" << endl;
                    d++;
                }
                else cout << "No" << endl;
                break;
            case 'b' :
                if(d<b+c&&e<c){
                    cout << "Yes" << endl;
                    d++;
                    e++;
                }
                else cout << "No" << endl;
                break;
            case 'c' :
                cout << "No" << endl;
                break;
 
        }
    }
 

  }

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	ll money = 1000;
	ll stock = 0;
	for (ll i = 0; i < n; i++) {
		money += a[i] * stock;
		stock = 0;
		if (i != n - 1) {
			if (a[i] < a[i + 1]) {
				stock = money / a[i];
				money = money % a[i];
			}
		}
	}
	cout << money << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

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

                if ((s[0] == s[1] && s[1] == s[2]) ||
                        (s[1] == s[2] && s[2] == s[3])) {
                        cout << "Yes" << endl;
                }
                else cout << "No" << endl;



}


Measured memory_bytes: 256
module Main where
--import Debug.Trace
import Data.List
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: Int -> [[Int]] -> [String]
solve cols = iterR (replicate cols 0) where
    iterR s []     = [edit s]
    iterR s (r:rs) = (edit r): iterR (sumCol s r) rs where
        sumCol [] [] = []
        sumCol (x:xs) (y:ys) = (x + y):sumCol xs ys
    edit l = concat (map (\x -> show x ++ " ") l) ++ show (sum l)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n)))

main :: IO() 
main = do
    [r, c] <- readLine
    l <- readLines r
    mapM_ putStrLn (solve c l)



Measured memory_bytes: 6012
typedef long long ll;
main(){
  ll n, d;scanf("%lld %lld", &n, &d);
  ll c=0;
  for(ll i=0;i<n;i++) {
    ll a, b;scanf("%lld %lld", &a, &b);
    ll r = a*a + b*b;
    if(r<=d*d)c++;
  }
  printf("%lld\n", c);
}

Measured memory_bytes: 1680
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

typedef pair<int,int> P;

int dat[1<<20+2];
int low = 1<<19-1;

int q,lim;
int size;
map<int,int> num;
int rnum[400000];

void add(int x){
  num[x] = size;
  dat[size] = 0;
  rnum[size-low] = x;

  lim--;
  size++;

  int pos = size - 1;

  while(0 < pos){
    dat[pos]++;
    pos = (pos - 1) / 2;
  }
}

int find(int x){
  int pos = 0;

  while(pos < low){
    int left = pos * 2 + 1;
    int right = pos * 2 + 2;

    if(x <= dat[left]){
      pos = left;
    }
    else{
      x -= dat[left];
      pos = right;
    }
  }

  return pos;
}

void erase(int pos){
  lim++;

  while(0 < pos){
    dat[pos]--;
    pos = (pos - 1) / 2;
  }
}

int main(void){
  while(scanf("%d%d",&q,&lim),q||lim){
    memset(dat,0,sizeof(dat));
    memset(rnum,0,sizeof(rnum));
    num.clear();
    size = low;

    while(q--){
      int query,x;
      scanf("%d%d",&query,&x);

      if(query == 0){
        add(x);
        if(lim < 0){
          int pos = find(0);
          erase(pos);
        }
      }
      else if(query == 1){
        int pos = find(x);
        erase(pos);
      }
      else if(query == 2){
        int pos = find(x);
        printf("%d\n",rnum[pos-low]);
      }
      else if(query == 3){
        int pos = num[x];
        erase(pos);
      }
    }

    printf("end\n");
  }
}

Measured memory_bytes: 30000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int t = a+b;
    int h = a-b;
    int k = a*b;
    int s = max(t,h);
    if(k>=s)
    cout << k << endl;
    else 
    cout << s << endl;
}


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

int main(){
  int n,ans;
  cin >> n;
  n%2==0?ans=n/2:ans=n/2+1;
  cout <<ans << endl;
}


Measured memory_bytes: 3536
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        s:[usize;n]
    }
    let mut sv = s.iter().enumerate().collect::<Vec<_>>();
    sv.sort_by(|t1, t2| t1.1.partial_cmp(t2.1).unwrap());
    sv.iter()
        .map(|t| (t.0 + 1).to_string())
        .collect::<Vec<_>>()
        .join(" ")
}
test! {
    "3\n2 3 1" => "3 1 2",
    "5\n1 2 3 4 5" => "1 2 3 4 5",
    "8\n8 2 7 3 4 5 6 1" => "8 2 4 5 6 7 3 1",
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=210;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m,book[N],res;
int head[N],maxE; struct Edge{ int nxt,to; }e[N];
inline void Add(int u,int v) { e[++maxE].nxt=head[u]; head[u]=maxE; e[maxE].to=v; }
void DFS(int x,int st)
{
    if(st==n) { res++; return; }
    for(int i=head[x];i;i=e[i].nxt)
    {
        if(book[e[i].to]) continue;
        book[e[i].to]=1;
        DFS(e[i].to,st+1);
        book[e[i].to]=0;
    }
}
signed main()
{
    n=read(), m=read();
    for(ri int i=1;i<=m;i++)
    {
        int u,v;
        u=read(), v=read();
        Add(u,v), Add(v,u);
    }
    book[1]=1, DFS(1,1);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
真ん中さえ0にできれば
最低でもN+1)/2までとれそう
4
1001001
0110001
0111110
0000000

5
1001001
1110111
0001011
0010100
1101011
0010111
0001000
むりだなあ
5
1011101
0100001
0111110
0000000

3
101101
110001
001001
001110
000000

4
101101
010001
001111
000000

5
010011
001100 NG
1122=4まで？

4
101110
110000
111111
000000

1131 1+3=4

000011110 441=8?
5までならいける
端同士の和はとらない。
011110 141=5までいける

01010=11111=2じゃなくて3
00110
8
0101111010
1010000010
1101111100
0010000000
0001111111
1110000000

7までならいける
1114111
343まで減らせる

数字が違ってたら、入れ替える必要がある。max(k,n-k)
*/
int main(){
  string S; cin>>S;
  ll ssz=S.size(),ans=ssz;
  for(ll i=1; i<ssz; i++){
    if(S[i]!=S[i-1]){
      ll n=ssz-i;
      ans=min(ans,max(i,n));
    }
  }
  cout<<ans<<endl;
}

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

int main(int argc, char const *argv[])
{
	int a,b,c,d;
	while(cin>>a>>b>>c>>d,a)
	{
		int ans=0;
		while(a/b<c) a+=d,++ans;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  priority_queue<Pair> q;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    q.emplace(Pair(a, 1));
  }
  for (int64_t j = 0; j < M; ++j) {
    int64_t b, c;
    cin >> b >> c;
    q.emplace(Pair(c, b));
  }

  int64_t result = 0;
  while (!q.empty()) {
    const Pair p = q.top();
    q.pop();
    const int64_t card = p.first;
    const int64_t count = p.second;
    const int64_t counted = min(N, count);
    result += card * counted;
    N -= counted;
    if (N <= 0) {
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6512
#include <stdio.h>
#include <stdlib.h>
#define INF 100000000

void maxHeapify(int *,int,int);
void insert(int *,int,int);
void increasekey(int *,int,int);
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main()
{
  int A[2000001],key,H=0;
  char command[10];

  while(1){
    scanf("%s",command);
    //printf("%c",command[0]);
    if(command[0]=='i'){
      scanf("%d",&key);
      //printf("aaaaa");
      if(key>2000000000) exit(1);
      insert(A,H,key);
      H++;
    }
    else if(command[0]=='e' && command[1]=='x'){
      printf("%d\n",A[1]);
      A[1] = A[H]; //最後の数を根に持って来る
      H--; //最後の数を持って来たからサイズを減らす
      maxHeapify(A,H,1);
    }
    else break;
  }

  return 0;
}

void maxHeapify(int *A,int H,int i)
{
  int l,r,largest,t;
  
  l = left(i);
  r = right(i);
  //printf("/l=%d,r=%d\n",l,r);

  if(l<=H && A[l]>A[i]) largest = l; //親と左の子の比較
  else largest = i;
  if(r<=H && A[r]>A[largest]) largest = r; //親と右の子の比較
  if(largest != i){ //子が大きければ交換
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(A,H,largest); 
  }
}

void insert(int *A,int H,int key)
{
  H++; //サイズを上げる
  //A[H] = -INF; // 大きい負の数を入れることで後の判定をできるようにする
  increasekey(A,H,key);
}

void increasekey(int *A,int H,int key)
{
  int t;
  
  //if(key < A[H]) return; 
  A[H] = key;
  while(1){
    if(H<=1 || A[H/2] >=A[H]) break; // サイズがなくなるか、子が自分よりも大きいときは交換しない
    t = A[H];
    A[H] = A[H/2];
    A[H/2] = t;
    H = H/2; //自分の親に移動
  }
  
}



Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
// ll mod=1000000007;
// ld pi = 3.14159;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,t1,i,j,k,temp,temp2,n,m,x,y,z,sum=0,o;
    cin >> i >> j >> x >> y >> k;
    temp = (x-i)*60;
    temp2 = (y-j)+temp;
    cout << max(temp2-k,sum);
}


Measured memory_bytes: 3664