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

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

  int q;
  cin >> q;

  for (int i = 0; i < q; i++) {
    string command;
    int a, b;
    cin >> command >> a >> b;

    if (command == "print") {
      cout << str.substr(a, (b - a + 1)) << endl;
    } else if (command == "reverse") {
      // 2文字目から4文字目の場合 (abcdef)
      // * 0 から 2 文字 (ab)
      // * 2 から 3 文字 (cde)
      // * 4 文字目から最後まで (ef)
      string p1 = str.substr(0, a);
      string p2 = str.substr(a, (b - a + 1));
      reverse(p2.begin(), p2.end());
      string p3 = str.substr(b + 1);

      str = p1 + p2 + p3;
    } else if (command == "replace") {
      string p;
      cin >> p;
      str.replace(a, (b - a + 1), p);
    }
  }

  return 0;
}



Measured memory_bytes: 3224
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let nk = lines.next().unwrap().unwrap();
    let mut nk = nk.split_whitespace();
    let n: i32 = nk.next().unwrap().parse().unwrap();
    let k: i32 = nk.next().unwrap().parse().unwrap();

    let mut pow = k;
    let mut ans = 1;
    while n >= pow {
        pow *= k;
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using ldouble = long double;

int main() {
    int n;
    std::cin >> n;

    std::vector<ldouble> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> xs[i] >> ys[i];
    }

    auto calcr = [&](ldouble cx, ldouble cy) {
        ldouble cr = 0;
        for (int i = 0; i < n; ++i) {
            cr = std::max(cr, std::hypot(xs[i] - cx, ys[i] - cy));
        }
        return cr;
    };

    ldouble r = 1e10;
    ldouble lx = 0, rx = 1000;
    for (int q = 0; q < 1000; ++q) {
        ldouble clx = (lx * 2 + rx) / 3,
                crx = (lx + rx * 2) / 3;

        ldouble xlr;
        {
            ldouble ly = 0, ry = 1000;
            for (int p = 0; p < 100; ++p) {
                ldouble cly = (ly * 2 + ry) / 3,
                        cry = (ly + ry * 2) / 3;
                ldouble lr = calcr(clx, cly),
                        rr = calcr(clx, cry);
                if (lr < rr) {
                    ry = cry;
                } else {
                    ly = cly;
                }
            }
            xlr = calcr(clx, ly);
        }

        ldouble xrr;
        {
            ldouble ly = 0, ry = 1000;
            for (int p = 0; p < 100; ++p) {
                ldouble cly = (ly * 2 + ry) / 3,
                        cry = (ly + ry * 2) / 3;
                ldouble lr = calcr(crx, cly),
                        rr = calcr(crx, cry);
                if (lr < rr) {
                    ry = cry;
                } else {
                    ly = cly;
                }
            }
            xrr = calcr(crx, ly);
        }

        if (xlr < xrr) {
            rx = crx;
        } else {
            lx = clx;
        }
        r = xlr;
    }

    std::cout << std::fixed << std::setprecision(10) << r << std::endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 1; i < n; i++){
        cin >> a[i];
        b[a[i] - 1]++;
    }
    rep(i,n){
        cout << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
#include<stdio.h>

int main(void)
{
	int a,b;
	{
	scanf("%d",&a);
	scanf("%d",&b);
		
	if(a>b)
		printf("a > b\n");
	else if(a<b)
		printf("a < b\n");
	else if(a==b)
		printf("a == b\n");
	}
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string ans="";
    ll n=s.length();
    ll i0=0,i1=n-1;
    ll num=0;
    while(i0<i1){
        if(s[i0]=='x'){
            if(s[i1]=='x'){
                i0++;
                i1--;
            }
            else{
                i0++;
                num++;
            }
        }
        else{
            if(s[i1]=='x'){
                i1--;
                num++;
            }
            else{
                if(s[i0]==s[i1]){
                    i0++;
                    i1--;
                }else{
                    cout << -1<<endl;
                    return 0;
                }
            }
        }
    }
    cout << num<<endl;
    return 0;
}



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

using namespace std;

int gcd(int x, int y) {
  while (y != 0) {
    int tmp = x;
    x = y;
    y = tmp % y;
  }
  return x;
}

int main() {
  int n, x;
  cin >> n >> x;
  int g = 0;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    g = gcd(g, abs(y - x));
  }
  cout << g << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(void){
	char moji[1500];
	int len;
	cin>>moji;
	len=strlen(moji);
	for(int i=0;i<len;i++){
		if(moji[i]-'A'>=3&&moji[i]-'A'<=25){
			moji[i]=moji[i]-3;
		}
		else{
			moji[i]=moji[i]+23;
		}
	}
	for(int i=0;i<len;i++){
		cout<<moji[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		country = '#';
	}
	char country;
};

void func(int n,int m){
	Info info[n];
	char tmp[2];
	int maximum,most_left_index,pre_index,div,left_dist;
	bool FLG;

	for(int loop = 0; loop < m; loop++){
		scanf("%s",tmp);

		switch(tmp[0]){
		case 'A':
			for(int i = 0; i < n; i++){
				if(info[i].country == '#'){
					info[i].country = 'A';
					break;
				}
			}
			break;
		case 'B':
			FLG = false;

			if(info[n-1].country == '#' && info[n-2].country != 'A'){
				info[n-1].country = 'B';
				break;
			}

			for(int i = n-2; i >= 1; i--){
				if(info[i].country == '#' && info[i-1].country != 'A' && info[i+1].country != 'A'){
					info[i].country = 'B';
					FLG = true;
					break;
				}
			}

			if(FLG)break;

			if(info[0].country == '#' && info[1].country != 'A'){
				info[0].country = 'B';
				break;
			}

			for(int i = 0; i < n; i++){
				if(info[i].country == '#'){
					info[i].country = 'B';
					break;
				}
			}
			break;
		case 'C':
			if(loop == 0){
				if(n%2 == 1){
					info[((n+1)/2)-1].country = 'C';
				}else{
					info[(n/2)].country = 'C';
				}
			}else{
				FLG = false;
				if(info[0].country != '#' && info[1].country == '#'){
					info[1].country = 'C';
					break;
				}
				for(int i = 1; i <= n-2; i++){
					if(info[i].country != '#'){
						if(info[i+1].country == '#'){
							info[i+1].country = 'C';
							FLG = true;
							break;
						}else if(info[i-1].country == '#'){
							info[i-1].country = 'C';
							FLG = true;
							break;
						}
					}
					if(FLG)break;
				}
				if(FLG)break;

				if(info[n-1].country != '#' && info[n-2].country == '#'){
					info[n-2].country = 'C';
					break;
				}
			}
			break;
		case 'D':

			if(loop == 0){
				info[0].country = 'D';
			}else{
				maximum = 0;
				most_left_index = -1;
				pre_index = -1;

				if(info[0].country == '#'){
					most_left_index = 0;
					for(div = 1; div <= n-1; div++){
						if(info[div].country != '#'){
							break;
						}
					}
					maximum = div;
				}else{
					pre_index = 0;
				}

				for(int i = 1; i <= n-1; i++){
					if(info[i].country == '#'){

						left_dist = i - pre_index;

						if(i <= n-2){
							for(div = 1; i+div <= n-1; div++){
								if(info[i+div].country != '#'){
									break;
								}
							}
						}else{ //i == n-1
							div = left_dist;
						}

						div = min(left_dist,div);

						if(div > maximum){
							maximum = div;
							most_left_index = i;
						}
					}else{
						pre_index = i;
					}
				}

				info[most_left_index].country = 'D';
			}

			break;
		}
	}

	for(int i = 0; i < n; i++)printf("%c",info[i].country);
	printf("\n");
}

int main(){

	int n,m;
	while(true){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0)break;

		func(n,m);

	}

    return 0;
}

Measured memory_bytes: 2452
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>

int main (){
	int A, B;
	scanf("%d",&A);
	scanf("%d", &B);
	int ans = A+B;
	ans = std::max(ans, A*B);
	ans = std::max(ans, A-B);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 100010

int gcd(int a, int b){
    int r;
    r = a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main() {
    int k, ans=0;cin>>k;

    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                ans += gcd(gcd(a,b),c);
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;


ll N, M;
/*
S[j] - S[i] % M == 0
すなわちS[j]とS[i]のMの剰余が等しいようなi<jの組数
Mで剰余を取ってソート、カウント
*/

int main() {
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> S(N);
    S[0] = A[0] % M;
    for (int i = 1; i < N; i++) {
        S[i] = (S[i-1] + A[i]) % M;
    }
    S.insert(S.begin(), 0);
    sort(S.begin(),S.end());
    ll res = 0;
    ll cnt = 1; ll tmp = S[0];
    for (int i = 1; i < N+1; i++) {
        if (S[i] != tmp) {
            res += (cnt-1) * cnt / 2;
            tmp = S[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    res += (cnt-1) * cnt / 2;
    cout << res << endl;
    


}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int calc_digit(int n){
  int res = 0;
  while (n > 0){
    res++;
    n /= 10;
  }
  return res;
}

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

  int ans = 0;
  for (int i = 1; i <= N; ++i){
    if (calc_digit(i) % 2 != 0) ans++;
  }
  cout << ans << endl;
}


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

int main(){
	int N, M;
	cin >> N >> M;
	int a[M], b[M];
	for(int i=0; i<M; i++) cin >> a[i] >> b[i];
	for(int i=1; i<=N; i++) cout << count(a,a+M,i) + count(b,b+M,i) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        left = min(a[i], b[i])
        ans += left
        b[i] -= left

        right = min(a[i + 1], b[i])
        ans += right
        a[i + 1] -= right

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18624
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAX = (int)1e9;
const int LIMIT = 30000000;  //sqrt(1e9)
bool prime[LIMIT + 1];
int main() {
	int n;
	cin >> n;
	int tmp = n;
	vector<int> factr;
	fill(prime, prime + LIMIT + 1, 1);
	prime[0] = prime[1] = 0;
	for (int i = 2; i <= LIMIT; i++) {
		if (tmp < i) {
			break;
		}
		if (prime[i]) {
			if (tmp%i == 0) {
				factr.push_back(i);
				while (tmp%i == 0) {
					tmp /= i;
				}
			}
			for (int k = 2; k*i <= LIMIT; k++) {
				prime[i*k] = 0;
			}
		}
	}
	if (factr.size() == 0) factr.push_back(n);
	ll ans = (ll)n - n / factr[0];
	for (int i = 1; i < factr.size(); i++) {
		ans = ans - ans / factr[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 32420
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

void Dicewap(int *dice, int a, int b, int c, int d);

int main()
{
  int n;
  string in;

  while (scanf("%d", &n), n){
    int dice[] = {0, 1, 2, 3, 4, 5, 6};
    int sum = 1;
    for (int i = 0; i < n; i++){
      cin >> in;
      if (in == "North") Dicewap(dice, 1, 2, 6, 5);
      if (in == "East") Dicewap(dice, 1, 4, 6, 3);
      if (in == "West") Dicewap(dice, 1, 3, 6, 4);
      if (in == "South") Dicewap(dice, 1, 5, 6, 2);
      if (in == "Right") Dicewap(dice, 2, 3, 5, 4);
      if (in == "Left") Dicewap(dice, 2, 4, 5, 3);
      sum += dice[1];
    }
    printf("%d\n", sum);
  }

  return (0);
}

void Dicewap(int *dice, int a, int b, int c, int d)
{
  int tmp = dice[a];
  dice[a] = dice[b];
  dice[b] = dice[c];
  dice[c] = dice[d];
  dice[d] = tmp;
}

Measured memory_bytes: 1248
N,M= [ int(it) for it in input().split() ]
A = [ int(it) for it in input().split() ]

for i in range(N,10000000000000):
  n = i
  flag = True
  for j in range(1000000):
    if (n%10 in A ):
      flag = False
      break
    n//=10
    if (n==0):
      break
  if (flag):
    print (i)
    break

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <queue>
using namespace std;
main(){
	queue<pair<string,int> >v;
	int N,q,Q,T;
	string s;
	for(cin>>N>>Q;N--;)cin>>s>>T,v.push(make_pair(s,T));
	for(q=Q,T=0;!v.empty();){
		pair<string,int>p=v.front();v.pop();
		if(p.second<=q){
			q-=p.second;
			T+=p.second;
			cout<<p.first<<' '<<T<<endl;
			q=Q;
		}else{
			p.second-=q;
			T+=q;
			v.push(p);
			q=Q;
		}
	}
}

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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


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

    vi l(3);

    for ( int i = 0; i < 3; i++ ) cin >> l[i];

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

	cout << l[0] * l[1] / 2 << endl;

    return 0;
}


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

int main() {
  int N,K,value=1;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    if (K<=value) {
      value += K;
      //cout << value << endl;
    }
    else {
      value = 2*value;
      //cout << value << endl;
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
cin>>a>>b;
if(a.size()>b.size())
{cout<<"GREATER"<<endl;}
else if(a.size()<b.size())
{cout<<"LESS"<<endl;}
else if(strcmp(a.c_str(),b.c_str())==0)
{cout<<"EQUAL"<<endl;}
else if(strcmp(a.c_str(),b.c_str())>0)
{cout<<"GREATER"<<endl;}
else
{cout<<"LESS"<<endl;}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    rep(_,100){
        // cout << best << endl;
        // rep(i,d)now[i] = rnd1(mt);
        int choice = rnd2(mt);
        rep(i,26){
            now[choice] = i;
            ll now_s = score();
            if(best < now_s){
                best = now_s;
                swap(t,now);
            }
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3688
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import numpy as np
a,b,x = map(int, input().split())


if a**2*b/2 < x:
    y=(2/a) * ((a**2*b-x)/a)
    print(np.degrees(np.arctan(y/a)))
else:
    y=(x/a)*(2/b)
    print(np.degrees(np.arctan(b/y)))    

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// --------------------------------------------------------------------------------

void solve_main()
{
 	int n;cin>>n;
 	int total = 0;
 	for(int i=0;i<=1e7;++i)
 	{
 		total = (total*10+7)%n;
 		if(total==0)
 		{
 			cout<<i+1<<"\n";
 			return;
 		}
 	}   
 	cout<<"-1\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("/home/suryakant/input.txt","r",stdin);
	// 	freopen("/home/suryakant/output.txt","w",stdout);
	// #endif
	
    int t=1;
    // cin>>t;
    while(t--)
    {
    	solve_main();
    }    
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  int tmp=N;
  int ans=0;
  while (tmp!=0){
    ans+=tmp%10;
    tmp=tmp/10;
  }
  if(ans==1){
    ans=10;
  }
  cout <<ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
#define M(x,y) memset(x,y,sizeof(x))
#define ll long long
using namespace std;
char c;
bool flag;
int main()
{
	while((c=getchar())!=EOF)
	{
		if(c=='C') flag=true;
		if(c=='F' && flag) 
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>


#ifndef _USEFUL_MACROS_
#define _USEFUL_MACROS_
#define INF 99999999
#define N_PRIME 1000000007
#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--)
#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x) do{}while(false)
#endif
#endif 

using namespace std;

int gcd(int a,int b){
    int left = min(a,b);
    int right = max(a,b);
    
    
    if( right % left == 0 )return left;
    return gcd(right%left,left);
}

int main(void){
    int n;
    int ret=1;
    int dv;
    
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    
    ret = a[0];
    
    FOR(i,1,n){
        dv = gcd(ret,a[i]);
        ret*=a[i];
        ret/=dv;
    }
    
    cout << (ret) << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 3084
S = input()
L = ['dream', 'dreamer', 'erase', 'eraser']
#L = ['eraser', 'erase', 'dreamer', 'dream']
cnt=0 
while len(S):
  for item in L:
    if S[-1*len(item):] == item:
      S = S[:-1*len(item)]
  cnt+=1
  if len(S) == 0:
    print("YES")
  if cnt > 100001:
    print("NO")
    exit(0)


Measured memory_bytes: 3188
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	ll a, b; cin >> a >> b;
	cout << a / __gcd(a, b) * b;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int h,w,k;
char s[325][325];
int cc[325];

int a[325][325];

int main(){
    scanf("%d%d%d",&h,&w,&k);
    REP(i,h)scanf("%s",s[i]);
    REP(i,h)REP(j,w)cc[i] += s[i][j]=='#';
    bool first = true;
    int it = 1;
    REP(i,h)if(cc[i]!=0){
        int l = first ? 0 : i;
        first = false;
        int r = i+1;
        while(r<h && cc[r]==0)r++;
        bool fi = true;
        REP(j,w)if(s[i][j]=='#'){
            int t = fi ? 0 : j;
            fi = false;
            int b = j+1;
            while(b<w && s[i][b]!='#')b++;
            FOR(y,l,r)FOR(x,t,b)a[y][x] = it;
            it++;
        }
    }
    REP(i,h)REP(j,w)printf("%d%c",a[i][j]," \n"[j==w-1]);
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

using namespace std;
int main(void){
    int N;cin>>N;
    string s;cin>>s;
    
    int R_n;R_n=0;
    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            R_n++;
        }
    }
    if(R_n>(N-R_n)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt =0;
    for (int i=0;i<s.size();i++)
        if (s[i] == 'R')
            cnt++;
    int k = cnt;
    for (int i=0;i<k;i++)
        if (s[i] == 'R')
            cnt--;
    cout << cnt << "\n";
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
const ll mod=998244353;
void add(ll &a,ll b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
void sub(ll &a,ll b)
{
    a-=b;
    if(a<0)a+=mod;
}
ll qpow(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod, b >>= 1;
    }
    return res;
}
ll dp[2][411][411][2],inv[411];
int p[411],b[411];
int main()
{
    inv[0]=1;
    rep(i,1,411)inv[i]=qpow(i,mod-2);
    rep(i,1,411)inv[i]=inv[i]*inv[i-1]%mod;
    int n;scanf("%d",&n);
    rep(i,1,n+1)scanf("%d%d",&p[i],&b[i]);
    int sump=0,sumb=0;
    bool type=1;
    dp[0][0][0][0]=1;
    rep(i,1,n+1)
    {
        rep(j,0,sump+1)rep(k,0,sumb+1)rep(k2,0,2)dp[type][j][k][k2]=dp[!type][j][k][k2];
        rep(j,0,sump+1)rep(k,0,sumb+1)rep(k2,0,2)
        if(dp[!type][j][k][k2])
        {
            ll nowx=1,nowf=1;
            rep(x,0,b[i])
            {
                (dp[type][j+p[i]][k+x][!k2]+=dp[!type][j][k][k2]*nowx%mod*nowf)%=mod;
                nowx=nowx*p[i]%mod,nowf=inv[x+1];
            }
        }
        sump+=p[i],sumb+=b[i];
        type=!type;
    }
    ll res=0;
    rep(i,0,sump+1)rep(j,0,sumb+1)rep(k,0,2)
    if(dp[!type][i][j][k])
    {
        dp[!type][i][j][k]=dp[!type][i][j][k]*qpow(inv[j],mod-2)%mod*qpow(qpow(i,j),mod-2)%mod;
        dp[!type][i][j][k]=dp[!type][i][j][k]*sump%mod*qpow(i,mod-2)%mod;
        if(k)add(res,dp[!type][i][j][k]);
        else sub(res,dp[!type][i][j][k]);
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 5504
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2,mod); }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int pr[200005],pw[200005];
signed main() {
    //ifstream cin("E:\\acm dream\\in.in");
	//ofstream cout("E:\\acm dream\\out.out");
	FIO;
    #ifdef err
	double be = clock();
    #endif

    int n;cin>>n;
    string s;cin>>s;
    _for(i,0,n){
        if(s[i]=='W')pw[i+1]=pw[i]+1,pr[i+1]=pr[i];
        else pw[i+1]=pw[i],pr[i+1]=pr[i]+1;
    }
    int ans = INT_MAX;
    _for(i,0,n+1){
        int t=0;
        if(!i)t=pr[n];
        else if(i==n)t=pw[n];
        else{
            int lr=pr[i],lw=pw[i];
            int rr=pr[n]-pr[i],rw=pw[n]-pw[i];
            t=min(lw,rr);
            lw-=t,rr-=t;
            t+=lw+rr;
        }
        ans=min(ans,t);
    }
    cout<<ans;

    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 5324
#include <iostream>

int main(){
    int a1, a2, b1, b2;
    std::cin >> a1 >> a2 >> b1 >> b2;

    int ans;
    if(a1 < b1){
        if(a2 < b1){
            ans = 0;
        }else if(a2 <= b2){
            ans = a2 - b1;
        }else{
            ans = b2 - b1;
        }
    }else if(b1 < a1){
        if(b2 < a1){
            ans = 0;
        }else if(b2 <= a2){
            ans = b2 - a1;
        }else{
            ans = a2 - a1;
        }
    }else{
        if(a2 < b2){
            ans = a2 - a1;
        }else{
            ans = b2 - a1;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n, m, sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>n){
        cout<<"-1";
    }
    else{
        cout<<n-sum;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N % 2 == 1) {
    cout << B.at(N / 2) - A.at(N / 2) + 1 << endl;
  }
  else {
    cout << B.at(N / 2) + B.at(N / 2 - 1) - A.at(N / 2) - A.at(N / 2 - 1) + 1 << endl;
  }
}

Measured memory_bytes: 4844
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(a, b));
    }

    const int N = 100000 + 10;
    bool  p[N];
    double q[N];
    fill(p, p + N, 0);
    fill(q, q + N, 1);
    p[1] = 1;

    each (i, v) {
      const int x = i.first;
      const int y = i.second;

      if (q[x] == 1) {
        p[y] |= p[x];
        p[x] = 0;
      } else {
        p[y] |= p[x];
      }
      --q[x];
      ++q[y];
    }

    // for (int i = 0; i <= n; ++i) {
    //   cout << i << ":" << p[i] << endl;
    // }
    
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
      if (p[i]) ++cnt;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n;
    int a, b;
    cin >> n >> a >> b;
    int p = 0, q = 0, r = 0;
    rep(i, n){
        int x;
        cin >> x;
        if (x <= a) p++;
        else if (x <= b) q++;
        else r++;
    }

    cout << min({p, q, r}) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int x = cin.Int();
			long sum = 0;
			for (int i = 0; i < x; i++) {
				sum += i + 1;
				if (sum >= x) {
					Console.WriteLine(i + 1);
					return;
				}
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  string S, T;
  int flag = 0;
  cin >> S >> T;
  if (S.size()+1 == T.size()) {
    flag = 1;
    for (unsigned int i = 0; i < S.size(); i++) {
      if (S.at(i) != T.at(i)) {
        flag = 0;
        break;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int s, int d, Weight w){
  g[s].push_back(Edge(s,d,w));
  g[d].push_back(Edge(d,s,0));
}

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  return match;
}

typedef complex<double> P;
P p[100];
P q[100];
double v[100];
template<class T> T lower_search(T lb, T ub, bool (*C)(T)) {
  REP(i,100) {
    T mid = (lb+ub)/2;
    if (C(mid)) ub = mid;
    else lb = mid;
  }
  return ub;
}
int n,m;
bool C(double x) {
  Graph g(n+m);
  REP(i,n) {
    REP(j,m) {
      double d = abs(p[i]-q[j]);
      if (v[i]*x >= d) {
        add_edge(g,i,j+n,d);
      }
    }
  }
  return bipartiteMatching(g,n) == m;
}

int main() {
  while(cin>>n>>m, n||m) {
    REP(i,n)cin>>p[i].real()>>p[i].imag()>>v[i];
    REP(i,m)cin>>q[i].real()>>q[i].imag();
    double ans = lower_search<double>(0,INF,C);
    printf("%.10f\n", ans);
  }
}

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

#define MAX 100000

int main(int, char**)
{
    int n ,k, tmp;
    int w[MAX];

    cin >> n >> k;
    int max = 0;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        w[i] = tmp;
        if (tmp > max) max = tmp;
    }

    int p_upper = max * n;
    int p_lower = 0;
    int p_mid;
    int count, sum;
    while (p_lower + 1 < p_upper) {
        p_mid = (p_upper + p_lower) / 2;
        count = 1;
        sum = 0;
        for (int i = 0; i < n; i++) {
            if (w[i] > p_mid) {
                count = k + 1;  // 絶対に載せられない
                break;
            }
            if (sum + w[i] > p_mid) {
                sum = 0;
                count++;
            }
            sum += w[i];
        }
        if (count <= k) p_upper = p_mid;
        else if (count > k) p_lower = p_mid;
    }

    cout << p_upper << endl;

    return 0;
}


Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

//A
//int main()
//{
// int n, h;
// std::vector<int> heights;
//
// cin >> n;
// for (int i = 0; i < n; ++i)
// {
//  cin >> h;
//  heights.push_back(h);
// }
//
// vector<int> m(n, 0);
// m[0] = 0;
// m[1] = abs(heights[1] - heights[0]);
//
// for (int i = 2; i < n; ++i)
// {
//  m[i] = min(m[i - 2] + abs(heights[i] - heights[i - 2]), m[i - 1] + abs(heights[i] - heights[i - 1]));
// }
//
// cout << m[n - 1];
//}


//B
//int main()
//{
// int n, k, h;
// std::vector<int> heights;
//
// cin >> n >> k;
// for (int i = 0; i < n; ++i)
// {
//  cin >> h;
//  heights.push_back(h);
// }
//
// vector<int> m(n, 0);
// m[0] = 0; 
//
// for (int i = 1; i < n; ++i)
// {
//  int m_min = INT_MAX;
//  for (int j = 1; j <= k; ++j)
//  {
//   if (i - j < 0) break;
//   int m_cur = m[i - j] + abs(heights[i] - heights[i - j]);
//   if (m_cur < m_min) m_min = m_cur;
//  }
//  m[i] = m_min;
// }
//
// cout << m[n - 1];
//}

//C
//int main()
//{
//    size_t n;
//    cin >> n;
//    vector<vector<int>> activities;
//
//    int a, b, c;
//    for (size_t i = 0; i < n; ++i)
//    {
//        cin >> a >> b >> c;
//        vector<int> acts;
//        acts.push_back(a);
//        acts.push_back(b);
//        acts.push_back(c);
//        activities.push_back(acts);
//    }
//
//    vector<vector<int>> m(n, vector<int>(3, 0));
//
//	for (int j = 0; j < 3; ++j)
//	{
//        m[0][j] = activities[0][j];
//	}
//
//    for (size_t i = 1; i < n; ++i)
//    {
//        m[i][0] = activities[i][0] + max(m[i - 1][1], m[i - 1][2]);
//        m[i][1] = activities[i][1] + max(m[i - 1][0], m[i - 1][2]);
//        m[i][2] = activities[i][2] + max(m[i - 1][0], m[i - 1][1]);
//    }
//
//    cout << *max_element(m[n-1].begin(), m[n-1].end());
//}

//D
int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> weights;
    vector<long long> values;

    int w, v;
    for (int i = 0; i < n; ++i)
    {
        cin >> w >> v;
        weights.push_back(w);
        values.push_back(v);
    }

    vector<vector<long long>> m(n + 1, vector<long long>(W + 1, 0));

    for (int j = 0; j <= W; ++j)
    {
        m[0][j] = 0;
    }

    for (int i = 1; i <=n; ++i)
    {
        int index = i - 1;
	    for (int j = 0; j <= W; ++j)
	    {
		    if (weights[index] > j)
		    {
                m[i][j] = m[i - 1][j];
		    }
            else
            {
                m[i][j] = max(m[i - 1][j], m[i - 1][j - weights[index]] + values[index]);
            }
	    }
    }

    cout << m[n][W];
}

Measured memory_bytes: 80256
use std::io;
use std::process;

macro_rules! get {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.parse::<$t>().unwrap()
        }
    };
    ($($t: ty), *) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            let mut inter = x.split_whitespace();
            (
                $(inter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

macro_rules! insert_vec {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.split_whitespace().map(|x| x.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

macro_rules! word_chars_vec {
    () => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.chars().collect::<Vec<_>>()
        }        
    };
}

macro_rules! two_vec {
    ($t: ty; $e: expr) => {
        {
            (0..$e).map(|_| insert_vec!($t)).collect::<Vec<_>>()
        }
    };
}

fn main() {
    let n = get!(usize);
    let mut two_vec = two_vec!( usize ; n);
    two_vec.sort_by_key(|x| x[1]);
    let mut time = 0;
    for i in &two_vec {
        time = time + i[0];
        if time > i[1] {
            println!("No");
            process::exit(0x0100);
        };
    }
    println!("Yes");
}


Measured memory_bytes: 14588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
	int a,b,c;
	int d[50];
	int n;
	int i,j,k;
	int x;

	scanf("%d",&n);
	x = 0;
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}

	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			x += d[i] * d[j];
		}
	}

	printf("%d\n",x);


	return 0;
}

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

int main(){
	string s;
	cin >> s;
	s.at(3) = '8';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
using namespace std;
int main() {
	int H,W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		string tile[100];
		bool memo[100][100];
		for (int i = 0;i < H;i++) {
			cin >> tile[i];
			for (int j = 0;j < W;j++) {
				memo[i][j] = false;
			}
		}
		int x = 0;
		int y = 0;
		while (true) {
			if (memo[x][y]) {
				cout << "LOOP" << endl;
				break;
			}
			if (tile[x][y] == '.') {
				cout << y << " " << x << endl;
				break;
			}
			memo[x][y] = true;
			if (tile[x][y] == '>') {
				y++;
			}
			if (tile[x][y] == '<') {
				y--;
			}
			if (tile[x][y] == '^') {
				x--;
			}
			if (tile[x][y] == 'v') {
				x++;
			}

		}
	}
	return 0;

}

Measured memory_bytes: 1240
#include <stdio.h>
int main(void){
	int i,kazu;
	long sum=0,a,min=1000001,max=-1000001;
	scanf("%d",&kazu);
	
	for(i=0;i<kazu;i++){
		scanf("%ld",&a);
		if(a<=min){
		min=a;
		}
		if(a>=max){
		max=a;
		}
		sum=sum+a;
	}
	printf("%d %d %ld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 600
n = int(input())
A = sorted(map(int, input().split()), reverse = True)

x = 0; y = 0
count = 0
i = 0
while i < n - 1:
    if A[i] == A[i + 1]:
        if count == 0:
            x = A[i]
        else:
            y = A[i]
        count += 1
        i += 2
    else:
        i += 1
    if count == 2:
        break

print(x * y)


Measured memory_bytes: 14252
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double a = (double)w * (double)h / 2.0;
  int f = 0;
  if(w == 2 * x && h == 2 * y) f = 1;
  printf("%.20f %d\n", a, f);
  return 0;
}

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

using namespace std;

signed main() {
    string s;
    unsigned long long sum = 0;
	cin >> s;
	
	for(int i = 0; i < (int)s.size(); ++i) sum += (s[i] - '0');
	
	if (sum % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ab;
  ab = a * b;
  int A, B;
  A = ab / 2;
  B = (ab + 1) / 2;
  
  if (A == B) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
} 

Measured memory_bytes: 256
import Data.Functor( (<$>))
import Control.Monad( replicateM)

main = do
    n <- read <$> getLine
    vss <- replicateM n getLine
    let
	battle vs = let
			[tar,han] = words vs
		    in
			case tar `compare` han of
			    LT	-> (0,3)
			    EQ	-> (1,1)
			    GT	-> (3,0)

	(tScore, hScore) = unzip $ battle <$> vss

    putStrLn $ (show $ sum tScore)++" "++(show $ sum hScore)



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

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a,b;
  cin>>a>>b;
  V<P<int,int>> c(a);
  fo(i,a){
    cin>>c[i].fi>>c[i].se;
  }
  int d=100000;
  fo(i,a){
    if(c[i].se<=b)
      d=min<int>(d,c[i].fi);
  }
  if(d==100000)
    cout<<"TLE"<<endl;
  else
    cout<<d<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if((a<=b && b<=a+w) || (a<=b+w && b<=a))
		cout<<0<<endl;
	else if(b+w<a)
		cout<<a-(b+w)<<endl;
	else
		cout<<b-(a+w)<<endl;
}

Measured memory_bytes: 256