akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	vector<int> d(10),e(10);
	for(int i = 1;i<10;i++)
	{
		int now = i*2;
		int num = 2;
		int cnt = 1;
		while(now != i)
		{
			if(now>9)
			{
				now = now%10+now/10;
				cnt++;
				if(now==i)break;
			}
			now += i;
			num++;
			cnt++;
			if(now==i)break;
			if(now>9)
			{
				now = now%10+now/10;
				cnt++;
				
			}
		}
		//cout<<i << ' ' << num << ' ' << cnt<<endl;
		d[i]= num;
		e[i]= cnt;
		d[i]--;
	}
	d[0] = 1;
	e[0]=1;
	int n;
	cin >> n;
	ll ans = 0;
	int now = 0;
	map<ll,ll> mp;
	for(int i = 0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		mp[x] += y;
	}
	for(int i = 0;i<10;i++)
	{
		if(mp[i]>0)
		{
			mp[i]--;
			ans += mp[i]/d[i]*e[i];
			//cout << mp[i]<<endl;
			//cout<< "ans" << ans << endl;
			//cout << d[i] <<';'<< e[i]<<endl;;
			mp[i]%=d[i];
			mp[i]++;
			for(int j = 0;j<mp[i];j++)
			{
				now += i;
				ans++;
				if(now>9)
				{
					now = now/10+now%10;
					ans++;
				}
			}
		}
	}
	cout << ans -1<< endl;

}


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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    constexpr ll MOD = 1e9 + 7;

    cout << setprecision(16) << fixed;

    ll n;
    cin >> n;
    vector<ll> dp(1<<n, 1);
    for(ll i=0; i<n; i++) {
        vector<ll> pre(1<<n);
        swap(pre, dp);

        vector<ll> a(n);
        for(auto &e: a) cin >> e;
        for(ll k=0; k<n; k++) {
            if(!a[k]) continue;
            for(ll j=0; j<1<<n; j++) {
                if(~(j>>k)&1) continue;
                (dp[j] += pre[j & ~(1<<k)]) %= MOD;
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
}


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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)cin >> i.first >> i.second;
        sort(p.begin(), p.end());
        iota(perm.begin(), perm.end(), 0UL);
        sort(perm.begin(), perm.end(), [&p](auto i, auto j){return p[i].second < p[j].second;});
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    binary[0] = 1;
    for(unsigned long i = 0; i < N; ++i)binary[i + 1] = binary[i] * 2 - (binary[i] > 499122176) * MOD;

    vector<unsigned long> fenwick_tree(N);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long r = i;
        unsigned long ret{fenwick_tree[i]};
        while(i &= i + 1)ret += fenwick_tree[--i];
        i = r;
        while(i < N){
            ++fenwick_tree[i];
            i |= i + 1;
        }
        return ret;
    };

    vector<unsigned long> coef(N + 1);
    for(unsigned long i = 0; i < N; ++i){
        auto q = que(perm[i]);
        ++coef[q];
        ++coef[i - q];
        ++coef[perm[i] - q];
        ++coef[N - i - perm[i] + q - 1];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), (N + MOD - 4) * (binary[N] - 1)) % MOD << endl;
    return 0;
}

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

const int MAX_N = 1500, MAX_M = 1500, MAX_W = 1000;
int roadV[MAX_N], roadH[MAX_M];
int widthV[MAX_N * MAX_W + 1];
int widthH[MAX_M * MAX_W + 1];

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

int main(int argc, char const* argv[])
{
    ios_base::sync_with_stdio(0);
    int n, m, i, j, sumV, sumH, cnt, minWidth;
    while (1) {
        cin >> n >> m;
        if (n == 0 and m == 0) break;
        sumV = 0;
        sumH = 0;
        for (i = 0; i < n; i++) {
            cin >> roadV[i];
            sumV += roadV[i];
        }
        for (i = 0 ; i < m; i++) {
            cin >> roadH[i];
            sumH += roadH[i];
        }
        minWidth = min(sumV, sumH);

        for (i = 1; i <= minWidth; i++) {
            widthV[i] = 0;
        }
        for (i = 1; i <= minWidth; i++) {
            widthH[i] = 0;
        }

        for (i = 0; i < n; i++) {
            sumV = 0;
            for (j = i; j < n; j++) {
                sumV += roadV[j];
                widthV[sumV]++;
            }
        }

        for (i = 0; i < m; i++) {
            sumH = 0;
            for (j = i; j < m; j++) {
                sumH += roadH[j];
                widthH[sumH]++;
            }
        }

        cnt = 0;
        for (i = 1; i <= minWidth; i++) {
            cnt += widthV[i] * widthH[i];
        }

        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 6980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    long l;

    cin >> l;
    double length = (double)l / 3;
    cout << fixed;
    cout << setprecision(12) << (length * length * length) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vl w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  vector<vl> dp(n + 1, vl(m + 1, 0));
  rep(i, n) rep(j, m + 1) {
    if(j >= w[i])
      dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    else
      dp[i + 1][j] = dp[i][j];
  }
  cout << dp[n][m] << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int len = S.length(), counter = 0;
    for (int i = 0; i < len / 2; i++)
    {
        if(S[i] != S[len-1-i]){
            counter += 1;
        }
    }

        cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{

  string s; cin >> s;
  string scomp = "abcdefghijklmnopqrstuvwxyz";
  auto ssize = s.size();
  set<char> t;
  REP(i,ssize){
   t.insert(s[i]);
  }
 
  int cnt = 0;
  for(auto itr = t.begin(); itr != t.end(); ++itr){
     if(scomp[cnt] != *itr){
      cout << scomp[cnt];
      return 0;
    }
    ++cnt;
  }
  auto itr = t.end();
  --itr;
  if(*itr != 'z')
    cout << 'z';
  else
  cout << "None";
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define ednl endl //* missspell check

void solve(long long N, long long H, long long W){
    cout << (N+1-H)*(N+1-W) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(N, H, W);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

const int N = 50000;

void solve() {
    int n, q;
    ll sum(0);
    vi x(pow(10, 5) + 1, 0);
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    cin >> q;
    vi b(q), c(q);
    for(int i = 0; i < q; ++i){
        cin >> b.at(i) >> c.at(i);
    }
    for(int i = 0; i < n; ++i){
        x.at(a.at(i)) += 1;
    }
    for(int i = 0; i < x.size(); ++i){
        sum += x.at(i) * i;
    }
    for(int i = 0; i < q; ++i){
        sum += (c.at(i) - b.at(i)) * x.at(b.at(i));
        x.at(c.at(i)) += x.at(b.at(i));
        x.at(b.at(i)) = 0;
        cout << sum << nl;
    }
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-5

vector<pair<double, double>> intersection(double x0, double y0, double r0, double x1, double y1, double r1){
	double d = hypot(x1 - x0, y1 - y0);
	vector<pair<double, double>> ans(0);
	if(d > r0 + r1 || r1 > r0 + d || r0 > r1 + d){
		return ans;
	}
	double x = x1 - x0, y = y1 - y0;
	double x2_y2 = x * x + y * y;
	double a = (x2_y2 + r0 * r0 - r1 * r1) / 2;
	double c = sqrt(x2_y2 * r0 * r0 - a * a);
	ans.push_back(make_pair((a * x + y * c) / x2_y2 + x0, (a * y - x * c) / x2_y2 + y0));
	ans.push_back(make_pair((a * x - y * c) / x2_y2 + x0, (a * y + x * c) / x2_y2 + y0));
	return ans;
}

int overlap(int N, vector<double> &x, vector<double> &y, vector<double> &c, double T){
//	printf("T = %.10lf\n", T);
	vector<pair<double, double>> cand(N);
	int i, j, k, ans = 0;
	for(i = 0; i < N; i++){
		cand[i] = make_pair(x[i], y[i]);
	}
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
			vector<pair<double, double>> res = intersection(x[i], y[i], T / c[i], x[j], y[j], T / c[j]);
			for(k = 0; k < res.size(); k++){
				cand.push_back(res[k]);
			}
		}
	}
	for(i = 0; i < cand.size(); i++){
//		printf("cand[%d] = (%lf, %lf)\n", i, cand[i].first, cand[i].second);
		int now = 0;
		for(j = 0; j < N; j++){
			if(hypot(x[j] - cand[i].first, y[j] - cand[i].second) <= T / c[j] + eps){
				now++;
			}
		}
//		printf("now = %d\n", now);
		ans = max(ans, now);
	}
//	printf("ans = %d\n", ans);
	return ans;
}

int main(){
	int N, K, i;
	scanf("%d%d", &N, &K);
	vector<double> x(N), y(N), c(N);
	for(i = 0; i < N; i++){
		scanf("%lf%lf%lf", &x[i], &y[i], &c[i]);
	}
	double l = 0, h, r = 2000 * 100;
//	r = 5;
	for(i = 0; i < 50; i++){
		h = (l + r) / 2;
		if(overlap(N, x, y, c, h) >= K){
			r = h;
		}
		else{
			l = h;
		}
	}
	printf("%.10lf\n", h);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VP ans;
    if(n % 2 == 1) {
        rep(i, 1, n+1) {
            rep(j, 1, n+1) {
                if(i >= j) continue;
                if(i + j == n) continue;
                ans.push_back({i, j});
            }
        }
    }else{
        rep(i, 1, n+1) {
            rep(j, 1, n+1) {
                if(i >= j) continue;
                if(i + j == n+1) continue;
                ans.push_back({i, j});
            }
        }
    }
    cout << ans.size() << endl;
    for(auto e : ans) cout << e.first << " " << e.second << endl;
    return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int cnt = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        if ((500 * a + 100 * b + 50 * c) == X) ++cnt;
      }
    }
  }
  cout << cnt << endl;
}

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

typedef long long int ll;

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

	ll i,j,t,k,l,m,n,c,r,d;

	cin >> n;

	m = 0;
	for(i=1;i<=n;i++)
	{
		cin >> k;

		if(i%2 == 1)
		{
			if(k%2 == 1)
				m++;
		}

	}

	cout << m << '\n';

	
	

}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

const ll mod = 1e9 + 7;

int main(){
    ll n, k; cin >> n >> k;
    ll ans = 0;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, n){
        ll mm = lis[i];
        ll count1 = 0, count2 = 0;
        REP(l, i+1, n){
            if(mm > lis[l]){
                count1++;
            }
        }
        REP(l, 0, n){
            if(mm > lis[l]){
                count2++;
            }
        }
        ll mid = (k * k - (k*(k+1))/2) % mod;
        ans = (ans + ((count1*k) + (count2*mid)) % mod) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, s = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mod = 998244353

dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    dp[i][0] = i + 1
    for j in range(1, s + 1):
        if j >= a[i]:
            dp[i+1][j] += dp[i][j-a[i]]
        dp[i + 1][j] += dp[i][j]
        dp[i + 1][j] %= mod

ans = 0
for i in range(1, n + 1):
    ans += dp[i][-1] * 1#(n + 1 - i)
    ans %= mod
print(ans)


Measured memory_bytes: 112476
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " <<c;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string u = "URDL";
    vector<vector<pair<int, int>>> a(4);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        char c;
        cin >> c;
        for (int j = 0; j < 4; j++) {
            if (c == u[j]) {
                a[j].emplace_back(x, y);
            }
        }
    }
    int inf = 2e9;
    int ans = inf;
    auto cmp = [&](pair<int, int> x, pair<int, int> y) {
        if (x.first + x.second == y.first + y.second) {
            return x.second < y.second;
        }
        return x.first + x.second < y.first + y.second;
    };
    for (int loop = 0; loop < 4; loop++) {
        sort(a[2].begin(), a[2].end());
        for (int i = 0; i < a[0].size(); i++) {
            auto it = lower_bound(a[2].begin(), a[2].end(), a[0][i]);
            if (it == a[2].end()) {
                continue;
            }
            pair<int, int> p = *it;
            if (p.first == a[0][i].first) {
                ans = min(ans, 5 * (p.second - a[0][i].second));
            }
        }
        sort(a[1].begin(), a[1].end(), cmp);
        for (int i = 0; i < a[0].size(); i++) {
            auto it = lower_bound(a[1].begin(), a[1].end(), a[0][i], cmp);
            if (it == a[1].end()) {
                continue;
            }
            pair<int, int> p = *it;
            if (p.first + p.second == a[0][i].first + a[0][i].second) {
                ans = min(ans, 10 * (p.second - a[0][i].second));
            }
        }
        debug(a);
        for (int i = 0; i < 3; i++) {
            swap(a[i], a[i + 1]);
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < a[i].size(); j++) {
                a[i][j].second *= -1;
                swap(a[i][j].first, a[i][j].second);
            }
        }
    }
    cout << (ans == inf ? "SAFE" : to_string(ans)) << '\n';
    return 0;
}

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

int main() {
  long N;
  string A,B,C;
  cin>>N>>A>>B>>C;
  long ans=0;
  for(int i=0;i<N;i++){
    vector<long> a(26);
    a[A[i]-'a']++;
    a[B[i]-'a']++;
    a[C[i]-'a']++;
    sort(a.begin(),a.end());
    ans+=3-a[25];
  }
cout<<ans<<endl;
  }


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    string ans = "";
    rep(i, s.size()) {
        if (i % 2 == 0) ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main() {
  char c;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c;
      if (i == j) cout << c;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long H = scanner.nextLong();
        long N = scanner.nextLong();
        long total = 0;
        for (int i=0;i<N;i++)
        {
            total+=scanner.nextLong();
        }
        System.out.println(total<H?"No":"Yes");
    }
}

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

using namespace std;

const int N = 2e5 + 100;

queue<int> q;
vector<int> adj[N];
bool mark[N];
char a[N];
int d1[N], d2[N];
int n, m, cnt;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		adj[--v].push_back(--u);
		adj[u].push_back(v);
		(a[v] == 'A' ? d1[u]++ : d2[u]++);
		(a[u] == 'A' ? d1[v]++ : d2[v]++);
	}
	for (int i = 0; i < n; i++)
		if (!d1[i] || !d2[i]) {
			q.push(i);
			mark[i] = true;
		}
	cnt = n;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		cnt--;
		for (auto u : adj[v]) {
			(a[v] == 'A' ? d1[u]-- : d2[u]--);
			if ((!d1[u] || !d2[u]) && !mark[u]) {
				mark[u] = true;
				q.push(u);
			}
		}
	}
	return cout << (cnt ? "Yes" : "No"), 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
using ll = long long;
using namespace std;

#define NIL -2000000100

ll A[1000010], h;

inline void maxHeapify(ll id){
    ll left = id * 2, right = id * 2 + 1, largest;
    if(A[left] > A[right] && A[left] > A[id]){
        largest = left;
    }else if(A[right] > A[id]){
        largest = right;
    }else{
        largest = id;
    }
    if(largest != id){
        ll swapTmp;
        swapTmp = A[largest];
        A[largest] = A[id];
        A[id] = swapTmp;
        maxHeapify(largest);
    }
}

signed main(){
    cin >> h;
    REP(i, 1000010) A[i] = NIL;
    REP(i, (int)h) cin >> A[i + 1];
    for(ll ill = (int)h / 2; ill > 0; ill--){
        maxHeapify(ill);
    }
    FOR(i, 1, (int)h + 1){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 10836
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	ll A,B,C,D,E,F;

	cin>>A>>B>>C>>D>>E>>F;
	
	ll a_i = 0,b_i = 0,c_i = 0,d_i = 0;
	
	double max_noudo = -1;
	ll max_sugar = -1;
	ll max_water = -1;
	
	while(a_i * 100 * A < F){
		
		b_i = 0;
		ll water = (a_i * A + b_i * B) * 100;
		if(water == 0){
			b_i++;
			water = (a_i * A + b_i * B) * 100;

		}
		while(water < F){


			ll mod_F = F - water;
			c_i = 0;
			ll sup = (A * a_i + B * b_i) * E;
			while( (c_i * C <= mod_F) && (c_i * C <= sup) ){

				d_i = 0;
				ll sugar = c_i * C + d_i * D;
				while( (sugar <= mod_F) && (c_i * C + d_i * D <= sup) ){
					double noudo = double(100 * sugar) / double(water + sugar);
					if(noudo > max_noudo){
						max_noudo = noudo;
						max_sugar = sugar;
						max_water = water;
					}

					d_i++;
					sugar =  c_i * C + d_i * D;
				}

				c_i++;
			}

			b_i++;
			water = (a_i * A + b_i * B) * 100;
		}

		a_i++;
	}
	
	cout<<(max_water+max_sugar)<<" "<<max_sugar<<endl;

	
	return 0;
}


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



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

using namespace std;
string a;

int main(){
  cin >> a;
  if(a[0]==a[2]) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  return 0;
}


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

size_t N;

class solver {
public:
  solver(size_t size_)
      : cur(0), bests(vector<vector<long>>(size_ + 1, vector<long>(2, 0))),
        num_seq(vector<long>(size_ + 1, 0)) {
    bests[0][0] = 0;
    bests[0][1] = LONG_MIN;
  }

  void push_num(long num) {
    num_seq[cur + 1] = num;
    bests[cur + 1][0] = get_best(cur, 0);
    bests[cur + 1][1] = get_best(cur, 1);
    cur++;
  }

  long get_total(void) { return bests[bests.size() - 1][0]; }

protected:
  long get_best(size_t cur_, long flag) {
    if (cur_ == 0) {
      if (flag == 0)
        return num_seq[1];
      else
        return -num_seq[1];
    }

    if (flag == 0)
      return max(bests[cur][0] + num_seq[cur + 1],
                 bests[cur][1] - num_seq[cur + 1]);
    else
      return max(bests[cur][0] - num_seq[cur + 1],
                 bests[cur][1] + num_seq[cur + 1]);
  }

  size_t cur;
  vector<vector<long>> bests;
  vector<long> num_seq;
};

int main(void) {
  cin >> N;

  solver sol = solver(N);
  long num;

  for (long i = 0; i < N; i++) {
    cin >> num;
    sol.push_num(num);
  }

  cout << sol.get_total() << "\n";
  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
using namespace std;



int main()
{
    vector<int> vec(3);
    for(int i = 0; i < 3; i++) cin >> vec.at(i);

    sort(vec.begin(), vec.end());

    int sum = 0, ans = 0;
    for(int i = 0; i < 3; i++) sum += vec.at(i);

    if((vec.at(2) % 2) != (sum % 2)) vec.at(2)++;

    while((vec.at(1) != vec.at(2)))
    {
        if((vec.at(2) - vec.at(1)) % 2 == 0 and vec.at(1) != vec.at(2))
        {
            vec.at(1) += 2;
            ans++;
        }
        else if((vec.at(2) - vec.at(1)) % 2 == 1)
        {
            vec.at(1)++;
            vec.at(0)++;
            ans++;
        }
    }


    while((vec.at(1) != vec.at(0)))
    {
        if((vec.at(1) - vec.at(0)) % 2 == 0 and vec.at(1) != vec.at(0))
        {
            vec.at(0) += 2;
            ans++;
        }
        else if((vec.at(1) - vec.at(0)) % 2 == 1)
        {
            vec.at(0)++;
            ans++;
        }
    }

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

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

#define ll long long

const int MaxN(100003);

int n, tot;
ll a[MaxN], F[MaxN], Ans[MaxN], Tag[MaxN];

void solve(ll x, ll y)
{
	if(!x) return;
	int t = upper_bound(a + 1, a + 1 + tot, x) - a - 1;
	if(!t) Ans[x] += y;
	else F[t] += y * (x / a[t]), solve(x % a[t], y);
}

int main()
{
	int n, Q;
	scanf("%d%d", &n, &Q);
	a[++tot] = n;
	for(ll x; Q--; )
	{
		scanf("%lld", &x);
		while(tot && a[tot] >= x) --tot;
		a[++tot] = x;
	}
	F[tot] = 1;
	for(int i = tot; i > 1; i--)
	{
		F[i - 1] += F[i] * (a[i] / a[i - 1]);
		solve(a[i] % a[i - 1], F[i]);
	}
	Ans[a[1]] += F[1];
	for(int i = n; i; i--)
		Ans[i] += Ans[i + 1];
	for(int i = 1; i <= n; i++)
		printf("%lld\n", Ans[i]);
	return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int x;
    cin >> x;
    cout << x * x * x << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 40
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int32_t main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		long  A = sc.nextInt();
		long B = sc.nextInt();

		long ans = A*B/gcd(A, B);


		System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35812
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(a) < sum(b):
  print(-1)
  exit()
cnt = 0
ans = 0
d = []
for i in range(n):
  if a[i] < b[i]:
    ans += 1
    cnt += b[i] - a[i]
  else:
    d.append(a[i] - b[i])
if ans == 0:
  print(ans)
  exit()
d.sort(reverse=True)
for x in d:
  ans += 1
  cnt -= x
  if cnt <= 0:
    print(ans)
    break

Measured memory_bytes: 81328
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			long n = long.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			Console.WriteLine($"{array.Min()} {array.Max()} {array.Sum()}");
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18440
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>
#include <sstream>


using namespace std;

struct data {
	int x, y;
};

int main() {
	/*while (true) {
		int n, count = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 2; i < n; i++) {
			if (((n - i * (i + 1) / 2) >= 0)&&(((n - i * (i + 1) / 2) % i == 0))) count++;
		}
		cout << count << endl;
	}*/
	while (true) {
		int n, l, r;
		cin >> n >> l >> r;
		int a[51];
		if (n == 0) {
			break;
		}
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		int count = 0;
		bool flag = false;
		for (int i = l; i < r + 1; i++) {
			flag = false;
			for (int j = 1; j <= n; j++) {
				if (i % a[j] == 0) {
					if (j % 2 == 1) {
						count++;
						flag = true;
						break;
					}
					else{
						flag = true;
						break;
					}
				}
				/*if (i % a[j] == 0 && j % 2 == 1) {
					count++;
					break;
				}
				else if (i % a[j] != 0 && j % 2 == 0) {
					count++;
					break;
				}*/
			}
			if (flag == false) {
				if (n % 2 == 0) {
					count++;
				}
			}
		}
		cout << count << endl;

	}
	/*
	while (true) {
		int n;
		int a[405][405];
		int l = 200;
		int r = 200;
		int u = 200;
		int d = 200;
		cin >> n;
		struct data data[201];
		data[0] = 
		for (int i = 1; i < n; i++) {
		
		}
	}*/
}



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[300000];
int sum[300000];

int main(){
	int n,K;cin>>n>>K;
	rep(i,n)scanf("%d",&a[i]);
	rep(i,K){
		memset(sum,0,sizeof(sum));
		rep(j,n){
			int l=max(0,j-a[j]);
			sum[l]++;
			int r=min(n,j+a[j]+1);
			sum[r]--;
		}
		bool ok=false;
		rep(j,n){
			if(j)sum[j]+=sum[j-1];
			a[j]=sum[j];
			if(a[j]<n)ok=true;
		}
		if(!ok)break;
	}
	rep(i,n){
		if(i)cout<<' ';
		cout<<a[i];
	}
	cout<<endl;
}

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

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

    bool can = true;
    for (char c = 'a'; c <= 'z'; c++) {
        int cnt = count(s.begin(), s.end(), c);
        if (2 <= cnt && cnt <= s.size()) can = false;
    }
    if (can) cout << "yes" << endl;
    else cout << "no" << endl;
}

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

using namespace std;

#define ll              long long
#define mod             1000000007
#define inf             1e18
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    /**************************/
    
    int a;
    cin >> a;
    
    cout << a + a*a + a*a*a;

    /**************************/
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}




Measured memory_bytes: 3736
n,k = map(int,input().split())

mod_ls = [0] * k
for i in range(1,n+1):
    rest = i % k
    mod_ls[rest] += 1

ans = 0
for i in range(1,k):
    first = i
    second = k - i
    third = k - second
    if (first + third) % k == 0:
        ans += mod_ls[first] * mod_ls[second] * mod_ls[third]
ans += mod_ls[0] ** 3
print(ans)


Measured memory_bytes: 4596
#include<algorithm>
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,m,cnt,tot,ans;
const int N=100010,mod=1e9+7;
int tr[N],x[N],y[N],val[N];
struct ys
{
	int x,y;
	friend bool operator <(const ys &a,const ys &b)
		{return a.x==b.x?a.y>b.y:a.x>b.x;}
	friend bool operator ==(const ys &a,const ys &b)
		{return a.x==b.x&&a.y==b.y;}
}a[N];

int lowbit(int x){return x&(-x);}
void add(int pos,int val)
{
	for(;pos<=tot;pos+=lowbit(pos))(tr[pos]+=val)%=mod;
}
int ask(int pos)
{
	int res=0;
	for(;pos;pos-=lowbit(pos))(res+=tr[pos])%=mod;
	return res;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i)scanf("%d",&y[i]);
	for(int i=1;i<=m;++i)scanf("%d",&x[i]);
	for(int i=1,l,r;i<=n;++i)
		if(x[1]<y[i]&&y[i]<x[m])
		{
			r=lower_bound(x+1,x+1+m,y[i])-x;l=r-1;
			a[++cnt]=(ys){x[l]-y[i],x[r]-y[i]};
		}
	sort(a+1,a+1+cnt);cnt=unique(a+1,a+1+cnt)-a-1;
	for(int i=1;i<=cnt;++i)val[++tot]=a[i].y;
	sort(val+1,val+1+tot);tot=unique(val+1,val+1+tot)-val-1;
	for(int i=1;i<=cnt;++i)a[i].y=lower_bound(val+1,val+1+tot,a[i].y)-val;
	for(int i=1,t;i<=cnt;++i)
	{
		t=(ask(a[i].y-1)+1)%mod;
		(ans+=t)%=mod;
		add(a[i].y,t);
	}
	cout<<(ans+1)%mod;
	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>

struct Card{
  char suit;
  char value;
};


void BubbleSort(struct Card *A, int length) {

  int i,j;
  char tmp;
  char tmp_1;

  for(i=0;i<length;i++){
    for(j=length-1;j>i;j--) {
      if(A[j].value<A[j-1].value) {

	tmp=A[j].value;
	tmp_1=A[j].suit;

	A[j].value=A[j-1].value;
	A[j].suit=A[j-1].suit;

	A[j-1].value=tmp;
	A[j-1].suit=tmp_1;

      }
    }
  }
}

void SelectionSort(struct Card *A,int length) {

  int i,j,mini;
  char tmp;
  char tmp_1;

  for(i=0;i<length;i++) {
    mini=i;
    for(j=i;j<length;j++) {
      if(A[j].value<A[mini].value) {
	mini=j;
      }
    }
    if(i!=mini) {
    tmp=A[i].value;
    tmp_1=A[i].suit;

    A[i].value=A[mini].value;
    A[i].suit=A[mini].suit;

    A[mini].value=tmp;
    A[mini].suit=tmp_1;

    }
  }
}



int main(){
  struct Card C1[101],C2[101];
  char table[9][4]={};
  int cnt[9]={};

  int n, i,j,flg=0;
  char ch;

  scanf("%d%c",&n,&ch);
  for (i=0;i<n;i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
    table[C1[i].value-'1'][cnt[C1[i].value-'1']]=C1[i].suit;
    cnt[C1[i].value-'1']++;
  }
  for(i=0;i<n;i++) {

    C2[i].suit=C1[i].suit;
    C2[i].value=C1[i].value;
  }

  BubbleSort(C1,n);
  SelectionSort(C2,n);


  for(i=0;i<9;i++)cnt[i]=0;

  if(table[C1[0].value-'1'][cnt[C1[0].value-'1']++]!=C1[0].suit)
    {
      flg=1;
    }
  printf("%c%c",C1[0].suit,C1[0].value);
  for(i=1;i<n;i++) {
  if(table[C1[i].value-'1'][cnt[C1[i].value-'1']++]!=C1[i].suit)
    {
      flg=1;
    }
  printf(" %c%c", C1[i].suit,C1[i].value);
  }

  if(flg==0)
    printf("\nStable\n");
  else
    printf("\nNot stable\n");

  for(i=0;i<9;i++)cnt[i]=0;
  flg=0;

  if(table[C2[0].value-'1'][cnt[C2[0].value-'1']++]!=C2[0].suit)
    {
      flg=1;
    }


 printf("%c%c",C2[0].suit,C2[0].value);
  for(i=1;i<n;i++) {
  if(table[C1[i].value-'1'][cnt[C1[i].value-'1']++]!=C2[i].suit)
    {
      flg=1;
    }
  printf(" %c%c",C2[i].suit,C2[i].value);
  }

  if(flg==0)
    printf("\nStable\n");
  else
    printf("\nNot stable\n");

  return 0;
}

Measured memory_bytes: 608
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	map<string, ll> a;
	for (int i = 0; i < n; i++)
	{
		int q;
		cin >> q;

		string s;
		

		switch (q)
		{
			case 0:
				cin >> s;

				ll x;
				cin >> x;
				a[s] = x;
				break;

			case 1:
				cin >> s;

				if (a.count(s))
				{
					println(a[s]);
				}
				else
				{
					println(0);
				}
				break;

			case 2:
				cin >> s;

				if (a.count(s))
				{
					a.erase(s);
				}
				break;

			case 3:
				string l, r;
				cin >> l >> r;

				for (auto it = a.equal_range(l).first; it != a.equal_range(r).second; it++)
				{
					println(it->first << " " << it->second);
				}
				break;
		}
	}
}




Measured memory_bytes: 27752
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define N 200003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};

// ll dx[] = {1, -1, 0, 0};
// ll dy[] = {0, 0, 1, -1};
ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}

// bool check(ll i, ll j)
// {
//     if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != '#')
//         return true;
//     return false;
// }

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        string s;
        cin >> s;
        ll x = 0;
        REP(i, 0, s.size())
        x += s[i] - '0';
        if (x % 9 == 0) cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int X;cin>>X;
  if(X<100){
    cout<<0<<endl;
  }else if(2100<=X){
    cout<<1<<endl;
  }else{
    int tmp=X/100;
    if(tmp*100<=X&&X<=tmp*105){
      cout<<1<<endl;
    }else{
      cout<<0<<endl;
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#include <numeric>

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K;
  cin >> K;

  int r = 0;

  // 

  FOR(i, 1, K + 1) {

    FOR(j, 1, K + 1) {

      u8 a = std::gcd(i, j);

      FOR(k, 1, K + 1) {
        r += std::gcd(a, k);
      }
    }
  }

  cout << r;

}
#endif

Measured memory_bytes: 3652
import sys,heapq
_,a,q=[[-int(e) for e in sys.stdin.readline().split() if e!='0'] for _ in[0]*3]
heapq.heapify(q)
for e in a:
	t=[]
	for _ in [0]*-e:
		if not q:print(0);exit()
		if q[0]!=-1:heapq.heappush(t,q[0]+1)
		heapq.heappop(q)
	while t:heapq.heappush(q,t[0]);heapq.heappop(t)
print(int(not q))


Measured memory_bytes: 4920
#include<iostream>
#include<vector>
#include<algorithm>

void drawdown(int a, int size){
	int i = 0;
	for (; i < a; i++)std::cout << " ";
	for (; i < size; i++)std::cout << "^";
	std::cout << std::endl;
}

int main(){

	long long p, q;
	while (std::cin >> p >> q){
		std::vector<long long>r;
		r.push_back(p);

		while (true){

			if (p / q == 0)p *= 10;
			std::cout << p / q;
			p %= q;
			if (p == 0){
				std::cout << std::endl;
				break;
			}
			std::vector<long long>::iterator it = std::find(r.begin(), r.end(), p);
			if (it != r.end()){
				std::cout << std::endl;
				drawdown(it - r.begin(), r.size());
				break;
			}
			r.push_back(p);
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char,long long> mp;
    for(int i = 0; i < N; i++){
        mp[S[i]]++;
    }
    long long ans = mp['R']*mp['G']*mp['B'];
    long long Notans = 0;
    for(int k = 2; k < N; k++){
        for(int j = 1; j < k; j++){
            int i = 2*j - k;
            if(0 <= i && i < j){
                    if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) Notans++; 
            }
        }
    }
    cout << ans - Notans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int a;
	cin>>a;
	string s;
	cin>>s;
	if(a>=3200)cout<<s;
	else cout<<"red";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = [int(i) for i in input().split()]

low = 200000
ans = 0
for i in range(1,n+1):
    x = t - h[i-1] * 0.006
    y = abs(a - x)
    if y < low:
        low = y
        ans = i

print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n,m;
    cin>>n>>m;
    int arr1[n+1][m+1];
    int arr2[m+1];
    int arr3[n+1];

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

    for(int i=0;i<m;i++){
        cin>>arr2[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            sum=sum+arr1[i][j]*arr2[j];
        }
        arr3[i]=sum;
        sum=0;
    }

    for(int i=0;i<n;i++){
        cout<<arr3[i]<<endl;
    }
}



Measured memory_bytes: 3140
#include <stdio.h>

int main(void) {
	int a,b,d,r;
	double f;
	d=0;
	r=0;
	f=0;
	scanf("%d%d",&a,&b);
	printf("%d\n",d=a/b);
	printf("%d\n",r=a%b);
	printf("%.8lf\n",f=1.0*a/b);
	return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>
int main(void)
{
  int n;
  int cnt;
  int i;
  while(1){
    scanf("%d",&n);
    if(n){
      int sum=0;
      for(i=0;i<n/4;i++){
	scanf("%d",&cnt);
	sum+=cnt;
      }
      printf("%d\n",sum);
    }
    else
      break;
  }
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S!="AAA"&&S!="BBB")cout<<YES<<endl;else cout<<NO<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
int n;
P data[3010];
int bs(int i,int j){
	int dx = data[i].first - data[j].first;
	int dy = data[i].second - data[j].second;

	if(binary_search(data,data+n,P(data[i].first+dy,data[i].second-dx))==0) return 0;
	if(binary_search(data,data+n,P(data[j].first+dy,data[j].second-dx))==0) return 0;

	return dx*dx+dy*dy;
}

int main(){
	while(cin >> n , n){
		for(int i=0;i<n;i++){
			cin >> data[i].first >> data[i].second;
		}
		sort(data,data+n);
		int ans = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i == j) continue;
				ans = max(ans,bs(i,j));
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188