akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = inputLongArray[0];
            
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var q = inputLongArray[0];

            long[] b = new long[q];
            long[] c = new long[q];

            long[] d = new long[100001];//iが数列に存在する数
            for (int i = 0; i < n; i++)
            {
                d[a[i]]++;
            }

            var ans = new long[q];
            var sum = a.Sum();
            for (int i = 0; i < q; i++)
            {
                inputLongArray = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
                b[i] = inputLongArray[0];
                c[i] = inputLongArray[1];

                ans[i] = sum + (c[i] - b[i]) * d[b[i]];
                sum = ans[i];

                d[c[i]] += d[b[i]];
                d[b[i]] = 0;
            }

            for (int i = 0; i < q; i++)
            {
                Console.WriteLine(ans[i]);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 46908
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std ;
long long N, W;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin>>N>>W ;
    vector<long long> dp(W+1,0ll) ;
    while(N--)
    {
        long long w, v;
        cin>>w>>v;
        for(int i=W-w;i>=0;--i)  dp[i+w]=max(dp[i+w],dp[i]+v);
    }
    long long res=0;
    for(int i=1;i<=W;++i) res=max(dp[i],res) ;
    printf("%lld\n",res);
}


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

void solve()
{
    // 入力の処理
    int N;
    cin >> N;
    long long d[N];
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;

    return;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<double,ll,ll>T;
#define PI 3.14159265358979
const int MAX = 510000;
const int MOD = 1000000007;
//この設定だとn<10^7が限界。maxの０を一個増やせば100msかかるが一桁増やせる。
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  int N;
  cin>>N;
  COMinit();
  map< ll, int > ret;
 for(ll j=2;j<=N;j++){
   ll n=j;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n]++;
 }
  ll a=0,b=0,c=0,d=0,e=0;
  ll z=0;
  for(auto k:ret){
  	if(k.second>=2){a++;}
    if(k.second>=4){b++;}
    if(k.second>=14){c++;}
    if(k.second>=24){d++;}
    if(k.second>=74){e++;}
  }
  ll ans=0ll;
  ans+=e;
  ans+=d*(a-1);
  ans+=c*(b-1);
  ans+=b*(b-1)*(a-2)/2;
  cout<<ans;
} 

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
using namespace std;
typedef vector <double> DVEC;

int Aout(DVEC &A);
int insertionsort(DVEC &A);

int main(void){
	int n;

	cin>>n;
	DVEC A(n);

	for (int i=0; i<n; i++)
		cin>>A[i];
	Aout(A);
	insertionsort(A);

	return 0;
}

int Aout(DVEC &A){
	for (int i=0; i<(int)A.size(); i++){
		if (i!=0) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	return 0;
}

int insertionsort(DVEC &A){
	double key;
	int i;
	for (int j=1; j<(int)A.size(); j++){
		key = A[j];
		i = j-1;
		while (i>=0){
			if (A[i] <= key) break;
			A[i+1] = A[i];
			i--;
		}
		A[i+1] = key;
		Aout(A);
	}
	return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n;cin>>n;
	vector<pair<int,int> > v(n);
	rep(i,n){
		int a,b;cin>>a>>b;
		v[i]=make_pair(b,a);
	}
	sort(all(v));
	int time=0;
	rep(i,n){
		time+=v[i].second;
		if(time>v[i].first){cout<<"No"<<endl;return 0;}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;

int main(int argc, char const *argv[]) {
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); i++) {
		if ((s.size() - i) % 2 != 0) continue;
		int k = (s.size() - i) / 2;
		if (s.substr(0, k) == s.substr(k, k)) {
			cout << k * 2 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	int x, y, b[4000][4000], w[4000][4000], bs[4000][4000], ws[4000][4000];
	char c;
	int max=0;

	scanf("%d %d", &n ,&k);
	for(int i=0; i<4*k; i++){
		for(int j=0; j<4*k; j++){
			b[i][j]=0; w[i][j]=0;
		}
	}
	for(int i=0; i<n; i++){
		scanf("%d %d %c", &x, &y, &c);
		int xr=x%(2*k);
		int yr=y%(2*k);
		if(c=='B'){
			b[xr][yr]++;
			b[xr+2*k][yr]++;
			b[xr][yr+2*k]++;
			b[xr+2*k][yr+2*k]++;
		}else{
			w[xr][yr]++;
			w[xr+2*k][yr]++;
			w[xr][yr+2*k]++;
			w[xr+2*k][yr+2*k]++;
		}
	}
	bs[0][0]=b[0][0];
	ws[0][0]=w[0][0];
	for(int i=1; i<4*k; i++){
		bs[i][0]=bs[i-1][0]+b[i][0];
		ws[i][0]=ws[i-1][0]+w[i][0];
	}
	for(int j=1; j<4*k; j++){
		bs[0][j]=bs[0][j-1]+b[0][j];
		ws[0][j]=ws[0][j-1]+w[0][j-1];
	}
	for(int i=1; i<4*k; i++){
		for(int j=1; j<4*k; j++){
			bs[i][j]=bs[i][j-1]+bs[i-1][j]-bs[i-1][j-1]+b[i][j];
			ws[i][j]=ws[i][j-1]+ws[i-1][j]-ws[i-1][j-1]+w[i][j];
		}
	}
	for(int i=1; i<=2*k;i++){
		for(int j=1; j<=2*k; j++){
			int s=0;
			s=s+ws[i+k-1][j+k-1]-ws[i-1][j+k-1]-ws[i+k-1][j-1]+ws[i-1][j-1];
			s=s+ws[i+2*k-1][j+2*k-1]-ws[i+2*k-1][j+k-1]-ws[i+k-1][j+2*k-1]+ws[i+k-1][j+k-1];
			s=s+bs[i+2*k-1][j+k-1]-bs[i+2*k-1][j-1]-bs[i+k-1][j+k-1]+bs[i+k-1][j-1];
			s=s+bs[i+k-1][j+2*k-1]-bs[i-1][j+2*k-1]-bs[i+k-1][j+k-1]+bs[i-1][j+k-1];
			if(max<s){
				max=s;
			}
		}
	}
	printf("%d\n", max);


	return 0;

}

Measured memory_bytes: 250112
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int k;
	cin >> k;
	int val = 7%k;
	FOR(i,1,1e7+1){
		if(val == 0){
			cout << i <<"\n";
			return;
		}
		val = (val*10+7)%k;
	}
	cout << -1 <<"\n";
	
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    
    count = [0] * N

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        count[a] += 1
        count[b] += 1
    
    for i in range(N):
        print(count[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int x = 0;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
using namespace std;
      
int bubbleSort(int A[], int N) {
  int sw = 0;
  bool flag = 1;
  for ( int i = 0; flag; i++){
    flag = 0;
    for ( int j = N - 1; j >= i + 1; j-- ){
      if ( A[j] < A[j-1] ) {
        swap(A[j], A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}
             
      
int main() {
  int N, sw;
  int A[100];
      
  cin >> N;
  for ( int i = 0; i < N; i++) cin >> A[i];
      
  sw = bubbleSort(A, N);
      
  for ( int i = 0; i < N; i ++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
      
  return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>

struct node{
  int key;
  struct node *r,*l,*p;
};

typedef struct node Node;

Node *root,*nil;

void insert(int t){
  Node *x=root,*y=nil,*z;

  z=malloc(sizeof(Node));
  z->key = t;
  z->r=nil;
  z->l=nil;

  while(x!=nil){
    y=x;

    if(z->key < x->key){
      x = x->l;
    }
    else {
      x = x->r;
    }
  }

  z->p = y;
  if(y==nil)root = z;
  else {
    if(z->key < y->key){
      y->l = z;
    }
    else {
      y->r = z;
    }
  }
}

void inorder(Node *q){
  if(q==nil)return;

  inorder(q->l);
  printf(" %d",q->key);
  inorder(q->r);
}
void preorder(Node *q){
  if(q==nil)return;

  printf(" %d",q->key);
  preorder(q->l);
  preorder(q->r);
}


int main(){
  int n,i,j,t;
  char s[10];

  root = nil;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0]=='i'){
      scanf("%d",&t);
      insert(t);
    }
    else if(s[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25128
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let W = xs[0];
   let a = xs[1];
   let b = xs[2];
   let ans = 0;
   if(b-a>=W){
      console.log(ans=(b-a)-W);
   }else if(a-b>=W){
      console.log(ans=(a-b)-W);
   }else{
      console.log(ans=0);
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
n = int(input())
b = list(map(int, input().split()))
b = b[::-1]
ans = b[0]
for i in range(1, n-1):
    if b[i] >= b[i-1]:
        ans += b[i-1]
    else:
        ans += b[i]
print(b[-1]+ans)

Measured memory_bytes: 3060
# abc113_a.py
# https://atcoder.jp/contests/abc113/tasks/abc113_a

# A - Discount Fare /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 100点

# 問題文
# A駅と B 駅を結ぶ鉄道があり、運賃は X円です。
# また、B駅と C 駅を結ぶバスがあり、運賃は Y円です。
# joisinoお姉ちゃんは、A駅から B 駅まで鉄道で移動し、B 駅から C駅までバスで移動すると、バスの運賃が半額になる特別券を手に入れました。
# この特別券を用いたとき、A駅から C駅まで移動するのにいくらかかるか求めてください。

# 制約
#     1≤X,Y≤100
#     Yは偶数
#     入力は全て整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# X Y

# 出力
# A駅から C 駅まで移動するのに x 円かかるとき、xを出力せよ。

# 入力例 1
# 81 58

# 出力例 1
# 110

#     鉄道の運賃は 81円です。
#     バスの運賃は半額となるため、58⁄ 2=29円です。

# よって、A駅から C 駅まで移動するのに 110円かかります。

# 入力例 2
# 4 54

# 出力例 2
# 31


def calculation(lines):
    # N = int(lines[0])
    X, Y = list(map(int, lines[0].split()))
    # n = lines[0]

    return [X + int(Y/2)]



# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['81 58']
        lines_export = [110]
    if pattern == 2:
        lines_input = ['4 54']
        lines_export = [31]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
/*
ID: jerrywcy
LINK: https://atcoder.jp/contests/abc121/tasks/abc121_d
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

using namespace std;

long long a,b;

int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	if (a%2==0 && b%2==0)cout<<(b^((b-a+1)/2%2))<<endl;
	else if (a%2==0 && b%2!=0)cout<<((b-a+1)/2%2)<<endl;
	else if (a%2!=0 && b%2==0)cout<<(a^b^((b-a-1)/2%2))<<endl;
	else if (a%2!=0 && b%2!=0)cout<<(a^((b-a+1)/2%2))<<endl;

	return 0;
}



Measured memory_bytes: 256
#abc079-c
#bit全探索をやっていこうと　思うわよ
abcd = input()
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

total = 7
#０か１かの、選択肢である記号部分は３つあるわ
n = 3
#全探索すべきは、2^nだわよ
k = 0
for i in range(2 ** n):
  #Aだけ入れた文字列に、”＋” or ”-” を入れて、その次の文字(abcd[j + 1])を続けて入れるわよ
    way = a
    for j in range(n):
        if ((i >> j) & 1):
            way += "+"
            way += (abcd[j + 1])
        else:
            way += "-"
            way += (abcd[j + 1])
    #evalで引数の文字列を、式として計算するわ
    ans = eval(way)
    #あら、７になったわね
    if ans == 7:
      #これで優勝
      print(way + "=7")
      k = 1
      break
if k != 1:
    print("No")


Measured memory_bytes: 9148
//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)

void solve()
{
	int n,k;
	cin>>n>>k;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	nth_element(a.begin(),a.begin()+k,a.end());
	int ans=0;
	rep(i,0,k)
		ans+=a[i];
	cout<<ans<<endl;
}
int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	while(t--)
		solve();
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
    int a, b;
    scanf("%d%d",&a,&b);
    if(a == 1 && b == 2){
        printf("3\n");
    }

    else if(a == 1 && b == 3){
        printf("2\n");

    }
    else if(a == 2 && b == 3){
        printf("1\n");
    }

    else if(a == 2 && b == 1){
        printf("3\n");
    }

    else if(a == 3 && b == 1){
        printf("2\n");

    }
    else if(a == 3 && b == 2){
        printf("1\n");
    }

}


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

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

    int x = 0;
    int max = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }

        if(max < x){
            max = x;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

int main()
{
	int N,K;
	cin>>N>>K;
	int result = 0;
	if(K==1)
	{
		result = 0;
	}
	else
	{
		result = N - K;
	}
	cout<<result<<endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b,c,d; cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            out("Yes");
            return 0;
        }
        a-=d;
        if(a<=0){
            out("No");
            return 0;
        }
    }
}


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

using namespace std;

#define ge getchar()
#define Re read()

inline int read() {
	int x = 0, ch;
	while(!isdigit(ch = ge)) ;
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = ge;
	return x;
}

const int MAXN = 200000;

int n, N;
int a[MAXN + 1];
int v[MAXN + 1];
int x[MAXN + 1];

inline int chk() {
	int l = n, r = n, res = x[n]; x[0] = x[1], x[N + 1] = x[N];
	for(; x[l] != x[l - 1] && x[r] != x[r + 1]; --l, ++r) res ^= 1;
	return res;
}

int main() {
	n = Re, N = (n << 1) - 1;
	for(int i = 1; i <= N; i++) v[i] = a[i] = Re;
	sort(v + 1, v + 1 + N); int l = 1, r = N, res = v[r];
	while(l <= r) {
		int mid = (l + r) >> 1, val = v[mid];
		for(int i = 1; i <= N; i++) x[i] = a[i] > val;
		if(!chk()) res = val, r = mid - 1;
		else l = mid + 1;
	} printf("%d\n", res);
	return 0;
}

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

#define rep(loop, N) for (int loop = 0; loop < N; loop++)
using namespace std;

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Harmony(void) {

	int A, B; cin >> A >> B;

	if ((A + B) % 2 == 0)	cout << (A + B) / 2 << endl;
	else					cout << "IMPOSSIBLE" << endl;
	return;
}

int main(void) {

	A_Harmony();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b;
  cin>>a>>b;

  if(a==b){
    cout << "Draw" <<"\n";
    return;
  }
  if(a==1){
    cout << "Alice" <<"\n";
    return;
  }
  if(b==1){
    cout << "Bob" <<"\n";
    return;
  }
  
  cout << (a>b? "Alice" :"Bob") <<"\n";

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  long long N;
  cin >> N;

  long long answer = 0;
  //5の倍数の個数を求める                                                                           
  if (N % 2 == 1) {
    answer = 0;
  } else {
    long long t = 10;
    //long long p = N / 10;                                                                         
    //answer = p;                                                                                   
    while (t <= N) {
      answer += N / t;
      //p = answer;                                                                                 
      t *= 5;
    }


  }
  cout << answer <<"\n";
}


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

int main(){
    int n;cin>>n;double x[n],y[n];double sum=0.0;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    long long n_s=1;
    for(int i=1;i<n;i++) n_s*=i;
    for(int i=0;i<n;i++){
        int j=(i+1)%n;
        while(j!=i){
            double s=pow(pow(x[i]-x[j],2)+pow(y[i]-y[j],2),0.5)*n_s;
            sum+=s;
            j=(j+1)%n;
        }
    }
    sum=sum/(n_s*n);
    cout<<setprecision(10)<<sum<<endl;
}

Measured memory_bytes: 512
import sys

K = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

items = sorted(A, reverse=True)
weights = [K[x] for x in items]

m = [[0]*M] + [None for i in range(N)]
for i in range(1, N+1):
	best = [0]*M
	
	for j in range(M):
		remaining = i - weights[j]
		if remaining >= 0 and m[remaining] is not None and sum(m[remaining])+1 > sum(best):
			best = m[remaining][:j] + [m[remaining][j]+1] + m[remaining][j+1:]
	
	if sum(best) == 0:
		best = None

	m[i] = best

for i in range(M):
	for j in range(m[N][i]):
		sys.stdout.write(str(items[i]))

sys.stdout.write("\n")

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (max({a, b, c}) * 2 == a + b + c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/11/20 21:59:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<pair<int,int>> ps(n);
  for (int i = 0; i < n; i++) {
    int x,y; cin>>x>>y;
    ps[i] = {x,y};
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      double dist = sqrt(pow(ps[i].first-ps[j].first, 2) + pow(ps[i].second-ps[j].second, 2));
      ans += dist*2/n;
    }
  }
  cout <<fixed<<setprecision(10)<< ans << endl;

  return 0;
}


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

int main(){
    ll N, K;
    cin >> N >> K;
    
    ll ans=1;
    rep(i,0,N){
        ans=min(ans*2, ans+K);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    unsigned long long S, A, B;
    cin >> S;
    cin >> A;
    cin >> B;
    // cout << S << " " << A << " " << B << endl;
    unsigned long long loop = S / (A + B); //青赤何セットあるかチェック
    // cout << "loop: " << loop << endl;
    unsigned long long result = 0;
    if (loop == 0) { //1セット無い時
        if (A > S) { //青の合計が先頭から取得する数よりも多い
            result = S;
        } else { //少ない
            result = A;
        }
    } else { //1セット以上ある時
        unsigned long long amari = S % (A+B); //セットからはみ出た分の青
        // cout << "amari: " << amari << endl;
        if(amari > A) {
            amari = A;
        }
        result = loop * A + amari; //セットの中の青色とはみ出た分をたす
    }
    if(A == 0) { //そもそも青が0の時
        cout << 0 << endl;
    } else { //それ以外
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String args[]) {
        StringBuilder sb = new StringBuilder();
        
        
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                sb.append(i);
                sb.append('x');
                sb.append(j);
                sb.append('=');
                sb.append(i*j);
                sb.append('\r');
                sb.append('\n');
            }
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 16832
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]


res = 0
for ih in range(1<<h):
    for iw in range(1<<w):

        h_use = [False] * h # 1: use
        w_use = [False] * w # 1: use
        for jh in range(h):
            if(ih & (1 << jh) != 0): h_use[jh] = True
        
        for jw in range(w):
            if(iw & (1 << jw) != 0): w_use[jw] = True

        cnt = 0
        for i in range(h):
            for j in range(w):
                
                if(h_use[i] or w_use[j]): continue
                if(c[i][j] == '.'): continue
                
                cnt += 1
        
        if(cnt == k): res += 1

print(res)

Measured memory_bytes: 8952
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
#define N 100002
using namespace std;
int head[N],ver[N*2],nxt[N*2],l;
int head1[N],ver1[N*2],nxt1[N*2],l1;
int n,m,i,j,a[N],b[N],c[N],fa[N],p[N],f[N],sum[N];
bool vis[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y)
{
	l++;
	ver[l]=y;
	nxt[l]=head[x];
	head[x]=l;
}
void insert1(int x,int y)
{
	l1++;
	ver1[l1]=y;
	nxt1[l1]=head1[x];
	head1[x]=l1;
}
int my_comp(const int &x,const int &y)
{
	return c[x]<c[y];
}
int find(int x)
{
	if(fa[x]!=x) fa[x]=find(fa[x]);
	return fa[x];
}
void dfs(int x)
{
	sum[x]=b[x];
	for(int i=head1[x];i;i=nxt1[i]){
		int y=ver1[i];
		dfs(y);
		sum[x]+=sum[y];
	}
	f[x]=sum[x]+c[x];
	for(int i=head1[x];i;i=nxt1[i]){
		int y=ver1[i];
		f[x]=min(f[x],sum[x]-sum[y]+max(f[y],c[x]));
	}
}
signed main()
{
	n=read();m=read();
	for(i=1;i<=n;i++){
		a[i]=read();b[i]=read();
		c[i]=max(a[i]-b[i],1LL*0);
	}
	for(i=1;i<=m;i++){
		int u=read(),v=read();
		insert(u,v);
		insert(v,u);
	}
	for(i=1;i<=n;i++) fa[i]=p[i]=i;
	sort(p+1,p+n+1,my_comp);
	for(i=1;i<=n;i++){
		int x=p[i];
		vis[x]=1;
		for(j=head[x];j;j=nxt[j]){
			int y=ver[j];
			if(vis[y]){
				int f=find(y);
				if(f!=x){
					fa[f]=x;
					insert1(x,f);
				}
			}
		}
	}
	dfs(p[n]);
	cout<<f[p[n]]<<endl;
	return 0;
}


Measured memory_bytes: 19716
def main():
    n = int(input())
    data = []
    for i in range(n):
        tt, xx, yy = [int(i) for i in input().split()]
        data.append([tt, xx, yy])

    nx, ny = 0, 0
    nt = 0
    for t, x, y in data:
        # x + y が偶数か奇数か
        tt = t-nt; tx = x-nx; ty = y-ny
        if not ((abs(tx)+abs(ty)) % 2 == tt % 2) or abs(tx)+abs(ty) > tt:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

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

typedef pair<int, int> P;

static const int MAX_H = 1000;
static const int MAX_W = 1000;

int H, W;
char grid[MAX_H][MAX_W + 1];
int count[MAX_H][MAX_W];

//#define OCTAS
#ifdef OCTAS
static const int dh[] = {-1, -1, -1, 0, 0, +1, +1, +1};
static const int dw[] = {-1, 0, +1, -1, +1, -1, 0, +1};
#else
static const int dh[] = {-1, 0, 0, +1};
static const int dw[] = {0, -1, +1, 0};
#endif

void initialize() {
  // memset(::count, -1, sizeof(::count));
  fill_n(::count[0], MAX_H * MAX_W, -1);
}

void bfs() {
  queue<P> que;
  for (int i{}; i < H; ++i) {
    for (int j{}; j < W; ++j) {
      if (grid[i][j] == '#') {
        ::count[i][j] = 0;
        que.push(P(i, j));
      }
    }
  }

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int cnt = ::count[p.first][p.second];
    ++cnt;
    for (int i = 0; i < sizeof(dh) / sizeof(int); ++i) {
      int nh = p.first + dh[i];
      int nw = p.second + dw[i];
      if (nh < 0 || nh >= H ||
          nw < 0 || nw >= W ||
          ::count[nh][nw] >= 0 ||
          grid[nh][nw] == '#')
        continue;
      ::count[nh][nw] = cnt;
      que.push(P(nh, nw));
    }
  }
}

int main() {
  initialize();
  scanf("%d%d", &H, &W);
  for (int h = 0; h < H; ++h) {
    scanf("%s", &grid[h][0]);
  }

  bfs();
  int ans{};
  for (int i{}; i < H; ++i) {
    for (int j{}; j < W; ++j) {
      if (ans < ::count[i][j])
        ans = ::count[i][j];
    }
  }

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


Measured memory_bytes: 13328
#include<stdio.h>
int max(int a,int b){
    return a<b?b:a;
}
int main(){
  int a,b,ab,na,nb,i;
  scanf("%d %d %d %d %d",&a,&b,&ab,&na,&nb);
  long ans=1000000000000000;
  long tmp;
  for(i=0;i<=100000;i++){
    tmp= i*2*ab + max(na-i,0)*a + max(nb-i,0)*b;
    if(tmp < ans)
      ans = tmp;
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 128
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[];
  let outs: Print[] = [];

  const main = (): Print => {
    const r = _io();
    const [s] = r.ss();

    return 'a' <= s && s <= 'z' ? 'a' : 'A';
  };

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8');
    const lines = str.trim().split('\n');
    const s = () => lines[i++] || '';
    const n = () => Number(s());

    const mn = (v: string[]) => v.map(Number);
    const sp = (v: string) => v.split(' ');

    const ss = () => sp(s());
    const nn = () => mn(ss());
    const nls = () => mn(lines.slice(i));
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)));

    return { lines, s, n, ss, nn, nls, nnls };
  };

  outs.push(main());

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  );
}


Measured memory_bytes: 29584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
   char ch; cin>>ch;
   if(ch >= 'A' && ch <= 'Z')cout << "A";
   else cout << 'a';
    return 0;
}
    

// Химаншу


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
const int N_MAX = 202;

ll popcnt(string S){
    int N = S.length();
    int cnt = 0;
    REP(i,N){
        if (S[i] == '1') cnt++;
    }
    return cnt;
}

ll firstcomp(string S, ll m){
    if (m == -1) return 0;
    if (m == 0) return 0;

    int N = S.length();
    ll Bs = 1;
    ll ret = 0;
    REPr(i,N){
        if (S[i] == '1') ret += Bs % m;
        ret %= m;
        Bs *= 2;
        Bs %= m;
    }
    return ret % m;
}

ll secondcomp(ll x){
    ll ret = 0;
    while(__builtin_popcountll(x) != 0){
        x = x % __builtin_popcountll(x);
        ret++;
    }
    return ret;
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    ll pcnt = popcnt(S);

    ll cnt0 = firstcomp(S, popcnt(S));
    ll cnt1 = firstcomp(S, popcnt(S) + 1);
    ll cnt2 = firstcomp(S, popcnt(S) - 1);

    

    vector<ll> bin1(N+3),bin2(N+3);
    bin1[0] = 1 % (pcnt + 1);
     if (pcnt != 1) bin2[0] = 1 % (pcnt - 1);
    for(int i = 1; i <= N + 1; i++){
        bin1[i] = (bin1[i-1] * 2) % (pcnt + 1);
        if (pcnt != 1) bin2[i] = (bin2[i-1] * 2) % (pcnt - 1);
    }

    REP(i,N){
        if (S[i] == '0'){
            cout << 1 + secondcomp((cnt1 + (bin1[N - i - 1])) % (pcnt + 1) ) << "\n";
        }else{
            //cout << "cnt2 = " << cnt2 << "\n";
            //cout << "bin2[N-i-1] = " << bin2[N - i - 1] << "\n";
            if (pcnt == 1){
                cout << 0 << "\n";
                continue;
            }
            
            ll secin = ((cnt2 - (bin2[N - i - 1])) + (pcnt - 1)) % (pcnt - 1);
            cout << 1 + secondcomp(secin) << "\n";
        }
    }
}

Measured memory_bytes: 6604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,r;
    while(cin>>n>>r,r){
        int a,b;
        vector<int> v;
        for(int i=0;i<n;i++){
            v.push_back(n-i-1);
        }
        for(int x:v){
                //cout <<x<<" ";
            }
            //cout<<endl;
        for(int i=0;i<r;i++){
            cin>>a>>b;
            vector<int> tmp=v;
            for(int j=0;j<a-1;j++){
                for(int k=0;k<n;k++){
                    if(tmp[k]==j){
                        v[k]+=b;
                    }
                }
            }
            for(int j=0;j<b;j++){
                for(int k=0;k<n;k++){
                    if(tmp[k]==j+a-1){
                        v[k]-=a-1;
                    }
                }
            }
            for(int x:v){
                //cout <<x<<" ";
            }
            //cout<<endl;
            
        }
        for(int i=0;i<n;i++){
            if(v[i]==0)cout<<i+1<<endl;
        }
    }
}

Measured memory_bytes: 3060
// to format a document: ctrl + K -> ctrl + D

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

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

    for (int i = 0; i <= N; i += 4) {
        if ((N - i) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
S = raw_input()
S.replace("a","sine")
if "eraser" in S:
    S=S.replace("eraser", "")
if "erase" in S:
    S=S.replace("erase", "")
if "dreamer" in S:
    S=S.replace("dreamer", "")
if "dream" in S:
    S=S.replace("dream","")
print "YES" if len(S)==0 else "NO"

Measured memory_bytes: 2820
#include "bits/stdc++.h"
     
    #define REP(i,n) for(ll i=0;i<n;++i)
    #define RREP(i,n) for(ll i=n-1;i>=0;--i)
    #define FOR(i,m,n) for(ll i=m;i<n;++i)
    #define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
    #define ALL(v) (v).begin(),(v).end()
    #define PB(a) push_back(a)
    #define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
    #define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
    #define INF 1000000001ll
    #define MOD 1000000007ll
    #define EPS 1e-9
     
    const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
    const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };
     
     
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<vi> vvi;
    typedef vector<vl> vvl;
    typedef pair<int, int> pii;
    typedef pair<ll, ll> pll;
    ll max(ll a, int b) { return max(a, ll(b)); }
    ll max(int a, ll b) { return max(ll(a), b); }
    ll min(ll a, int b) { return min(a, ll(b)); }
    ll min(int a, ll b) { return min(ll(a), b); }
    ///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
    int main() {
    	cin.tie(0);
    	ios::sync_with_stdio(false);
    	int n, a, b;
    	cin >> n >> a >> b;
    	vi h(n);
    	REP(i, n)cin >> h[i];
    	ll r = INF, l = 0;
    	while (r - l > 1) {
    		ll mid = (r + l) / 2;
    		ll cnt = 0;
    		REP(i, n) {
    			if (h[i] > mid*b)cnt += (h[i] - mid*b+a-b-1) / (a - b);
    		}
    		if (cnt > mid)l = mid;
    		else r = mid;
    	}
    	cout << r << endl;
    	return 0;
    }

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;


int main() {
    ll N, A;
    ll x[50];
    cin >> N >> A;
    ll i, j, k;
    ll dp[N+1][N+1][N*A+1];
    for(i=0; i<N; i++)
        cin >> x[i];
    
    for(i=0; i<=N; i++) {
        for(j=0; j<=N; j++) {
            for(k=0; k<=N*A; k++) {
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    
    for(i=0; i<N; i++) {
        for(j=0; j<N; j++) {
            for(k=0; k<=N*A; k++) {
                dp[i+1][j][k]+=dp[i][j][k];
                if(k+x[i]<=N*A)
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    for(j=1; j<=N; j++) {
        ans+=dp[N][j][j*A];
    }
    
    prin(ans);
}


Measured memory_bytes: 51072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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(){
    string N;
    cin >> N;

    ll sum = 0;
    for (char c : N) {
        sum += c - '0';
    }
 
    string result = sum % 9 == 0 ? "Yes" : "No";
    cout << result << endl;

    return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    sort(X.begin(), X.end());

    ll ans = 0;
    rep(i, N - 1) {
        ans += min(B, A * (X[i + 1] - X[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>

int ans(void)
{
    std::string s;
    std::cin >> s;
    if(s == "Vacant")
        return 0;
    else if(s == "Male")
        return 1;
    else
        return 2;
}

int main(void)
{
    int N;
    std::cin >> N;
    int l=0, r=N/2;
    bool lm, rm;
    std::cout << l << std::endl;
    int a = ans();
    if(a == 0)
        return 0;
    lm = a == 1;

    for(int i=0; i<19; ++i)
    {
        std::cout << r << std::endl;
        int a = ans();
        if(a == 0)
            return 0;
        rm = a == 1;
        bool d;
        int w = r-l;
        if(w%2)
            d = lm == rm;
        else
            d = lm != rm;
        if(d)
            r -= (w+1)/2;
        else
        {
            l = r;
            lm = rm;
            r += (w+1)/2;
        }
    }
    return 0;
}


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

int N;
string S;
vector<int> indicies[10];

inline int ctoi(char c) {
  return c - '0';
}

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

  cin >> N >> S;
  set<int> first;
  set<int> second;
  for (int i = 0; i < N; ++i) {
    int cur = ctoi(S[i]);
    indicies[cur].push_back(i);
  }
  int res = 0;
  for (int i = 0; i <= 999; ++i) {
    string s = to_string(i);
    if (s.size() == 1) {
      s = "00" + s;
    } else if (s.size() == 2) {
      s = "0" + s;
    }
    vector<int> a = {ctoi(s[0]), ctoi(s[1]), ctoi(s[2])};
    if (indicies[a[0]].empty()) {
      continue;
    }
    int first = indicies[a[0]][0];
    auto second = upper_bound(indicies[a[1]].begin(), indicies[a[1]].end(), first);
    if (second == indicies[a[1]].end()) {
      continue;
    }
    auto third = upper_bound(indicies[a[2]].begin(), indicies[a[2]].end(), *second);
    if (third != indicies[a[2]].end()) {
      ++res;
    }
  }

  cout << res << '\n';
}


Measured memory_bytes: 512
//
// Created by yamunaku on 2020/06/20.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;
int main(){
    //CFS;
    int x;
    cin >> x;
    int tmp = x, k = 1;
    while(tmp%360){
        tmp += x;
        k++;
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <list>
#define MODULO 1000000007 // Hitesh Vadher
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;
//#define endl '\n'

void solve()
{
    string s {};
  	cin >> s;
  
  	if(s.at(s.size()-1) == 's')
      s += "es";
  	else
      s += "s";
  
  	cout << s << endl;
}

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

Measured memory_bytes: 3648
// A - Odds of Oddness

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

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

	int odds;

	if (N % 2 == 0) odds = N / 2;
	else odds = N / 2 + 1;

	double ans = (double)odds / (double)N;

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

acc_a = list(accumulate(a))
acc_b = list(accumulate(b))

ans = 0
for i, e in enumerate(acc_b):
    if e > k:
        break
    a_cnt = bisect_right(acc_a, k - e)
    ans = max(ans, i + a_cnt)

print(ans)


Measured memory_bytes: 47312