akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

const int MAX_V = 1000;
const int MAX_E = 2000;

struct edge{ll from,to,cost;};
edge es[MAX_E];

ll d[MAX_V];
int V,E;

bool shortest_path(int s){
	REP(i,V) d[i]=INFL;

	d[s]=0;
	REP(i,V){
		REP(j,E){
			edge e=es[j];
			if(d[e.from]!=INFL &&d[e.to]>d[e.from]+e.cost){ //始点から到達できるもののみ更新
				d[e.to]=d[e.from]+e.cost;
				if(i==V-1&&e.to==V-1) return false; //終点が決まっている場合
			}
		}
	}
	return true;
}
int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int from,to,cost;
	cin>>V>>E;
	REP(i,E){
		cin>>from>>to>>cost;
		es[i].from=from-1;
		es[i].to=to-1;
		es[i].cost=-cost;
	}
	if(!shortest_path(0)) print("inf");
	else print(-d[V-1]);
	
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int ans = 0;
        for(int i=0;i<N;i++){
            int cur = in.nextInt();
            while(cur%2==0){
                ans++;
                cur = cur/2;
            }
        }
        System.out.println(ans);

    }
}

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

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 2e9 + 1;
    for(int i=-1; i<=1; i+=2){
        for(int j=-1; j<=1; j+=2){
            int a = A*i;
            int b = B*j;
            int tmp = 0;
            if(i<0) tmp++;
            if(j<0) tmp++;

            if(b < a) continue;
            ans = min(ans, tmp + b - a);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<int>l(n);
  int i;
  for(i=0;i<n;i++){
    cin >> l[i];
  }
  int minMP = 1<<30;
  for(int bit = 0;bit < (1<<(2*n));bit++){
    int alen = 0;
    int blen = 0;
    int clen = 0;
    int tmp = bit;
    int cnt = 0;
    int tmpMP = -30;
    vector<bool>chk(3,false); // 0:a, 1:b, 2:c
    while(tmp>0){
      switch (tmp%4) {
        case 0:
          break;
        case 1:
          chk[0] = true;
          tmpMP += 10;
          alen += l[cnt];
          break;
        case 2:
          chk[1] = true;
          tmpMP += 10;
          blen += l[cnt];
          break;
        case 3:
          chk[2] = true;
          tmpMP += 10;
          clen += l[cnt];
          break;
        default:
          break;
      }
      cnt++;
      tmp/=4;
    }
    if(chk[0] && chk[1] && chk[2]){
      tmpMP += abs(a-alen);
      tmpMP += abs(b-blen);
      tmpMP += abs(c-clen);
      if(tmpMP<minMP)minMP = tmpMP;
    }
  }
  cout << minMP << endl;
}


Measured memory_bytes: 256
MOD = int(1e9+7)
N = int(input())
S1 = input()
S2 = input()
now = 0
ans = 1
flag = False
for i in range(N):
    if flag:
        flag = False
        continue
    s11 = S1[i]
    s21 = S2[i]
    if s11 == s21:
        ans = (ans * (3 - now)) % MOD
        now = 1
    else:
        flag = True
        if now == 0:
            ans = (ans * 6) % MOD
        elif now == 1:
            ans = (ans * 2) % MOD
        else:
            ans = (ans * 3) % MOD
        now = 2
print(ans)

Measured memory_bytes: 3064
class SegmentTree:
	def __init__(self, orig, func, unit):
		_len = len(orig)
		self.func = func
		self.size = 1 << (_len - 1).bit_length()
		self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
		self.unit = unit

		for i in range(self.size - 1, 0, -1):
			self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

	def update(self, i, v):
		i += self.size
		self.tree[i] = v
		while i:
			i //= 2
			self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def find(self, l, r):
		l += self.size
		r += self.size
		ret = self.unit
		while l < r:
			if l & 1:
				ret = self.func(ret, self.tree[l])
				l += 1
			if r & 1:
				r -= 1
				ret = self.func(ret, self.tree[r])
			l //= 2
			r //= 2
		return ret

import sys
input=sys.stdin.readline
from operator import or_

n=int(input())
s=input()
li=[1<<ord(x)-97 for x in s[:-1]]
seg=SegmentTree(li,or_,0)
ans=[]
for _ in range(int(input())):
	f,x,y=input().split()
	if f=="1":
		x=int(x)
		seg.update(x-1,1<<ord(y)-97)
	else:
		x=int(x)
		y=int(y)
		z=seg.find(x-1,y)
		cnt=0
		for i in range(26):
			if z & (1<<i):
				cnt+=1
		ans.append(cnt)
print(*ans)

Measured memory_bytes: 48672
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int prev = 0;
        int longest = 0;
        for(int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            longest += Math.abs(array[i] - prev);
            prev = array[i];
        }
        longest += Math.abs(prev);
        int prevPosition = 0;
        int currentPosition = 0;
        int nextPosition = 0;
        for(int i = 0; i < n; i++) {
            if(i == n-1) {
                nextPosition = 0;
            } else {
                nextPosition = array[i+1];
            }
            currentPosition = array[i];
            if((prevPosition <= currentPosition && currentPosition <= nextPosition) ||
                    (prevPosition >= currentPosition && currentPosition >= nextPosition)) {
                System.out.println(longest);
            } else {
                int midPosition = prevPosition;
                if((currentPosition <= nextPosition && nextPosition <= prevPosition) ||
                        (prevPosition <= nextPosition && nextPosition <= currentPosition)) midPosition = nextPosition;
                System.out.println(longest - (Math.abs(currentPosition - midPosition) * 2));
            }
            prevPosition = array[i];
        }
    }
}

Measured memory_bytes: 78996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll> a(N);
    bool flag = 0;
    rep(i,N){
        cin >> a[i];
    }
    ll pcnt;
    rep(i,N){
        ll cnt = 0;
        
        ll  now =a[i];
        
        while((now%2)==0){
            cnt++;
            now /=2;
        }
        if(cnt != pcnt && i != 0){
            flag = 1;
            break;
        }
        pcnt = cnt;
    }
    ll ans;
    if(flag == 0){
        ll LCM;
        if(N==1){
            LCM = a[0]/2;
        }else{
            LCM = lcm(a[0]/2,a[1]/2);
        }
        for(ll i = 2; i<N;i++){
            LCM = lcm(LCM,a[i]/2);
        }
        
     
            ans = (M/LCM+1)/2;

    }else{
        ans = 0;
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4056
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

base = 1
v = k
while v / 2 > 0 do
  v /= 2
  base *= 2
end

r = 0
while base > 0
  c = as.count { |a| (a / base) % 2 != 0 }
  # ['test base', base].tapp
  if c <= n / 2
    # ['base ok', base].tapp
    if r + base <= k
      # ['sum ok', base, r].tapp
      r += base
    end
  end

  base /= 2
end

# as.map { |a| a.to_s(2) }.tapp
# r.tapp

sum = as.map { |a| a ^ r }.reduce { |m, i| m + i }
puts(sum)

Measured memory_bytes: 11660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int mod = 1000000007;

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++){
        cin >> a[i];
    }
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j]=='#') continue;
            for(int dxy = 0; dxy < 2; dxy++){
                int nx = i+dx[dxy], ny = j+dy[dxy];
                if(nx>=h||ny>=w) continue;
                if(a[nx][ny] == '#')continue;
                (dp[nx][ny] += dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0; 
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int dp[105][2][4];

int main() {
    string S;
    int K;
    cin >> S >> K;
    int L = S.size();

    dp[0][0][0] = 1;
    for (int i = 0; i < L; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= K; k++) {
                int D = S[i] - '0';
                for (int d = 0; d <= 9; d++) {
                    int ni = i + 1, nj = j, nk = k;

                    // jを決定
                    if (j == 0) {
                        if (d < D) nj = 1;
                        if (d > D) break;
                    } else {
                        nj = 1;
                    }

                    if (d != 0) nk++;
                    if (nk > K) continue;
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[L][0][K] + dp[L][1][K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL k;
	cin >> k;
	int n = 50;
	LL l = 0, r = LL(1e16) + 1000;
	LL key = 0;
	LL ret = 0;;
	while (l <= r)
	{
		LL mid = (l + r) / 2;
		LL tot = (mid + k - (n - 1) + n) / (n + 1) * n;
		tot = max(0LL, tot);
		if (tot <= k) key = mid, ret = tot, l = mid + 1;
		else r = mid - 1;
	}
	for (int i = 1; i <= n; i++) a[i] = key;
	for (int i = 1; ret + i - 1 < k; i++) a[i] += k - ret + 1;
	puts("50");
	for (int i = 1; i <= n; i++) printf("%lld%c", a[i], " \n"[i == n]);
	return 0;
}

Measured memory_bytes: 256
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

x,y,z = ips()


print(z,x,y)

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

typedef long long ll;

struct V {
	double x, y;
	V(double x = 0, double y = 0): x(x), y(y) {}
	
	void operator+=(const V& v) {
		x += v.x; y += v.y;
	}
	
	V operator+(const V& v) const {
		return V(x + v.x, y + v.y);
	}
	
	double dot(const V& v) const {
		return x * v.x + y * v.y;
	}
	
	double cross(const V& v) const {
		return x * v.y - y * v.x;
	}
	
	double norm2() const {
		return x * x + y * y;
	}
	
	double norm() const {
		return sqrt(norm2());
	}
	
	int ort() const {
		if (y >= 0) return x >= 0 ? 1 : 2;
		else return x >= 0 ? 4 : 3;
	}
	
	bool operator<(const V& v) const {
		if (ort() != v.ort()) return ort() < v.ort();
		return cross(v) > 0;
	}
};

int main() {
	int N;
	cin >> N;
	
	vector<V> A;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		A.emplace_back(x, y);
	}
	
	sort(A.begin(), A.end());
	
	double ans = 0;
	for (int i = 0; i < N; ++i) {
		V now;
		for (int j = 0; j < N; ++j) {
		    int index = (i + j) % N;
		    now += A[index];
		    ans = max(ans, now.norm());
		}
	}
	
	printf("%.12f\n", ans);
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


int main()
{
    int N, A;
    cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String str = sc.next();
        int num = Integer.parseInt(str);
        if ((num % S(str)) == 0) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    static int S(String str) {
        int result = 0;
        for (int ct = 0; ct < str.length(); ct++) {
            result += Integer.parseInt(str.charAt(ct) + "");
        }
        return result;
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>

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

using namespace std;

const int INF = 10000;

int main()
{
	
	for (int i = 0; i < 100; i++) {
		int a, b;
		char op;

		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-')
		{
			cout << a - b << endl;
		}
		else if (op == '*')
		{
			cout << a * b << endl;
		}
		else if (op == '/')
		{
			cout << a / b << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3100
def floor_sum(n,m,a,b):
    ans = n*(b//m)
    b %= m
    while True:
        ans += (n-1)*n*(a//m)//2
        a %= m
        if a*n+b < m:
            return ans
        y_max = (a*n + b)//m
        b -= y_max*m #now we have x_max = -(b//a)
        ans += (n + b//a)*y_max
        n = y_max
        b %= a
        m,a = a,m

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read

T = int(readline())
for _ in range(T):
    n,m,a,b = map(int,readline().split())
    print(floor_sum(n,m,a,b))


Measured memory_bytes: 70116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        while (n >= k) {
            n = n / k;
            ans++;
        }
        ans++;
        System.out.println(ans);
    }
}

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

// as + bt = GCD(a,b) a,b:const s,t:var(any)
// return GCD(a,b)
long long extGCD(long long a, long long b, long long& s,
                 long long& t) {
  s = 1, t = 0;
  long long u = 0, v = 1;
  while(b) {
    long long tmp = a / b;
    a -= b * tmp;
    s -= u * tmp;
    t -= v * tmp;
    swap(s, u);
    swap(t, v);
    swap(a, b);
  }
  return a;
}

// (mod)x+ay=1, calculate y -> a^-1 (mod m) (a,m : coprime)
long long calcinv(long long a, long long m) {
  long long s, t;
  extGCD(a, m, s, t);
  return (s + m) % m;
}

// P(x_i) = y_i(i:[0,n])
//  calc c_i : P(x) = c_n x^n + c_(n-1) x^(n-1)...c_0
vector<long long> lagrange_interpolation(
    long long mod, vector<long long>& y,
    vector<long long>& x) {
  assert(y.size() == x.size());
  long long n = y.size();
  vector<long long> ans(n, 0), Q(n), c[2];
  for(int i = 0; i < 2; ++i) c[i] = vector<long long>(n, 0);
  c[0][0] = 1;
  for(int i = 0; i < n; ++i) {
    long long inv = 1;
    for(int j = 0; j < n; ++j)
      if(j != i) {
        inv *= x[i] - x[j];
        if((inv %= mod) < 0) inv += mod;
      }
    Q[i] = y[i] * calcinv(inv, mod) % mod;
    for(int j = 0; j < n; ++j) {
      c[(i + 1) % 2][j] =
          (c[i % 2][j] * (-x[i]) % mod + mod) % mod;
      if(j != 0)
        (c[(i + 1) % 2][j] += c[i % 2][j - 1]) %= mod;
    }
  }
  for(int i = 0; i < n; ++i) {
    for(int j = n - 1; j >= 0; --j) {
      if(j == n - 1)
        c[(n + 1) % 2][j] = 1;
      else
        c[(n + 1) % 2][j] =
            (c[n % 2][j + 1] +
             c[(n + 1) % 2][j + 1] * x[i] % mod) %
            mod;
      (ans[j] += (c[(n + 1) % 2][j] * Q[i]) % mod) %= mod;
    }
  }
  return ans;
}

long long MOD;
vector<long long> ans;

int main() {
  cin >> MOD;
  vector<long long> a(MOD), b(MOD);
  for(int i = 0; i < MOD; ++i) cin >> a[i];
  for(int i = 0; i < MOD; ++i) b[i] = i;
  ans = lagrange_interpolation(MOD, a, b);
  for(int i = 0; i < MOD; ++i) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
string x,v[]={"dream","dreamer","erase","eraser"};
bool b=0;
void find2(int k){
    if(k==x.size())b=1;
    for(int i=0;i<4;i++){
        if(x.substr(k,v[i].size())==v[i]){
            find2(k+v[i].size());
        }
    }
}
int main(){

    cin>>x;
    find2(0);
    if(b)cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 2048
n = int(input())
ss = list(map(int, input().split()))

cnt = 0
ans = 0

for i, s in enumerate(ss):
    cnt += 1
    if i+1 < n and ss[i] != ss[i+1]:
        ans += cnt // 2
        cnt = 0

if cnt:
    ans += cnt // 2

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
using namespace std;

int main()
{
	
	
	int a,b,h;
	cin>>a>>b>>h;
	
	int area;
	if(h%2==0)
	area=(a+b)*h/2;

	
	cout<<area<<endl;
	
	return 0;
}

Measured memory_bytes: 3568
import sys,math,collections,itertools
input = sys.stdin.readline

N,A,B,C=list(map(int,input().split()))
l = [ int(input()) for _ in range(N)]

use_list = list(itertools.product(range(4),repeat = N))
point = float('inf')

for i in range(len(use_list)):
    ABC = [0]*3
    count = [0]*3
    if (0 not in use_list[i]) or(1 not in use_list[i]) or (2 not in use_list[i]):
        continue
    for j in range(len(use_list[i])):
        if use_list[i][j] != 3:
            ABC[use_list[i][j]] += l[j]
            count[use_list[i][j]] += 1
    p = (sum(count)-len(count))*10+abs(ABC[0]-A)+abs(ABC[1]-B)+abs(ABC[2]-C)
    point = min(point,p)   
print(point)


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

using namespace std;

double prob[305][305][305];
double expected[305][305][305];

int main()
{
    int n;
    int a, ones, twos, threes;

    cin >> n;

    ones = twos = threes = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a;

        if (a == 1)
            ones++;
        if (a == 2)
            twos++;
        if (a == 3)
            threes++;
    }

    prob[ones][twos][threes] = 1.0;

    for (int k = n; k >= 0; k--)
    {
        for (int j = n; j >= 0; j--)
        {
            for (int i = n; i >= 0; i--)
            {
                if (i == 0 && j == 0 && k == 0)
                    continue;

                if (i + j + k > n)
                    continue;

                double p1 = 1.0 * i / (i+j+k);
                double p2 = 1.0 * j / (i+j+k);
                double p3 = 1.0 * k / (i+j+k);
                
                double p0 = 1.0 * (n - (i+j+k)) / n;
                double e = 1.0 + (p0 / (1 - p0));

                expected[i][j][k] += e * prob[i][j][k];

                if (i > 0)
                {
                    prob[i-1][j][k] += p1*prob[i][j][k];
                    expected[i-1][j][k] += p1*expected[i][j][k];
                }
                if (j > 0)
                {
                    prob[i+1][j-1][k] += p2*prob[i][j][k];
                    expected[i+1][j-1][k] += p2*expected[i][j][k];
                }
                if (k > 0)
                {
                    prob[i][j+1][k-1] += p3*prob[i][j][k];
                    expected[i][j+1][k-1] += p3*expected[i][j][k];
                }
            }
        }
    }

    cout << fixed << setprecision(12) << expected[0][0][0] << "\n";


    return 0;
}

Measured memory_bytes: 438528
# 尺取り
S = input()
start = 0
ans = 0

while start < len(S):
    while start < len(S) and S[start] not in "ACGT":
        start += 1
    end = start
    while end < len(S) and S[end] in "ACGT":
        end += 1
    ans = max(ans, end - start)
    start = end

print(ans)


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

static int cnt = 0;

void trace(int a[], int n) {
	int i;

	for (i = 1; i <= n; i++) {
		if (i > 1) {
			printf(" ");
		}
		printf("%d", a[i]);
	}
	printf("\n%d\n", cnt);

}

int main(void) {
	int *a, i, j, n, temp;

	scanf("%d", &n);
	a = (int *) malloc(sizeof(int) * (n + 1));

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

	for (i = 1; i < n; i++) {
		for (j = n; j > i; j--) {
			if (a[j] < a[j - 1]) {
				temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				cnt++;
			}
		}
	}

	trace(a, n);

	return 0;
}

Measured memory_bytes: 604
s = input().strip()
n = len(s)

ansone, anszero = n, n
for i, c in enumerate(s):
    ld, rd = i, n - i - 1
    if c == '1':
        ansone = min(ansone, max(ld, rd))
    else:
        anszero = min(anszero, max(ld, rd))
print(max(ansone, anszero))


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

#define iin(x) scanf("%d", &x)
#define lin(x) scanf("%lld", &x)
#define fin(x) scanf("%lf", &x)

#define iout(x) printf("%d", x)
#define lout(x) printf("%d", x)
#define fout(x) printf("%.10f", x)
#define _ putchar(' ')
#define endl puts("")

#define reps(i, x, n) for(i = (x); i < (n); i++)
#define rep(i, n) reps(i, 0, n)

int cnt = 0;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[500001], R[500001];
  int i, j, k;
  rep(i, n1) L[i] = A[left+i];
  rep(i, n2) R[i] = A[mid+i];
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  i = 0, j = 0;
  reps(k, left, right) {
    cnt++;
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if(left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n; iin(n);
  int A[500001];
  int i;
  rep(i, n) iin(A[i]);
  mergeSort(A, 0, n);
  rep(i, n) {
    if(i) _;
    iout(A[i]);
  }
  endl;
  iout(cnt),endl;
  return 0;
}

Measured memory_bytes: 5596
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	k := nextInt()
	puts(a[k-1])
}


Measured memory_bytes: 1780
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn gcd(m: usize, n: usize) -> usize {
    if m < n {
        gcd(n, m)
    } else {
        if n == 0 {
            m
        } else {
            gcd(n, m % n)
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let k: usize = sc.input();

    let mut ans: usize = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(a, gcd(b, c));
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<numeric>
int main()
{
	int N,T,L,B,i,j,k,x;
	while(scanf("%d%d%d%d",&N,&T,&L,&B),N)
	{
		double a[102][101]={1};
		bool b[101]={0},l[101]={0};
		for(i=0;i<L;++i)scanf("%d",&x),l[x]=1;
		for(i=0;i<B;++i)scanf("%d",&x),b[x]=1;
		for(i=1;i<=T;++i)
		{
			a[i][N]+=a[i-1][N]*6;
			for(j=0;j<N;++j)
			{
				for(k=1;k<7;++k)
				{
					if(j+k>N)x=2*N-(j+k);		else x=j+k;
					if(l[x]) a[i+1][x]+=6*a[i-1][j];else if(b[x])a[i][0]+=a[i-1][j];else a[i][x]+=a[i-1][j];}
			}
		}
		for(i=0;i<=N;++i)a[T+1][i]=a[T+1][i]/6+a[T][i];
		if(a[T+1][N])
			printf("%f\n",a[T+1][N]/std::accumulate(a[T+1],a[T+1]+N+1,0.));
		else puts("0.000000");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5,M=1e9+7;
int fac[N],inv[N];
int n,m,t,ns,os,p[30],k[30],pk[30][30],b[30],c[30],sz,an;
map<int,int> op,nw;
int C(int x,int y) {
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%M*inv[x-y]%M;
}
void init1() {
	fac[0]=inv[0]=fac[1]=inv[1]=1;
	for (int i=2;i<N;++i) fac[i]=1ll*fac[i-1]*i%M;
	for (int i=2;i<N;++i) inv[i]=1ll*inv[M%i]*(M-M/i)%M;
	for (int i=2;i<N;++i) inv[i]=1ll*inv[i-1]*inv[i]%M;
}
void init2() {
	int d=m;
	for (int i=2;i*i<=d;++i) {
		if (d%i==0) {
			p[++sz]=i;
			while (d%i==0) d/=i,++k[sz];
		}
	}
	if (d>1) p[++sz]=d,k[sz]=1;
	for (int i=1;i<=sz;++i) {
		pk[i][0]=1;
		for (int j=1;j<=k[i];++j) {
			pk[i][j]=pk[i][j-1]*p[i];
		}
	}
}
void dfs2(int u) {
	if (u==sz+1) {
		os=1;
		for (int i=1;i<=sz;++i) os*=pk[i][b[i]+c[i]];
		if (os>ns) (nw[ns]+=op[os])%=M;
		return;
	}
	for (int i=0;b[u]+i<=k[u];++i) c[u]=i,dfs2(u+1);
}
void dfs1(int u) {
	if (u==sz+1) {
		ns=1;
		for (int i=1;i<=sz;++i) ns*=pk[i][b[i]];
		dfs2(1);
		if (ns==1) (an=1ll*nw[ns]*C(n,t)+an)%=M;
		return;
	}
	for (int i=0;i<=k[u];++i) b[u]=i,dfs1(u+1);
}
 main() {
	scanf("%lld%lld",&n,&m);
	if (m==1) return puts("1"),0;
	init1();
	init2();
	op[m]=1;
	for (t=1;t<=n&&t<=30;++t) {
		dfs1(1);
		swap(nw,op);
		nw.clear();
	}
	printf("%lld\n",an);
}

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    LLONG N; cin >> N;
    vector<LLONG> sums{ 0 };
    LLONG sum = 0;
    LLONG dig = 26;
    int len = 0;
    for (;;)
    {
        sum += dig;
        sums.push_back(sum);
        dig *= 26;
        ++len;
        if (N <= sum)
        {
            break;
        }
    }
    N = N - sums[len - 1] - 1;
    string ans = "";
    for (int i = 0; i < len; ++i)
    {
        ans += 'a' + N % 26;
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[1101];
int l[1111];
int j[1];

long long x,y,z,mod=998244353;
//string r;
char r[1];

P u[1111];
queue<int> q;
stack<P> s;
vector<int> v[1111];

bool as(P a,P b)
{
  return a.x<b.x;
}

int ccw(P a,P b)
{
  return a.x*b.y-a.y*b.x;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    scanf("%d %d",&n,&m);
    u[t]={n,m};
  }
  o[0]=1;
  for(int t=1;t<=333;t++)
  o[t]=o[t-1]*2%mod;
  x=(o[a]-a-1+mod)%mod;
  for(int t=1;t<a;t++)
    for(int w=t+1;w<=a;w++)
    {
      int k=0;
      for(int h=w+1;h<=a;h++)
        if(ccw({u[t].x-u[h].x,u[t].y-u[h].y},{u[t].x-u[w].x,u[t].y-u[w].y})==0) k++;
      x-=(o[k]+mod)%mod;
      x=(x+mod)%mod;
      //printf("%lld\n",x);
    }
  printf("%lld",x);
}
//3




Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b=gsmi
s=gs
puts_yesno !s.scan(/\A[0-9]{#{a}}-[0-9]{#{b}}\Z/).empty?

Measured memory_bytes: 1788
n,k=map(int,input().split())
a=list(map(int,input().split()))
S=set(a)
dic={i:0 for i in S}
for i in a:
    dic[i]+=1
cnt=0
l=sorted(dic.values())
if len(l)>k:cnt+=sum(l[:len(l)-k])
print(cnt)


Measured memory_bytes: 44984
#include <stdio.h>

#define maxN 100

void bubble(int N,int A[]){
	int c,tmp,swc=0;
	int flag = 1;
	while(flag){
		flag = 0;
		for(c=N-1;c>=1;c--){
			if(A[c]<A[c-1]){
				tmp = A[c];
				A[c] = A[c-1];
				A[c-1] = tmp;
				swc++;
				flag = 1;
			}
		}
	}
	for(c=0;c<N;c++){
		printf("%d",A[c]);
		if(c < N-1){
			printf(" ");
		}
	}
	printf("\n%d\n",swc);
}

int main(void){
	int c,n,a[maxN];
	scanf("%d",&n);
	for(c=0;c<n;c++){
		scanf("%d",&a[c]);
	}
	bubble(n,a);
}


Measured memory_bytes: 2048
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a[21],b[21],c[21],ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;++i)
	{
		cin>>b[i];
	}
	for(int i=2;i<=n;++i)
	{
		cin>>c[i];
	}
	for(int i=1;i<=n;++i)
	{
		ans+=b[a[i]];
		if(a[i-1]+1==a[i])
		{
			ans+=c[a[i]];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val imos = IntArray(n+2){ 0 }
    repeat(m) {
        val (l,r) = readLine()!!.split(" ").map { it.toInt() }
        imos[l]++
        imos[r+1]--
    }
    val ans = imos.toList().summed().count{it==m}
    println(ans)
}

inline fun List<Int>.summed() = { var sum = 0; this.map { sum += it; sum } }()


Measured memory_bytes: 56012
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<100||n>999)   return 0;
	else
    {
        int a=n/100;
	    int b=(n-a*100)/10;
	    int c=n-a*100-b*10;
	    if(a==7||b==7||c==7)  printf("Yes");
	    if(a!=7&&b!=7&&c!=7) printf("No");
	}
    return 0;
}




Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    vs a;
    a.pb("Sunny");
    a.pb("Cloudy");
    a.pb("Rainy");
    ll in=find(a.begin(),a.end(),s)-a.begin();
    cout<<a[(in+1)%3]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int x,a;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x>>a;
    if(x<a)cout<<0<<newl;
    else cout<<10<<newl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int k = reader.nextInt();
        long t = 0;
        long ans = 0;
        if (k % 2 == 0) {
            t = n / k;
            ans += (t * t * t);
            t = ((n*2) / k +1)/2;
            ans += (t * t * t);
        } else {
            t = n / k;
            ans += (t * t * t);
        }

        System.out.println(ans);

    }
}


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

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	int x=a[n-1]/2,m=a[n-1];
	auto num=lower_bound(a.begin(),a.end(),x);
	int y=*num,z=*(num-1);
	if(z==0){
		cout<<m<<" "<<0<<endl;
		return 0;
	}
	int b=abs(x-y),c=abs(x-z);
	if(b==c){
		if(m-y<m-z)cout<<m<<" "<<y<<" "<<endl;
		else cout<<m<<" "<<z<<" "<<endl;
	}
	else if(b<c){
		cout<<m<<" "<<y<<" "<<endl;
	}else{
		cout<<m<<" "<<z<<" "<<endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <vector>
#include <stack>
using namespace std;

int main () {
	int n; cin >> n;
	vector <vector <pair<int, int> > > graph(n+1);
	for (int i = 0; i < n-1; i++) {
		int a, b, c; cin >> a >> b >> c;
		graph[a].push_back(make_pair(b,c));
		graph[b].push_back(make_pair(a,c));
	}
	int q, k; cin >> q >> k;
	//DFS
	vector <bool> visited(n+1, false);
	stack <long long> nodes, distances;
	vector <long long> distances_from_k(n+1);
	nodes.push(k);
	distances.push(0);
	while (!nodes.empty()) {
		int top_node = nodes.top(); nodes.pop();
		long long top_distance = distances.top(); distances.pop();
		distances_from_k[top_node] = top_distance;
		visited[top_node] = true;
		//push neighbours
		for (int i = 0; i < (int)graph[top_node].size(); i++) {
			int current_neighbour = graph[top_node][i].first;
			if (visited[current_neighbour] == false) {
				nodes.push(current_neighbour);
				distances.push(top_distance+ graph[top_node][i].second);
			}
		}
	}
	for (int i = 0; i < q; i++) {
		int s, e; cin >> s >> e;
		cout << distances_from_k[s]+distances_from_k[e] << endl;
	}


	return 0;
}

Measured memory_bytes: 9972
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  vector<string> texts = {"dream", "dreamer", "erase", "eraser"};
  auto Dfs = [&](auto &&Func, const int64_t i) -> bool {
    if (i >= static_cast<int64_t>(S.length())) {
      return true;
    }
    bool result = false;
    for (auto text : texts) {
      const int64_t n = static_cast<int64_t>(text.length());
      if (S.substr(i, n) == text) {
        result = Func(Func, i + n);
        if (result) {
          break;
        }
      }
    }
    return result;
  };
  const bool result = Dfs(Dfs, 0);
  if (result) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 7012
def solve(N, K, Q, As, X):
    mins = []
    tmp = []
    for A in As:
        if A >= X:
            tmp.append(A)
        else:
            if len(tmp) >= K:
                tmp.sort()
                mins.extend(tmp[:len(tmp)-K+1])
            tmp = []
    if len(tmp) >= K:
        tmp.sort()
        mins.extend(tmp[:len(tmp)-K+1])

    if len(mins) < Q:
        return None
    mins.sort()
    taken = mins[:Q]
    return taken[-1] - taken[0]


N, K, Q = map(int, input().split())
As = [int(x) for x in input().split()]

ans = -1
for A in As:
    cand = solve(N, K, Q, As, A)
    if cand is not None and (ans == -1 or ans > cand):
        ans = cand

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

int main() {
    ll a,b; cin >> a >> b;
    cout << (ll)LCM(a,b);
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
long long N,M;
int main(){
	cin>>N>>M;
	long long arr[M];
	long long total=0;
	for(long long i=0; i<M; i++){
		cin>>arr[i];
		total+=arr[i];
	}
	if(N<total){
		cout<<-1<<'\n';
	}else{
		cout<<N-total<<'\n';
	}
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a'){
    cout << "vowel" << endl;
  }else if(c == 'i'){
	cout << "vowel" << endl;
  }else if(c == 'u'){
	cout << "vowel" << endl;
  }else if(c == 'e'){
	cout << "vowel" << endl;
  }else if(c == 'o'){
	cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
from bisect import bisect_right
from math import ceil
n,d,a=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
x,h=[],[]
for i in range(n):
  x.append(l[i][0])
  h.append(l[i][1])
accum=[0]*(n+1)
bomb,ans=0,0
for i in range(n):
  bomb+=accum[i]
  hp=h[i]-bomb*a
  if hp>0:
    ans+=ceil(hp/a)
    bomb+=ceil(hp/a)
    inde=bisect_right(x,x[i]+2*d)
    accum[inde]-=ceil(hp/a)
print(ans)


Measured memory_bytes: 64088
# S = "erasedream"
#
# ARR = ['dream', 'dreamer', 'erase', 'eraser']

# S = "erasedream"
# S = "dreameraser"
# S = "dreamerer"

S = input()
def calculate(s):

    index = 0
    isOK = True
    while index < len(s):

        #p1 = 'dreameraser'
        p1 = s[index:index + 11]
        if p1 == 'dreameraser':
            index += 11
            continue
        #p2 = 'dreamerase'

        p2 = s[index:index + 10]
        if p2 == 'dreamerase':
            index += 10
            continue

        s1 = s[index:index+7]

        if s1 == 'dreamer':
            index += 7
            continue

        s2 = s[index:index+6]

        if s2 == 'eraser':
            index += 6
            continue

        s3 = s[index:index+5]

        if s3 == 'erase':
            index += 5
            continue

        if s3 == 'dream':
            index += 5
            continue

        isOK = False
        break

    if isOK:
        print("YES")
    else:
        print("NO")
calculate(S)

Measured memory_bytes: 9092
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
# https://atcoder.jp/contests/abc059/tasks/abc059_b

def main():
    a = int(input())
    b = int(input())
    if a > b:
        print('GREATER')
        return
    if a < b:
        print('LESS')
        return

    print('EQUAL')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DIGIT_MAX		35										// 最大桁数

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 対象値 - 取得
	long long llVal;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld", &llVal);

//	llVal = 17;

	// 桁毎の値範囲セット
	long long ll1RngS[D_DIGIT_MAX];
	long long ll1RngE[D_DIGIT_MAX];
	ll1RngS[0] = 1;
	ll1RngE[0] = 1;
	ll1RngS[1] = -2;
	ll1RngE[1] = -1;
	long long llTwo = 4;
	for (i = 2; i < D_DIGIT_MAX; i++) {
		if (llTwo > 0) {
			ll1RngS[i] = ll1RngE[i - 2] + 1;
			ll1RngE[i] = ll1RngE[i - 2] + llTwo;
		}
		else {
			ll1RngS[i] = ll1RngS[i - 2] + llTwo;
			ll1RngE[i] = ll1RngS[i - 2] - 1;
		}

		llTwo *= -2;									// 次へ
	}

	// 開始桁取得
	int liDNo = 0;
	llTwo = 1;
	if (llVal != 0) {
		for (i = 0; i < D_DIGIT_MAX; i++) {
			if (ll1RngS[i] <= llVal && llVal <= ll1RngE[i]) {
				liDNo = i;
				break;
			}
			else {
				llTwo *= -2;									// 次へ
			}
		}
	}

	// 算出
	int liSNo = 0;
	for (i = liDNo; i >= 0; i--) {
		if (ll1RngS[i] <= llVal && llVal <= ll1RngE[i]) {
			lc1Out[liSNo] = '1';
			llVal -= llTwo;									// 現在値更新
		}
		else {
			lc1Out[liSNo] = '0';
		}

		liSNo++;
		llTwo /= -2;									// 次へ
	}

	// 改行
	lc1Out[liSNo] = '\n';
	lc1Out[liSNo + 1] = '\0';

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s[3];
rep(i,3){
    cin>>s[i];
}
string ans = {s[0][0],s[1][0],s[2][0]};
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >>b;
    // cout << (b-1)/a +1;
    if((b-1)%(a-1)==0){
        cout << (b-1)/(a-1);
    }
    else{
        cout << (b-1)/(a-1) + 1;
    }

    return 0;
}

Measured memory_bytes: 3648