akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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__)
const long long inf = 1LL << 60;
const int intinf = 1 << 30;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << ", ";
    }
};

const int max_n = 100010;
vector<int> parent(max_n, -1);
vector<int> child[max_n];
vector<int> depth(max_n);

void dep(int i, int d) {
    depth[i] = d;
    rep(j, child[i].size()) { dep(child[i][j], d + 1); }
}

int main() {
    int n;
    cin >> n;
    int p, k, c;
    rep(i, n) {
        cin >> p >> k;
        rep(j, k) {
            cin >> c;
            child[p].push_back(c);
            parent[c] = p;
        }
    }
    rep(i, n) {
        if(parent[i] < 0) {
            dep(i, 0);
        }
    }
    rep(i, n) {
        // node 0: parent = -1, depth = 0, root, [1, 4, 10]
        cout << "node " << i << ": parent = " << parent[i]
             << ", depth = " << depth[i];
        if(parent[i] < 0) {
            cout << ", root, [";
        } else if(child[i].size() == 0) {
            cout << ", leaf, [";
        } else {
            cout << ", internal node, [";
        }
        vecout(child[i]);
        cout << "]\n";
    }
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll result=0;
	string S;
	cin>>N;
	VVI a(2,VI(N,0));
	REP(j, 2) {
		REP(i,N)
		cin >> a[j][i];
	}
	ll dp[2][101] = {};
	memset(dp, 0, sizeof(dp));
	dp[0][0]=a[0][0];
	dp[1][0]=a[1][0]+dp[0][0];
	//初期条件
	REP(j,1){
		REP(i,N-1){
			dp[j][i+1] = dp[j][i]+a[j][i+1];//右
			//dp[j+1][i] = dp[j][i]+a[j+1][i];//下
			ll top=dp[j][i+1]+a[j+1][i+1];
			ll left=dp[j+1][i]+a[j+1][i+1];
			dp[j+1][i+1] = max(top,left);
		}
	}
	result=dp[1][N-1];
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod = 1000000007;

string l;
int ab;
int ans;
int dp[100010][2]; // is_small
signed main() {
    cin >> l;
    dp[0][0] = 2;
    dp[0][1] = 1;
    for (int i=0;i<l.size()-1;i++) {
        int d = l[i+1] - '0';
        // same to same
        
        if (d == 1) {
            dp[i+1][0] += 2*dp[i][0];
            dp[i+1][1] += dp[i][0];
        } else {
            dp[i+1][0] += dp[i][0];
        }
        dp[i+1][1] += 3*dp[i][1];

        dp[i+1][0] %= mod;
        dp[i+1][1] %= mod;
        // cout << i+1 << " " << dp[i+1][0] << " " << dp[i+1][1] << endl;
    }
    ans = dp[l.size()-1][0] + dp[l.size()-1][1];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i)cin>>vec[i];
	int ret = 1e9;
	while(true){
		sort(vec.begin(), vec.end());
		vector<int> res;
		for(int i = 1; i < n; ++i){
			vec[i] %= vec[0];
			if(vec[i]){res.push_back(vec[i]); ret = min(ret, vec[i]);}
		}
		res.push_back(vec[0]);
		vec = res;
		if(vec.size() == 1){
			ret = min(ret, vec[0]);
			cout<<ret<<endl;
			return 0;
		}
	}
	return 0;
}


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

int main()
{
	string s,t;
	while(cin >> s, s!="0")
	{
		for(int i=0; i<2; i++)
		{
			cin >> t;
			s+=t;
		}
		int b=0, w=0;
		for(int i=0; i<9; i++)
		{
			if(s[i] == 'b') b++;
			if(s[i] == 'w') w++;
		}
		bool bw=false, ww=false;
		for(int i=0; i<9; i+=3)
		{
			if(s[i] == 'b' && s[i+1] == 'b' && s[i+2] == 'b') bw=true;
			if(s[i] == 'w' && s[i+1] == 'w' && s[i+2] == 'w') ww=true;
		}
		for(int i=0; i<3; i++)
		{
			if(s[i] == 'b' && s[i+3] == 'b' && s[i+6] == 'b') bw=true;
			if(s[i] == 'w' && s[i+3] == 'w' && s[i+6] == 'w') ww=true;
		}
		if(s[0] == 'b' && s[4] == 'b' && s[8] == 'b') bw=true;
		if(s[0] == 'w' && s[4] == 'w' && s[8] == 'w') ww=true;
		if(s[2] == 'b' && s[4] == 'b' && s[6] == 'b') bw=true;
		if(s[2] == 'w' && s[4] == 'w' && s[6] == 'w') ww=true;
		
		cout << (bw?"b":ww?"w":"NA") << endl;
	}
}

Measured memory_bytes: 0
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Sugoroku
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // = 262144
const int INF = 1 << 30;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2];
  SegTreeMin() {}

  void init(int _n) {
    n = _n;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, INF);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = min<T>(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }
  
  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return INF;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = min_range(r0, r1, k * 2 + 2, im, i1);
    return min<T>(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

/* global variables */

char s[MAX_N + 4];
SegTreeMin<int,MAX_E2> st;
int rs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d%s", &n, &m, s);

  st.init(n + 1);
  st.set(n, 0);

  for (int i = n - 1; i >= 0; i--)
    if (s[i] == '0') {
      int a = st.min_range(i + 1, min(i + m + 1, n + 1));
      if (a >= INF) {
	puts("-1");
	return 0;
      }
      st.set(i, a + 1);
    }

  int rn = 0;
  for (int i = 0; i < n;) {
    int ai = st.get(i);
    int j = i + 1;
    while (j < n && st.get(j) >= ai) j++;
    rs[rn++] = j - i;
    i = j;
  }

  for (int i = 0; i < rn; i++) {
    if (i) putchar(' ');
    printf("%d", rs[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;


map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
signed main() {
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    int tmp = 0;
    rep(i,n) { 
       if(s[i]=='A' ||s[i]=='C' ||s[i]=='G' ||s[i]=='T') {
            tmp++;
        }else {
            tmp = 0;
        }
        ans = max(tmp,ans);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  ll N;
  cin >> N;
  if(N==0){
    cout << 0 << endl;
    return 0;
  }
  string ans="";
  ll now=2;
  ll sum=0;
  rep(i,60){
    ll res=N-sum;
    ll rem=(res%now);
    if(rem<0)rem+=now;
    int r=i%2==0?1:-1;
    if(rem!=0){sum+=r*(now/2);ans+="1";}
    else{ans+="0";}
    now*=2;
  }
  reverse(ans.begin(),ans.end());
  bool beg=false;
  rep(i,ans.size()){
    if(ans[i]=='1')beg=true;
    if(beg)cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
cnt=cnt2=0
for s in S:
    if s=='c':
        print('No')
    elif s=='a' and cnt < A+B:
        print('Yes')
        cnt+=1
    elif s=='b' and cnt < A+B and cnt2 < B:
        print('Yes')
        cnt+=1
        cnt2+=1
    else:
        print('No')

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll N; cin>>N;
	vector<ll> A(N+1);
	rep1(i,N) cin>>A[i];

	//solve
	ll i=0,sub=1;
	while(i<N+3){
		sub=A[sub];
		i++;
		if(sub==2) break;
	}
	
	if(i==N+3) cout<<-1;
	else cout<<i;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int64 A, B, C, X, Y;	
	cin >> A >> B >> C >> X >> Y;
	int64 res = INF_LL;
	REP(i, max(X, Y)+1){
		res = min(res, C*i*2+max((int64)0, X-i)*A+max((int64)0, Y-i)*B);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
function main()
    n = parse(Int, chomp(readline()))
    i = 0
    while true
        val = 4*i
        if val > n
            break
        end
        while val <= n
            if val == n
                println("Yes")
                return
            end
            val += 7
        end
        i += 1
    end
    println("No")
end

main()


Measured memory_bytes: 110584
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

k,n = l_in()
A = l_in()
A.append(A[0]+k)
print(k-max(A[i+1]-A[i] for i in range(n)))


Measured memory_bytes: 79352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int N;
	int lgt[100010];
	vector<int> seq;
	cin >> N;
	REP(i, N){
		cin >> lgt[i];
	}
	int cur = lgt[0];
	REP(i, N){
		int l = lgt[i];
		int r_i = 0;
		cur = lgt[i];
		while(r_i+i < N && cur == lgt[i+r_i]){
			r_i++;
			cur = 1-cur;
		}
		seq.push_back(r_i);
		i += r_i-1;
	}
	ll res = 0;
	REP(i, max(1, (int)seq.size()-2)){
		ll cnt = 0;
		REP(j, 3){
			if(i+j < seq.size())
				cnt += seq[i+j];
		}
		res = max(res, cnt);
	}
	cout << res << endl;
}

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

int main(){
  bool cards[4][13];
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 13; j++){
      cards[i][j] = false;
    }
  }

  int n, x;
  char A;
  cin >> n;

  for (int i = 0; i < n; i++){
    cin >> A >> x;
    if ( A == 'S' ) cards[0][x-1] = true;
    else if ( A == 'H' ) cards[1][x-1] = true;
    else if ( A == 'C' ) cards[2][x-1] = true;
    else if ( A == 'D' ) cards[3][x-1] = true;

  }

  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 13; j++){
      if (cards[i][j] == false) {
        if (i == 0) cout << 'S' << " " << j + 1 << endl;
        else if (i == 1) cout << 'H' << " " << j + 1 << endl;
        else if (i == 2) cout << 'C' << " " << j + 1 << endl;
        else if (i == 3) cout << 'D' << " " << j + 1 << endl;
      }
    }
  }

return 0;
}

Measured memory_bytes: 3024
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B >= C)
    {
        cout << "Yes\n";
    }else
    {
    cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

string s;
int main(void){
    cin >> s;
    if(s[0]=='7' or s[1]=='7' or s[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

long long int dp[5010][5010],pre[5010],po[5010],inv[5010];

const int mod = 1e9 + 7;
const int i2 = 5e8 + 4;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	po[0]=inv[0]=1;
	for(int i=1;i<=5005;i++)	po[i]=po[i-1]*2%mod,inv[i]=inv[i-1]*i2%mod;
	cin>>n>>m;
	for(int i=1;i<=m;i++)	dp[n][i]=1;
	for(int i=n-1;i>=0;i--){
		for(int j=1;j<=m;j++){
			pre[j]=(pre[j-1]+dp[i+1][j]*inv[j+1]%mod*j)%mod;
			dp[i][j]=(dp[i+1][j]*(j+1)+pre[j-1]*po[j])%mod;
		}
	}
	cout<<dp[0][m]<<endl;
}


Measured memory_bytes: 199440
n = int( input() )
s = []
for _ in range( n ):
    s_i = str( input() )
    s.append( s_i )

cnt = { "AC" : 0, "WA" : 0, "TLE" : 0, "RE" : 0 }

for s_i in s:
    cnt[ s_i ] += 1

print( "AC x " + str( cnt[ "AC" ] ) )
print( "WA x " + str( cnt[ "WA" ] ) )
print( "TLE x " + str( cnt[ "TLE" ] ) )
print( "RE x " + str( cnt[ "RE" ] ) )

Measured memory_bytes: 16292
N, M = map(int, input().split())

L = [0 for _ in range(M)]
R = [0 for _ in range(M)]

for i in range(M):
    L[i], R[i] = map(int, input().split())

maxL = max(L)
minR = min(R)

sa = minR - maxL + 1

if sa >= 0:
    print(sa)
else:
    print(0)


Measured memory_bytes: 11016
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B

main = B.interact$B.pack.unlines.f.unfoldr (B.readInt.B.dropWhile isSpace)

f (_:x:y:xys)=case chk (odd (x +y)) xys of
    Nothing -> ["-1"]
    Just(p) -> sol p (x:y:xys)

chk True [] = Just(0)
chk False [] = Just(1)
chk f (x:y:xys)
    | odd (x+y) == f = chk f xys
    | otherwise = Nothing

sol 0 xys = "31":dl:s 0 xys
sol 1 xys = "32":('1':' ':dl):map ('D':) (s 1 xys)

dl = unwords $ map (show.(2^)) [0..30]

s _ [] = []
s p (x:y:xys) = unfoldr t (31, us, vs) : s p xys
    where
        u = x+y+p
        v = x-y-p
        us = (2^31 - 1 - u)`div`2
        vs = (2^31 - 1 - v)`div`2

t (k,us,vs)
    | k==0 = Nothing
    | otherwise = Just(h us vs, (k-1,us`div`2,vs`div`2))
h us vs
    | even us && even vs = 'R'
    | even us = 'U'
    | even vs = 'D'
    | otherwise = 'L'

Measured memory_bytes: 7548
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, P[1001], X[1001];
	scanf("%d", &N);
	for (i = 2, P[1] = 1; i <= N; i++) scanf("%d", &(P[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(X[i]));
	
	list *adj[1001] = {}, e[1003];
	for (i = 2; i <= N; i++) {
		e[i].v = i;
		e[i].next = adj[P[i]];
		adj[P[i]] = &(e[i]);
	}
	
	int q[1001], head, tail;
	list *p;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		for (p = adj[q[head]]; p != NULL; p = p->next) q[tail++] = p->v;
	}
	
	int u, w, min[1001] = {}, sum;
	char dp[5001];
	for (head--; head >= 0; head--) {
		u = q[head];
		for (i = 1, dp[0] = 1; i <= 5000; i++) dp[i] = 0;
		for (p = adj[u], sum = 0; p != NULL; p = p->next) {
			w = p->v;
			sum += X[w] + min[w];
			for (i = X[u]; i >= 0; i--) {
				if (dp[i] == 1) {
					dp[i] = 0;
					if (i + X[w] <= X[u]) dp[i+X[w]] = 1;
					if (i + min[w] <= X[u]) dp[i+min[w]] = 1;
				}
			}
		}
		for (i = X[u]; i >= 0; i--) if (dp[i] == 1) break;
		if (i < 0) break;
		
		min[u] = sum - i;
	}
	
	if (head >= 0) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
	fflush(stdout);
	return 0;
}

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

using namespace std;

string a[102];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int X, Y, gx, gy;

int dfs(int y, int x){
  int i;
  if(y < 0 || Y <= y || x < 0 || X <= x || a[y][x] == '.') { gx = x; gy = y; return 0;}
  if(a[y][x] == '#') return 1;
  if(a[y][x] == '^')      i = 0;
  else if(a[y][x] == '>') i = 1;
  else if(a[y][x] == 'v') i = 2;
  else                    i = 3;
  a[y][x] = '#';
  dfs(y + dy[i], x + dx[i]);
}

int main(){
  while(cin >> Y >> X, X != 0 || Y != 0) {
    for(int i = 0; i < Y ; i++)
      cin >> a[i];
    if(dfs(0, 0) == 1)cout << "LOOP" << endl;
    else  cout << gx << ' ' << gy << endl;
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int flag_a=0,flag_b=0;
    string str;
    cin>>str;
    for(int i=0; str[i]; i++)
    {
        if(str[i]=='A')
        {
            flag_a=1;
        }
        else if(str[i]=='B')
        {
            flag_b=1;
        }
        if(flag_a&&flag_b)
        {
            break;
        }
    }
    if(flag_a&&flag_b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;

    }








    return 0;
}



Measured memory_bytes: 256
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    S = input()

    weathers = ["Sunny", "Cloudy", "Rainy", "Sunny"]

    idx = weathers.index(S)

    print(weathers[idx+1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;
import java.lang.*;
import java.io.*;
 
class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String p = scan.next();
         
        String ring = s + s;
         
        if (ring.contains(p)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");           
        }
    }
}

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

int N, MOD;
vector<vector<int>> adj;

// up[node] = number of ways to color the subtree of node that its parent is responsible for, empty coloring included.
// down[node] = number of ways to paint node's subtree where node must be painted black.
vector<int> up, down;

long long solve_down(int node, int parent) {
    down[node] = 1;

    // Erase parent from adj[node].
    for (int &neighbor : adj[node])
        if (neighbor == parent) {
            swap(neighbor, adj[node].back());
            adj[node].pop_back();
            break;
        }

    for (int child : adj[node])
        down[node] = down[node] * (solve_down(child, node) + 1) % MOD;

    return down[node];
}

void solve_up(int node) {
    int n = adj[node].size();
    vector<int> prefix(n, 1), suffix(n, 1);

    for (int i = 0; i + 1 < n; i++)
        prefix[i + 1] = (long long) prefix[i] * (down[adj[node][i]] + 1) % MOD;

    for (int i = n - 1; i > 0; i--)
        suffix[i - 1] = (long long) suffix[i] * (down[adj[node][i]] + 1) % MOD;

    for (int i = 0; i < n; i++)
        up[adj[node][i]] = (1 + (long long) prefix[i] * suffix[i] % MOD * up[node]) % MOD;

    for (int child : adj[node])
        solve_up(child);
}

int main() {
    scanf("%d %d", &N, &MOD);
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    up.assign(N, 1);
    down.assign(N, 1);
    solve_down(0, -1);
    solve_up(0);

    for (int i = 0; i < N; i++)
        printf("%lld\n", (long long) up[i] * down[i] % MOD);
}


Measured memory_bytes: 17536
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n,x,a[150],sum=0;
  std::cin >> n >> x;
  for(int i=0; i<n; i++) {
    std::cin >> a[i];
    sum+=a[i];
  }

  sort(a,a+n);
  int cnt=n-1;
  x=x-sum;

  while(x>=0){
    x-=a[0];
    cnt++;
  }
  
  std::cout << cnt << '\n';
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n, q int
	fmt.Sscan(getNextLine(scanner), &n, &q)
	processes := make([]Process, n+1)
	for i := 0; i < n; i++ {
		fmt.Sscan(getNextLine(scanner), &processes[i].name, &processes[i].time)
	}
	head := 0
	tail := n
	time := 0
	n++
	for head != tail {
		p := processes[head]
		head = (head + 1) % n
		p.time -= q
		time += q
		if p.time <= 0 {
			time += p.time
			fmt.Fprintln(writer, fmt.Sprintf("%s %d", p.name, time))
			continue
		}
		processes[tail] = p
		tail = (tail + 1) % n

	}

	writer.Flush()
}

type Process struct {
	name string
	time int
}



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

// template < typename T >
// void (const vector < T > & )

void solve () {

}

int main() {
    int n; string s;
    cin >> n >> s;
    if (n%2) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0, j = n/2; i < n/2; i++, j++) {
        if (s[i] != s[j]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
int n;
int a[2000],pre[2000],dp[500][500];
int solve(int i,int j)
{
	if(i==j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	int ans=inf;
	for(int k=i;k<j;k++)
	{
		ans=min(ans,solve(i,k)+solve(k+1,j)+pre[j]-pre[i-1]);
	}
	dp[i][j]=ans;
	return ans;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   cin>>n;
   memset(dp,-1,sizeof(dp));
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }
   for(int i=1;i<=n;i++)
   {
   	pre[i]=pre[i-1]+a[i-1];
   }
   cout<<solve(1,n)<<endl;
}        


Measured memory_bytes: 2432
n=int(input())
A=list(map(int,input().split()))
B=sorted(A)
hanbun=n//2
left_B=B[hanbun-1]
right_B=B[hanbun]
for a in A:
    if a <= left_B:
        print(right_B)
    else:
        print(left_B)

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    int M = 13;
    vec<ll> pow26(M+1,1);
    for(int i=1;i<=M;i++) pow26[i] = pow26[i-1]*26;
    ll n = 0;
    int len = 1;
    if(N>26){
        for(int i=1;i<=M;i++){
            n += pow26[i];
            len = i+1;
            if(n+pow26[i+1]>=N){
                break;
            }
        }
    }
    N -= n+1;
    string ans = "";
    for(int i=0;i<len;i++){
        ll n = N/pow26[len-i-1];
        N -= n*pow26[len-i-1];
        char c = 'a'+n;
        ans += c;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3580
using System;

class Program
    {

        static int input;
        static int reversedinput;

        static void Main(string[] args)
        {
        input = Convert.ToInt32(Console.ReadLine());
        reversedinput = Convert.ToInt32(Reverse(input.ToString()));

        if(input == Convert.ToInt32(reversedinput))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

  
        }

        private static string Reverse(string s)
        {
            char[] arr = s.ToCharArray();
            Array.Reverse(arr);
            return new string(arr);
        }


}


Measured memory_bytes: 11220
import numpy as np
import itertools 
def distance(a,b):
    x1,y1 = a
    x2,y2 = b
    return np.sqrt((x1-x2)**2 + (y1- y2)**2)
n = int(input())
xy = []
for _ in range(n):
    x,y = map(int,input().split())
    xy.append([x,y])
n_permutations = itertools.permutations(range(n))
dist_list=[]
for one_case in n_permutations:
    dist = 0
    for i in range(n-1):
        a = xy[one_case[i]]
        b = xy[one_case[i+1]]
        dist += distance(a,b)
    dist_list.append(dist)
print(sum(dist_list)/len(dist_list))

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

double dist(int x1, int y1, int x2, int y2)
{
	double a = x1 - x2, b = y1 - y2;;
	return sqrt(a * a + b * b);
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n;
	cin >> n;

	double sum = 0, X[n], Y[n];
	for (int i = 0; i < n; ++i)
		cin >> X[i] >> Y[i];
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			sum += dist(X[i], Y[i], X[j], Y[j]);
	cout << setprecision(10) << (2 * sum) / n << '\n';
}


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

int  main()
{
int ans;
double sa=1000000000;
  int n,T,A,H;
scanf("%d",&n);
scanf("%d%d",&T,&A);
for(int i=0;i<n;i++)
{
scanf("%d",&H);
if(sa>fabs(A-(T-H*0.006)))
 {
sa=fabs(A-(T-H*0.006));
ans=i;
 }


}



printf("%d",ans+1);
return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    lisA = list(map(lambda x: int(x), input().split()))
    lisB = list(map(lambda x: int(x), input().split()))
    total = 0
    for i in range(len(lisB)):
        if lisA[i] > lisB[i]:
            total += lisB[i]
            lisA[i] -= lisB[i]
            lisB[i] = 0
        else:
            total += lisA[i]
            lisB[i] -= lisA[i]
            lisA[i] = 0
        if lisA[i+1] > lisB[i]:
            total += lisB[i]
            lisA[i+1] -= lisB[i]
            lisB[i] = 0
        else:
            total += lisA[i+1]
            lisB[i] -= lisA[i+1]
            lisA[i+1] = 0

    print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

/****************** グラフ ******************/
// 諸宣言
using Weight = lint;
using Flow = lint;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
    Edge(int s, int d, Weight w, Flow c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
    g[b].emplace_back(b, a, w, c);
}
void add_arc(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
}

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> x;
    repeat_from_to (i, 0, n) {
        int value = 1;
        rep(i) value *= 2;
        rep(n - i) value += k;
        x.emplace_back(value);
    }
    cout << *min_element(x.begin(), x.end()) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, ndata1, ndata2, nfound = 0, data1[100000], data2[50000];
  int mid, left, right;
  
  scanf("%d",&ndata1);
  for(i = 0; i < ndata1; i++) {
    scanf("%d",&data1[i]);
  }
  scanf("%d",&ndata2);
  for(i = 0; i < ndata2; i++) {
    scanf("%d",&data2[i]);
  }

  for(i = 0; i < ndata2; i++) {
    left = 0;
    right = ndata1;

    while(left < right) {
      mid = (left + right)/2;
      if(data1[mid] == data2[i]) {
	nfound++;
	break;
      }
      else if(data2[i] < data1[mid]) right = mid;
      else left = mid + 1;
    }
  }

  printf("%d\n",nfound);
  
  return 0;
}



Measured memory_bytes: 2316
import java.util.*;

public class Main {

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

		long ans = 0;

		for (int i = 1; i <= K; i++) {
			for (int j = 1; j <= K; j++) {
				for (int k = 1; k <= K; k++) {
					ans += threeGCD(i, j, k);
				}
			}
		}

		System.out.println(ans);
	}

	public static long GCD(long a, long b) {
		if (b == 0) {
			return a;
		}
		return GCD(b, a % b);
	}

	public static long threeGCD(long a, long b, long c) {
		long d = GCD(a, b);
		return GCD(c, d);
	}
}


Measured memory_bytes: 35764
n = int(input())
words = []
flg = 0
for i in range(n):
    tmp_word = input()
    if tmp_word not in words:
        words.append(tmp_word)
    else:
        flg =1
        
if flg ==1:
    print("No")
else:
    for i in range(n-1):
        if words[i][-1] == words[i+1][0] and i < n-2:
            pass
        elif words[i][-1] == words[i+1][0] and i == n-2:
            print("Yes")
        else:
            print("No")
            break

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

int main(){
  int W;
  int H;
  int x;
  int y;
  int r;

  cin >> W >> H >> x >> y >> r;

  if(x>=r && y>=r && x<=W-r && y<=H-r){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
	
using namespace std;
int main()
{
	
	std::ios::sync_with_stdio(false);

		int a,b,c,d;
		cin>>a>>b>>c>>d;

		int ans = 0;

		if(d>0){
			ans+=min(a,d);
			d-=a;
		}
		if(d>0){
			d-=b;
		}
		if(d>0){
			ans-=min(c,d);
			d-=c;
		}

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

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
int N, M, Q;
vector<tuple<int, int, int, int>> T;
int eval(vint A){
    // for(int a:A)
    //     cout<<a<<" ";
    // cout<<endl;
    int ret =0;
    for(auto t:T){
        int a, b, c, d;
        tie(a, b, c, d)=t;
        if(A[b]-A[a]==c)
            ret+=d;
    }
    return ret;
}
int DFS(vint A){
    if (A.size()==N)
        return eval(A);
    int ret=0;
    int init=(A.size()?A.back():1);
    for(int i=init;i<=M;i++){
        A.pb(i);
        ret = max(ret, DFS(A));
        A.pop_back();
    }
    return ret;
}
signed main(){

    cin>>N>>M>>Q;
    for(int i=0;i<Q;i++){
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        a--, b--;
        T.eb(a, b, c, d);
    }
    vint A;
    cout<<DFS(A)<<endl;

    return 0;
}


Measured memory_bytes: 3636
from itertools import permutations
import math
read = input 
rn = lambda :list(map(int, read().split()))
n, = rn()
init_list = range(1, n + 1)
l_1 = rn()
l_2 = rn()
i_1 = -1
i_2 = -1
# print(l_1, l_2)
for i,p in enumerate(permutations(init_list)):
    p = list(p)
#     print(i, p)
    if p == l_1:
        i_1 = i
    if p == l_2:
        i_2 = i
print(abs(i_1 - i_2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N;
    cin >> N;
    int cake_max = 100/4;
    int donut_max = 100/7;
    rep(i,0,cake_max){
        rep(j,0,donut_max){
            if(i*4+j*7 == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    var args = input.split(' ').map(Number);
    var a = args[0];
    var b = args[1];
    var c = args[2];
    var x = 0;
    for (var i = a; i <= b; i++) {
        if (c % i == 0) {
            x++;
        }
    }
    console.log(x);
});

Measured memory_bytes: 7648
# -*- coding: utf-8 -*-
S = input()
L = len(S)
S += "________"
i = 0
res = "YES"
while i < L:
    if S[i:i+5] == "dream":
        if S[i+5:i+7] == "er":
            if S[i+7] == "a":
                i += 5 # dream
            else:
                i += 7 # dreamer
        else:
            i += 5 # dream
    elif S[i:i+5] == "erase":
        if S[i+5] == "r":
            i += 6 # eraser
        else:
            i += 5 # erase
    else:
        res = "NO"
        break

print(res)    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int nu[150];
int main()
{
	int a,b,c;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		nu[a]=1;
	}
	int ans=0;
	for(int i=1;i<=100;i++)
	{
		if(nu[i]==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a == 0 && b == 0) break;
			if(a < b) System.out.println(a + " " + b);
			else System.out.println(b + " " + a);
		}
	}
}

Measured memory_bytes: 27196
fn main() {
    #[allow(unused_imports)]
    use std::io::{Read, Write, BufWriter};
    let mut a = Vec::new();
    std::io::stdin().read_to_end(&mut a).unwrap();
    let a = String::from_utf8(a).unwrap();
    let mut a = a.split_whitespace();
    #[allow(unused_mut,unused_variables)]
    let mut b = BufWriter::new(std::io::stdout());
    macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) }
    #[allow(unused_macros)]
    macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) }
    #[allow(unused_imports)]
    use std::cmp::{min, max};

    let n: i32 = yomu!();
    let a: i32 = yomu!();
    let b: i32 = yomu!();
    println!("{}", min(n*a, b)); 
}


Measured memory_bytes: 4352
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){
	string s;
	cin >> s;
	auto posc = s.find("C");
	auto posr = s.rfind("F");
	if(posc != -1 && posr != -1 && posc < posr){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}


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

int cmp_str(const void* left,const void* right){
  char *left_char=(char *)left;
  char *right_char=(char *)right;

  return strcmp(left_char,right_char);
}

int main(){
  int N=0,L=0;
  char S[100][101]={""};

  scanf("%d %d",&N,&L);
  for(int i=0;i<N;i++) scanf("%s",S[i]);
  qsort(S,N,sizeof(S[0]),cmp_str);
  for(int i=0;i<N;i++) printf("%s",S[i]);
  return 0;
}

Measured memory_bytes: 128
import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
r = np.full(n,-1,dtype=int)
for i in range(m):
    a,b = getLine()
    
    if r[a - 1] == -1:
        r[a - 1] = b
    elif r[a - 1] != b:
        print(-1)
        break
else:
    if n > 1 and r[0] == 0:
        print(-1)
    else:
        if r[0] == 0 and n == 1:
            print('0')
        else:
            if n > 1 and r[0] == -1:
                r[0] = 1
            r[r == -1] = 0
            r = r.astype(str)
            print(''.join(r))

Measured memory_bytes: 12452
#include <bits/stdc++.h>
#include <vector>
#define ll long long int
using namespace std;
int main()
{
  int i,j,k,n;
  cin>>n;
  j=n%10;
  if(j==2||j==4||j==5||j==7||j==9)
  {
    cout<<"hon";
  }
  else if(j==0||j==1||j==6||j==8)
  {
    cout<<"pon";
  }
  else{
    cout<<"bon";
  }
}

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

int N;

int main()
{
    cin >> N;
    vector<ll> a(N);
    vector<ll> v;
    v.push_back(0);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++)
    {
        v.push_back(v.back() + a[i]);
    }
    ll ans = 1;
    for (int i = N - 2; i >= 0; i--)
    {
        //cout << v[i] << " " << a[i] << endl;
        if (a[i + 1] <= 2 * (a[i] + v[i]))
            ans++;
        else
            break;
    }
    cout << ans << endl;
}

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

int main(void)
{
    int n, d, i;
    int ans=0;
    double r;
    scanf("%d", &n);
    scanf("%d", &d);

    int x[200000],y[200000];
    for(i=0; i<n; i++){
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
        r = sqrt(pow(x[i],2) + pow(y[i],2));
        if(d>=r){
            ans++;
        }
    }

    printf("%d", ans);
}

Measured memory_bytes: 3708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  string s;
  for(int i=0; i<3; i++){
    cin >> s;
    char c = s[0];
    c -= 'a';
    c += 'A';
    cout << c;
  }
  cout << endl;

  return 0;
}


// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
const double PI = 3.14159265358979323846;
int main()
{
  double a, b, x;
  cin >> a >> b >> x;
  double theta = 0;
  double arc = 0;
  if(x <= a*a*b/2){
    arc = 2*x/(a*b*b);
    theta = atan(arc);
    cout << setprecision(20)<< 90.0 - theta*180.0/PI << endl;
    return 0;
  }else{
    arc = 2*(a*a*b - x)/(a*a*a);
    theta = atan(arc);
    cout << setprecision(20)<<theta*180.0/PI << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2020202;
char s[N];
int a[N];
int n,sum,ans;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1; i<=n; i++){
		if (s[i]=='R')	sum++;
		else sum=0;
		ans=max(ans,sum);	
	}
	printf("%d\n",ans);	
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int M;
II AB[MAX_N];

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

  sort(AB,AB+N);

  int ans = 0;
  int pos = 0;
  priority_queue<int> pq;
  REP(m,M) {
    while(pos < N) {
      if(AB[pos].first <= m+1) {
        pq.push(AB[pos].second);
        pos++;
      } else {
        break;
      }
    }
    if(pq.size() > 0) {
      ans += pq.top(); pq.pop();
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      if(n<1200)Cout("ABC");
      else if(n<2800)Cout("ARC");
      else Cout("AGC");
    
       
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
	return (b == 0 ? a : gcd(b, a % b));
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
int main() {
	int N;
	cin >> N;
	long long ans = 1;
	for (int i = 0; i < N; i++) {
		long long T;
		cin >> T;
		ans = lcm(T, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256