akhauriyash/Code-Regression huggingface dataset:
#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;
template <typename T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x)                                                                 \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(   \
              c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)
typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};
void solve();
void pre();
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) {
        // cout << "Case # " << i << ": ";
        solve();
    }
    return 0;
}
const int mod = 1e9 + 7;
void pre() {}
void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    if (s[n - 1] == 's') {
        cout << s << "es";
    } else {
        cout << s << "s";
    }
}


Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var aab = ab[0] + ab[1];
            var asb = ab[0] - ab[1];
            var amb = ab[0] * ab[1];
            Console.WriteLine(Math.Max(Math.Max(aab, asb), amb));
        }
    }
}


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

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, l;
	cin >> n >> l;
	int L = n*l;
	for(int i = 0; i < n; ++i)
	    L += i;
	//cout << L << '\n';
	int minDif = INT_MAX;
	int ind = n;
	for(int i = 0; i < n; ++i){
	    //cout << i << ": " << l+i << ' ' << abs(L - abs(L - (l+i))) << '\n';
	    if( abs(L - (L - (l+i))) < minDif){
	        minDif = abs(L - (L - (l+i))); 
	        ind = i;
	    }
	}
	cout << L - (l+ind) << '\n';
}

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

typedef struct town {
    char name;
    struct town *zero;
    struct town *ichi;
}town;

void make_map(void);
town a, x, y, z, w, b, n;

int main(void)
{
    char input[101];
    int i;
    town *now;

    make_map();
    scanf("%s",input);

    while (input[0] != '#') {
        now = &a;
        for (i = 0; input[i] != '\0'; i++) {
            if (input[i] == '0') {
                now = now->zero;
            } else {
                now = now->ichi;
            }
        }
        if (now->name == 'b') {
            puts("Yes");
        } else {
            puts("No");
        }
        scanf("%s",input);
    }
    return 0;
}

void make_map(void)
{
    n.name = 'n';
    n.zero = &n;
    n.ichi = &n;
    
    a.name = 'a';
    w.name = 'w';
    x.name = 'x';
    y.name = 'y';
    z.name = 'z';
    b.name = 'b';
    
    a.zero = &x;
    w.zero = &b;
    x.zero = &n;
    y.zero = &x;
    z.zero = &w;
    b.zero = &y;

    a.ichi = &y;
    w.ichi = &y;
    x.ichi = &z;
    y.ichi = &n;
    z.ichi = &b;
    b.ichi = &x;
}

Measured memory_bytes: 524
#include<stdio.h>

int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
     
    int a[n];
    int i,j;
int tmp = 0 ;
    
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d",&a[i]);
    }
    
    for(i = 0 ; i < n ; i++)
    {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
    }
    
    int sum = 0;
    
    for(i = 0 ; i < k ; i++)
    {
        sum += a[i];
    }

printf("%d",sum);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long ll;
const int mod=1e9+7;
int main()
{
    fastio;
    int n,w;
    cin>>n>>w;
    ll table[n+1][w+1];
    int wt[n],v[n];
    fore(i,0,n)
    cin>>wt[i]>>v[i];
    fore(i,0,n+1)
    {
        fore(j,0,w+1)
        {
            if(i==0||j==0)
            table[i][j]=0;
            else if(j>=wt[i-1])
            table[i][j]=max(table[i-1][j],v[i-1]+table[i-1][j-wt[i-1]]);
            else
            table[i][j]=table[i-1][j];
        }
    }
    cout<<table[n][w];
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
const int MAXE = 102 * 102;
const int MAXA = 102;
const int INF = 100000000;

void update(int& x, int y){
    if(x < y) x = y;
}

int main(){
    int S, T, U, N, O, D;
    cin >> S >> T >> U >> N >> O >> D;
    vector<int> e(T), c(T);
    REP(i, T) cin >> e[i] >> c[i];
    vector<int> h(N), a(N);
    REP(i, N) cin >> h[i] >> a[i];
    int dp1[MAXA][MAXA] = {};
    REP(i, MAXA) fill(dp1[i], dp1[i] + MAXA, -INF);
    dp1[0][0] = 0;
    int dp2[MAXE] = {};
    fill(dp2, dp2 + MAXE, -INF);
    dp2[0] = 0;
    for(int i = 0; i < T; i++){
        for(int j = i; j >= 0; j--){
            for(int k = MAXA - 1 - e[i]; k >= 0; k--){
                if(dp1[j][k] < 0) continue;
                update(dp1[j + 1][k + e[i]], dp1[j][k] + c[i]);
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j + a[i] < MAXE; j++){
            if(dp2[j] < 0) continue;
            update(dp2[j + a[i]], dp2[j] + h[i]);
        }
    }
    for(int j = 1; j < MAXE; j++){
        update(dp2[j], dp2[j - 1]);
    }
    int value[MAXA] = {};
    fill(value, value + MAXA, -INF);
    for(int i = 0; i < MAXA; i++){
        if(dp1[U][i] < 0) continue;
        value[i] = dp2[ dp1[U][i] ];
    }

    vector<int> cur(S + 1, -INF);
    cur[S] = 0;
    for(int i = 0; i < D; i++){
        vector<int> next(S + 1, -INF);
        for(int j = 0; j < S + 1; j++){
            if(cur[j] < 0) continue;
            for(int k = 0; k <= j; k++){
                if(value[k] < 0) continue;
                int nj = j - k + O;
                if(nj > S) nj = S;
                update(next[nj], cur[j] + value[k]);
            }
        }
        cur.swap(next);
    }
    int ans = -INF;
    for(int i = 0; i < S + 1; i++){
        update(ans, cur[i]);
    }
    if(ans < 0) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1288
/**
 * @author khokharnikunj8
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class segment {
public:
    vector<long long> tree;
    vector<long long> lazy;

    segment(int n) {
        tree.resize(4 * n + 5, 0);
        lazy.resize(4 * n + 5, 0);
    }

    void update(int node, int start, int end, int l, int r, long long value) {
        if (end < l || start > r) return;
        if (l <= start && end <= r) {
            tree[node] += value;
            return;
        }
        int mid = (start + end) >> 1;
        update(node << 1, start, mid, l, r, value);
        update(node << 1 | 1, mid + 1, end, l, r, value);
    }

    long long query(int node, int start, int end, int pos) {
        if (end < pos || start > pos) return 0;
        if (pos == start && end == pos) return tree[node];
        int mid = (start + end) >> 1;
        return tree[node] + query(node << 1, start, mid, pos) + query(node << 1 | 1, mid + 1, end, pos);
    }

};

class FSilverFoxVsMonster {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, d, a;
        in >> n >> d >> a;
        vector<pair<int, int>> ar(n);
        for (int i = 0; i < n; i++) {
            in >> ar[i].first >> ar[i].second;
        }
        segment sg(n);
        sort(ar.begin(), ar.end());
        long long ans = 0;
        long long currentA = 0;
        for (int i = 0; i < n; i++) {
            long long get = sg.query(1, 0, n - 1, i);
            if (get >= ar[i].second) continue;
            long long rem = ar[i].second - get;
            int index = i;
            {
                int low = i + 1;
                int high = n - 1;
                while (low <= high) {
                    int mid = (low + high) >> 1;
                    if (ar[mid].first <= 2ll * d + ar[i].first) {
                        index = mid;
                        low = mid + 1;
                    } else {
                        high = mid - 1;
                    }
                }
            }
            if (rem % a != 0) rem = (rem / a + 1) * a;
            sg.update(1, 0, n - 1, i, index, rem);
            ans += rem / a;
        }
        out << ans << "\n";

    }
};


int main() {
    FSilverFoxVsMonster solver;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
int main(void)
{
	double x1,x2,y1,y2,l;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	l=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	printf("%f\n",l);
	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int a, b, i, j, k;
	vi x;
	cin >> a >> b >> k;

	rep(i, min(a, b)) {
		if (a % (i + 1) == 0 && b % (i + 1) == 0)
			x.push_back(i + 1);
	}

	cout << x[x.size() - k];

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n], b[n], c[n];
    rep(i, n) scanf("%lld", &a[i]);
    rep(i, n) scanf("%lld", &b[i]);
    rep(i, n) scanf("%lld", &c[i]);
    sort(a, a+n);
    sort(c, c+n);
    lint ans=  0;
    rep(i, n){
        lint x = lower_bound(a, a+n, b[i]) - a;
        lint y = c+n - upper_bound(c, c+n, b[i]);
        ans += x * y;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb push_back
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const long long mod = 1e9 + 7LL;
typedef long long ll;
typedef pair<int, int> ii;
typedef double db;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
ll pwr(ll x , ll n) { ll ans = 1; while (n) {ans *= x; n--;} return ans;}

void solve(){
    
}

int main()
{
    IO;
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M,Q;
int L[200001];
int R[200001];

int A[511][511];

void add(int a,int b){
	A[0][b]++;
	A[a+1][b]--;
	A[0][501]--;
	A[a+1][501]++;
}

int main(){
	REP(i,511){
		REP(j,511){
			A[i][j]=0;
		}
	}
	cin>>N>>M>>Q;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		add(a,b);
	}
	/*cout<<endl;
	REP(i,11){
		REP(j,11){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	REP(i,511){
		REP(j,511){
			if(j==0)continue;
			A[i][j]+=A[i][j-1];
		}
	}
	/*
	cout<<endl;
	REP(i,11){
		REP(j,11){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	REP(i,511){
		REP(j,511){
			if(i==0)continue;
			A[i][j]+=A[i-1][j];
		}
	}
	/*
	REP(i,11){
		REP(j,11){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	
	REP(i,Q){
		int a,b;
		cin>>a>>b;
		cout<<A[a][b]<<endl;
	}
	return(0);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define intl unsigned long long
using namespace std;
intl len(intl a)
{
	intl ans=0;
	while(a) {
		a/=10;
		ans++;
	}
	return ans;
}
int main()
{
	intl a,minn=10000;
	cin>>a;intl l=sqrt(a);
	for(intl i=1;i<=l;i++){
		if(a%i==0) minn=min(minn,max(len(i),len(a/i)));
	}
	cout<<minn<<endl;
	return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  vector<int> rank;
  unionfind(int n=1){
    init(n);
  }
  void init(int n=1){
      par.resize(n); rank.resize(n);
      for(int i=0;i<n;++i) par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y]) swap(x,y);
    if(rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    return true;
  }
};

int main(){
  int N,K,L;
  cin >> N >> K >> L;
  unionfind ufa(N);
  unionfind ufb(N);
  rep(i,K){
    int p,q;
    cin >> p >> q;
    p--; q--;
    ufa.merge(p,q);
  }
  rep(i,L){
    int r,s;
    cin >> r >> s;
    r--; s--;
    ufb.merge(r,s);
  }
  map<i_i,int> mp;
  rep(i,N){
    mp[i_i(ufa.root(i),ufb.root(i))]++;
  }
  rep(i,N){
    if(i==N-1){cout << mp[i_i(ufa.root(i),ufb.root(i))] << endl; continue;}
    cout << mp[i_i(ufa.root(i),ufb.root(i))] << " ";
  }
}

Measured memory_bytes: 15104
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
template <class T> class Graph2 {
public:
	static const T INF = numeric_limits<T>::max();
	int V, E; vector<vector<pair<int, T> > > G;
	Graph2() : V(0), E(0), G(vector<vector<pair<int, T> > >()) {}
	Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, T> > >(v)) {}
	Graph2(vector<vector<pair<int, T> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }
	int size() { return V; }
	void add1(int v1, int v2, T w) { G[v1].push_back(make_pair(v2, w)); E++; }
	void add2(int v1, int v2, T w) { add1(v1, v2, w); add1(v2, v1, w); }
	bool operator==(const Graph2& g) const { return G == g.G; }
	bool operator!=(const Graph2& g) const { return G != g.G; }
	vector<pair<int, T> > operator[](int x) { return G[x]; }
	T minspan() {
		vector<T> d(V, INF);
		vector<bool> used(V, false);
		priority_queue<pair<T, int> > que;
		for (int i = 0; i < V; i++) d[i] = INF;
		d[0] = 0; que.push(make_pair(0, 0));
		while (!que.empty()) {
			pair<T, int> pa = que.top(); que.pop();
			int u = pa.second; used[u] = true;
			for (int i = 0; i < G[u].size(); i++) {
				int v = G[u][i].first;
				if (d[v] > G[u][i].second && !used[v]) {
					d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
				}
			}
		}
		T sum = 0;
		for (int i = 0; i < V; i++) sum += d[i];
		return sum;
	}
};
int V, E, s, t, w;
int main() {
	scanf("%d%d", &V, &E);
	Graph2<int> G(V);
	for(int i = 0; i < E; i++) {
		scanf("%d%d%d", &s, &t, &w);
		G.add2(s, t, w);
	}
	printf("%d\n", G.minspan());
}

Measured memory_bytes: 6180
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  int x = stoi(s.substr(0, 2));
  int y = stoi(s.substr(2, 2));
  int a = 0, b = 0;
  if(1 <= x && x <= 12) a = 1;
  if(1 <= y && y <= 12) b = 1;
  string ans = "NA";
  if(a && b) ans = "AMBIGUOUS";
  else if(a) ans = "MMYY";
  else if(b) ans = "YYMM";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		long num = Long.parseLong(input);
		int range = (int) Math.pow(10, (input.length() + 1) / 2);
		int result = 100;
		for (int i = 1; i < range; i++) {
			if (num % i == 0) {
				int candidate = Math.max(length(i), length(num / i));
				if (candidate < result) result = candidate;
			}
		}
		System.out.println(result);
	}

	private static int length(long num) {
		return Long.toString(num).length();
	}
}


Measured memory_bytes: 23636
import Control.Monad

main = do
    n <- read <$> getLine
    putStrLn $ show $ solve n

solve :: Int -> Int
solve n | n < 105   = 0
        | n < 135   = 1
        | n < 165   = 2
        | n < 189   = 3
        | n < 195   = 4
        | otherwise = 5


Measured memory_bytes: 380
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		boolean[] flag = new boolean[100001];
		flag[0] = flag[1] = true;
		int[] dp = new int[100001];
		dp[0] = dp[1] = 0;
		for(int i = 2; i < 100001; i++) {
			if(flag[i]) {
				dp[i] = dp[i - 1];
				continue;
			}
			if(!flag[(i + 1) / 2]) {
				dp[i] = dp[i - 1] + 1;
			} else {
				dp[i] = dp[i - 1];
			}
			for(int j = i * 2; j < 100001; j += i) {
				flag[j] = true;
			}
		}
		for(int i = 0; i < q; i++) {
			System.out.println(dp[r[i]] - dp[l[i] - 1]);
		}
	}
}


Measured memory_bytes: 78248
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

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

signed main(){
  string S; cin >> S;
  bool flag = false;
  REP(i, (ll)S.size()) {
    if(S.at(i) == '7') flag = true;
  }
  cout << (flag ? YES : NO) << endl;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

long long p10(long long i) {
	long long r = 1;
	for(; i > 0; i--) {
		r *= 10;
	}
	return r;
}

int main() {
	long long n;
	long long c[10][10] = {};

	cin >> n;
	long long d = 0;
	for(int m = n; m > 0; m /= 10)
		d++;
	if (d == 1) {
		cout << n << endl;
		return 0;
	}
	long long l = n;
	for(int i = 0; i < d - 1; i++) {
		l /= 10;
	}
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j <= 9; j++) {
			long long t = 0;
			long long dd = d - 2;
			if (i == j)
				t += 1;
			if (l > i) {
				t += p10(dd);
			} else if (l == i) {
				long long n2 = (n - l*p10(d-1))/10;
				if (j > n%10) {
					n2--;
				}
				t += n2 + 1;
			}
			for(dd -= 1; dd >= 0; dd--) {
				t += p10(dd);
			}
			c[i][j] = t;
		}
	long long r = 0;
	for(int i = 1; i <= 9; i++)
		for(int j = i; j <= 9; j++) {
			if (i == j) {
				r += c[i][j] * c[j][i];
			}else{
				r += c[i][j]*c[j][i]*2;
			}
		}
	cout << r << endl;
	return 0;
}

			
				





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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> t(n);
  
  for (int i= 0; i < n; i++){
    string s;
    int p;
    cin >> s >> p;
    t[i] = make_tuple(s, -p, i+1);
  }
  sort(t.begin(), t.end());// sがアルファベット順にソートされた。pは小さい順になっている。
  
  for (int i= 0; i < n; i++)
    cout << get<2>(t[i]) << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  char X, Y;
  cin >> X >> Y;
  if (X > Y) {
    cout << '>' << endl;
  } else if (X < Y) {
    cout << '<' << endl;
  } else {
    cout << '=' << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k, l;
  
  ll a[3];
  for(i=0; i<3; i++) cin >> a[i];
  sort(a, a+3);
  
  if(a[0]%2==0||a[1]%2==0||a[2]%2==0) {
    pt(0);
  }else {
    pt(a[0]*a[1]);
  }
  
  
}




Measured memory_bytes: 256
N=int(input())

graph=[]
for i in range(N):
  graph.append([])

for i in range(N):
  S=list(map(int,input()))
  for j in range(N):
    if S[j]==1:
      graph[i].append(j)
      
#print(graph)
max_set=-1
for i in range(N):
  node_list=[-1]*N
  #bfs
  d=1
  queue={i}
  illegal=False
  while(True):
    new_queue=set()
    for q in queue:
      node_list[q]=d
      for qq in graph[q]:
        if node_list[qq]==-1:
          new_queue.add(qq)
        elif node_list[qq]!=d-1:
          illegal=True
          break
      
    if illegal:
      break
    elif len(new_queue)==0:
      #print(node_list,d)
      max_set=max(max_set,d)
      break
    else:
      #print(node_list,new_queue)
      queue=new_queue
      d+=1
      
print(max_set)


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	for(int N,K;cin>>N>>K && N|K;){
		vi as(K),bs(K);
		for(int i=0;i<K;i++){
			cin>>as[i]>>bs[i];
			as[i]--; bs[i]--;
		}
		
		for(int i=0;i<K;i++)
			for(int j=K-1;j--;)
				if(as[j]>as[j+1]){
					swap(as[j],as[j+1]);
					swap(bs[j],bs[j+1]);
				}
		
		int si=0;
		vector<vvi> ps(N,vvi(3,vi(3)));
		
		int i=0;
		if(i<N){
			for(int j=0;j<3;j++)
				ps[i][j][0]=1;
			if(si<K && as[si]==i){
				for(int j=0;j<3;j++)
					if(j!=bs[si])
						ps[i][j][0]=0;
				si++;
			}
			i++;
		}
		if(i<N){
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					for(int l=0;l<3;l++)
						ps[i][j][k]+=ps[i-1][k][l];
			if(si<K && as[si]==i){
				for(int j=0;j<3;j++)
					if(j!=bs[si])
						for(int k=0;k<3;k++)
							ps[i][j][k]=0;
				si++;
			}
			i++;
		}
		for(;i<N;i++){
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					for(int l=0;l<3;l++){
						if(j==k && k==l)
							continue;
						ps[i][j][k]=(ps[i][j][k]+ps[i-1][k][l])%10000;
					}
			if(si<K && as[si]==i){
				for(int j=0;j<3;j++)
					if(j!=bs[si])
						for(int k=0;k<3;k++)
							ps[i][j][k]=0;
				si++;
			}
		}
		
		int res=0;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				res+=ps[N-1][i][j];
		cout<<res%10000<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A, B = map(int, input().split())
*P, = map(int, input().split())

# Firstは1問目にのみ、Secondは2問目にのみ、Thirdは2,3問目に使えるもの
First, Second, Third = [], [], []
for p in P:
	if p <= A:
		First.append(p)
	elif p >= B + 1:
		Third.append(p)
	elif p >= A + 1:
		Second.append(p)

print(min(len(First), len(Second), len(Third)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  cout<<min({a*x+b*y,c*max(x,y)*2,c*x*2+max(0,(y-x)*b),c*y*2+max(0,(x-y)*a)})<<endl;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	vector<int> A(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	long C=0;
	int D=1;
	int i=0;
	while(i<N) {
		if (A.at(i)>D) {
			C +=(A.at(i)-1)/D;
			A.at(i)=1;
			if (1==D)
				D++;
		} else if (A.at(i)==D)
			D++;
		i++;
	}
	cout <<C <<endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);

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

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    cin >> b[i];

    if(a[i] + a[i+1] >= b[i]) {
      ans += b[i];
      if (b[i] >= a[i]) {
        a[i+1] = a[i+1] - (b[i] - a[i]);
        a[i] = 0;
      } else {
        a[i] = a[i] - b[i];
      }
    } else {
      ans += a[i] + a[i+1];
      a[i] = 0;
      a[i+1] = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
 char A[] = "abcdefghijklmnopqrstuvwxyz";
  char C;
  scanf("%c",&C);
  for(int i= 0;i<26;i++){
  if(C == A[i]){
  printf("%c",A[i+1]);
  }
  }
}

Measured memory_bytes: 128
a,b,c=map(int,input().split())
if a==b and b==c:
    print(1)
elif a==b and b!=c:
    print(2)
elif a==c and b!=c:
    print(2)
elif b==c and b!=a:
    print(2)
elif a!=b and b!=c:
    print(3)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int n;
  double a,sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lf",&a);
    sum+=(1/a);
  }
  printf("%lf\n",1/sum);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            for (int i = 0; i < b; i++) {
                System.out.print(a);
            }
        } else if (b < a) {
            for (int i = 0; i < a; i++) {
                System.out.print(b);
            }
        } else {
            int min = Math.min(a, b);
            for (int i = 0; i < min; i++) {
                System.out.print(min);
            }
        }
        System.out.println("");
        sc.close();
    }
}


Measured memory_bytes: 22356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


ll rec(ll n, ll x){
    if(n==0)return 1;
    ll len=(1LL<<(n+1))-3; // レベルn-1のバーガーの長さ
    ll num=(1LL<<n)-1; // レベルn-1に含まれるP
    if(x==1)return 0;
    if(x<=len+1)return rec(n-1,x-1);
    if(x==len+2)return 1+num;
    else if(x<=2*(len+1)) return 1+num+rec(n-1,x-len-2);
    else return 2*num+1;
}

int main(void) {
    
    ll n,x;
    cin>>n>>x;
    cout<<rec(n,x)<<endl;
}


Measured memory_bytes: 256
def get_subordinate(n, members):
    new_dict = {}

    for i in range(1, n+1):
        new_dict[i] = 0

    for member in members:
        if member in new_dict:
            new_dict[member] += 1

    print(*new_dict.values(), sep="\n")


if __name__ == '__main__':
    n = int(input())
    members = list(map(int, input().rstrip().split()))
    get_subordinate(n, members)



Measured memory_bytes: 38848
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    long long t,n;
    cin>>t;
    if(t==0) break;
    cin>>n;
    long long sum=0;
    for(int i=0;i<n;i++){
      long long a,b;
      cin>>a>>b;
      sum+=b-a;
    }
    if(sum>=t) cout<<"OK"<<endl;
    else cout<<t-sum<<endl;
  }
}

Measured memory_bytes: 3084
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var a = F();
		var b = F();
		Console.WriteLine(2 * b - a);
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  reverse(t.begin(),t.end());
  if(s<t){
    printf("Yes");
  }else{
    printf("No");
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> v(n);
    for(LL i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for(LL i = 1; i < n; ++i){
        ans = (ans + v[i]) / 2.0;
    }
    cout << setprecision(13) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  private static int N;
  private static int[] S;
  private static int Q;
  private static int[] C;

  private static int binarySearch(int v, int low, int high) {
    if (low <= high) {
      int mid = (low + high) / 2;
      if (v > S[mid]) {
        return binarySearch(v, mid + 1, high);
      } else if (v < S[mid]){
        return binarySearch(v, low, mid - 1);
      } else if (v == S[mid]) {
        return v;
      }
    }
    return -1;
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    S = new int[N];
    for (int i = 0; i < N; i++) {
      S[i] = in.nextInt();
    }

    Q = in.nextInt();
    C = new int[N];
    for (int i = 0; i < Q; i++) {
      C[i] = in.nextInt();
    }

    int cnt = 0;
    for (int i = 0; i < Q; i++) {
      int ret = binarySearch(C[i], 0, N - 1);
      if (ret >= 0) {
        cnt++;
      }
    }

    System.out.println(cnt);
  }
}

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

typedef long long ll;

int n, k;

int main() {
	cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n; i++)
  {
    cin>>v[i];
  }
  for(int rd=1; rd<=k; rd++)
  {
    vector<int> newv(n, 0);
    for(int i=0; i<n; i++)
    {
      int i1=max(i-v[i], 0);
      int i2=i+min(v[i]+1, n);
      newv[i1]++;
      if(i2<n) newv[i2]--;
    }
    for(int i=1; i<n; i++)
    {
      newv[i]+=newv[i-1];
    }
    bool done=true;
    for(int i=0; i<n; i++)
    {
      v[i]=newv[i];
      if(v[i]<n) done=false;
    }
    if(done) break;
  }
  for(int i=0; i<n; i++) cout<<v[i]<<" ";
  cout<<endl;
	return 0;
}


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

int main(){
	int A, B, C, K, i, tmp;
	scanf("%d%d%d%d", &A, &B, &C, &K);
	if(A < B || A < C){
		if(B >= C){
			tmp = A;
			A = B;
			B = tmp;
		}
		else{
			tmp = A;
			A = C;
			C = tmp;
		}
	}
	for(i = 0; i < K; i++){
		A *= 2;
	}
	printf("%d\n", A + B + C);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int C[3][3];

int main(){
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> C[i][j];
		}
	}

	for(int i=0; i<3; i++){
		bool ok = true;
		for(int j=0; j<3; j++){
			ok = ok && (C[i][j]-C[i][(j+1)%3])==(C[(i+1)%3][j]-C[(i+1)%3][(j+1)%3]);
			ok = ok && (C[i][j]-C[(i+1)%3][j])==(C[i][(j+1)%3]-C[(i+1)%3][(j+1)%3]);
		}
		if(!ok){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop

X, Y, A, B, C = map(int, input().split())
H = []
for p in map(int, input().split()):
  heappush(H, ((-p, 'r')))
for q in map(int, input().split()):
  heappush(H, ((-q, 'g')))
for r in map(int, input().split()):
  heappush(H, ((-r, '')))

count = X + Y
ans = 0
while count > 0:
  h = heappop(H)
  if h[1] == 'r' :
    if X > 0:
      X -= 1
      count -= 1
      ans -= h[0]
  elif h[1] == 'g':
    if Y > 0:
      Y -= 1
      count -= 1
      ans -= h[0]
  else:
    count -= 1
    ans -= h[0]

print(ans)

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

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

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

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int diff = values[i] - costs[i];
    if (diff > 0) {
      ans += diff;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#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(){
  ll n=0,nt=0,c=0,maxc;
  string s,t;
  
 cin >> s;
 cin >> t;
 n = s.size();
 maxc = n;
 nt = t.size();
 if(s.find(t) != string::npos){
 	cout << 0 << endl;
 }
 else {
 	rep(i,n - nt+1){
      c=0;
    	for(int j = 0; j < nt;  j++){
        	if(s[i+j] != t[j]){ c++;}
        }
      if(maxc > c){ maxc = c;}
    }
   cout << maxc << endl;
 }

  return 0;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  reverse(all(s));
  ll n = s.size();
  string str[] = {"dreamer", "eraser", "dream", "erase"};
  rep(i, 4) reverse(all(str[i]));

  rep(i, s.size()) {
    if(s[i] == 'r') {
      if(i + 6 < n) {
        bool flag = true;
        rep(j, str[0].size()) {
          if(str[0][j] != s[i + j]) {
            flag = false;
          }
        }
        if(flag) {

          i += 6;
          continue;
        }
      }
      if(i + 5 < n) {
        bool flag = true;
        rep(j, str[1].size()) {
          if(str[1][j] != s[i + j]) {
            flag = false;
          }
        }
        if(flag) {
          i += 5;
          continue;
        }
      }
      cout << "NO"
           << "\n";
      return 0;
    } else if(s[i] == 'e') {
      if(i + 4 < n) {
        bool flag = true;
        rep(j, str[3].size()) {
          if(str[3][j] != s[i + j]) {
            cout << str[3][j] << " " << s[i + j] << endl;
            flag = false;
          }
        }
        if(flag) {
          i += 4;
          continue;
        }
      }
    } else if(s[i] == 'm') {
      if(i + 4 < n) {
        bool flag = true;
        rep(j, str[2].size()) {
          if(str[2][j] != s[i + j]) {
            cout << "ng " << str[2][j] << " " << s[i + j] << endl;
            flag = false;
          }
        }
        if(flag) {
          i += 4;
          continue;
        }
      }
    }
    cout << "NO"
         << "\n";
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class Program {
	static int[] array = new int[10];
	public static int Main()
	{
		int n = int.Parse(Console.ReadLine());
		while (n-- != 0)
		{
			string[] input = Console.ReadLine().Split(' ');
			for (int i = 0; i < 10; i++)
			{
				array[i] = int.Parse(input[i]);
			}
			Console.WriteLine(is_can(0, 0, 0) ? "YES" : "NO");
		}
		return 0;
	}

	static bool is_can(int left, int right, int now)
	{
		if (now == array.Length)
		{
			return true;
		}
		if (left < array[now] && is_can(array[now], right, now + 1))
		{
			return true;
		}
		if (right < array[now] && is_can(left, array[now], now + 1)) {
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 5316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n;
    cin >> n;
    
    ll T = 1, A = 1;
    
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ll k = max((T + a - 1) / a, (A + b - 1) / b);
        T = k * a;
        A = k * b;
    }
    cout << T + A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int K = 1E9 + 7;
int dp[3000 + 1][3000 + 1][2];

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

  dp[0][0][1] = 1;
  for (int i = 1; i <= n; ++i) {
    dp[0][i][0] = 1;
  }

  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j <= n; ++j) {
      // 1
      // red, red
      if (j < n) dp[i][j][1] += dp[i - 1][j + 1][1];
      dp[i][j][1] %= K;
      if (j == 0) dp[i][j][1] += dp[i - 1][j + 1][0];
      dp[i][j][1] %= K;
      
      // red, blue
      if (j > 0) dp[i][j][1] += dp[i - 1][j][1];
      dp[i][j][1] %= K;
      if (j == 1) dp[i][j][1] += dp[i - 1][j][0];
      dp[i][j][1] %= K;

      // blue, blue
      if (j > 0) dp[i][j][1] += dp[i - 1][j - 1][1];
      dp[i][j][1] %= K;
      // blue, red
      if (j < n) dp[i][j][1] += dp[i - 1][j][1];
      dp[i][j][1] %= K;

      // 0
      // red, red
      if (j > 0 && j < n) dp[i][j][0] += dp[i - 1][j + 1][0];
      dp[i][j][0] %= K;

      // red, blue
      if (j > 1) dp[i][j][0] += dp[i - 1][j][0];
      dp[i][j][0] %= K;

      // blue, blue
      if (j > 0) dp[i][j][0] += dp[i - 1][j - 1][0];
      dp[i][j][0] %= K;

      // blue, red
      if (j < n)  dp[i][j][0] += dp[i - 1][j][0];
      dp[i][j][0] %= K;
    }
  }

  int sum = 0;
  for (int i = 0; i <= n; ++i) {
    sum += (dp[m][i][1]);
    sum = sum % K;
  }
  cout << sum << endl;
}

Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		double ans=0;
		for(int i = 1;i<=s[0];i++) {
			int k=0,p=i;
			while(p<s[1]){p*=2;k++;}
			ans+=(1.0/s[0])*Math.Pow(0.5,k);
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}

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

#define NIL -1

typedef struct Node {
	int id = NIL;
	int parent = NIL;
	int l_child = NIL;
	int r_siblibg = NIL;
	int depth = 0;
}node;

void treeDepth(vector<node>& tree, int n, int depth)
{
	tree.at(n).depth = depth;
	if (tree.at(n).r_siblibg != NIL) treeDepth(tree, tree.at(n).r_siblibg, depth);
	if (tree.at(n).l_child != NIL) treeDepth(tree, tree.at(n).l_child, depth + 1);
	return;
}

void print(vector<node>& tree, int x)
{
	cout << "node " << x << ": parent = " << tree.at(x).parent << ", depth = ";
	cout << tree.at(x).depth << ", ";
	if (tree.at(x).parent == NIL) cout << "root, [";
	else if (tree.at(x).l_child == NIL) cout << "leaf, [";
	else cout << "internal node, [";

	int i = 0;
	for (int t = tree.at(x).l_child; t != NIL; t = tree.at(t).r_siblibg)
	{
		if (i++) cout << ", ";
		cout << t;
	}
	cout << "]" << endl;
}

int main(void)
{
	int N, Id, totalChild;
	cin >> N;
	vector<node> tree(N);
	for (int i = 0; i < N; i++) tree.at(i).id = i;

	int root = NIL;
	for (int i = 0; i < N; i++)
	{
		int leftsibling;
		cin >> Id >> totalChild;
		for (int j = 0; j < totalChild; j++)
		{
			int child;
			cin >> child;
			if (j == 0) tree.at(Id).l_child = child;
			else tree.at(leftsibling).r_siblibg = child;
			tree.at(child).parent = Id;
			leftsibling = child;
		}
	}

	for (int i = 0; i < N; i++)
	{
		if (tree.at(i).parent == NIL) root = i;
	}

	treeDepth(tree, root, 0);

	for (int i = 0; i < N; i++) print(tree, i);

	return 0;
}


Measured memory_bytes: 9416