akhauriyash/Code-Regression huggingface dataset:
point = Array.new

def solve(point)
  source = point[0]
  point.delete_at(0)
#  point.sort{|p1,p2| p1[1] <=> p2[1]}
    
  sum = 0
  while point.size > 1 do
    p1 = point[0]
    p2 = point[1]
    
    a = getDistance(source, p1)
    b = getDistance(source,p2)
    c = getDistance(p1, p2)
    z = (a + b + c) / 2
      
    sum += getArea(a, b, c, z)
    
    #不要になった座標は削除する
    point.delete_at(0)
  end
  sum
end

def getDistance(p1, p2)
  Math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)
end

def getArea(l1, l2, l3, z)
  Math.sqrt(z * (z - l1) * (z - l2) * (z - l3))
end

while input = $stdin.gets do
  point << input.chomp.split(",").map(&:to_f)
end

printf "%.6f\n", solve(point)

Measured memory_bytes: 6152
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt(),k=nxtl();
    vector <pair<int,int> > v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].first>>v[i].second;
    sort(all(v));
    ll cur=v[0].second;
    int i=0;
    while(k>cur)
    {
        cur+=v[++i].second;
    }
    cout<<v[i].first<<endl;

    
    
    return 0;   
}




 
 


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
int  n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	if(m-n>=2*k){
		for(int i=n;i<=n+k-1;i++) printf("%d\n",i);
		for(int i=m-k+1;i<=m;i++) printf("%d\n",i);
	}
	else{
		for(int i=n;i<=m;i++) printf("%d\n",i);
	}
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

int grid_search(vector<vector<int>>&grid, pii s) {
	int H = grid.size();
	int W = grid[0].size();
	enum { BLOCK, OK };
	assert(0 < H and 0 < W);
	auto inrange = [&](int x, int y) {return 0 <= x and x < H and 0 <= y and y < W; };
	int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
	assert(grid[s.first][s.second] == OK);
	vector<vector<int>>visited(H, vector<int>(W));
	queue<pii>q;
	q.push(s);
	vector<vector<int>>dist(H, vector<int>(W, INF));
	dist[s.first][s.second] = 0;
	visited[s.first][s.second] = true;
	int ret = 0;
	while (q.size()) {
		pii v = q.front();
		q.pop();
		chmax(ret, dist[v.first][v.second]);
		for (int k = 0; k < 4; k++) {
			pii u(v.first + dx[k], v.second + dy[k]);
			if (not inrange(u.first, u.second))continue;
			if (visited[u.first][u.second])continue;
			if (grid[u.first][u.second]) {
				visited[u.first][u.second] = true;
				q.push(u);
				dist[u.first][u.second] = dist[v.first][v.second] + 1;
			}
		}
	}
	return ret;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int H, W; cin >> H >> W;
	vector<string>v(H); rep(i, 0, H) { cin >> v[i]; }
	vector<vector<int>>grid(H, vector<int>(W));
	rep(i, 0, H) {
		rep(j, 0, W) {
			grid[i][j] = (v[i][j] == '.');
		}
	}
	dump(grid);
	int ans = 0;
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (grid[i][j] == 0)	continue;
			chmax(ans, grid_search(grid, pii(i, j)));
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    vi v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(all(v));

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

    cout << ans << endl;

    
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.print(in.nextInt() / 3);
        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
#define pl pair<ll,ll>

ll n;
ll arr[100005][3];
map<pl,ll> dp,marked;
ll recursor(ll state, ll type)
{
		if(type>=3)
		{
			type = type%3;
		}
	
		if(marked[m_p(state,type)]==1)
		{
			return dp[m_p(state,type)];
		}
		
		marked[m_p(state,type)] = 1;
		if(state==n-1)
		{
			return dp[m_p(state,type)] = arr[state][type];
			
		}
		return dp[m_p(state,type)] = max(recursor(state+1,type+1),recursor(state+1,type+2))+arr[state][type];
}
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		
		cin >> n;
		ll i;
		
		F(i,0,n)
		{
			cin >> arr[i][0] >> arr[i][1] >>arr[i][2] ;
		}
		
		ll a = recursor(0,0);
		ll b= recursor(0,1);
		ll c= recursor(0,2);
		cout << max(a,max(b,c));
		
		
	}
	return 0;

}



Measured memory_bytes: 49536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	int t,a;
	cin>>t>>a;
	cout<<t*a<<endl;
	
}



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

  int main(){
   ll n,a,b,c,d,e;
   ll ans=0;
   cin >> n >> a >> b >> c >> d >> e;
   ll waru=min({a,b,c,d,e});
   if (n%waru > 0) ans+=n/waru;
   else ans+=(n/waru)-1;
   ans+=5;
   cout << ans << endl;
    return 0;
  }

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	string s;
	cin>>s;
	j=0;
	rep(i,0,s.length()/2){
	    if(s[i]!=s[s.length()-1-i])
	        j++;
	}cout<<j<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, res = -INF, mx = -INF;
    string s;
    in(n);
  	if(n == 2){
      in(n, res);
      out(n), space(), out(res);
      return 0;
    }
    int a[n];
    rep(i, n){
        in(a[i]);
        chmax(mx, a[i]);
    }
    rep(i, n){
        if(abs(mx / 2 - a[i]) < abs(mx / 2 - res)){
            res = a[i];
        }
    }
    out(mx), space(), out(res);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, abc[26];
string S;
ll res;

int main(){
	cin >> N >> S;
	for (int i = 0; i != N; ++i) {
		++abc[S[i] - 'a'];
	}
	res = 1;
	for (int i = 0; i != 26; ++i) {
		res = res*(abc[i] + 1) % mod;
	}
	cout << res - 1 << endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
    
    int A,B;
    
    cin >> A >> B ;
    double digit=5;
    int sum=0;
    int P = pow(10,digit);
    
    for (int i=0 ; i<B-A+1 ;i++){
        int a,b;
        int C=0;
        int N=A+i;
        int p=1, q=1;
        
        for (int j=0 ; j < digit/2 ; j++) {
            q *= 10;
            
            a = ((N/p)*p - (N/q)*q)/p;
            b = N/(P/q) - (N/(P/p))*10;
            
            /*
            cout << a <<endl;
            cout << b <<endl;
            */
            
            if(a==b){
                C++;
            }
            
            p *= 10;
        }
        if (C >= digit/2){
            sum++;
        }
    }
    
    cout << sum << endl;
    
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  vector<map<ll, int>> m(n);
  map<ll, int> cnt;
  rep(i, n) {
    auto pm = prime_factor(a[i]);
    for (auto p : pm) cnt[p.first]++;
  }
  int mx = 0;
  for (auto c : cnt) {
    maxs(mx, c.second);
  }
  dump(cnt, mx);
  if (mx <= 1) {
    cout << "pairwise coprime" << endl;
  } else if (mx < n) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 58900
#include <cstdio>
#include <queue>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

void bfs()
{
    queue<string> q;
    q.push("01234567");
    d["01234567"] = 1;
    while(!q.empty())
    {
        string str, s = q.front(); q.pop();
        str = s;
        for(int i = 0; i < 4; i++)
        {
            s = str;
            int k = -1;
            for(int j = 0; j < 8; j++)
            {
                if('0' == s[j])
                {
                    k = j;
                    break;
                }
            }
            int px = k / 4;
            int py = k % 4;
            int x = px + dir[i][0];
            int y = py + dir[i][1];
            if(x >= 0 && x <= 1 && y >= 0 && y < 4)
            {
                int a = 4 * x + y;
                int tmp = d[s];
                swap(s[k], s[a]);
                if(0 == d[s])
                {
                    q.push(s);
                    d[s] = tmp + 1;
                }
            }
        }
    }
}

int main()
{
    int a;
    d.clear();
    bfs();
    while(~scanf("%d", &a))
    {
        string s = "";
        s += '0' + a;
        for(int i = 1; i < 8; i++)
        {
            scanf("%d", &a);
            s += '0' + a;
        }
        printf("%d\n", d[s] - 1);
    }
    return 0;
}

Measured memory_bytes: 3472
#include <iostream>
using namespace std;
constexpr int SIZE = 'z' - 'a' + 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int num[SIZE]{};
  char ch;
  while (cin >> ch) {
    if ('a' <= ch && ch <= 'z') {
      num[ch - 'a']++;
    } else if ('A' <= ch && ch <= 'Z') {
      num[ch - 'A']++;
    }
  }
  for (int i{0}; i < SIZE; ++i) {
    cout << static_cast<char>('a' + i) << " : " << num[i] << '\n';
  }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
bool is_ok(ll x, ll y){
    if(x == y) return true;
    else return false;
}
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll r_b = a + b;
    ll ans = (n / r_b) * a;
    if((n % r_b) < a) ans += (n % r_b);
    else ans += a;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#define il inline
#define rgi register int
#define sp putchar(' ')
#define el putchar('\n')
#define db double
using namespace std;
il int ri()
{
	register int o1=0;
	register bool o2=0;
	register char o3;
	while(!isdigit(o3=getchar()))
		o2|=o3=='-';
	while(isdigit(o3))
		o1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();
	return o2?-o1:o1;
}
il void wi(int o1)
{
	if(o1<0)
		putchar('-'),o1=-o1;
	rgi o2=o1/10;
	if(o2)
		wi(o2);
	putchar((o1-(o2<<1)-(o2<<3))^48);
}
int n;
db ans;
signed main()
{
	n=ri();
	if(n&1)
	{
		ans=(db)(n/2+1)/(db)n;
		printf("%.8lf\n",ans);
	}
	else
		printf("0.5000000\n");
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{ 
    static void Main(string[] args)
    {
        var num = Input.num;
        var dic = new Dictionary<long, long>();
        for (var i = 2; i <= num; i++)
        {
            var d = Calculation.Factorization(i);
            foreach (var pair in d)
                if (dic.ContainsKey(pair.Key))
                    dic[pair.Key] += pair.Value;
                else dic[pair.Key] = pair.Value;
        }
        var res = 1L;
        foreach (var val in dic.Values)
            res = (res * (val + 1)) % Input.MOD;
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Calculation
{
    public static int LCM(int num1, int num2)
    {
        return num1 / GCD(num1, num2) * num2;
    }

    public static long LCM(long num1, long num2)
    {
        return num1 / GCD(num1, num2) * num2;
    }

    public static int GCD(int num1, int num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }

    public static long GCD(long num1, long num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }

    public static List<int> GetPrime(long num)
    {
        if (num < 2) return new List<int>();
        var prime = new List<int> { 2 };
        var bo = new bool[num + 1];
        for (var i = 3; i <= num; i += 2)
            if (!bo[i])
            {
                prime.Add(i);
                for (var j = 3 * i; j <= num; j += 2 * i)
                    bo[j] = true;
            }
        return prime;
    }

    public static Dictionary<long,int> Factorization(long num)
    {
        var dic = new Dictionary<long, int>();
        for(var i = 2; i * i <= num; i++)
        {
            var ct = 0;
            while (num % i == 0)
            {
                ct++;
                num /= i;
            }
            if (ct != 0) dic[i] = ct;
        }
        if (num != 1) dic[num] = 1;
        return dic;
    }
        
    
}


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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    string ans = "Yes";
    if(n%2==0){
        rep(i, n){
            if(!(s.at(i)=='h'&&s.at(i+1)=='i')){
                ans = "No";
            }
            i++;
        }
    }
    else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val s = sc.next()
    val t = sc.next()
    val a = sc.nextInt()
    val b = sc.nextInt()
    val u = sc.next()
    if (s == u) println("${a - 1} $b")
    else println("$a ${b - 1}")

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int saisho(string a){
char c;
c = a.at(0);
return c;
}

int matubi(string a){
  char c;
  int s;
  s = a.size();
  c = a.at(s-1);
  return c;
}

int main() {
  int N;
  cin >> N;
  vector<string> A(N);
  for(int i = 0; i < N; i++){
    cin >>A.at(i);
  }
  bool decide = true;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < i;j++){
      if(A.at(i) == A.at(j)) decide = false;
    }
  }

  for(int i = 0; i < N-1; i++){
   char c1 = matubi(A.at(i));
   char c2 = saisho(A.at(i+1));
   if(c1 == c2){
   }else{
     decide = false;
   }
  }

  if(decide){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

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


int main()
{
  int N,num=0;
  scanf("%d",&N);
  if(N%2==1)
  {
    num=num+1;
  }
  
  num=num+N/2;
  
  printf("%d",num);

  
  return 0; 
}

Measured memory_bytes: 128
n = int(input())
l = []
for i in range(n):
  l.append(list(map(int,input().split())))

k = []
m = []
for i in l:
  a,b = i
  k.append(a+b)
  m.append(a-b)
k.sort()
m.sort()
print(max([k[-1]-k[0],m[-1] -m[0]]))

Measured memory_bytes: 62052
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100001
ll a[MAXN];
map<ll, ll> mp;
int main() {
    int n;
    ll m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    ll ret = 0;
    mp[0]++;
    for (int i = 1; i <= n; i++) {
        sum = (sum + a[i]) % m;
        ret += mp[sum];
        mp[sum]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 8228
#include <iostream>
using namespace std;
int main(){
	string str;
	cin >> str;
	for(int i=0;i<str.size()-1;i++){
		if(str[i]=='A'&&str[i+1]=='C'){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  map<int, int> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  cout << mp.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++)
	{
		if(s==t)
		{
			cout<<"Yes\n";
			return 0;
		}
		char w=s[s.length()-1];
		for(int j=s.length()-1;j>=0;j--) s[j]=s[j-1];
		s[0]=w;
	}
	if(s==t) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
	int n, sum = 0;
	cin>>n;
	vector<int> v(n);
	for(auto &i:v){ cin>>i; sum += i;}
	bitset<4000010> dp(1);
	for(auto &i:v)
	    dp = dp | (dp<<i);
	for(int i=(sum+1)/2;i<=sum;i++)
	    if(dp[i])
	        return cout<<i,0;
	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#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 REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100000;

int N, M;
Pair P[kMaxN];
int ans = 0;

signed main() {
  cin >> N >> M;
  REP(i, M) { cin >> P[i].second >> P[i].first; }

  sort(P, P+M);

  int x = -1;
  REP(i, M) {
    int a = P[i].second;
    int b = P[i].first;
    // cout << a << " " << b << " " << x << " " << ans << endl;
    if (a <= x) {
      continue;
    } else {
      x = b - 1;
      ++ans;
    }
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int even = 0;
    int forbai = 0;
    int odd = 0;
    for(int i = 0; i < N; i++){
        if(a[i] % 2 == 0 && a[i] % 4 != 0)even ++;
        else if(a[i] % 4 == 0) forbai++;
        else if(a[i] % 2 == 1) odd++;
    }
    if(even % 2 == 1){
        N -= (even - 1);
        odd++;
    }
    else N -= N - even;
    
    //cout << odd << " " << forbai;
    
    if(forbai >= odd - 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

typedef long long ll;
ll mod = 1000000007;
ll times(ll a, ll b) {
  return (a * b) % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll coefficient = 1;
  ll colors[3] = {0, 0, 0};
  for(int i = 0; i < n; i++) {
    ll temp_coef = 0;
    for(int j = 0; j < 3; j++) {
      if(a[i] == colors[j]) {
        if(temp_coef == 0) {
          colors[j]++;
        }
        temp_coef++;
      }
    }
    coefficient = times(coefficient, temp_coef);
  }
  cout << coefficient << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s,t;
    cin>>s>>t;
    int len=s.size();
    rep(i,len){
        s=s.back()+s.substr(0,len-1);
        if (s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3592
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int N = in.nextInt();
            List<Integer> array = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                array.add(in.nextInt());
            }
            Collections.sort(array);

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < array.get(array.size() - 1); i++) {
                double p = i + 1;
                int sum = 0;
                for (int x : array) {
                    sum += Math.pow(x - p, 2.0);
                }
                min = Math.min(min, sum);
            }
            out.println(min);
        }
    }
}

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

using namespace std;

const int MAX_N = 5010;

int n, k;
vector<int> a;
bool dp1[MAX_N][MAX_N], dp2[MAX_N][MAX_N];
short pref[MAX_N][MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if (t < k) {
            a.push_back(t);
        }
    }
    n = a.size();
    dp1[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (dp1[i][j]) {
                dp1[i + 1][j] = 1;
                if (j + a[i] <= k) {
                    dp1[i + 1][j + a[i]] = 1;
                }
            }
        }
    }
    dp2[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (dp2[i][j]) {
                dp2[i + 1][j] = 1;
                if (j + a[n - 1 - i] <= k) {
                    dp2[i + 1][j + a[n - 1 - i]] = 1;
                }
            }
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            pref[i][j + 1] = pref[i][j] + dp2[i][j];
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (dp1[i][j]) {
                int x = pref[n - 1 - i][k - j];
                if (k >= a[i] + j) {
                    x -= pref[n - 1 - i][k - a[i] - j];
                }
                if (x > 0) {
                    break;
                }
            }
            if (j == k) {
                cnt++;
            }
        }
    }
    cout << cnt << "\n";
}



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

const int mod=1e9+7;
const int sz=100010;

int fact[sz],inv[sz],ifact[sz];
void make(){
    fact[0]=fact[1]=inv[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<sz;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}
int perm(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[n-k]%mod;
}

int N,K;
vector<int> G[100010];

int dfs(int v,int p)
{
    int res;
    if(p==-1){
        res=perm(K,G[v].size()+1);
    }else{
        res=perm(K-2,G[v].size()-1);
    }
    for(int u:G[v]) if(u!=p){
        res=res*dfs(u,v)%mod;
    }
    return res;
}

signed main(){
    make();

    cin>>N>>K;
    for(int i=0;i<N-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout<<dfs(0,-1)<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include <cstdio>

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    char a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("\n%c",&a[i][j]);
        }
    }

    for(int i = 0; i < h + 2; i++){
        for(int j = 0; j < w + 2; j++){
            if(i == 0 || i == h + 1 || j == 0 || j == w + 1){
                printf("#");
            }else{
                printf("%c",a[i - 1][j - 1]);
            }
            if(j == w + 1){
                printf("\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<string.h>
#include<map>
using namespace std;
int a[3001];
int main(){
  int n;
  cin>>n;
  long long sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i]-1;
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	a.push_back(0);

	ll ans = 1, cur = a[0], cnt = 0;
	int hoge = 0;
	for (int i = 0; i <= n; i++) {
		if (cur == a[i]) {
			cnt++;
		} else {
			if (cnt <= 1) {
				cur = a[i];
				cnt = 1;
				continue;
			}
			if (hoge == 0) {
				ans = cur;
				if (cnt >= 4) {
					ans *= cur;
					hoge = 2;
					break;
				} else {
					hoge++;
					cur = a[i];
					cnt = 1;
				}
			} else if (hoge == 1) {
				ans *= cur;
				hoge = 2;
				break;
			}
		}
	}
	if (hoge != 2) ans = 0;	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    long long A, B, C;
    long long ans;

    cin >> A >> B >> C;

    if (A*B*C % 2 == 0) {
        cout << 0 << endl;
    } else {
        ans = min({A*B, B*C, C*A});
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

struct S{
   int l, r, c;
};

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	while(cin >> n >> k, n, k){
		vector<int> a;
		bool f = false;
		rep(i, 0, k){
			int in;
			cin >> in;
			if(in == 0) f = true;
			else a.push_back(in);
		}
		sort(all(a));
		a.push_back(INF);
		int l = a[0], pre = a[0], cnt = 1;
		vector<S> d; 
		rep(i, 1, a.size()){
			if(pre + 1 != a[i]){
				d.push_back(S{l, pre, cnt});
				l = a[i];
				cnt = 0;
			}
			cnt++;
			pre = a[i];
		}
		int ans = 1;
		rep(i, 0, d.size()){
			chmax(ans, d[i].c);
			if(f && i != d.size() - 1){
				if(d[i].r + 2 == d[i + 1].l){
					chmax(ans, d[i].c + d[i + 1].c + 1);
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i,sum=0,k;
	cin>>a>>b>>k;
	for(i=min(a,b);i>=1;--i){
		if((a%i==0) && (b%i==0))sum++;
		if(sum==k)break;
	}
	cout<<i;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int A[1<<20], N, K, B[1<<20];

void print_array() {
  rep(i, N) cout << A[i] << " ";cout<<endl;
}

bool update_array() {
  rep(i,N) B[i]=0;
  rep(i,N) {
    int s = i - A[i], e = i+A[i]+1;
    if(s < 0) s = 0;
    B[s]++;B[e]--;
  }

  rep(i,N) B[i+1]  += B[i];
  rep(i,N) A[i]=B[i];

  rep(i,N) if(A[i] < N) return false;
  return true;
}

int main() {

  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> K;
  rep(i, N) cin>>A[i];

  for(int i = 0;i < K;i++) {
    if(update_array()) break;
  }

  rep(i,N)cout<<A[i]<<" ";

  return 0;
}


Measured memory_bytes: 5916
#include <iostream>

using namespace std;

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

	int fib[100]={0};

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

	cout<<fib[n]<<endl;

	return 0;
}

Measured memory_bytes: 3072
# vim: set fileencoding=utf-8:
import collections


def main():
    N, K = map(int, raw_input().split())
    h = [input() for _ in xrange(N)]
    h = sorted(h)
    col = collections.Counter(h)
    """
    Kが最頻出回数以下であれば、answerは0となり即終了
    """
    ans = 0
    if K <= max(col.values()):
        pass
    else:
        """
        そうでない場合は、面倒だがソート済みのhに対して、 i = 0としたとき、 abs(h[i] - h[i+K])を全空間に対して行う
        """
        ans = 9999999999999999
        for i in xrange(N - K + 1):
            ans = min((abs(h[i] - h[i + K - 1])), ans)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        ArrayList<int[]> bridge = new ArrayList<int[]>();
        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o1[1], o2[1]);
            }
        };
        for (int i=0;i<M;i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int[] add = {a, b};
            bridge.add(add);
        }
        Collections.sort(bridge, comparator);

        int cnt = 0;
        int before = -1;
        for (int[] rem : bridge) {
            if (rem[0]<=before) {
                continue;
            } else {
                cnt++;
                before = rem[1]-1;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 63120
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_T 301

using namespace std;

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

ll gcm(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcm(b, a % b);
  }
}

bool check(ll A, ll B, ll C, ll D) {

  if (A < B) return false;
  if (B > D) return false;
  ll g = gcm(B, D);

  if ((B-1 - (A%g)) / g >= (C+1 + g-1 -(A%g)) / g) {
    return false;
  } else {
    return true;
  }
}

int main()
{
  int T;
  ll A[MAX_T], B[MAX_T], C[MAX_T], D[MAX_T];
  cin >> T;
  for (int i = 0; i < T; i++) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }

  for (int i = 0; i < T; i++) {
    if (check(A[i], B[i], C[i], D[i])) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


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

//少数を考えるときはdouble!!!intだけ使うと引っかかるぞ！！


int main(){
  string s,rev;
  cin >> s;
  //str = reverse(s);
  reverse(s.begin(),s.end());
  string str[4];
  str[0]="dream";
  str[1]="dreamer";
  str[2]="erase";
  str[3]="eraser";
  for(int i=0;i<4;i++){
    reverse(str[i].begin(),str[i].end());
    //cout  <<  str[i] <<endl;
  }
  bool hantei =false;
  int siz;
  while(!hantei){
    siz=s.size();
    for(int i=0;i<4;i++){
      string sub=s.substr(0,str[i].size());
      if(sub==str[i]){
        s.erase(s.begin(),s.begin()+str[i].size());
      }
    }
    if(s.size()==0)hantei =true;
    if(siz==s.size())break;
  }
  if(hantei)cout << "YES" <<endl;
  else cout << "NO" <<endl;

}


Measured memory_bytes: 512
#include "atcoder/all"

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>


using namespace std;
using namespace atcoder;


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


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, n, m);
	dsu d(n);
	int a, b;
	repi(m) {
		std::cin >> a >> b;
		d.merge(a - 1, b - 1);
	}
	
	int cnt = 0;
	repi(n) {
		if (!d.same(0, i)) {
			d.merge(0, i);
			cnt++;
		}
	}
	
	otp(cnt);
	
	return 0;
}


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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)

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

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

//a,bの最大公約数
ll gcd(ll a, ll b)
{
	ll temp;
	while (a % b != 0)
	{
		temp = a;
		a %= b;
		b = temp;
	}
	return b;
}

//a,bの最小公倍数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

const ll INF = 1LL << 60;
const int MAX_N = 20 + 10;

int n, ans;
int p[MAX_N];

int main()
{
	cin >> n;
	REP(i, n)
	{
		cin >> p[i];
	}

	ans = 0;
	FOR(i, 2, n)
	{
		if ((p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i]))
		{
			++ans;
		}
	}
	cout << ans << endl;
}


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

int main(){
	int a[100];
	for(int i = 0;i<4;i++){
		cin >> a[i];
	}
	sort(a,a+4);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second
typedef long long ll;
typedef std::pair<ll,ll> pii;

void check_max(ll a,ll &b){if(a>b)b=a;}

const int N=100100;
pii s[N];
int n,K;

int main()
{
	ll ans=0,tmp=0;

	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&s[i].x,&s[i].y);
		if((s[i].x&K)==s[i].x)ans+=s[i].y;
	}


	for(int k=0;k<=29;k++)
	{
		if((K>>k)&1)
		{
			ll sum=0;
			for(int i=1;i<=n;i++)
			{
				if(!(s[i].x>>k&1))
				{
					int a=s[i].x>>k,b=K>>k;
					if((a&b)==a)sum+=s[i].y;
				}
			}
			check_max(sum,ans);
		}
	}

	/*
	for(;tmp;tmp>>=1)
	{

		if(K&tmp)
		{
			int ind=n;
			std::sort(s+1,s+n+1);
			while(ind && (s[ind].x&tmp))ind--;

			ll sum=0;
			for(int i=1;i<=ind;i++)sum+=s[i].y;
			check_max(sum,ans);

			for(int i=ind+1;i<=n;i++)
				s[i].x^=tmp;
		}
		else 
		{
			int tot=0;
			ll sum=0;
			for(int i=1;i<=n;i++)
			{
				if((s[i].x&tmp)==0)s[++tot]=s[i];
				if(s[i].x==0)sum+=s[i].y;
			}
			n=tot;
			check_max(sum,ans);
		}

//		printf("tmp =%lld, %lld\n",tmp,ans);
	}
	*/

	printf("%lld\n",ans);

	return 0;
}


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

int main() {
	int A;
  	cin >> A;
    
    for(int i = 1; i <= A; i++){
      if(floor(i * 1.08) == A){
        cout << i << endl;
        return 0;
      }
    }
  cout << ":(" << endl;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    int ans=1e5;
    for(int bit=0;bit<(1<<N);bit++){
        int tmp=1;
        for(int i=0;i<N;i++){
            if(bit&(1<<i)){
                tmp+=K;
            }else{
                tmp*=2;
            }
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

int main()
{
    ll n, d, x;
    cin >> n >> d >> x;

    ll c = 0;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;

        c += (1 + (d- 1) / a);
    }

    println(c + x);
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,k,x,y;
int main()
{
    cin>>n>>k>>x>>y;
    if(n>k)
        cout<<x*k+(n-k)*y;
    else
        cout<<n*x;
}




Measured memory_bytes: 256