akhauriyash/Code-Regression huggingface dataset:
//トランプの整理
#include<stdio.h>
#define sum 54
#define false 0
#define true 1
int n,q,w;
//構造体配列を使う時はこのように宣言する
struct trump{
    int num;
    char sym;
};

void swap(struct trump a[q],struct trump b[w]){
    struct trump temp;
    temp=a[q];
    a[q]=b[w];
    b[w]=temp;
}
//出力
void out(struct trump c[]){
    for(int i=0;i<n-1;i++){
     printf("%c%d ",c[i].sym,c[i].num);
    }
    printf("%c%d\n",c[n-1].sym,c[n-1].num);
}
//安定かどうかを調べる
int isStable(struct trump c1[],struct trump c2[]){
    int i;
    for(i=0;i<n;i++){
      if(c1[i].sym!=c2[i].sym){
        return false;
      }
    }
    return true;
}
//バブルソート、隣どうしを比較するので安定
void bubble(struct trump c[]){
    int i,j;
    for(i=0;i<n-1;i++){
        for(j=n-1;j>i;j--){
            if(c[j].num < c[j-1].num){
                swap(&c[j],&c[j-1]);
            }
        }
    }
}
//選択ソート、最小値を見つけて挿入するので不安定
void Selection(struct trump c[]){
    int i,j,minj;
    for(i=0;i<n-1;i++){
        minj=i;
        for(j=i+1;j<n;j++){
            if(c[j].num < c[minj].num){
                minj=j;
            }
        }
        if(minj!=i){
            swap(&c[i],&c[minj]);
        }
    }
}

int main(){
    int i,j;
    struct trump card[sum],Bcard[sum],Scard[sum];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        //一文字読み込むためにスペースを開ける必要がある
        scanf(" %c%d",&card[i].sym, &card[i].num);
    }
    //カードのコピー
    for(i=0;i<n;i++){
        Bcard[i]=card[i];
        Scard[i]=card[i];
    }
    //出力
    bubble(Bcard);
    Selection(Scard);
    out(Bcard);
    printf("Stable\n");
    out(Scard);
     if(isStable(Bcard,Scard)){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    return 0;
}


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

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE    
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout); 
    #endif

    string s;cin>>s;
    if(s.back()!='s')   s+="s";
    else                s+="es";
    cout<<s<<"\n";
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var n = int.Parse(s);
				while (n > 39) n -= 39;
				Console.WriteLine("3C{0:00}", n);
			}
		}
	}
}

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

#define ll long long

using namespace std;
const int N = 100'004;
int n, m;
pair<int, int> a[N];
ll sol;
priority_queue<int> q;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    sort(a, a+n);

    int i = 0;
    for (int d = m; d > 0; --d) {
        while (i < n && a[i].first <= m - d + 1) {
            q.push(a[i].second);
            ++i;
        }
        if (!q.empty()) {
            sol += q.top();
            q.pop();
        }
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

int main() {

    int i, j, k;
    int a[3][3];
    int ans[3][3]={0};
    int n;
    int b[10]={0};

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

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 3; j++) {
            for(k = 0; k < n; k++){
                if(a[i][j] == b[k]) {
                    ans[i][j] = 1;
                }
            }
        }
    }

    for(i = 0; i < 3; i++) {
        if(ans[i][0] + ans[i][1] + ans[i][2] == 3) {
            printf("Yes\n");
            return 0;
        }
        if(ans[0][i] + ans[1][i] + ans[2][i] == 3) {
            printf("Yes\n");
            return 0;
        }
    }
    if(ans[0][0] + ans[1][1] + ans[2][2] == 3) {
        printf("Yes\n");
        return 0;
    }
    if(ans[0][2] + ans[1][1] + ans[2][0] == 3) {
        printf("Yes\n");
        return 0;
    }

    printf("No\n");
    
    return 0;
}

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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	char a, b;
	cin >> a >> b;

	if ( a == 'H' and b == 'H')
	{
		cout << "H" << endl;
	}
	else if ( a == 'D' and b == 'D')
	{
		cout << "H" << endl;
	}
	else {
		cout << "D" << endl;
	}


	return 0;
}

Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int main()
{
	string A;
  	int count=0;
    cin >> A;
  	if(A[0]=='A'&&A[A.size()-1]!='C'){
      	for(int i=0;i<A.size();i++){
        	if(i<A.size()-3&&A[i+2]=='C')count++;
          if((A[i]<'a'||A[i]>'z')&&i!=0&&A[i]!='C'){
          	cout<<"WA"<<"\n";return 0;
          }
        }
      	if(count==1)cout << "AC"<<"\n";
      else cout<<"WA"<<"\n";
    }
  	else cout << "WA" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef pair<int,int> ii;
const int maxn=(1<<18)+5;
ii res[maxn];
int a[maxn];
void merge(int x,int y) {
	if(res[y].se>=res[x].fi) {
		res[x].fi=res[y].fi;
		res[x].se=res[y].se;
	}
	else if(res[y].se<=res[x].fi&&res[y].fi>=res[x].fi) {
		res[x].se=res[x].fi;
		res[x].fi=res[y].fi;
	}
	else if(res[y].fi<=res[x].fi&&res[y].fi>=res[x].se) {
		res[x].se=res[y].fi;
	}
}
signed main() {
    int n;
    cin>>n;
    for(int i=0 ; i<(1<<n) ; i++) {
        cin>>a[i];
        res[i].fi=a[i];
        res[i].se=-1;
    }
    for(int i=0 ; i<n ; i++) {
        for(int j=0 ; j<(1<<n) ; j++) {
            if((j&(1<<i))==0) {
                // no bit i
                merge(j|(1<<i),j);
            }
        }
    }
    int ans=0;
    for(int i=1 ; i<(1<<n) ; i++) {
        ans=max(ans,res[i].fi+res[i].se);
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 6652
'''     J A I ~ S H R E E ~ R A M     '''

# Title: aising2020_c.py
# dated: 11-07-2020 17:43:44
# Creator & Template by : Udit Gupta @luctivud


import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]] #up, down, right, left
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if (i!=0 or j!=0)]

OrdUnicode_a = ord('a'); OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i+OrdUnicode_A) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+OrdUnicode_a) : i for i in range(26)}

MOD_JOHAN = int(1e9)+7; MOD_LIGHT = 998244353; INFINITY = float('inf')
MAXN_EYEPATCH = int(1e5)+1; MAXN_FULLMETAL = 501

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())): 
n = int(input())
ans = [0] * (n+1)
i = 1
while i * i < n:
    i += 1
n0001 = i+1
for i in range(1, n0001):
    for j in range(1, n0001):
        for k in range(1, n0001):
            e = (i**2) + (j**2) + (i*j) + (k**2) + (j*k) + (i*k)
            if e <= n:
                # print(i, j, k, e)
                ans[e] += 1

print(*ans[1:], sep="\n")




'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
'''


Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N,M; cin >> N >> M;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    int S = 0;
    sort(A.begin(),A.end(),greater<int>());
    for (auto a : A) S += a;
    int cnt = 0;
    for (int i=0;i<N;i++){
        if (4*M*A[i]<S) break;
        cnt++;
    }
    if (cnt>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int n, k; cin >> n >> k;
	int res = k;
	rep(i,2,n) res *= (k-1);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = "";
        while(stdIn.hasNext()) {
        s += stdIn.nextLine();
        }
        s = s.toLowerCase();
        int[] ans = new int[k.length];
        for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < k.length; j++) {
                if(s.charAt(i) == k[j]) {
                    ans[j]++;
                }
            }
        }
         
        for(int i = 0; i < 26; i++) {
            System.out.println(k[i]+" : " + ans[i]);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int maxn = 1e7+10;

bool notPrime[maxn];
int primes[maxn], qnt;
int divs[maxn], pot[maxn];

void calc(int lim){
	qnt = 0;
	memset(divs, 0, sizeof divs);
	divs[1] = 1;
	pot[1] = 1;
	for(int i = 2; i <= lim; i++){
		if(!notPrime[i]){
			primes[qnt++] = i;
			divs[i] = 2;
			pot[i] = i;
		}
		ll next;
		for(int j = 0; j < qnt && (next = 1LL*i*primes[j]) <= lim; j++){
			notPrime[next] = true;
			if(i % primes[j] != 0){
				pot[next] = primes[j];
				divs[next] = divs[i] * divs[primes[j]];
			}
			else{
				pot[next] = pot[i] * primes[j];
				divs[next] = (divs[pot[i]] + 1) * divs[i/pot[i]];
				break;
			}
		}
	}
}

void solve(){
	
	int n;
	cin >> n;
	
	calc(n);
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		//cout << i << " " << pot[i] << endl;
		//cout << ans << " " << divs[i] << " " << i << endl;
		ans += (divs[i] * i);
	}
	cout << ans << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}


Measured memory_bytes: 94048
two n | n `mod` 2 == 0  = 1 + two (n `div` 2)
      | otherwise       = 0

main = do ln1 <- getLine
          ln2 <- getLine
          let n = read ln1
              ar = map (two .read) (words ln2)
              two_cnt = length (filter (>= 2) ar)
              zero_cnt = length (filter (== 0) ar)
              ans = if two_cnt >= zero_cnt || two_cnt == zero_cnt - 1 && two_cnt + zero_cnt == n then "Yes" else "No"
              in putStrLn ans


Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll cnt1=a+b+a*(n-2);
    ll cnt2=a+b+b*(n-2);
    cout<<max((ll)0,cnt2-cnt1+1)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long q = parseLong(sc.next());
		long h = parseLong(sc.next());
		long s = parseLong(sc.next());
		long d = parseLong(sc.next());
		long n = parseLong(sc.next());
		sc.close();
		long l1 = 100000000000000000L;
		l1 = Math.min(l1, 4*q);
		l1 = Math.min(l1, 2*h);
		l1 = Math.min(l1, s);
		long l2 = 100000000000000000L;
		l2 = Math.min(l1*2, d);
		out.println((n/2)*l2+(n%2)*l1);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; i + j <= n; j++) {
			int k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				cout << i << ' ' << j << ' ' << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second

int main(void){
	ll n,p,q;
	cin >> n >> p >> q;
	vector<ll> c(n);
	ll s =  0;
	rep(i,n){
		ll tmp;
		cin >> tmp;
		s += tmp;
		c[i] = p * i + tmp;
	}
	sort(all(c));
	ll ans = s;
	for(int k=1; k<=n; k++){
		s -= c[k-1];
		ans = max(ans, s + k * p * q + p * k * (k-1));
	}
	cout << ans << endl;
}


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

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A <= X)if(B >= X-A){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import bisect
def main():
    N, M, K = map(int, input().split())
    MAX = 10 ** 9 + 7
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    A = []
    B = []
    A.append(0)
    B.append(0)
    for i in range(N):
        A.append(a[i] + A[i])
    for i in range(M):
        B.append(b[i] + B[i])
    B.append(B[M - 1] + MAX)
    ans = 0
    for i in range(N+1):
        if A[i] <= K:
            a = bisect.bisect_right(B, (K - A[i]))
            a -= 1
            ans = max(ans, (i + a))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 133432
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll  max(ll a,ll b){
	return (a>b)?a:b;
}
ll knapsack(ll W,ll val[],ll wt[],ll k){
	ll t[k+1][W+1];
	for(int i=0;i<=k;i++){
		for(int w=0;w<=W;w++){
			if(i==0 || w==0)
				t[i][w]=0;
			else if(wt[i-1]<=w)
			    t[i][w]=max(val[i-1]+t[i-1][w-wt[i-1]],t[i-1][w]);
			else  t[i][w]=t[i-1][w];  
		}
		
	}
     return t[k][W];
}
int main(){
	ll n,wtt;
	cin>>n>>wtt;
	ll v[n],w1[n];
	for(int j=0;j<n;j++){
		cin>>w1[j]>>v[j];
	}
	cout<<knapsack(wtt,v,w1,n);
	
}

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

int main()
{
    int N, N1 = 0, N2 = 0, N3 = 0, N4 = 0;

    cin >> N;
    N1 = N / 1000;
    N2 = (N - N1 * 1000) / 100;
    N3 = (N - N1 * 1000 - N2 * 100) / 10;
    N4 = N - N1 * 1000 - N2 * 100 - N3 * 10;

    if ((N1 == N2 && N2 == N3) || (N2 == N3 && N3 == N4))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
/*  CREATED BY
    STREAM_CIPHER
    7-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n,w;cin>>n>>w;
        vector<pair<int,int>>a(n+1);
        for(int i=1;i<=n;i++)
            cin>>a[i].first>>a[i].second;
        int dp[n+9][n*2000+9];
        memset(dp,inf,sizeof dp);
        dp[0][a[1].second]=a[1].first;
        // cout<<dp[0][a[1].second]<<endl;
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<=n*2000;j++)
            {
                if(j+a[i+1].second<=n*2000)
                    dp[i][j+a[i+1].second]=min(dp[i-1][j+a[i+1].second],min(dp[i-1][j]+a[i+1].first,dp[i][j+a[i+1].second]));
                dp[i][j]=min(dp[i-1][j],dp[i][j]);
            }
            dp[i][a[i+1].second]=min(dp[i-1][a[i+1].second],min(dp[i][a[i+1].second],a[i+1].first));
            // dp[i][a[i].second]=dp[i-1][a[i].second];
        }
        int ans=0;
        for(int i=0;i<=n;i++)
            for(int j=1;j<=n*2000;j++)
                if(dp[i][j]<=w)
                    ans=max(ans,j);
        cout<<ans<<endl;
}


Measured memory_bytes: 173944
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int s=accumulate(a.begin(),a.end(),0);
  using BS = bitset<2020*2020>;
  BS dp(1);
  for(Int i=0;i<n;i++) dp|=dp<<a[i];
  for(Int i=(s+1)/2;i<=s;i++){
    if(dp[i]){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	vector<int> v(3,0);
	REP(i,3){
		v[S[i]-'a']++;
	}
	if(v[0]==v[1] && v[0]==v[2]) out("Yes");
	else out("No");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int W,H,x,y,r,a,b,c,d;
    cin >> W >> H >> x >> y >> r;
    a = x - r;
    b = x + r;
    c = y - r;
    d = y + r;
    if(W >= 2*r && H >= 2*r)
    {
        if(a>=0&&b<=W&&c>=0&&d<=H)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 1000000007;
	static int inf = (int) 1e16;
	static ArrayList<Integer>[] ad;
	static int n, m;
	static long[][] memo, c;
	static HashSet<Integer> h;
	static int[] ans;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] oc = new int[n + 1];
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		for (int i = 0; i < n; i++)
			oc[sc.nextInt()]++;
		for (int i = 0; i <= n; i++)
			if (oc[i] != 0)
				pq.add(oc[i]);
		if (pq.size() == k) {
			out.print(0);
		} else if (pq.size() > k) {
			int ans = 0;
			while (pq.size() > k)
				ans += pq.poll();
			out.print(ans);
		} else {
			out.print(0);
		}
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 44148
n = int(input())
a = []
counter = 0
a = input().split()
success_result = [0] * n
while True:
    for index, item in enumerate(a):
        if int(item) % 2 == 0:
            a[index] = int(item) / 2
            success_result[index] = True
        else:
            continue
    if all(success_result):
        counter += 1
        success_result = [None for _ in range(n)]
    else:
        break
print(counter)

Measured memory_bytes: 3064
import Data.List

judge :: [String] -> Bool
judge words = and $ zipWith (\x y -> last x == head y) words (tail words)

main = do
  words <- lines <$> (getLine >> getContents)
  if length (nub words) < length words then putStrLn "No"
  else if judge words then putStrLn "Yes" else putStrLn "No"

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


int main() {
  while (true){
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '?'){
      break;
    }else{
      if (op == '+'){
        cout << a+b << endl;
      }else if (op == '-'){
        cout << a-b << endl;
      }else if (op == '*'){
        cout << a*b << endl;
      }else if (op == '/'){
        cout << a/b << endl;
      }
    }

  }

}


Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int A, B;
    cin >> A >> B;
    A = A == 1 ? 14 : A;
    B = B == 1 ? 14 : B;
    if (A == B) cout << "Draw" << endl;
    else if (A > B) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

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

ll divisor=1e9+7;
int main(){
	int n;
	cin>>n;
	string s[n];
	rep(i,n)cin>>s[i];
	sort(s,s+n);
	int count=0;
	rep(i,n){
		if(i==0){
			count++;
			continue;
		}
		if(s[i]==s[i-1]){
			continue;
		}else{
			count++;
		}
	}
  puts(count);
}

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

using namespace std;

int TimeOfPerson[10000];

void solve(int n) {
	long long int sum, now;

	sum = now = 0;
	for (int i = 0; i < n; i++) {
		now += TimeOfPerson[i];
		sum += now;
	}
	cout << sum << endl;
}

int main() {
	int n;

	while (cin >> n, n) {
		memset(TimeOfPerson, 0, sizeof(TimeOfPerson));
		for (int i = 0; i < n; i++) {
			cin >> TimeOfPerson[i];
		}
		sort(TimeOfPerson, TimeOfPerson + n);
		solve(n-1);
	}

	return 0;
}


Measured memory_bytes: 3044
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+50*c==X:
                count += 1
print(count)

Measured memory_bytes: 3060
n, x = map(int,input().split())

while not (n==0 and x== 0):
    count = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1
    print(count)
    n, x = map(int,input().split())


Measured memory_bytes: 5596
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
x = parseInt(x, 10)
var h = Math.floor(x / 3600)
var m = Math.floor((x % 3600) / 60)
var s = x % 3600 % 60;
console.log(h + ":" + m + ":" + s);


Measured memory_bytes: 15368
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (auto &t : v) {
		cin >> t;
	}
	int ans = 0;
	for (int f = 0; f <= n; f++) {
		for (int s = 0; f + s <= n; s++) {
			if (f + s > k) continue;
			vector<int> h;
			for (int i = 0; i < f; i++) {
				h.push_back(v[i]);
			}
			for (int i = n - 1; i > n - 1 - s; i--) {
				h.push_back(v[i]);
			}
			sort(h.begin(), h.end());
			for (int i = 0; i < min((int)h.size(), k - f - s); i++) {
				h[i] = max(h[i], 0);
			}
			int c = 0;
			for (auto x : h) {
				c += x;
			}
			ans = max(ans, c);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = a;
        for (; i < a + k && i <= b; i++) {
            if (i <= b) System.out.println(i);
        }
        i--;
        for (int j = b - k + 1; j <= b; j++) {
            if (i < j) System.out.println(j);
        }
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=1&&a<=13&&b>=1&&b<=13){
        if((a>b||a==1)&&(b!=1)){
            cout<<"Alice";
            }else if((b>a||b==1)&&(a!=1)){
             cout<<"Bob";
             }else if(a==b){
                cout<<"Draw";



        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] S = new int [n];
        for (int i = 0; i < n; i++) {
            S[i] = s.nextInt();
        }
        int q = s.nextInt();
        int [] T = new int [q];
        for (int i = 0; i < q; i++) {
            T[i] = s.nextInt();
        }

        int C  = 0;

        for (int i = 0; i < q; i++) {
            if (search(T[i], S)) {
                C++;
            }
        }
        System.out.println(C);
    }

    static boolean search(int a, int []S) {
        int left = 0;
        int right = S.length ;
        int middle;

        while (left < right) {
            middle = (left + right ) / 2;
            if (S[middle] == a) {
                return true;
            } else if (S[middle] < a) {
                left = middle + 1;
            } else {
                right = middle;
            }
        }
        return false;
    }
}



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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}

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

    int N; cin >> N;

    Yes(N/10==9||N%10==9);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	long long x, y;
	cin>>x>>y;
	long long ans = 0;
	while(x <= y){
		ans++;
		x = x<<1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,n+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    return ans

n = int(input())
mod = 10**9 + 7

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1)
print(ans%mod)


Measured memory_bytes: 3316
N = int(input())
p_list = []
for _ in range(N):
    a, b = input().split()
    a, b = int(a), int(b)
    p_list.append((a, b))

# print(list_pt)

# 凸包? が判定できれば？

def det(p, q):
    return p[0]*q[1] - p[1]*q[0]


def sub(p, q):
    return (p[0]-q[0], p[1]-q[1])

def convex_hull(points):
    # どの3点も直線上に並んでいないと仮定する。
    n = len(points)
    points.sort()
    size_convex_hull = 0
    ch = []
    for i in range(n):
        while size_convex_hull > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    t = size_convex_hull
    for i in range(n-2, -1, -1):
        while size_convex_hull > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    return ch[:-1]


# p_list = convex_hull([(1,1), (3,1), (2,2), (2,3)])

""" try max time """
# N = 2*10**5
# import numpy as np
# X = np.random.randint(1, 10**9, (N, 2)).tolist()

p_list = convex_hull(p_list)

from itertools import combinations

max_len = 0
for a, b in combinations(p_list, 2):
    max_len = max(max_len, abs(a[0] - b[0]) + abs(a[1] - b[1]))

print(max_len)



Measured memory_bytes: 36436
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		
		int x = 1;
		int y = 1;
		
		while ( !(x == 0 && y == 0)){
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0){
				break;
			}else {
				System.out.println(Math.min(x, y) + " " + Math.max(x, y));
			}
		}
	}

}


Measured memory_bytes: 35892
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<int,pll> P;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
struct edge{
  int from;
  int to;
  int cost;
  edge(int f,int t,int w) : from(f),to(t),cost(w){}
};
bool comp(P p1,P p2){
  return p1.second.first>p2.second.first;
}
bool comp1(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
int main(){
  vector<edge> g;
  int n,i,x,y;
  vector<P> p;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    cin >> x >> y;
    p.push_back(make_pair(x,pll(y,i)));
  }
  sort(p.begin(),p.end());
  for(i=0;i<n-1;i++){
    g.push_back(edge(p[i].second.second,p[i+1].second.second,min(abs(p[i+1].first-p[i].first),abs(p[i+1].second.first-p[i].second.first))));
  }
  sort(p.begin(),p.end(),comp);
  for(i=0;i<n-1;i++){
    g.push_back(edge(p[i].second.second,p[i+1].second.second,min(abs(p[i+1].first-p[i].first),abs(p[i+1].second.first-p[i].second.first))));
  }
  sort(g.begin(),g.end(),comp1);
  ll ans=0;
  unionfind tree(100010);
  for(i=0;i<g.size();i++){
    if(!tree.same(g[i].from,g[i].to)){
      tree.unite(g[i].from,g[i].to);
      ans+=g[i].cost;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=100000000000;
int main(){
int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vector<int64_t>p(A);
  for(int i=0;i<A;i++)
    cin>>p.at(i);
  vector<int64_t>q(B);
  for(int i=0;i<B;i++)
  cin>>q.at(i);
  vector<int64_t>r(C);
  for(int i=0;i<C;i++)
    cin>>r.at(i);
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
   sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
   sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  vector<int64_t>P;
  for(int i=0;i<X;i++)
    P.push_back(p.at(i));
  for(int i=0;i<Y;i++)
    P.push_back(q.at(i));
  sort(P.begin(),P.end());
  int a=min(X+Y,C);
  for(int i=0;i<a;i++){
  if(P.at(i)<r.at(i))
    P.at(i)=r.at(i);
    else
      break;
  
  }int64_t ans=0;
  for(int i=0;i<X+Y;i++)
    ans+=P.at(i);
  cout<<ans<<endl;
  
    return 0;
}

Measured memory_bytes: 4724
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;



public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean able = false;
		for(int i = a; i <= b; i++) {
			if(i%k==0) {
				able = true;
				break;
			}
		}
		System.out.println(able? "OK":"NG");
	 }
}

Measured memory_bytes: 35796
import java.util.Scanner;

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

    char[] S = scanner.next().toCharArray();
    int[] num = new int[S.length + 1];
    int c = 0;
    for (int i = 0; i < S.length; i++) {
      if (S[i] == '<') c++;
      else c = 0;
      num[i + 1] = c;
    }
    c = 0;
    for (int i = S.length - 1; i >= 0; i--) {
      if (S[i] == '>') c++;
      else c = 0;
      num[i] = Math.max(num[i], c);
    }
    long sum = 0;
    for (int value : num) sum += value;
    System.out.println(sum);
  }
}


Measured memory_bytes: 32208
#include<iostream>

using namespace std;

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

	if (n/100 == 1)
		cout << 9;
	else if (n/100 == 9)
		cout << 1;
	else
		cout << n/100;

	if ((n%100)/10 == 1)
		cout << 9;
	else if ((n%100)/10 == 9)
		cout << 1;
	else
		cout << (n%100)/10;

	if((n%100)%10 == 1)
		cout << 9;
	else if ((n%100)%10 == 9)
		cout << 1;
	else
		cout << (n%100)%10;

	cout << "\n";

	return 0;

}


Measured memory_bytes: 256
n,m=map(int,input().split())
x=[set() for _ in range(n+1)]
lift=[-1 for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    x[a].add(b)
    x[b].add(a)

cnt=0
next={1}
while len(next)>0:
    tmp=set()
    for p in next:
        for q in x[p]:
            if lift[q]==-1:
                tmp.add(q)
                lift[q]=p
            x[q].remove(p)

    next=tmp

if -1 in x[2:]: print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        print(lift[i])

Measured memory_bytes: 126332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int N, X, Y, depth;

int main()
{
    cin >> N >> X >> Y;
    vector<vector<int>> Graph(N);
    // 最短距離がkの個数を格納
    vector<ll> d(N, 0);
    Graph.at(X - 1).push_back(Y - 1);
    Graph.at(Y - 1).push_back(X - 1);
    rep(0, i, N - 1)
    {
        Graph.at(i).push_back(i + 1);
        Graph.at(i + 1).push_back(i);
    }
    // すべての点についてbfsを行う
    rep(0, i, N)
    {
        // BFS のためのデータ構造
        vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
        queue<int> que;

        dist.at(i) = 0;
        que.push(i);
        while (!que.empty())
        {
            int v = que.front();
            que.pop();

            for (auto nv : Graph.at(v))
            {
                if (dist.at(nv) != -1)
                {
                    continue;
                }
                dist.at(nv) = dist.at(v) + 1;
                que.push(nv);
            }
        }
        rep(0, j, N)
        {
            d.at(dist.at(j))++;
        }
    }
    rep(1, i, N)
    {
        cout << d.at(i) / 2 << endl;
    }
}

Measured memory_bytes: 384
N, K = map(int, input().split())
V = [int(i) for i in input().split()]

ans = 0
R = min(N, K)
for i in range(R + 1):
    for j in range(R - i + 1):
        A = []
        A += V[: i]
        if j > 0:
            A += V[- j :]
        A.sort()
        A2 = A[: K - (i + j)]
        for a in A2:
            if a < 0:
                A.remove(a)
        tmp = sum(A)
        ans = max(ans, tmp)
                
print(ans)

Measured memory_bytes: 41200
#include<forward_list>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<iterator> 
#include<sstream>
#include<fstream>
#include<istream>
#include<utility>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<list>
#include<map> 
#include<set>
#define NinjaTurtle ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infile freopen(".txt", "r", stdin);
#define outfile freopen(".txt", "w", stdout);
#define all(v) v.begin(),v.end()
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define ll long long 
#define endl "\n"
using namespace std;
int frq[10];
int main()
{
	NinjaTurtle
		ll x,ans=0;
	cin >> x;
	ans = x / 500 * 1000;
	//cout << ans << endl;
	x %= 500;
	ans += x / 5*5;
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

const string YES = "YES";
const string NO = "NO";

string w[] = {"dream","dreamer","erase","eraser"};
void solve(std::string S){
   reverse(S.begin(),S.end());

    for(int i = 0; i < 4; i++)
    {
        reverse(w[i].begin(),w[i].end());
    }

    int pos= 0;

    while(pos < S.length()){
        bool found = false;
        for(int i = 0; i < 4; i++)
        {
            if(S.substr(pos,w[i].length()) == w[i]){
                pos += w[i].length();
                found = true;
                break;
            }
        }
        if(!found){
            cout << NO << endl;
            return;
        }
    }

    cout << YES << endl;
    
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
//Base2Number.cpp (B)
#include <iostream>
#include <string>

using namespace std;

int main(){
  long long N,D;
  string S = "";
  cin >> N;
  if(N == 0) printf("0\n");
  else{
    while(N != 0){
      D = abs(N);
      if(D%2==0){
        if(N < 0) N = -N/2;
        else N = -N/2;
        S = "0" + S;
      }else{
        N = N -1;
        if(N < 0) N = -N/2;
        else N = -N/2;
        S = "1" + S;
      }
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var nl = Console.ReadLine().Split().Select(int.Parse).ToList();
            var n = nl[0];
            var l = nl[1];

            var s = new List<string>();
            for(int i = 0; i < n; i++)
            {
                s.Add(Console.ReadLine());
            }
            s.Sort();

            var ans = "";
            for(int i = 0; i < n; i++)
            {
                ans += s[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 29012
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;cin>>N;
    vector<long long> A(N),B(N),C(N);
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N){
        cin>>B[i];
    }
    REP(i,N){
        cin>>C[i];
    }
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    long long res =0;
    REP(i,N){
        long long a = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
        long long c = N - (upper_bound(C.begin(),C.end(),B[i]) - C.begin());
        res += a * c;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
typedef long long ll;
int inf=1<<30;

int n,m;
int c[23]; //c[i]=i番目のコインの額面
int T[50001]; //T[j]=j円支払うときの最小枚数

int main(){
    cin>>n>>m;
    Rep(i,m) cin>>c[i];
    Rep(i,n+1) T[i]=inf;
    T[0]=0;
    Rep(i,m){
        Rep(j,n+1-c[i]){
            T[j+c[i]]=min(T[j+c[i]],T[j]+1);
        }
    }
    cout<<T[n]<<endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  map<int, int> mm;
  rep(i,m){
    int a,b;cin>>a>>b;
    mm[a]++;
    mm[b]++;
  }

  rep(i,n){
    cout<<mm[i+1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
x=[int(i) for i in input().split()]
if n==2:
    for i in x[::-1]:
        print(i)
    exit()

d={}
y=sorted(x)
#for a,i in enumerate(x):
#    d[a]=i
#x.sort()
ans={}
for a,i in enumerate(y):
    if a<n//2:
        if i not in ans:
            ans[i]=y[n//2]
    elif a>=n//2:
        if i not in ans:
            ans[i]=y[n//2-1]
            #ans[i]=10000
for i in x:
    print(ans[i])
#chk=x[n//2]
#for i in range(n):
    #if i<chk: print(x[min(n-1,n//2+1)])
    #else: print(x[max(0,n//2)])
#    if i<chk: print(x[min(n-1,n//2+1)])
#    else: print(x[max(0,n//2)])



Measured memory_bytes: 34824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N , P;
    cin >> N >> P;
    long long pp;
    pp = int(pow(P,0.5));
    vector<long long> prime(pp+1,0);
    for (long long i = 2; i <= P && i <= pp ; i++){
        while(P%i == 0){
            P = P/i;
            prime.at(i)++;
        }
    }
    long long ans = 1;
    for(long long i = 2; i <= pp; i++){
        ans = ans * pow(i, prime.at(i)/N);
    }
    if(N == 1){
        ans = ans * P;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 8064
#!/mnt/c/Users/moiki/bash/env/bin/python
# NM = map(int, input().split())
N = int(input())
L = list(map(int, input().split()))

L = sorted(L)
max_ = L[-1]
L = L[:-1]


print("Yes" if max_ < sum(L) else "No")



Measured memory_bytes: 38484
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    set<int> st;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            int p = i;
            int m = n / i - 1;
            if(p < m) st.insert(m);
            p = n / i;
            m = i - 1;
            if(p < m) st.insert(m);
        }
    }
    for(auto i : st) ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 384