akhauriyash/Code-Regression huggingface dataset:
// C - Monsters Battle Royale
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){return b? gcd(b, a%b): a;}

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

	vector<int> A(N);
	for(int i=0; i<N; ++i) cin>>A[i];

	int g = gcd(A[0],A[1]);
	for(int i=2; i<N; ++i) g = gcd(g, A[i]);
	cout<< g <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

vector<P> graph[100005];
vector<int> dist(100005, INF);

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

    int k;
    cin >> k;
    for(int i = 0; i < k; ++i){
        graph[i].push_back(P(i * 10 % k, 0));

        if(i == k - 1)  graph[i].push_back(P(0, 1));
        else    graph[i].push_back(P(i + 1, 1));
    }

    deque<P> deq;
    dist[1] = 1;
    deq.push_back(P(1, 1));
    while(!deq.empty()){
        P p = deq.front();
        deq.pop_front();
        int d = p.first, u = p.second;
        if(d > dist[u]) continue;
        for(int i = 0; i < graph[u].size(); ++i){
            int v = graph[u][i].first, cost = graph[u][i].second;
            if(dist[v] > dist[u] + cost){
                dist[v] = dist[u] + cost;
                if(cost == 0)   deq.push_front(P(dist[v], v));
                else    deq.push_back(P(dist[v], v));
            }
        }
    }
    cout << dist[0] << endl;
}

Measured memory_bytes: 6528
def f(a, b):
    if a == b:
        return 'Draw'
    if a > b:
        return 'Alice'
    if a < b:
        return 'Bob'

a, b = map(int, input().split())
if a == 1:
    a += 100
if b == 1:
    b += 100
print(f(a, b))



Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

void solve() {
  int n;
  cin >> n;
  int cand = 1e9;
  int ret = 0;
  while(n--) {
    int x;
    cin >> x;
    if(x < cand) {
      ret++;
      cand = x;
    }
  }
  cout << ret << "\n";
}

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


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

int main()
 {
 	int n,m;
 	cin>>n>>m;
 	if(n==m)
 		cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;	
 	return 0;
}
 	
 					

Measured memory_bytes: 3600
function ts() {
    local mat;mat=(`dd`)
    local H;H=${#mat[@]}
    local W;W=${#mat[0][@]}
    for ((w=0;w<W;++w))
    do
        local tmp;tmp=''
        for ((h=0;h<H;++h))
        do
            tmp=$tmp${mat[h]: w: 1}
        done
        echo $tmp
    done
}

read H W
grep '#' | ts | grep '#' | ts


Measured memory_bytes: 1172
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func storeIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}


func main() {
    sc.Split(bufio.ScanWords)
    //sc.Split(bufio.ScanLines)

    n, y := nextInt(), nextInt()

    res10000, res5000, res1000 := -1, -1, -1

    for i := 0; i <= n; i++ {
        for j := 0; j <= n - i; j++ {
            k := n - i - j
            total := 10000*i + 5000*j + 1000*k
            if total == y {
                res10000 = i
                res5000 = j
                res1000 = k
            }
        }
    }

    fmt.Println(res10000, res5000, res1000)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;

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

int main(){
    int N,_gcd;
    int pos[100001];
    int delta[100000];
    cin >> N;
    for(int i=0;i<=N;i++){
        cin >> pos[i];
    }
    sort(pos,pos+N+1);
    for(int i=0;i<N;i++) delta[i] = pos[i+1] - pos[i];
    _gcd = gcd(delta[0],delta[1]);
    for(int i=2;i<N;i++){
        _gcd = gcd(_gcd, delta[i]);
    }
    cout << _gcd;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  double x[N];
  string u[N];
  double sum = 0;
  for (int i = 0; i < N; i++) {
		cin >>  x[i] >> u[i];
    if(u[i] == "BTC") x[i]*=380000.0;
    sum += x[i];
  }
  cout<<sum<<endl;
}

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

int main(){
  int n;
  cin>>n;
  int ans=0;
  for (int i = 1; i <=n ; i++)
  {
    /* code */
    if (i*i<=n)
    {
      /* code */
      ans=i*i;
    }
    else
    {
      break;
    }
    
    
  }
  cout<<ans<<endl;
  
  }

Measured memory_bytes: 256
import heapq

q = int(input())

minheap = [] # right
maxheap = [] # left
heapq.heapify(minheap)
heapq.heapify(maxheap)

s = 0
m = 0

for _ in range(0, q):
    token = input().split()
    if len(token) > 1:
        a = int(token[1])
        b = int(token[2])
        s += b
        heapq.heappush(minheap, a)
        heapq.heappush(maxheap, -a)
        if -maxheap[0] > minheap[0]:
            maxv = -heapq.heappop(maxheap)
            minv = heapq.heappop(minheap)
            m += abs(maxv - minv)
            heapq.heappush(minheap, maxv)
            heapq.heappush(maxheap, -minv)
    else:
        print('{} {}'.format(-maxheap[0], s + m))


Measured memory_bytes: 19012
def iskaibun(s):
    if(s==""):
        return 1
    else:
        if(s[0]==s[-1]):
            return iskaibun(s[1:-1])
        else:
            return 0


st = input()
l = len(st)
q = (l-1)//2
st1 = st[0:q]
st2 = st[q+1:]
if(iskaibun(st1)==1 and iskaibun(st2)==1 and iskaibun(st)==1):
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????°?????£?¨? ?????????
		long num = 0;
		long min =  1000000;  //????°????
		long max = -1000000;  //?????§???
		long sum = 0; //????¨????
		//??°????????????
		int n = sc.nextInt();
		
		//???????????????
		for(int i = 0; i < n; i++){
			num = sc.nextLong();
		
		//????°????
		if(num < min )
			min = num;
			
		//?????§???
		if(max < num)
			max = num;
		
		//????¨????
		sum += num;
		}
		//??¨???
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 41520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

int dx[4] = { 0, -1, 1, 0 };
int dy[4] = { -1, 0, 0, 1 };

int m[1010];

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= b; ++i) {
    if (i < a + k || i > b - k) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <= i && i < b)
#define ll long long
#define fi first
#define fs sirst
#define se second
#define sc second
//#define int long long
using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
typedef pair<int, int> P;

int n,m;
int riku[1111][1111], umi[1111][1111];
vec dp;

void solve() {
	REP(i, n) REP(j, n) riku[i][j] = umi[i][j] = 1 << 28;
	REP(i, n) riku[i][i] = umi[i][i] = 0;

	REP(_, m) {
		int x, y, c; char s;
		cin >> x >> y >> c >> s;
		x--; y--;
		if (s == 'L') riku[x][y] = min(riku[x][y], c), riku[y][x] = min(riku[y][x], c);
		else umi[x][y] = min(umi[x][y], c), umi[y][x] = min(umi[y][x], c);
	}

	int r;
	cin >> r;
	vec a(r,0);
	REP(i, r) cin >> a[i], a[i]--;
	
	REP(k, n) {
		REP(i, n) {
			REP(j, n) {
				riku[i][j] = min(riku[i][j],riku[i][k] + riku[k][j]);
				umi[i][j] = min(umi[i][j], umi[i][k] + umi[k][j]);
			}
		}
	}

	dp.assign(n, 1 << 28);
	dp[a[0]] = 0;

	REP(i, r-1) {
		vec tmp(n, 1 << 28);
		REP(j, n) {
			tmp[j] = min(tmp[j], dp[j] + riku[a[i]][a[i + 1]]);

			int base = riku[a[i]][j];
			REP(k, n) {
				tmp[k] = min(tmp[k], dp[j] + base + umi[j][k] + riku[k][a[i + 1]]);
			}
		}
		dp = tmp;
	}
	int ans = 1 << 30;
	REP(i, n) ans = min(ans, dp[i]);

	cout << ans << endl;
}

int main() {
	while (cin >> n >> m, n) solve();
}


Measured memory_bytes: 4900
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

vector<vector<int> > data;

void init(){
  data.clear();
}

bool input(){
  int n;
  cin>>n;
  if(n==0)return false;

  for(int i=0;i<n;i++){
    vector<int> vtmp;
    for(int j=0;j<n;j++){
      int tmp;
      cin>>tmp;
      vtmp.push_back(tmp);
    }
    data.push_back(vtmp);
  }
  return true;
}

void solve(){
  vector<int> last;
  last.resize(data[0].size()+1);
  for(int i=0;i<data.size();i++){
    int tmp=0;
    for(int j=0;j<data[i].size();j++){
      tmp+=data[i][j];
      last[j]+=data[i][j];
      last[last.size()-1]+=data[i][j];
    }
    data[i].push_back(tmp);
  }
  data.push_back(last);
}


int main(){
  while(init(),input()){
    solve();
    for(int i=0;i<data.size();i++){
      for(int j=0;j<data[i].size();j++){
        cout<<setw(5)<<data[i][j];
      }cout<<endl;
    }
  }
}

Measured memory_bytes: 1228
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			Tuple<int, int>[] a = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int aa = cin.Int();
				a[i] = new Tuple<int, int>(aa, i + 1);
			}

			var aaa = a.OrderBy(x => x.Item1).ToArray();
			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.Append($"{aaa[i].Item2} ");
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

// definitions
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256
#define pi 3.1415926535897932384

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;
// prevent collisions in unordered_map
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef unordered_map <long long, long long, custom_hash> umap;

// cin and cout overloaded for vectors and sets
template<typename T>             
istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>             
ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}

// standard functions
ll mystoi(string str)
{
    stringstream ss(str);
    ll ans=0;
    ss >> ans;

    return ans;
}

ll exp(ll x, ll ex) 
{
    ll ans = 1ll;
    while (ex > 0) 
    {
        if (ex & 1ll) ans = (ans * x);
        ex >>= 1ll;
        x = (x * x);
    }
    return ans;
}

bool sort_cond(const pair<ll,ll> &a, const pair <ll,ll> &b)
{
    if(a.first==b.first)
        return a.second<b.second;

    return a.first < b.first;
}

// code beigns in main
int main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;

    while(t--)
    {
        char ch;
        cin >> ch;

        if(ch>='A' && ch<='Z') cout << 'A' << endl;
        else cout <<'a' << endl;
    }
}

Measured memory_bytes: 3640
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int BinarySearch(vector<int> tab,int target)
  {
      int l = 0, r = tab.size()-1,mid;
      while (l <= r)
      {
          mid = l + ((r - l) / 2);
          if (tab[mid] == target)
          {
              return mid;
          }
          else if (tab[mid] < target)
          {
              l = mid + 1;
          }
          else //tab[mid] > target)
          {
              r = mid - 1;
          }
      }
      return -1;
  }
int main(){ 
  int x,n;
  cin>>x>>n;
  vector<int> tab(n);
  for(int i = 0;i<n;i++){
    cin>>tab[i];
  }
  sort(tab.begin(),tab.end());
  int index=BinarySearch(tab,x);
  if(index==-1){
    cout<<x<<"\n";
    return 0;  
  }
  else{
     int previusLeft= tab[index];
     int previusRight=tab[index];
     int leftPointer=index-1;
     int rightPointer=index+1;
     bool found =false;
     while(!found&&(leftPointer!=-1||rightPointer!=n)){
       if(leftPointer>=0){
         if(tab[leftPointer]!=previusLeft-1){
           cout<<previusLeft-1<<"\n"; 
           return 0;
         }
         else{
           previusLeft=tab[leftPointer];
           leftPointer--;
         }
       }
       if(rightPointer<n && !found){
         if(tab[rightPointer]!=previusRight+1){
           cout<<previusRight+1<<"\n"; 
           return 0;
         }
         else{
           previusRight=tab[rightPointer];
           rightPointer++;
         }
       }
     }
     if(abs(x-(previusLeft-1))<=abs(previusRight+1-x)){
       cout<<previusLeft-1<<"\n";  
     }
     else{
       cout<<previusRight+1<<"\n";  
     } 
         
  }
  
  return 0;
}

Measured memory_bytes: 3576
N = int(input())
h = list(map(int, input().split()))

if N == 2:
  print(abs(h[1]-h[0]))
  exit()

dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
  dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])

Measured memory_bytes: 13928
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
int main()
{
  long long N,D,X;
  int A[101] = {};
  int i,j;
  int number;
  char s[10];
  long long  cnt_c=0;
  long long  cnt=0;

//    int k=0;
  scanf("%lld ", &N);
  scanf("%lld %lld",  &D, &X);
  
  for(i=0;i<N;i++){
    scanf("%d ", &A[i]);
    cnt = ((D-1) / A[i]) + 1; 
//    printf("%lld\n",  cnt);
    cnt_c = cnt_c + cnt ;
  }
 //printf("%lld %lld %lld %lld", A, B, C, D);
//  scanf("%lld", &M);
    
  printf("%lld\n",(cnt_c + X));
//     printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



    int n;
    cin >> n;

    vector<int> v(n);

    for(int i = 0; i < n; i++)
    {
      cin >> v[i];
    }    

    sort(all(v));

    int k = n/2 -1;

    cout << max(0LL,v[k+1]-(v[k]+1)+1);


    


    return 0; 
}


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

int main(void)
{
  int64_t n,k,q;
  cin >> n >> k >> q;
  vector<int64_t> a(q);
  for(int64_t i=0;i<q;i++){
    cin >> a.at(i);
  }

  vector<int64_t> win(n);
  for(int64_t i=0;i<n;i++){
    win.at(i)=0;
  }


  for(int64_t i=0;i<q;i++){
    win.at(a.at(i)-1) += 1;
  }

  for(int64_t i=0;i<n;i++){
    if(k-q+win.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

}



Measured memory_bytes: 2176
{$R-,S-,Q-,I-,O+}
var n,l,r,ans:longint;s:ansistring;
begin
  readln(n);
  readln(s);
  ans:=0;
  l:=1;
  r:=n;
  while l<r do begin
    while (l<=n) and (s[l]='R') do inc(l);
    while (1<=r) and (s[r]='W') do dec(r);
    if l>=r then break else
    begin
      inc(ans);
      inc(l);
      dec(r);
    end;
  end;
  writeln(ans);
end.

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    double N;
    cin >> N;
    double cnt = 0;
    for (int i = 1; i <= N; i++) {
        if(i % 2 == 1) {
            cnt++;
        }
    }
        // cout << cnt << endl;
        // cout << cnt / N << endl;
        printf("%.9lf", cnt / N);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
	char a;
	cin>>a;
	if(a=='A') cout<<'T';
	else if(a=='T') cout<<'A';
	else if(a=='C') cout<<'G';
	else if(a=='G') cout<<'C';
	return 0;
}

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

using namespace std;

const int MAXN = 1000;
string board[MAXN];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool visited[MAXN][MAXN];

int main()
{
    int h, w;
    cin >> h >> w;
    queue<tuple<int, int, int>> q;
    for (int i = 0; i < h; i++)
    {
        cin >> board[i];
        for (int j = 0; j < w; j++)
        {
            if (board[i][j] == '#')
            {
                visited[i][j] = true;
                q.push(make_tuple(i, j, 0));
            }
        }
    }
    int ans = 0;
    while (!q.empty())
    {
        tuple<int, int, int> tup = q.front();
        q.pop();
        ans = get<2>(tup);
        int r = get<0>(tup);
        int c = get<1>(tup);
        for (int i = 0; i < 4; i++)
        {
            int newr = r + dx[i];
            int newc = c + dy[i];
            if (newr < 0 || newr >= h || newc < 0 || newc >= w || visited[newr][newc])
                continue;
            q.push(make_tuple(newr, newc, get<2>(tup) + 1));
            visited[newr][newc] = true;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 14480
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<set>
#include<vector>
#include<bitset>
#include<map>
#define N 400005
#define ll long long
#define oo 1000000000000000
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,a[N],l,r,p[N];
int main(){
	n=read();For(i,1,n) a[i]=read();
	p[l=r=200000]=a[1];
	For(i,2,n){
		if(i&1) p[--l]=a[i];
		else p[++r]=a[i];
	}
	if(n&1) For(i,l,r) cout<<p[i]<<" ";
	else Rep(i,r,l) cout<<p[i]<<" ";
	return 0;
}

Measured memory_bytes: 3712
H1, M1, H2, M2, K = map(int, input().split())

if H1 > H2 or (H1 == H2 and M1 >= M2):
    H2 += 24
    
diff_min = H2*60 + M2 - (H1*60 + M1)
if diff_min - K < 0:
    print(0)
else:
    print(diff_min - K)

Measured memory_bytes: 9168
def g(x)
  x.even? ? ((x/2).even? ? 0 : 1)^x : (((x+1)/2).even? ? 0 : 1)
end

A, B = gets.split.map(&:to_i)

p g(B) ^ g(A-1)

# 0 ^ n = n
# n ^ n = 0
# g(n) = 0^1^...^n = f(0, n)

# g(n) = n     if n % 4 == 0
# g(n) = 1     if n % 4 == 1
# g(n) = n + 1 if n % 4 == 2
# g(n) = 0     if n % 4 == 3
# 証明は数学的帰納法かな

# f(a,b) = f(0, b) ^ f(0, a-1) = g(b) ^ g(a)

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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i<s.size(); i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }
    if(15-s.size()+cnt <= 7){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    int k, x; cin >> k >> x;

    for (int i = x-k+1; i < x+k; ++i) {
        cout << i << ' ';
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin>>x;
  if(x==1){
    cout<<1<<" "<<0<<endl;
    return 0;
  }
  for(int a=10000;a>=-10000;a--){
    for(int b=a-1;b>=-10000;b--){
      if((a-b)*(a*(a+b)*((a*a)+(b*b))+b*b*b*b)==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3620
import sys
N, K = map(int, input().split())
S = input()

o = []
z = []

i = 0
while True:
  cnt = 0
  while i <= N-1 and int(S[i]) == 1:
    cnt += 1
    i += 1
  o.append(cnt)
  if i > N-1:
    break
  cnt = 0
  while i <= N-1 and int(S[i]) == 0:
    cnt += 1
    i += 1
  z.append(cnt)
#print(o)
#print(z)

if len(z) <= K:
  print(len(S))
  sys.exit()

num = o[0]
for j in range(K):
  num += z[j]+o[j+1]

max_num = num
for j in range(K, len(z)):
  num -= o[j-K]+z[j-K]
  num += z[j]+o[j+1]
  max_num = max(max_num, num)

print(max_num)

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

int main(){

  long long n,k;
  cin >> n >> k;
  long long max,min,sum;
  max=0;min=0;sum=0;
  for(long long i=k;i<=n+1;i++){
  	min=(i-1)*i/2;
    max=(n+n-i+1)*i/2;
    //cout << min << " " << max << endl;
    min--;
    sum+=max-min;
  }
  cout << sum%(long)(pow(10,9)+7);
  return 0;
}

Measured memory_bytes: 3652
from scipy import optimize
import numpy as np

n=int(input())
points=[tuple(map(int,input().split())) for i in range(n)]

maxd=0
def d(xy):
    maxd=0
    x,y=xy
    for p in points:
        px,py=p
        d=np.linalg.norm((x-px,y-py))
        if maxd<d:
            maxd=d
    return maxd
opt=optimize.fmin(d,np.zeros(2),ftol=10**(-6),disp=0)
print(d(opt))

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int k;
string s,ans;

signed main() {
    cin >> s >> k;
    rep(i,s.size()) {
        if (s[i] == 'a') {
            ans.pb('a');
            continue;
        }
        int tmp = 'z' - s[i]+1;
        if (tmp <= k) {
            k -= tmp;
            ans.pb('a');
        } else ans.pb(s[i]);
    }
    if (k) {
        auto tmp = ans.back();
        ans.pop_back();
        tmp = (tmp-'a'+k)%('z'-'a'+1)+'a';
        ans.pb(tmp);
    }
    cout << ans << endl;
}




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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

string s;

int main(){
    ll ans = 0;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '+') ++ans;
        else
        {
            --ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
x1,y1,x2,y2 = inm()
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
c = []
for i in range(h):
    c.append(ins())
d = [[-1]*w for i in range(h)]
q = deque([(x1,y1)])
d[x1][y1] = 0
dir = [(0,1),(0,-1),(1,0),(-1,0)]
while len(q)>0:
    x,y = q.popleft()
    dd = d[x][y]+1
    for dx,dy in dir:
        for i in range(1,k+1):
            xx = x+i*dx
            yy = y+i*dy
            if xx<0 or h<=xx or yy<0 or w<=yy or \
               (d[xx][yy]>=0 and d[xx][yy]<dd) or c[xx][yy]=='@':
                break
            if d[xx][yy] == dd:
                continue
            d[xx][yy] = dd
            q.append((xx,yy))
            if xx==x2 and yy==y2:
                print(dd)
                exit()
print(-1)


Measured memory_bytes: 96748
#include<bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int N, l;
  	l = 0;
  	cin >> N;
  	for(int i = 0; i < 50; i++){
    	for(int j = 0; j < 50 && l == 0; j++){
        if(N == 4 * i + 7 * j){
        	l = 1;
        }
       }
    }
  if(l == 0)
  {cout << "No" << endl;}
  else{cout << "Yes" << endl;}
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int s[50]={},w,n,a,b,i;
    cin >> w;
    for(i=1;i<=w;i++){
        s[i] = i;
    }
    cin >> n;
    for(i=1;i<=n;i++){
        scanf("%d,%d",&a,&b);
        swap(s[a],s[b]);
    }
    for(int i=1;i<=w;i++){
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    int n,m;
    while(true){
        ll ans = 0;
        cin>>n>>m;
        if((n==0)&&(m==0))break;
        vector<int>h(n),w(m),h1,w1;
        for(int i=0;i<n;i++)cin>>h[i];
        for(int i=0;i<m;i++)cin>>w[i];
        for(int i = 0;i<n;i++){
            int sum = 0;
            for(int j = i;j<n;j++){
                sum+=h[j];
                h1.push_back(sum);
            }
        }
        for(int i = 0;i<m;i++){
            int sum = 0;
            for(int j = i;j<m;j++){
                sum+=w[j];
                w1.push_back(sum);
            }
        }
        int hsize = h1.size();
        int wsize = w1.size();
        if(hsize>=wsize){
            sort(h1.begin(),h1.end());
            for(int i=0;i<wsize;i++){
                auto itr1 = lower_bound(h1.begin(),h1.end(),w1[i]);
                auto itr2 = upper_bound(h1.begin(),h1.end(),w1[i]);
                ll index1 = itr1-h1.begin();
                ll index2 = itr2-h1.begin();
                ans += index2 - index1;
            }
        }
        else{
            sort(w1.begin(),w1.end());
            for(int i=0;i<hsize;i++){
                auto itr1 = lower_bound(w1.begin(),w1.end(),h1[i]);
                auto itr2 = upper_bound(w1.begin(),w1.end(),h1[i]);
                ll index1 = itr1-w1.begin();
                ll index2 = itr2-w1.begin();
                ans += index2 - index1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 19724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <iterator>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    
    if(a+b>=10){
        cout<<"error";
    }else{
        cout<<a+b;
    }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int gokei = 0;
    REP(i, n) {
        cin >> a[i];
        gokei += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    REP(i, m) {
        if(4 * m * a[i] < gokei) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

int main() {
  int num = 0;
  int tmp = 0;
  int cnt = 0;
  vector<tuple<int, int, bool>> tpl;
  
  cin >> num;
  
  vector<bool> vecT(num,true);

  for(int i = 0; i < num; i++){
    cin >> tmp;
    tpl.emplace_back(i,tmp-1,true);
  }
  
  bool chk = true;
  int index = 0;
  while(chk == true){
    if(get<0>(tpl[index])+1 == 2){
      cout << cnt;
      break;
    }

    if(vecT.at(index) == false){
      chk = false;
      continue;
    }
    
    vecT.at(index) = false;
    index = get<1>(tpl[index]);
    cnt++;
  }
  
  if(chk == false) cout << -1;
}


Measured memory_bytes: 1912
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

bool compare_y_greater(vector<int> a, vector<int> b) {
    return a.at(1) >= b.at(1);
}

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(2));
    for (int i = 0; i < n; i++) cin >> a.at(i).at(0) >> a.at(i).at(1);
    vector<vector<int>> b(n, vector<int>(2));
    for (int i = 0; i < n; i++) cin >> b.at(i).at(0) >> b.at(i).at(1);
    
    sort(a.begin(), a.end(), compare_y_greater);
    sort(b.begin(), b.end());
    
    int ans = 0;
    vector<bool> a_checked(n, 0);
    for (int i = 0; i < n; i++) {
        int x = b.at(i).at(0), y = b.at(i).at(1);
        for (int j = 0; j < n; j++) {
            if (!a_checked.at(j) && a.at(j).at(0) < x && a.at(j).at(1) < y) {
                a_checked.at(j) = 1;
                ans++;
                break;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A < B) swap(A, B);
    if(B < C) swap(B, C);
    if(A < B) swap(A, B);
    cout << A*10+B+C << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[1000001];
int n,q,x;
Vi v;
ll query()
{
	int l=0,r=0;
	int M=0,C=0;
	ll cnt=0,res=0;
	for(int i:v)
	{
		while(r<n && r-i<x)
		{
			if(s[r]=='M')M++;
			if(s[r]=='C')cnt+=M,C++;
			r++;
		}
		while(l<i)
		{
			if(s[l]=='M')M--,cnt-=C;
			if(s[l]=='C')C--;
			l++;
		}
		res+=cnt;
	}
	return res;
}
int main() {
	scanf("%d%s%d",&n,s,&q);
	fup(i,0,n-1,1)if(s[i]=='D')v.pb(i);
	while(q--)
	{
		scanf("%d",&x);
		printf("%lld\n",query());
	}
}

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

ans = 1
for x in range(1, 10 ** 5 + 10):
    if M % x == 0:
        if N * x <= M:
            ans = max(ans, x)
        if N * (M // x) <= M:
            ans = max(ans, M // x)

print(ans)


Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())

AB_flag = C * 2 <= A + B

total = 0
if AB_flag:
  if X >= Y:
    total = C * 2 * Y
    if C * 2 >= A:
      total += (X - Y) * A
    else:
      total += (X - Y) * C * 2
  else:
    total =  C*2 * X
    if C * 2 >= B:
      total += (Y - X) * B
    else:
      total += (Y - X) * C * 2
else:
  total = A * X + B * Y

print(total)

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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	int N,X=0; cin >> N;
	vector<int> L(N);
	rep(i, N) { 
		cin >> L[i]; 
		X = max(X, L[i]);
	}

	int sum =0;
	rep(i,N) {
		sum += L[i];
	}
	if (X<sum-X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100020];
int f[100020];
signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	reverse(a,a+n);
	memset(f,0x3f,sizeof f);
	for(int i=0;i<n;i++){
		int p=upper_bound(f,f+n,a[i])-f;
		f[p]=a[i];
	}
	int ans2=upper_bound(f,f+n,0x3f3f3f3f)-f;
	cout<<ans2<<endl; 
}

Measured memory_bytes: 1792
L, R = gets.split.map(&:to_i)
min = 2019
find_zero = false
L.step(R-1) do |i|
  (i+1).step(R) do |j|
    min = [min, i*j%2019].min
    find_zero = true if min == 0
    break if find_zero
  end
  break if find_zero
end
puts min


Measured memory_bytes: 1788
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

bool judge(string &s,string &A){
    if(s.size()<A.size()){return false;}
    for(int i=0;i<A.size();i++){
        if(s[s.size()-A.size()+i]!=A[i]){return false;}
    }
    return true;
}

int main(){
    string s;
    cin>>s;
    vector<string> A={"dream","dreamer","erase","eraser"};
    while(!s.empty()){
        bool j=false;
        for(int i=0;i<4;i++){
            if(judge(s,A[i])){
                j=true;
                for(auto &I:A[i]){s.pop_back();}
                break;
            }
        }
        if(j){continue;}
        break;
    }
    cout<<(s.empty()?"YES":"NO")<<endl;
    
    return 0;
}


Measured memory_bytes: 512
/*
 * src.cpp
 *
 *  Created on: 2016/08/09
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=250,MAX_MAX=250;

int MAX,N,D[MAX_N+MAX_MAX+8];

bool flg[2][MAX_N+2];

vector<int> G[2][MAX_N+2];

void bfs(){
	REP(r,2){
		REP(i,N+2){
			flg[r][i]=false;
		}
		int s= !r ? 0 : N+1;
		flg[r][s]=true;
		queue<int> q;
		q.push(s);
		while (!q.empty()){
			int v=q.front();
			q.pop();
			REP(i,(int)G[r][v].size()){
				int to=G[r][v][i];
				if (!flg[r][to]){
					flg[r][to]=true;
					q.push(to);
				}
			}
		}
	}
}

int main(){
	do{
		cin>>MAX;
		if (MAX){
			cin>>N;
			memset(D,0,sizeof(D));
			FOR(i,1,N+1){
				cin>>D[i];
			}
			REP(i,2) REP(j,N+2) G[i][j].clear();
			REP(i,N+1){
				FOR(j,1,MAX+1){
					int to=i+j+D[i+j];
					to=max(to,0);
					to=min(to,N+1);
					G[0][i].push_back(to);
					G[1][to].push_back(i);
				}
			}
			bfs();
			bool f=true;
			REP(i,N+2){
				if (flg[0][i] && !flg[1][i]){
					f=false;
					break;
				}
			}
			if (f){
				cout<<"OK"<<endl;
			}else{
				cout<<"NG"<<endl;
			}
		}
	}while(MAX);
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
//ABC0120A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min(c,b/a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

static const int SIZE = 100;

void trace(int A[], int N)
{
    for(int i = 0; i < N; i++)
    {
        if ( i > 0)
        {
            cout << ' ';
        }
        cout << A[i];
    }
    cout << '\n';
}

void insertionSort(int A[], int N)
{
    int v, j;
    for(int i = 1; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}
int main()
{
    int N;
    int A[SIZE];
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    trace(A, N);
    insertionSort(A, N);
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>

int main() {
	using namespace std;
	int a,b,c;
	cin >> a >> b >> c;
	if ( a <= b && b<= c ) {
		cout << a << " " << b << " " << c << endl;
	} else if ( a <= c && c <= b ) {
		cout << a << " " << c << " " << b << endl;
	} else if ( b <= a && a <= c ) {
		cout << b << " " << a << " " << c << endl;
	} else if ( b <= c && c <= a ) {
		cout << b << " " << c << " " << a << endl;
	} else if ( c <= a && a <= b ) {
		cout << c << " " << a << " " << b << endl;
	} else {
		cout << c << " " << b << " " << a << endl;
	}
}

Measured memory_bytes: 1164
def counting_sort(A, B, k):
    n = len(A)
    B = [0] * n

    C = [0] * (k+1)

    # カウント
    for a in A:
        # print(a)
        C[a] += 1
    # print(*C)
    # print('just done')

    # 累積カウント
    for i in range(1, k+1):
        C[i] += C[i-1]

    # print(*C)

    # Bに移植
    for i in range(n-1, -1, -1):
        index_to_insert = C[A[i]] - 1
        C[A[i]] -= 1
        B[index_to_insert] = A[i]
        # print(*C)

    return B

_ = int(input())
A = list(map(int, input().split()))

B = []
B = counting_sort(A, B, 10000)
print(*B)


Measured memory_bytes: 224504
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n ;
  cin >> n ;
  vector<int> dif(n) ;
  REP(i,n){
    cin >> dif.at(i) ;
  }
  sort(ALL(dif)) ;
  
  cout<< dif.at(n/2)-dif.at(n/2-1) <<endl ;

  return 0 ;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;

    Vec a(60000,-1);
    rep(i,50001){
        a[i*1.08] = i;
    }

    if(a[n]==-1){
        cout<<":("<<endl;
    }else{
        cout<<a[n]<<endl;
    }
    return  0;
}


Measured memory_bytes: 768
N, A, B = map(int, input().split())
S = input()

passed = 0
foreigners = 0

for i in range(N):
    # 国内学生
    if S[i] == "a":
        if passed < (A + B):
            passed += 1
            print("Yes")
        else:
            print("No")

    # 海外学生
    if S[i] == "b":
        foreigners += 1
        if passed < (A + B) and foreigners <= B:
            passed += 1
            print("Yes")
        else:
            print("No")

    if S[i] == "c":
        print("No")


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

int main()
{
int K,S;scanf("%d %d",&K,&S);int ans=0;
for(int X=0;X<K+1;X++)for(int Y=0;Y<K+1;Y++)if(S-X-Y<K+1&&S-X-Y>-1)ans++;
printf("%d\n",ans);
}

Measured memory_bytes: 3804