akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <sstream>
#include <vector>
using namespace std;

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

    int N;
    cin >> N;
    bool flg = false;
    for (int i = 1; i <= 9 && !flg; i++)
    {
        for (int j = 1; j <= 9; j++)

        {
            if (i * j == N)
            {
                flg = true;
                break;
            }
        }
    }

    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,m;
  cin >> n >> m;
  mat d(n,vec(n,inf));
  vec a(m),b(m),c(m);
  for(ll i=0;i<n;i++) d[i][i]=0;
  for(ll i=0;i<m;i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    d[a[i]][b[i]]=c[i];
    d[b[i]][a[i]]=c[i];
  }
  for(ll k=0;k<n;k++) {
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<n;j++) {
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<m;i++) {
    ans+=d[a[i]][b[i]]!=c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i64, k: i64,
    }
    let nn: usize = n as usize;
    if n < 2 * k - 1 {
        puts!("-1\n");
        return;
    }
    let mut ans = vec![];
    for i in 0..k {
        ans.push((n - k + 1 + 2 * i, 2 * n - i, 3 * n - k + 1 + i));
    }
    for i in 0..k - 1 {
        ans.push((n - k + 2 + 2 * i, 2 * n + k - 1 - i, 3 * n + 1 + i));
    }
    for i in 0..n - k {
        ans.push((k + i, n + k + i, k + 2 * n + i));
    }
    for i in 0..nn {
        let (a, b, c) = ans[i];
        puts!("{} {} {}\n", a, b, c);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 16636
#include <stdio.h>
#include <string.h>

int main(void){
    int n;
    int length;
    char taro[1000];
    char hanako[1000];
    int pointt = 0;
    int pointh = 0;

    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
        scanf("%s %s", taro, hanako);

        if(strcmp(taro, hanako) == 0){
            pointt++;
            pointh++;

        }
        else if(strcmp(taro, hanako) > 0 ){
            pointt += 3;

        }
        else if(strcmp(taro, hanako) < 0){
            pointh += 3;

        }
    }
    printf("%d %d\n", pointt, pointh);

    return (0);
}




Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        int cnt = 0;
        for(int j = i; j < s.size(); j++)
        {
            if(not (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')) break;
            cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
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 sn, PrintWriter out) {
            String s = sn.next();
            if (s.contains("AC")) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }
}



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

int main()
{
    int N, M;
    long long L;
    cin>>N>>M>>L;

    long long oo = 1'000'000'000'000'000;
    vector<vector<long long>> D1(N, vector<long long>(N, oo));
    for (int i=0; i<M; i++)
    {
        int A, B;
        long long C;
        cin>>A>>B>>C;
        D1[A-1][B-1] = D1[B-1][A-1] = C;
    }

    for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            for (int k=0; k<N; k++)
                D1[j][k] = min(D1[j][k], D1[j][i]+D1[i][k]);

    vector<vector<long long>> D2(N, vector<long long>(N, oo));
    for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            if (D1[i][j]<=L)
                D2[i][j] = 0;
    for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            for (int k=0; k<N; k++)
                D2[j][k] = min(D2[j][k], D2[j][i]+D2[i][k]+1);

    int Q;
    cin>>Q;
    for (int i=0; i<Q; i++)
    {
        int s, t;
        cin>>s>>t;
        cout<<(D2[s-1][t-1]<oo ? D2[s-1][t-1] : -1)<<endl;
    }
}


Measured memory_bytes: 1920
#include<stdio.h>
#define N 100
#define Black 2
#define White 0
#define Gray 1

int n,A[N][N];
int IRO[N],a[N],b[N],tt ;

void DFS_HOUMON(int u)
{
  int i;
  IRO[u] = Gray;
  a[u] = ++tt;
  for(i=0;i<n;i++)
    {
      if(A[u][i] == 0) continue;
      if(IRO[i] == White)
	{
	  DFS_HOUMON(i);
	}
    }
  IRO[u] = Black;
  b[u] = ++tt;
}

void DFS()
{
  int u;
  for(u=0;u<n;u++)IRO[u] = White;
  tt = 0;

  for(u=0;u<n;u++)
    {
      if(IRO[u] == White)DFS_HOUMON(u);
    }

  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,a[u],b[u]);
    }
}
   

int main()
{
  int u,p,q,ii,j;

  scanf("%d",&n);

  for(ii=0;ii<n;ii++)
    {
      for(j=0;j<n;j++) A[ii][j] = 0;
    }
  for(ii=0;ii<n;ii++)
    {
      scanf("%d %d" ,&u,&q);
      u--;
      for(j=0;j<q;j++)
	{
	  scanf("%d",&p);
	  p--;
	  A[u][p] = 1;
	}
    }

  DFS();

  return 0;
}
  



Measured memory_bytes: 2720
L,R=map(int,input().split())
if R-L>=2018:
    A=list(range(2019))
else:
    A=set([n%2019 for n in range(L,R+1)])
    A=list(A)
n=len(A)
minimun=2019
for i in range(n):
    for j in range(i+1,n):
        new=(A[i]*A[j])%2019
        if new<minimun:
            minimun=new
print(minimun)

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if(a<b){
        if(a+w<b) cout << b-(a+w) << endl;
        else if(a+w>=b) cout << 0 << endl;
    }
    else if(a>b){
        if(b+w<a) cout << a-(b+w) << endl;
        else if(b+w>=a) cout << 0 << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import * as process from "process";
import * as readline from "readline";

process.stdin.resume();
process.stdin.setEncoding('utf8');

let lines = []
let reader = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', line => {
    lines.push(line);
});

reader.on('close', () => {
    let [a, b, c, d] = lines[0].split(" ");
    const a1 = a * b;
    const a2 = c * d;
    if (a1 >= a2) {
        console.log(a1);
    } else {
        console.log(a2);
    }

});

Measured memory_bytes: 7628
def main():
    N = int(input())
    H = list(map(int, input().split()))
    Max = 0
    for i in range(N):
        if H[i] > Max:
            H[i] -= 1
            Max = H[i]
        elif H[i] == Max:
            pass
        else:
            print('No')
            return
    print('Yes')
main()

Measured memory_bytes: 20508
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
 
int main(){
  int N, T, H, L;
  while(cin>>N>>T>>H>>L && N){
    int myt = T;
    int myh = H;
    int idx = 0;
    int t[100], h[100];
    REP(i, N) cin>>t[i]>>h[i];
    int ans = -1;
    int rest = 0;
    while(true){
      if(t[idx] > 0){
        myt++;
        t[idx]--;
        rest += 10;
      }else if(h[idx] > 0){
        myh++;
        h[idx]--;
        rest += 100;
      }else{
        ans = idx;
        break;
      }
      if(myt > L){
        ans = idx;
        break;
      }
      if(rest >= 90){
        int res = rest - 90;
        if(res / 10 > myt){
          ans = idx;
          break;
        }else{
          myt -= res / 10;
          t[idx] += res / 10;
        }
        rest = 0;
      }
      idx = (idx + 1) % N;
    }
    cout<<ans + 1<<endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);
	map< int, int > mp;

	REP(i, n) {
		mp[min(1LL*(a[i] / 400), 8LL)]++;
	}

	//min
	int mx = 0, mn=0;
	REP(i, 8) {
		if (mp.count(i)) mx++;
	}
	if (mp.count(8)) mn = mx + (mx == 0 ? 1 : 0);
	else mn = mx;

	OUT(mn)SP;

	if (mp.count(8)) mx += mp[8];
	OUT(mx)BR;

	
	
  
  return 0;
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< int > a(n);
  for (int i=0; i<n; ++i) cin >> a[i];
  vector< int > f(1e6+1, 0);
  for (int i=0; i<n; ++i) f[a[i]]++;
  int ans = 0;
  for (int i=0; i<n; ++i) {
    bool flg = true;
    if (f[a[i]] > 1) flg = false;
    if (a[i]==1) {
      if (f[a[i]] == 1) ans++;
      continue;
    }
    for (int j=1; j*j<=a[i]; ++j) {
      if (a[i]%j!=0) continue;
      if (f[j]) flg = false;
      if (j>1 && f[a[i]/j]) flg = false;
    }
    if (flg) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7928
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
vector<int> p(5);
void solve() {
	for (int i = 0; i < 5; ++i) {
		cin >> p[i];
	}
	int ans = INF;
	do {
		int sum = 0;
		for (int i = 0; i < 5; ++i) {
			//10の倍数の時にのみ注文できるので、割り切れるまでカウントアップ
			while(sum % 10 != 0) sum++;	
			sum += p[i];
		}
		ans = min(ans, sum);
	//順列を全列挙する
	}while(next_permutation(p.begin(), p.end()));
	cout << ans << endl;
	return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
	solve();
}

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

int main() {
    string S;
    cin >> S;
    int n = S.size();

    long sum = 0;
    for (int bit = 0; bit < (1 << (n-1)); ++bit) {

        // 数文字列
        string temp = "";
        // 一文字目を追加する
        temp += S.at(0);
        
        // + を入れるかどうかを判定
        for (int i = 0; i < n-1; ++i) {
            if (bit & (1<<i)) {
                // それまでの文字列を数値に変換し加算
                sum += stol(temp);
                // 数文字列をリセット
                temp = "";
            }
            // 数文字列に追加
            temp += S.at(i+1);
        }
        // 残りの数文字列を数値に変換し加算
        sum += stol(temp);
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int Max,Min,n,i,k,S,Count;
	
	int dataset[20];
	
	Count = 0;
	
	for(k=0;k<=19;k++){
	
		scanf ("%d",&n);
		
		if(n == 0){
			
			break;
			
		}
		
		int numbers[100];
		
		
		for(i=0;i<=n-1;i++){
		
			scanf ("%d",&numbers[i]);
			
			if(i == 0){
			
				Max = numbers[i];
				
				Min = numbers[i];
				
				S = numbers[i];
				
			}else if(i != 0){
				
				S = S + numbers[i];
			
				if(numbers[i] < Min){
				
					Min = numbers[i];
					
				}else if(numbers[i] > Max){
				
					Max = numbers[i];
					
				}
				
			}
			
		}
		
	dataset[k] = (S - Max - Min)/ (n - 2);
		
	Count++;
		
			
	}
	
	int l;
	
	for(l=0;l<Count;l++){
		
		printf ("%d\n",dataset[l]);
		
	}
	
	return 0;
	
}



Measured memory_bytes: 1984
#include<stdio.h>
#include<string.h>
int H,W,N,F[1005][1005],C[10][2],S[500005][3],i,j,mv[5]={1,0,-1,0,1},R;
char M[1005][1005],t;

int bfs(int sx,int sy,int gx,int gy)
{
	int i,j,p=1,x,y,c;
	memset(F,0,sizeof(F));
	S[0][0]=sx;S[0][1]=sy;S[0][2]=0;
	for(i=0;i<p;i++)
	{
		x=S[i][0];y=S[i][1];c=S[i][2];
		if(F[y][x]>c)
			continue;
		if(x==gx&&y==gy)
			return c;
		
		for(j=0;j<4;j++)
		{
			if(M[y+mv[j]][x+mv[j+1]]=='.'&&(F[y+mv[j]][x+mv[j+1]]==0||F[y+mv[j]][x+mv[j+1]]>c+1))
			{
				F[y+mv[j]][x+mv[j+1]]=c;
				S[p][0]=x+mv[j+1],S[p][1]=y+mv[j],S[p][2]=c+1;
				p++;
			}
		}
	}
	return -1;
}

int main()
{
	scanf("%d%d%d\n",&H,&W,&N);
	for(i=1;i<=H;i++)
		for(j=1;j<=W+1;j++)
		{
			t=getchar();
			if(t>10&&t!='.'&&t!='X')
			{
				if(t=='S')
					C[0][0]=i,C[0][1]=j;
				else
					C[t-'0'][0]=i,C[t-'0'][1]=j;
				M[i][j]='.';
			}
			else
				M[i][j]=t;
		}
	for(i=R=0;i<N;i++)
		R+=bfs(C[i][1],C[i][0],C[i+1][1],C[i+1][0]);
	printf("%d\n",R);
	return 0;
}

Measured memory_bytes: 10844
/*
    AUTHOR : TANMAY SINHA
    INFORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(i=L;i<R;i++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 5000000;
#define sq(X) ((X)*(X))

int main()
{
    ll x,i,s;
    cin>>x;
    s = (x/500);
    i = (x - s*500)/5;
    // deb1(i);
    s*=1000;
    i*= 5;
    cout<<s+i<<"\n";
}

Measured memory_bytes: 256
import java.io.*;
    import java.util.StringTokenizer;

    public class Main {

        private static void solver(InputReader sc, PrintWriter out) {
            int n =  sc.nextInt();
            int ans = n/500;
            long totans = ans * 1000;
            n = n%500;
            int next = n/5;
            totans += next * 5;
            out.println(totans);
        }

        public static void main(String[] args) {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            solver(in, out);
            out.close();
        }
        static class InputReader {
            public BufferedReader reader;
            public StringTokenizer tokenizer;

            public InputReader(InputStream stream) {
                reader = new BufferedReader(new InputStreamReader(stream), 32768);
                tokenizer = null;
            }

            public String next() {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    try {
                        tokenizer = new StringTokenizer(reader.readLine());
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                return tokenizer.nextToken();
            }

            public int nextInt() {
                return Integer.parseInt(next());
            }
            public long nextLong() {
                return Long.parseLong(next());
            }
        }
    }


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N, a[200001] = {0}, b[200001] = {0}, c[200001] = {0}, i, dp[200001][3], ans = 0;
	cin >> N;
	for(i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		dp[i][0] = dp[i][1] = dp[i][2] = 0;
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(i = 1; i < N; i++)
	{
		dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
		dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][0] + b[i]);
		dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
	}
	ans = max(ans, dp[N - 1][0]);
	ans = max(ans, dp[N - 1][1]);
	ans = max(ans, dp[N - 1][2]);
	cout << ans;
}

Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main{

	public static void main(String[] args) {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String work[]=new String[2];
		
		ArrayList<Integer> S=new ArrayList<Integer>();
		ArrayList<Integer> H=new ArrayList<Integer>();
		ArrayList<Integer> C=new ArrayList<Integer>();
		ArrayList<Integer> D=new ArrayList<Integer>();
		
		int n=0;
		try {
			//入力
			n=Integer.parseInt(br.readLine());	//nを入力
			
			for(int i=0; i<n; i++) {
				work=br.readLine().split("\\s+");
				switch(work[0]){
				case "S":
					S.add(Integer.parseInt(work[1]));
					break;
				case "H":
					H.add(Integer.parseInt(work[1]));
					break;
				case "C":
					C.add(Integer.parseInt(work[1]));
					break;
				case "D":
					D.add(Integer.parseInt(work[1]));
					break;
				}
			}
			
		}catch(IOException e) {
			e.printStackTrace();
		}
		
		//ソート
		Collections.sort(S);
		Collections.sort(H);
		Collections.sort(C);
		Collections.sort(D);
		
		//判定
		StringBuilder sb=new StringBuilder();
		
		for(int i=1; i<14; i++) {
			if((S.indexOf(i))==-1){		//indexOfは存在しない値を返すと-1出力.
				sb.append("S "+i);
				sb.append(String.format("%n", ""));
			}
		}
		
		for(int i=1; i<14; i++) {
			if((H.indexOf(i))==-1){		//indexOfは存在しない値を返すと-1出力.
				sb.append("H "+i);
				sb.append(String.format("%n", ""));
			}
		}
		
		for(int i=1; i<14; i++) {
			if((C.indexOf(i))==-1){		//indexOfは存在しない値を返すと-1出力.
				sb.append("C "+i);
				sb.append(String.format("%n", ""));
			}
		}
		
		for(int i=1; i<14; i++) {
			if((D.indexOf(i))==-1){		//indexOfは存在しない値を返すと-1出力.
				sb.append("D "+i);
				sb.append(String.format("%n", ""));
			}
		}
		
		//出力
		System.out.print(sb);
	}

}



Measured memory_bytes: 24748
n,m=map(int,input().split())
ab=[]
cd=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
for i in range(m):
    cd.append(list(map(int,input().split())))
for i in range(n):
    mi=10000000000000
    ans=-1
    for j in range(m):
        k=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi>k:
            ans=j+1
            mi=k
    print(ans)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int val[200005],ans[200005];
vector <int> g[200005];
void dfs(int v,int sum)
{
    sum+=val[v];
    ans[v]=sum;
    for(int i=0;i<g[v].size();i++)
    dfs(g[v][i],sum);
    sum-=val[v];
}
int main()
{
    char s[100005],s1[100005];
    int n,a1[100005],i,u,v,q;
    double a,b;
    scanf("%d %d",&n,&q);
    for(i=0;i<n-1;i++)
    {
        scanf("%d %d",&u,&v);
        g[u].push_back(v);
    }
    for(i=0;i<q;i++)
    {
        scanf("%d %d",&u,&v);
        val[u]+=v;
    }
    dfs(1,0);
    for(i=0;i<n;i++)
    {
        printf("%d ",ans[i+1]);
    }
}

Measured memory_bytes: 24192
n, k = map(int, input().split())
a = list(map(int, input().split()))
cycle = []
mark = [-1]*n
pos, l = 0, 0
while 1:
    if mark[pos] >= 0:
        l = mark[pos]
        break
    mark[pos] = len(cycle)
    cycle.append(pos)
    pos = a[pos]-1
if k <= l:
    print(cycle[k]+1)
else:
    k -= l
    print(cycle[l + k%(len(cycle)-l)] + 1)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vi div;
  rep1 (i, 100) {
    if (a % i == 0 && b % i == 0) div.push_back(i);
  }
  reverse(all(div));
  cout << div[k - 1] << endl;
}



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

int bit[50];
ll dp[50][15];
ll dfs(int pos,int t,int lead,int lim)
{
    if(pos==0) return lead?0:1;
    if(!lim && !lead && dp[pos][t]!=-1) return dp[pos][t];
    int num = lim?bit[pos]:9;
    ll res = 0;
    for(int i=0;i<=num;i++)
    {
        if(lead)
        {
            if(i==0) res += dfs(pos-1,0,1,lim&&i==num);
            else res += dfs(pos-1,i,0,lim&&i==num);
        }
        else
        {
            if(abs(t-i)<=1) res += dfs(pos-1,i,0,lim&&i==num);
        }
    }
    if(!lim&&!lead)return dp[pos][t]=res;
    else return res;
}
ll calc(ll k)
{
    int len = 0;
    while(k)
    {
        bit[++len] = k%10;
        k /= 10;
    }
    return dfs(len,0,1,1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    //cout<<calc(21)<<endl;
    int n;
    cin>>n;
    ll L=0,R=1LL<<60;
    ll ans;
    while(L<=R)
    {
        ll mid = (L+R)>>1;
        if(calc(mid)>=n) R=mid-1,ans=mid;
        else L=mid+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n;
    cin >> n;
    ll ans =0;
    for(ll i=1; i<=n; i++){
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
	private static int h, w, n;
	private static boolean[] wall;
	private static int[] sx, sy;
	
	private static int[] dx = { 0, 1,  0, -1 };
	private static int[] dy = { 1, 0, -1,  0 };
	
	private static int getInt() throws Exception {
		int i = 0;
		while(true){
			int buf = System.in.read();
			if('0' > buf || buf > '9'){
				break;
			}
			i = i * 10 + buf - '0';
		}
		return i;
	}
	private static int heuristic(final int sx, final int sy, final int ex, final int ey) {
		return Math.abs(sx - ex) + Math.abs(sy - ey);
	}
	private static int search(final int sx, final int sy, final int ex, final int ey) {
		Comparator<int[]> cmp = new Comparator<int[]>() {
			@Override
			public int compare(int[] a, int[] b) {
				return Integer.compare(a[2] + heuristic(a[0], a[1], ex, ey), b[2] + heuristic(b[0], b[1], ex, ey));
			}
		};
		int[] costs = new int[h*w];
		costs[sx + sy*w] = Integer.MAX_VALUE;
		PriorityQueue<int[]> q = new PriorityQueue<>(cmp);
		q.offer(new int[]{sx, sy, 0});
		while(true){
			int[] now = q.poll();
			int newCost = now[2] + 1;
			for(int i = 0; i < 4; i++){
				int nx = now[0] + dx[i];
				int ny = now[1] + dy[i];
				int p = nx + ny*w;
				if(0 <= nx && nx < w && 0 <= ny && ny < h && !wall[p] && (costs[p] == 0 || costs[p] > newCost)){
					if(nx == ex && ey == ny) return now[2] + 1;
					costs[p] = newCost;
					q.offer(new int[]{nx, ny, newCost});
				}
			}
		}
		
	}
	public static void main(String[] args) throws Exception {
		h = getInt();
		w = getInt();
		n = getInt();
		wall = new boolean[h*w];
		sx = new int[10];
		sy = new int[10];
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++) {
				int buf = System.in.read();
				if(buf =='\n' || buf == '\r'){
					x--;
					continue;
				}
				wall[x + y*w] = buf == 'X';
				if(buf == 'S'){
					sx[0] = x;
					sy[0] = y;
				}
				if('1' <= buf && buf <= '9'){
					buf -= '0';
					sx[buf] = x;
					sy[buf] = y;
				}
			}
		}
		int a = 0;
		for(int i = 1; i <= n; i++) a += search(sx[i-1], sy[i-1], sx[i], sy[i]);
		System.out.println(a);
	}

}

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

int main(){
    string s;
    cin >> s;
    int l = s.size(), r = 0; 
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' && l > i) l = i;
        if(s[i] == 'Z' && r < i) r = i;
    }
    cout << r - l + 1 << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e4+7;
int N[maxn];
int main()
{
	string s;cin>>s;int cnt1=0,cnt2=0;
	for(int i=0;i<s.length();i++)
	{
		if(i%2!=(s[i]-'0')) cnt1++;
		if(i%2==(s[i]-'0')) cnt2++;
	}
	cout<<min(cnt1,cnt2)<<endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << (h2 - h1) * 60 + m2 - m1 - k << endl;
	return 0;
}

Measured memory_bytes: 3624
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std ;



int main()
{
    
    long long k,x;
    cin >> k >> x;
    k=k*500;
    if (k>=x){
        cout << "Yes" ;
    }
    else {
        cout << "No" ;
    }
    
        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
 
struct node{
  int lc;
  int rc;
  int key;
  void init(int a){
    lc=rc=-1;
    key=a;
  }
};
 
#define bstN 600000
struct bst{
 
  int size;
  node t[bstN];
 
  void init(){
    size=0;
  }
   
  void insert(int v){
    int i=0;
    while(i<size){
      int& child=(v<t[i].key?t[i].lc:t[i].rc);
      if(child==-1)child=size;
      i=child; 
    }
    t[size++].init(v);
  }
 
  void preord(int pos){
    if(pos==-1||pos==size)return;
    preord(t[pos].lc);
    printf(" %d",t[pos].key);
    preord(t[pos].rc);
  }
   
  void inord(int pos){
    if(pos==-1||pos==size)return;
    printf(" %d",t[pos].key);
    inord(t[pos].lc);
    inord(t[pos].rc);
  }
};
 
 
bst T;
 
int main(){
  T.init();
  int n,a;
  char str[100];
  scanf("%d",&n);
   
  while(n--){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      T.insert(a);
    }else{
      T.preord(0);
      printf("\n");
      T.inord(0);
      printf("\n");
    }
  }
 
  return 0;
}


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

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


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

using namespace std;

int main(){
    int A[3], sum = 0;
    for (int i = 0; i < 3; ++i) {
        cin >> A[i];
    }
    sort(A, A+3);
    sum = abs(A[0] - A[1]) + abs(A[2] - A[1]);
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
char c[6005];
bool use[6005];
vector <string> vec;

void solve(int l,int r)
{
	string res="";
	if(c[l]=='b')
	{
		vector <string> vec;
		for(int i=l;i<r;i++)
		{
			use[i]=true;
		}
		for(int i=0;i<(r-l)/2;i++)
		{
			string t="";
			for(int j=l;j<r;j++)
			{
				if(use[j]) t+=c[j];
			}
			vec.push_back(t);
			for(int j=l;j<r;j++)
			{
				if(c[j]=='a' && use[j]==true)
				{
					use[j]=false;
					break;
				}
			}
			for(int j=l;j<r;j++)
			{
				if(c[j]=='b' && use[j]==true)
				{
					use[j]=false;
					break;
				}
			}
		}
		sort(all(vec));
		res=vec[(int)vec.size()-1];
	}
	else
	{
		int sa=0,sb=0,la=0;
		for(int i=l;i<r;i++)
		{
			if(c[i]=='a') sa++;else sb++;
			if(sb>la) la=sa,res+="ab";
		}
	}
	vec.push_back(res);
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	n*=2;
	scanf("%s",c);
	int s=0;
	int last=0;
	for(int i=0;i<n;i++)
	{
		if(c[i]=='a') s++;else s--;
		if(s==0)
		{
			solve(last,i+1);
			last=i+1;
		}
	}
	string res=vec[(int)vec.size()-1];
	for(int i=(int)vec.size()-2;i>=0;i--)
	{
		int isres=0;
		for(int len=0;len<min((int)res.size(),(int)vec[i].size());len++)
		{
			if(vec[i][len]!=res[len])
			{
				if(vec[i][len]<res[len])
				{
					isres=1;
					break;
				}
				else
				{
					isres=0;
					break;
				}
			}
		}
//		cout<<i<<endl;
		if(!isres) res=vec[i]+res;
	}
	cout<<res<<endl;
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}


vector<ll> pow3() {
	vector<ll> ans;
	ll b = 1;
	for (int i = 0; i <= 15; i++) {
		ans.push_back(b);
		b *= 3;
	}
	return ans;
}

inline int pop3(ll j) {
	int a = 0;
	while (j) {
		if (j % 3) a++;
		j /= 3;
	}
	return a;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> xs(n), ys(n), ps(n);
	rep(i, n) {
		cin >> xs[i] >> ys[i] >> ps[i];
	}
	vector<vector<ll>> dxs(n, vector<ll>(n));
	vector<vector<ll>> dys(n, vector<ll>(n));
	rep(i, n) {
		rep(j, n) {
			dxs[i][j] = min(abs(xs[i] - xs[j]), abs(xs[i]));
			dys[i][j] = min(abs(ys[i] - ys[j]), abs(ys[i]));
		}
	}
	const auto table = pow3();
	vector<ll> nxs(table[n],0);
	vector<ll> nys(table[n],0);
	for (ll j = 0; j < table[n]; j++) {
		ll c = j;
		for(int a = 0; a < n && c > 0; a++) {
			if (c % 3 == 1) {
				nxs[j] |= (1LL << a);
			}
			else if (c % 3 == 2) {
				nys[j] |= (1LL << a);
			}
			c /= 3;
		}
	}
	vector<vector<ll>> xss(n, vector<ll>(1LL << n, 0));
	vector<vector<ll>> yss(n, vector<ll>(1LL << n, 0));
	rep(j, 1LL << n) {
		rep(k, n) {
			ll dx = abs(xs[k]);
			ll dy = abs(ys[k]);							
			rep(i, n) {
				if (j & (1LL << i)) {
					dx = min(dx, dxs[k][i]);
					dy = min(dy, dys[k][i]);
				}
			}
			xss[k][j] = dx;
			yss[k][j] = dy;
		}
	}
	vector<ll> ans(n + 1, INF);
	for (ll j = 0; j < table[n]; j++) {
		ll d = 0;
		for (int k = 0; k < n; k++) {
			ll dx = xss[k][nxs[j]];
			ll dy = yss[k][nys[j]];
			d += min(dx, dy) * ps[k];
		}
		auto p = pop3(j);
		ans[p] = min(ans[p], d);
	}
	for (int i = 0; i <= n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 235472
N=int(input())
A=[int(i) for i in input().split()]
T=[2**i for i in range(1,35)]
table=[True]*N
A.sort()
ans=0
for t in T[::-1]:
  l,r=0,N-1
  while l<r:
    if A[l]+A[r]>t:
      r-=1
    elif A[l]+A[r]==t:
      if table[l] and table[r]:
        ans+=1
        table[l],table[r]=False,False
      if not table[l]:
        l+=1
      if not table[r]:
        r-=1
    elif A[l]+A[r]<t:
      l+=1
print(ans)
        


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string S;
    cin >> S;

    if (S.back() == 's') cout << S + "es" << '\n';
    else cout << S + "s" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  string S; cin >> S;
  reverse(ALL(S));
  vector<string> t ={"dream", "dreamer", "erase", "eraser"};
  rep(i, 4) reverse(ALL(t[i]));

  int idx = 0;
  while(1) {
    if(S.substr(idx, 7) == t[1]) idx+=7;
    else if(S.substr(idx, 6) == t[3]) idx+=6;
    else if(S.substr(idx, 5) == t[0] || S.substr(idx, 5) == t[2]) idx+=5;
    else {cout << "NO" << endl; return 0;}

    if(idx==S.size()) {
      cout << "YES" << endl;
      return 0;
    }
  }

  return 0;
}


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

typedef std::pair <int, int> pr;
const int N = 100054, INF = 0x3f3f3f3f;

int n, q;
int c[N], C[N], x[N];
int last[N], ans[N];
pr a[N];
std::priority_queue <int> pq;

inline int min(const int x, const int y) {return x < y ? x : y;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline int pos(int val) {return std::lower_bound(x, x + n, val) - x;}

int main() {
	int i, j, r, cur = 0, cov = 0; bool fail = false;
	scanf("%d", &n), ++n;
	for (i = 1; i < n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	for (i = 0; i < n; ++i) scanf("%d", x + i);
	std::sort(x, x + n);
	for (i = 1; i < n; ++i) down(a[i].second = pos(a[i].second), a[i].first = pos(a[i].first));
	std::fill(c, c + n, -1);
	for (i = 1; i < n; ++i) ++c[a[i].first], std::swap(a[i].first, a[i].second);
	std::sort(a + 1, a + n);

	for (j = 1, i = 0; i < n; ++i) {
		for (cur += c[i]; j < n && a[j].first == i; ++j) pq.emplace(a[j].second);
		for (r = INF; !pq.empty() && pq.top() > i && cur < 0; r = pq.top(), pq.pop(), ++cur, ++cov, --c[r]);
		for (; !pq.empty() && pq.top() <= i; pq.pop());
		
		C[i] = cur, last[i] = r;
		if (cur < -1) {fail = true; break;}
	}
	scanf("%d", &q);
	if (fail) {for (; q; --q) puts("-1"); return 0;}
	for (r = i = n - 1; i >= 0; --i) ~C[i] ? last[i] <= r && (r = i, --cov) : (r = j = i), ans[i] = cov;
	memset(ans + (j + 1), 63, (n - j + 5) << 2);
	
	for (; q; --q)
		scanf("%d%d", &i, &j), r = min(ans[pos(i)], ans[pos(j)] + 1),
		printf("%d\n", r >= INF ? -1 : n - r);
	return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include <algorithm>
#include<string.h>
#define ll long long
#define ull unsigned long long
using namespace std;
/* 
struct edge{
	int to, nxt;
}e[100005];
int head[100005], tot = 1, x, num[100005];
void add(int v, int u)
{
	e[tot].to = u, e[tot].nxt = head[v], head[v] = tot++;
}*/
int dis[100005], k, n, m;
int find(int x)
{
	if (dis[x] != x)	return dis[x] = find(dis[x]);
	return x;
}
void uni(int x, int y)
{
	int xx = find(x);
	int yy = find(y);
	if (xx != yy)
	{
		dis[xx] = yy;
	}
}
signed main() 
{
	while (~scanf("%d%d", &n, &m))
	{
		k = 0; 
		for (int i = 1; i <= n; i++)	dis[i] = i;
		for (int i = 0; i < m; i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			uni(a, b);
		}
		for (int i = 1; i <= n; i++)
			if (find(i) == i)	k++;
		printf("%d\n", k);
	}
}


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

using namespace std;

int main() {
    int n,k;
    while(cin >> n >> k){ 
            if(n % k) cout << 1 << endl;
    else cout << 0 << endl;
//        cout << n / k - n % k << endl;
    }
    return 0;
}


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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint GetFactorial(ll n) {
  mint ret = 1;
  for(ll i = 2; i <= n; ++i) ret*=i;
  return ret;
}

/***** MAIN *****/
signed main() {
  int N, M;
  cin >> N >> M;
  if(abs(N - M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  mint n = GetFactorial(N);
  mint m = GetFactorial(M);
  mint ans = 0;
  if(N == M) {
    ans = n * m * 2;
  } else {
    ans = n * m;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#define max(a,b)((a)>(b)?(a):(b))
long long BIT[100010], bit_size; // long long は 64bit 整数．
void bit_init(int n){
	memset(BIT,0,n*(sizeof(long long)));
	bit_size = n;
}
long long bit_max(int n){ // [1,n] の最大値
	long long ans = 0;
	while(n > 0){
		ans = max(ans, BIT[n]);
		n &= n-1;
	}
	return ans;
}
void bit_setmax(int n, long long v){ // # [1,n] の最大値を v に更新する
	while (n < bit_size){
		BIT[n] = max(BIT[n], v);
		n += n & (-n);
	}
}
int main(){
	long long N,x,i=0;
	scanf("%lld",&N);
	bit_init(N+1);
	for(; i<N; ++i){
		scanf("%lld",&x);
		long long cost = bit_max(x);
		bit_setmax(x,cost+x);
	}
	printf("%lld\n",(1+N)*N/2 - bit_max(N));
exit(0);}

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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builti
#define ll long long

int main()
{
	int m1,d1,m2,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if(m2==m1+1||(m2==1&&m1==12))
		cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
#define INF 1000000000000000000
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 long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	map<string, int>mp;
	rep(i, n) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	int ans = 0;
	for (auto& p : mp) {
		int s = p.second;
		ans += s * (s - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264