akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 84;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int H,W;
int A[MAXN][MAXN], B[MAXN][MAXN];
int dp[MAXN][MAXN][30000];
int base = 13000;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> H >> W;
    fore(i,1,H) fore(j,1,W) cin >> A[i][j];
    fore(i,1,H) fore(j,1,W) cin >> B[i][j];

    dp[0][1][base] = 1;
    dp[1][0][base] = 1;

    fore(i,1,H) {
        fore(j,1,W) {
            int d = A[i][j]-B[i][j];
            for(int b = -(80*80*2); b <= 80*80*2; b++) {
                //dp[i][j][base+b] = dp[i-1][j][base+b];
                //dp[i][j][base+b] = dp[i][j-1][base+b];

                int t = base+b;
                if(dp[i-1][j][t]) {
                    //debug(i-1);
                    //debug(j);
                    //debug(b);
                    //cout << endl;

                    dp[i][j][t+d] = 1;
                    dp[i][j][t-d] = 1;

                    //debug(i);
                    //debug(j);
                    //debug((t+d)-base);
                    //debug((t-d)-base);
                    //cout << endl;
                }

                if(dp[i][j-1][t]) {
                    //debug(i);
                    //debug(j-1);
                    //debug(b);
                    //cout << endl;

                    dp[i][j][t+d] = 1;
                    dp[i][j][t-d] = 1;
                    //debug(i);
                    //debug(j);
                    //debug((t+d)-base);
                    //debug((t-d)-base);
                    //cout << endl;
                }
            }
            //dp[i][j][base+d] = 1;
            //dp[i][j][base-d] = 1;
        }
    }

    //debug(dp[H][W][base]);

    int ans = 1e9;
    for(int b = -(80*80*2); b <= 80*80*2; b++) {
        if(dp[H][W][b+base]) {
            //debug(b);
            mmin(ans,abs(b));
        }
    }

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


Measured memory_bytes: 790912
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include <string.h>
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int maxn=200005;
long long ans1,ans2=1e18,n,da,xiao,maxx,maxy,minx=1e9+10,miny=1e9+10,weizhiy,weizhix;
struct pai
{
	long long x,y;
	bool operator < (const pai &a)const
	{
		long long gx1,gx2;
		if(xiao<=x&&x<=da)
			gx1=0;
		else if(xiao<=y&&y<=da)
			gx1=0;
		else if(y<xiao)
			gx1=xiao-y;
		else if(x>da)
			gx1=x-da;
		else 
			gx1=min(xiao-x,y-da);
		if(xiao<=a.x&&a.x<=da)
			gx2=0;
		else if(xiao<=a.y&&a.y<=da)
			gx2=0;
		else if(a.y<xiao)
			gx2=xiao-a.y;
		else if(a.x>da)
			gx2=a.x-da;
		else 
			gx2=min(xiao-a.x,a.y-da);
		return gx1>gx2;
	}
} p[maxn];
inline char nc()
{
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline long long read()
{
	char ch=nc();
	long long sum=0;
	while(!(ch>='0'&&ch<='9'))
	{
		ch=nc();
		if(ch==EOF)  
			return EOF;
	}
	while(ch>='0'&&ch<='9')
	{
		sum=sum*10+ch-48;
		ch=nc();
		if(ch==EOF)  
			return EOF;
	}
	return sum;
}

int main()
{
//	file("1"); 
	n=read();
	if(n==1)
	{
		printf("0");
		return 0;
	}
	for(int i=1; i<=n; i++)
	{
		p[i].x=read(),p[i].y=read();
		if(p[i].x>p[i].y)
			swap(p[i].x,p[i].y);
		maxx=max(maxx,p[i].x);
		if(p[i].y>maxy)
		{
			weizhiy=i;
			maxy=p[i].y;
		}
		if(p[i].x<minx)
		{
			weizhix=i;
			minx=p[i].x;
		}
		miny=min(miny,p[i].y);
	}
	ans1=(maxy-miny)*(maxx-minx);
//	cout<<ans1<<endl;
	da=p[weizhix].y,xiao=p[weizhiy].x;
	sort(p+1,p+n+1);
	if(da<xiao)
		swap(da,xiao);
	if(weizhix!=weizhiy)
	{
		for(int i=1; i<=n; i++)
		{
			int t=i;
			if((xiao<=p[i].x&&p[i].x<=da)||(xiao<=p[i].y&&p[i].y<=da))
				continue;
			else if(p[i].x>da)
				da=p[i].x;
			else if(p[i].y<xiao)
				xiao=p[i].y;
			else if(xiao-p[i].x<p[i].y-da)
				xiao=p[i].x;
			else
				da=p[i].y;
		}
		ans2=(maxy-minx)*(da-xiao);
	}
//	cout<<ans2<<endl;
	printf("%lld",min(ans1,ans2));
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n,m;cin>>n>>m;
    int p[n];rep(i,n)cin>>p[i];
    UnionFind uf(n);
    rep(i,m){
        int x,y;cin>>x>>y;
        --x;--y;
        uf.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if(uf.find(p[i]-1)==uf.find(i))++ans;
        else if((p[i]-1)==i)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
}

// nC2 = n * (n-1) / 2

Measured memory_bytes: 53572
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	static void solve() {
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			ArrayList<Integer> h = new ArrayList<>();
			for (int i = 0; i <= n; i++) {
				h.add(sc.nextInt());
			}
			for (int i = 0; i <= n; i++) {
				boolean flag = true;
				ArrayList<Integer> _h = new ArrayList<>(h);
				_h.remove(i);
				for (int j = 0; j < n - 2; j++) {
					if ((_h.get(j + 1) - _h.get(j)) != (_h.get(j + 2) - _h.get(j + 1))) {
						flag = false;
						break;
					}
				}
				if (flag) {
					out.println(h.get(i));
					break;
				}
			}
		}
		out.flush();
	}

	public static void main(String[] args) {
		solve();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

using namespace std;

string S;

int main(void)
{
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == ',') S[i] = ' ';
	}
	
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int, list(input())))
ans = 0

for a in range(10):
    for b in range(10):
        for c in range(10):
            targets = (a, b, c)
            target_idx = 0
            for i in range(len(S)):
                if S[i] == targets[target_idx]:
                    target_idx += 1
                    if target_idx == len(targets):
                        ans += 1
                        break

print(ans)


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

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

    S[3] = '8';
    cout << S << endl;
} 

Measured memory_bytes: 256
import numpy as np

n = int(input())

l = []

for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

l = np.array(l)
l = l[np.argsort(l[:,1],axis=0)]
ans = l[:,1]-np.cumsum(l[:,0])
ans = np.where(ans<0)[0]

print("Yes" if ans.shape[0]==0 else "No")



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

using ll = long long;

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

ll GCM(ll a, ll b)
{
	return (a / GCD(a, b)) * b;
}

int main(int argc, char **argv)
{
	int a, b;
	cin >> a >> b;
	std::cout << GCM(a, b) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)


//(a + b ) % m = (a % m + b % m ) %m

//(a - b ) % m = ( (a % m - b % m ) + m ) %m

//(a * b ) % m = (a % m * b % m ) %m

//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)


ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}




void solve(){
	ll n,i,j,sum=0;
	cin>>n;
	for(i=1;i<=n;i++){
		if(i%3==0&&i%5==0){

		}
		else if(i%3==0){

		}
		else if(i%5==0){

		}
		else{
			sum+=i;
		}
	}
	cout<<sum<<endl;

}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
 
 
void solve(){
    int r,g,b;
  	cin>>r>>g>>b;
    if((r*100+g*10+b)%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

int main(){
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define tc ll t;cin>>t;while(t--)
#define vll vector<ll>
#define p_b push_back
#define sll set<ll>
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
string s;
cin>>s;
int x=s.size();
string s1,s2;
//cout<<s.substr(0,4)<<endl;
ll p=0;
if(x % 2 == 0)
{
  int y=(x/2);
 // cout<<y<<endl;
 // cout<<s.substr(0,3)<<endl;
  s1=s.substr(p,y);
  s2=s.substr(x/2,y);
}
else
{
  s1=s.substr(p,x/2);
  s2=s.substr(x/2+1,x/2);
}
//cout<<s1<<endl<<s2<<endl;
ll c=0;
int n=s1.size();
for(int i=0;i<n;i++)
{
  if(s1[i]!=s2[n-1-i])
  c++;
}
cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  int i;
  for(i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  int a=d.at(n/2-1),b=d.at(n/2);
  cout << b-a;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <numeric>
#include <functional>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define INF 1e9
#define MOD 1e9+7
#define ll long long

using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<char>> v(n+2,vector<char>(m+2));
    
    rep(i,0,n+2){
        rep(j,0,m+2){
            if(i==0||j==0||i==n+1||j==m+1) cout<<"#";
            else {
                char x;
                cin>>x;
                cout<<x;
            }
        }
        cout<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
# 素因数分解をライブラリから使うため
require 'prime'

N = gets.to_i

# 素因数分解の結果が[基数，指数]の配列で返ってくる
arr = N.prime_division

z = N
ans = 0
arr.each do |f|
  e = 1
  while e*(e+1)/2 <= f[1]
    z /= (f[0]**e)
    # puts "z=#{z}"
    ans += 1
    e += 1
  end
end

puts ans

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int N;
vector<int> A;
int ans;

void dfs(int i, int cand) {
    if(i >= N) {
        if(cand % 2 == 0) { ans++; }
        return;
    }
    dfs(i+1, cand * A[i]);
    dfs(i+1, cand * (A[i]-1));
    dfs(i+1, cand * (A[i]+1));
    return;
}

int main()
{
    ans = 0;
    cin >> N;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    dfs(0, 1);
    printf("%d\n", ans);
    return 0;
}


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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define mii                          map< int, int >
#define msi                          map< string, int > 
#define mib                          map< int, bool > 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n;
int arr[N];


void solve()
{
      cin >> n;
      int x = 1e18;


      for(int i = 1; i*i <= n; i += 1)
      {
            if( n%i == 0 )
            {
                  int j = n/i;
                  x = min(x, (i-1 + j-1));
            }
      }
      cout << x;
}

int32_t main() {
    fastio;

  
  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















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

int dp1[3030][3030]; // 1-iまでにj分で食べ終わるときの最大値
int dp2[3030][3030]; // i-Nまでにj分で食べ終わる

int A[3030], B[3030];

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

    rep(i, N) {
        cin >> A[i] >> B[i];
    }

    // 1-iまで
    dp1[0][0] = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<=T; ++j) {
            dp1[i+1][j] = dp1[i][j];
            if (j-A[i] >= 0) {
                dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-A[i]] + B[i]);
            }
        }
    }

    // dp2[N][0] = 0;
    for (int i=N; i>0; --i) {
        for (int j=0; j<=T; ++j) {
            dp2[i][j] = dp2[i+1][j];
            if (j-A[i-1] >= 0) {
                dp2[i][j] = max(dp2[i][j], dp2[i+1][j-A[i-1]] + B[i-1]);
            }
        }
    }

    int ans = 0;
    for (int i=1; i<=N; ++i) {
        for (int j=0; j<T; ++j) {
            ans = max(ans, dp1[i-1][j] + dp2[i+1][T-1-j] + B[i-1]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 71936
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


ll dp[53][53];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int H,W;
int a[53][53]={0};
bool visited[53][53];
bool flag=false;

void dfs(int p,int q,int cost){
  // if(visited[p][q])return dp[p][q];
  //visited[p][q]=true;
  if(p==H-1 && q==W-1){
    flag =true;
    dp[p][q]=cost;
    return;
  }
  if(dp[p][q]>cost){
    dp[p][q]=cost;
    for(int i=0;i<4;i++){
      int x=p+dx[i],y=q+dy[i];
      if(a[x][y]==1)continue;
      if(x<0 || y<0 || x>=H || y>=W) continue;
      dfs(x,y,cost+1);
    }
  }
  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> H >> W;
  char c;
  ll kuro=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> c;
      if(c=='#'){
        a[i][j]=1;
        kuro++;
      }
      dp[i][j]=100000;
    }
  }
  dfs(0,0,1);
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  //cout << dp[H-1][W-1] << endl;
  ll ans=H*W-kuro-dp[H-1][W-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		Integer vlist[] = new Integer[n];
		Integer clist[] = new Integer[n];

		for(int i=0; i<n; i++){
			vlist[i] = sc.nextInt();
		}

		for(int j=0; j<n; j++){
			clist[j] = sc.nextInt();
		}

		int max = 0;

		Integer sumlist[] = new Integer[n];

		for(int s=0; s<n; s++){
			sumlist[s] = vlist[s] - clist[s];
		}
		Arrays.sort(sumlist,Collections.reverseOrder());
		for(int t=0; t<n; t++){
			if(max + sumlist[t] > max){
				max += sumlist[t];
			}
		}
		System.out.println(max);
		
	}
}


Measured memory_bytes: 24916
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		List<int[]> dishList = new ArrayList<int[]>();

		long point = 0;

		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			dishList.add(new int[] {a,b});
		}

		Collections.sort(dishList, new Comparator<int[]>() {
			public int compare(int[] obj1, int[] obj2) {
					long val1 = obj1[0] + obj1[1];
					long val2 = obj2[0] + obj2[1];
					return (Long.valueOf(val2)).compareTo(val1);
			}
		});

		for(int i = 0; i < n; i++) {
			if(i%2 == 0) {
				// 偶数は高橋ターン(Aを+)
				point += dishList.get(i)[0];
			} else {
				// 奇数は青木ターン(Bを-)
				point -= dishList.get(i)[1];
			}
		}

		System.out.println(point);


	}

}


Measured memory_bytes: 92004
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

const int maxn = 2e5 + 5;
int n;
ll k;
int a[maxn];
int ans[maxn];
int visited[maxn];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ans[0] = 1;
    int pd = n;
    int start_index, end_index;
    for (int i = 1; i <= n; i++) {
        visited[i] = -1;
    }
    visited[1] = 0;
    for (int i = 1; i <= n; i++) {
        ans[i] = a[ans[i - 1]];
        if (~visited[ans[i]]) {
            start_index = visited[ans[i]];
            end_index = i;
            break;
        }
        if (!(~visited[ans[i]])) visited[ans[i]] = i;
    }
    if (k <= start_index) {
        cout << ans[k] << "\n";
    } else {
        k -= start_index;
        int red = k % (end_index - start_index);
        cout << ans[start_index + red] << "\n";
    }
}

Measured memory_bytes: 5952
function Main(input) {
  input = input.split("\n");
  var C = input[0];
  var ans = String.fromCharCode(C.charCodeAt(0)+1);

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.next();
		int ans = 0;
		int len = string.length();

		for (int i = 0; i < len; i++) {
			if (string.charAt(i) != string.charAt(len - 1 - i)) {
				ans++;
			}
		}

		System.out.println(ans / 2);

		sc.close();
	}

}


Measured memory_bytes: 23124
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S;
  cin>>S;
  string T="No";
  int N=S.size();
  for(int i=0;i<N-1;i++){
    if(S[i]=='A'&&S[i+1]=='C') T="Yes";
  }
  cout<<T;
return 0;}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;

    string S;

    REP(i,a){
        cin >> S;
        cout << S << endl;
        cout << S << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    int max_t;
    scanf("%d",&n);
    scanf("%d",&max_t);

    int c;
    int t;
    int max_cost = 1001;
    
    for(int i = 0; i < n; i++){
        scanf("%d",&c);
        scanf("%d",&t);
        
        if(t <= max_t){
            if(max_cost > c){
                max_cost = c;
            }
        }
    }
    
    if(max_cost < 1001){
        printf("%d",max_cost);
    }else{
        printf("TLE");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	int a,b,k;
	cin>>k>>a>>b;
	int p=a/k;
	int q=b/k;
	if(q-p > 0)
		cout<<"OK";
	else if(a%k==0 || b%k==0)
		cout<<"OK";
	else
		cout<<"NG";
}

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

void Solve(){
 	int k;
 	string s;
 	cin>>k>>s;
 	int n = s.size();
 	if(n <= k){
 		cout<<s<<endl;
 		return;
 	}
 	string res = "";
 	for(int i = 0; i < k; i++) res += s[i];
 	res += "...";
 	cout<<res<<endl;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<decimal> lstInp = new List<decimal>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(decimal.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            decimal iOut = 0M;
            for (int i = 0; i < lstInp.Count; i++)
            {
                iOut += 1M / lstInp[i];
            }
            iOut = 1 / iOut;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(){
  int a, b; cin>>a>>b;
  if(a==1) a = 14;
  if(b==1) b = 14;
  if(a>b) cout << "Alice" << endl;
  else if(a<b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    return N,


@njit
def solve(N):
    ndivs = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ndivs += j
    return ndivs


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 108988
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	string s; cin >> s;
	int n = 0;
	FOR_LT(i, 0, s.size()) {
		if (s[i] != s[s.size() - 1 - i]) n++;
	}
	cout << (n / 2) << endl;


	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
#x,y = [int(i) for i in readline().split()]

s = input()
l = len(s)
s += "WXYZ"
dp1 = [0]*(l+10)
dp2 = [0]*(l+10)
dp1[0] = dp2[1] = 1
now = ""
for i in range(l):
    if s[i] != s[i+1]:
        dp1[i+1] = max(dp1[i+1],dp1[i]+1)
    if s[i:i+2] != s[i+2:i+3]:
        dp2[i+2] = max(dp2[i+2],dp2[i]+1)
    
    dp2[i+2] = max(dp2[i+2],dp1[i]+1)
    dp1[i+1] = max(dp1[i+1],dp2[i]+1)
    

#print(dp1)
#print(dp2)
print(max(dp1[l-1],dp2[l-1]))

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  vstr s(n); cin >> s;
  int ans = 0, a = 0, b = 0, ba = 0;
  rep(i, n) {
    rep(j, s[i].size() - 1) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
    }
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') ba++;
    else {
      if (s[i][0] == 'B') b++;
      if (s[i][s[i].size() - 1] == 'A') a++;
    }
  }
  if (ba > 0) {
    ans += ba - 1;
    if (a > 0) ans++, a--;
    if (b > 0) ans++, b--;
    ans += min(a, b);
    cout << ans << '\n';
  } else {
    cout << ans + min(a, b) << '\n';
  }
}


Measured memory_bytes: 768
#include <iostream>
#include <map>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int p,q;
    while(cin>>p>>q){
        map<int,int> mod;
        int i=0;
        while(1){
            int t=p/q;
            if(i!=0) cout<<t;
            p%=q;
            if(mod.count(p)){
                cout<<'\n';
                int b=mod[p];
                rep(j,b) cout<<' ';
                rep(j,i-b) cout<<'^';
                cout<<'\n';
                break;
            }
            mod[p]=i;
            if(p==0){
                cout<<'\n';
                break;
            }
            p*=10, i++;
        }
    }
}

Measured memory_bytes: 1192
#include<stdio.h>
int main()
{
    int p,q,r,min;
    scanf("%d%d%d",&p,&q,&r);
    min=((p+q)>(q+r)?((q+r)>(p+r)?(p+r):(q+r)):((p+q)>(p+r)?(p+r):(p+q)));
    printf("%d",min);
    return 0;
}


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

using namespace std;

int n, m, a[100005], id[100005], par[100005];

int find(int s){
	if(s == par[s]) return s;
	return par[s] = find(par[s]);
}

int main(){
	scanf("%d%d", &n, &m);
	
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		id[a[i]] = i;
	}
	
	for(int i = 1; i <= n; i++)
	par[i] = i;
	
	for(int i = 0; i < m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		
		int u = find(x);
		int v = find(y);
		
		par[u] = v;
	}
	
	int res = 0;
	
	for(int i = 1; i <= n; i++){
		if(find(i) == find(id[i]))
		res++;	
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(){
    int n,m;
    char ch[100][100];
    scanf("%d %d",&n,&m);
    getchar();
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%c",&ch[i][j]);
        }
        getchar();
    }
    for(int i=0; i<=m+1; i++){
        printf("#");
    }
    printf("\n");
    for(int i=0; i<n; i++){
        printf("#");
        for(int j=0; j<m; j++){
            printf("%c",ch[i][j]);
        }
        printf("#\n");
    }
   for(int i=0; i<=m+1; i++){
        printf("#");
    }
    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define pi acos(-1.0)

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


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double ang = abs(h * 30.0 + m * 1.0 / 2.0 - 6 * m) * pi / 180.0;
    ang = min(ang, 2 * pi - ang);
    cout << fixed << setprecision(15) << sqrtl(a * a + b * b - 2 * a * b * cos(ang)) << "\n";

    return 0;
}

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

int main() {

	int N,y,a,b,flag;
	unsigned long  Y;
	flag = 0;
	cin >> N >> Y;
	y = Y / 1000;
	a = floor(y / 10);
	for (int i = 0; i <= a; i++) {
		b = floor((y - 10 * i) / 5);
			for (int j = 0; j <= b; j++) {
				int k = N - i - j;
				if (10 * i + 5 * j + k == y) {
					cout << i <<' '<< j <<' '<< k;
					flag = 1;
					goto OUT;
				}
			}
	}
OUT:
	if (flag==0) cout << -1 << ' ' << -1 << ' ' << -1;
	return 0;
}


Measured memory_bytes: 256
# B
import re
s = input() 
# s = "keyencLeL"
patterns = ["^.+keyence$", 
            "^k.+eyence$",
            "^ke.+yence$",
            "^key.+ence$",
            "^keye.+nce$",
            "^keyen.+ce$",
            "^keyenc.+e$",
            "^keyence.+$",
            "^keyence$"]

found = False
for p in patterns:   
    c = re.compile(p)
    m = c.match(s)
    if m: found = True
print("YES" if found else "NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +100500;
const ll INF = 1e18;

ll a[MAXN];

vector <ll> dp(MAXN, INF);

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


Measured memory_bytes: 1792
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll dp[100005][3],a[100005],b[100005],c[100005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,0,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  forn(i,1,n){
    dp[i][0]=a[i] + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i] + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i] + max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  return 0;
}


Measured memory_bytes: 4992
S= input()
while len(S) >=0:
    if len(S) ==0:
        print("YES")
        break
    if S[-7:] == "dreamer":
        S = S[:-7]
    
    elif S[-6:] =="eraser":
        S = S[:-6]
    
    elif S[-5:] =="dream":
        S = S[:-5]
    
    elif S[-5:] =="erase":
        S = S[:-5]
    
    else:
        print("NO")
        break

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

using namespace std;

using ll=long long ;
void solve() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int _ = 1; _ < n; _++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<ll> hint(n, 0);
    while (q--) {
        int i, x;
        cin >> i >> x;
        i--;
        hint[i] += x;
    }
    vector<ll> res(n, 0);
    function<void(int, int)> dfs = [&](int u, int p){
        for (int v: g[u]) {
            if (v == p) continue;
            res[v] += res[u] + hint[v];
            dfs(v, u);
        }
    };
    res[0] = hint[0];
    dfs(0, -1);
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

typedef long long ll;

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

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

const ll MOD = 1000000007;

// auto mod int
// ref. https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

vector<ll> x;
vector<ll> y;

vector<ll> sx;
vector<ll> sy;

int main(void) {
    ll _n, _m;
    cin >> _n >> _m;

    // preparation

    mint n(_n);
    mint m(_m);

    x.resize(_n + 1, 0);
    sx.resize(_n + 1, 0);
    for (int i = 0; i < _n; i++) {
        cin >> x[i + 1];
        sx[i + 1] = sx[i] + x[i + 1];
    }

    y.resize(_m + 1, 0);
    sy.resize(_m + 1, 0);
    for (int i = 0; i < _m; i++) {
        cin >> y[i + 1];
        sy[i + 1] = sy[i] + y[i + 1];
    }

    // calculation

    mint term1(0);
    for (int i = 1; i < _n; i++) {
        term1 += sx[_n] - sx[i];
    }
    mint term2(0);
    for (int i = 1; i < _n; i++) {
        term2 += x[i] * ll(_n - (i + 1) + 1);
    }
    mint term3(0);
    for (int i = 1; i < _m; i++) {
        term3 += sy[_m] - sy[i];
    }
    mint term4(0);
    for (int i = 1; i < _m; i++) {
        term4 += y[i] * ll(_m - (i + 1) + 1);
    }
    // printf("temr1: %lld, term2: %lld, term3: %lld, term4: %lld\n", term1.x, term2.x, term3.x, term4.x);
    mint ans = term1 * term3 - term1 * term4 - term2 * term3 + term2 * term4;

    cout << ans.x << endl;

    return 0;
}


Measured memory_bytes: 3328
A, B, C, K = map(int,input().split())

if K <= A :
   ans = K
   print(ans)

elif K >= A :
   M = K - A
   if M <= B :
      ans = A
      print(ans)

   elif M >= B :
      L = M - B
      ans = A - L
      print(ans)


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

int main()
{
    int r,g,b,sum;

    scanf(" %d %d %d",&r,&g,&b);
    r=r*100;
    g=g*10;
    sum=r+g+b;
    if(sum%4==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int ta[100010],nt[200010],to[200010],co[200010],gg;
int MAX(int a,int b){return a<b?b:a;}
int d[100010];
void mkls(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[b[i]]=i+e]=co[ta[a[i]]=i]=c[i];
  }
}
int f(int s,int p){
  int m=0,i;
  for(i=ta[s];i+1;i=nt[i]){
    if(to[i]==p)continue;
    m=MAX(m,f(to[i],s)+co[i]);
  }//printf("%d %d\n",s,m);
  return d[s]=m;
}
int g(int s,int p){//printf("\ns%d p%d",s,p);
  int a=d[s],b,i,c=0,m=0;
  if(p+1){//????????????
    b=d[p];
    for(i=ta[p];i+1;i=nt[i]){//????????´??°
      if(to[i]==s)c=co[i];
      else m=MAX(m,d[to[i]]+co[i]);//????????????????????????m?????\??????
    }
    d[p]=m;
    m+=c;//??????????????????????????????m?????\???
  }
  for(i=ta[s];i+1;i=nt[i]){//????????´??°
    if(to[i]-p)m=MAX(m,d[to[i]]+co[i]);//????????????????????????m?????\??????
  }
  d[s]=m;
  for(i=ta[s];i+1;i=nt[i]){//??????????????????
    if(to[i]-p)m=MAX(m,g(to[i],s));//????????????????????????m?????\??????
  }
  if(p+1)d[p]=b;//????????????
  d[s]=a;//???????????????
  return m;
}
int main(){
  int n,m,a[100010],b[100010],c[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);//printf("c\n");
  mkls(n,n-1,a,b,c);//printf("a\n");
  f(n/2,-1);//printf("b\n");
  //for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
  printf("%d\n",g(n/2,-1));//,tyokkei(n));
  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

int seive[N];

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
		memset(seive,-1,sizeof seive);
		seive[1] = 0;
		seive[0] = 0;
		for(int i = 2; i * i < N; i++)
		{
			int cnt = 2;
			while(i * cnt < N) seive[i*cnt++] = 0;
		}	
		vector<int> v;
		for (int i = 0; i < N; i++)
		{
			if(seive[i] == -1) v.EB(i);
		}
		int x; cin>>x;
		auto it = lower_bound(ALL(v),x) - v.begin();
		cout<<v[it];
		
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  vector<string> s(n);
  REP(i,n){
    cin>>s[i];
  }
  int ans=0;
  char temp[n][n];
  bool flag;
  REP(d,n){
    flag = true;
    REP(i,n){
      REP(j,n){
        temp[i][(j+d)%n] = s[i][j];
      }
    }
    REP(i,n){
      REP(j,n){
        if(temp[i][j]==temp[j][i])continue;
        flag = false;
        break;
      }
      if(!flag)break;
    }
    if(flag)ans++;
  }
  
  ans *= n;
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 512