akhauriyash/Code-Regression huggingface dataset:
// T2020C2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n + 2);
	vector<int>b(n + 2);
	vector<int>c_sum(n + 2);
	for (int i = 1; i <= n; i++) {
		cin >> a.at(i);
	}
	for(int j=0;j<k;j++) {
		for (int i = 1; i <= n; i++)
		{
			int lp = i - a.at(i);
			if (lp < 0)
			{
				lp = 0;
			}
			b.at(lp) += 1;
			int rp = i + a.at(i) + 1;
			if (rp > n + 1)
			{
				rp = n + 1;
			}
			b.at(rp) -= 1;
		}
		c_sum.at(0) = b.at(0);
		for (int i = 1; i <= n; i++)
		{
			c_sum.at(i) = c_sum.at(i - 1) + b.at(i);
		}
		if (a == c_sum) { // vectorの比較
			break; // 変化がなくなったら、終わり
		}
		else {
			a = c_sum; // vectorのコピー
			fill(b.begin(), b.end(), 0); // vector<int>bを０に戻す
		}
	}
	for (int i = 1; i <=n; i++)
	{
		cout << c_sum.at(i) << " ";
	}
	cout << endl;
	return 0;
}


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

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  bool flag = true;
  REP(i, s.length() - 1)
  {
    if (s[i] == s[i + 1])
    {
      flag = false;
    }
  }
  if (flag)
  {
    cout << "Good" << endl;
  }
  else
  {
    cout << "Bad" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

ll T;

ll  quickpow(ll a,ll  b,ll mod) 
{
  ll res = 1;
  while (b > 0) 
  {
    if (b & 1) res = (res * a%mod)%mod;
    a = (a * a%mod)%mod;
    b >>= 1;
  }
  return res%mod;
}
int main()
{
	cin >> T;
	ll sum = quickpow(10,T,MOD)%MOD;
	ll tot = (2*quickpow(9,T,MOD)%MOD - (quickpow(8,T,MOD))%MOD)%MOD;
	cout << (sum - tot+MOD*2)%MOD << endl; 
	return 0;
}

Measured memory_bytes: 3584
// abc133d: Rain Flows into Dams
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))

int main(){
  int n; cin>>n;
  int m0 = 0;
  vi d(n);
  upto(i,0,n,1){
    cin>>d[i];
    if(i%2) m0 -= d[i]; else m0 += d[i];
  }
  upto(i,0,n,1){
    cout<<m0<<(i<n-1?" ":"\n");
    m0 = d[i]*2 - m0;
  }
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main(void) {
	int a, b, c,d=0;
	cin >> a >> b;
	for (int i = 0; i < b; i++) {
		cin >> c;
		d = d + c;
	}
	if (a <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int N, counter, dan = 0;
  
  
  cin >> N;
  vector<int> mochi(N);
  
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (i == N-1) {
      dan++;
    }
    else {
      counter = 0;
      for (int j = i+1; j < N; j++) {
        if (mochi.at(i) == mochi.at(j)) {
          counter++;
        }
      }
      if (counter == 0) {
        dan++;
      }
      else {
        counter = 0;
      }
    }
  }
  cout << dan << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, 1, -1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

void solve()
{
    string s;
    cin >> s;
    stack<char> st;
    st.push(s[0]);
    int ans = 0;

    for (int i = 1; i < s.size(); i++)
    {
        if (!st.empty())
        {
            if (s[i] == st.top())
            {
                st.push(s[i]);
            }
            else
            {
                ans++;
                st.pop();
            }
        }
        else
        {
            st.push(s[i]);
        }
    }
    cout << ans * 2 << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 +1;
int dp[N];
int main(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++) cin >> arr[i];
	dp[1] = abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1]+ abs(arr[i]-arr[i-1]),dp[i-2]+ abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1];
return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <functional>

using namespace std;

#define tp template
#define tn typename
#define cl class
#define us using

us str=string;
us ll=long long;
us ul=unsigned long long;
us sz=size_t;
tp<cl T,sz N>us ary=array<T,N>;
tp<sz N>using ari=array<ll,N>;

#define rep(i, n) for(ll i = 0,i##_len=(n); i < i##_len; i++)
#define loop(i, n, m) for(ll i = (n),i##_len<=(m); i < i##_len; i++)
#define all(x) (x).begin(),(x).end()

tp<tn a,tn f>void setary(a b,a e,f l){ll c=0;for(a i=b;i!=e;i++){*i=l(c);c++;}}

int main(){
	int a , b;
	cin >> a >> b;
	a = a*100+b;
	if(a<202){
		cout << 1;
	}else if(a<303){
		cout << 2;
	}else if(a<404){
		cout << 3;
	}else if(a<505){
		cout << 4;
	}else if(a<606){
		cout << 5;
	}else if(a<707){
		cout << 6;
	}else if(a<808){
		cout << 7;
	}else if(a<909){
		cout << 8;
	}else if(a<1010){
		cout << 9;
	}else if(a<1111){
		cout << 10;
	}else if(a<1212){
		cout << 11;
	}else{
		cout << 12;
	}
	cout << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.List ( sort )
import Data.Maybe ( fromJust )

getParm
  :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,x] <- getParm
  as    <- getParm
  print $ f n x as

f :: Int -> Int -> [Int] -> Int
f n x as
  | t < x     = n-1
  | k <= n    = k   
  | otherwise = 0
  where
    t = sum as 
    lengthUpto x = length . takeWhile (<= x) 
    k = lengthUpto x sums
    sums = scanl1 (+) as'
    as' = sort as

Measured memory_bytes: 508
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int flag=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if(a%2){
			flag=1;
		}
	}
	if(flag){
		printf("first");
	}else{
		printf("second");
	}
	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 all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int h, w, k;
        cin >> h >> w >> k;

        auto g = make_v(h, w, 0);
        REP(i, h) {
                string s;
                cin >> s;
                REP(j, w) g[i][j] = s[j] - '0';
        }

        int ans = numeric_limits<int>::max();

        REP(b, bit(h-1)) {
                int t = __builtin_popcount(b);
                bool ok = true;
        
                vector<int> f(h, -1);
                {
                        int s = 0;
                        REP(i, h) {
                                f[i] = s;
                                if (b & bit(i)) s++;
                        }
                }

                vector<int> size(h, 0);
                REP(j, w) {
                        vector<int> ds(h, 0);
                        REP(i, h) {
                                if (g[i][j]) {
                                        ds[f[i]]++;
                                }
                        }

                        bool border = false;
                        REP(i, h) {
                                if (size[i] + ds[i] > k) {
                                        if (j == 0) {
                                                ok = false;        
                                        } else {
                                                border = true;
                                                t++;
                                        }
                                        
                                        break;
                                }
                        }

                        if(!ok) break;
                
                        REP(i, h) {
                                if (!border) {
                                        size[i] += ds[i];
                                } else {
                                        size[i] = ds[i];
                                }
                        }
                }

                if (ok) {
                        ans = min(ans, t);
                }
        }

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


Measured memory_bytes: 256
from collections import defaultdict
N,X,M=map(int,input().split())
cnt=0
index=[X]
d=defaultdict(int)
i=1
while True:
	X=pow(X,2,M)
	if d[X]!=0:
		z=d[X]
		break
	d[X]=i
	i+=1
	index.append(X)
target=len(index)-z
total=0
for i in range(z,len(index)):
	total+=index[i]
for i in range(z):
	cnt+=index[i]
total2=0
for i in range(z,z+(N-z)%target):
	total2+=index[i]
cnt+=total*((N-z)//target)+total2
print(cnt)

Measured memory_bytes: 78032
inp = input().split()
line = list(map(int,inp))
n = line[0]
x = line[1] - 1
y = line[2] - 1

a = []
for i in range(0,n-1):
    a.append(0)

for i in range(n):
    for j in range(i+1,n):
        t = min([j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j)])
        a[t-1] += 1

for i in range(0,n-1):
    print(a[i])

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n,m;
  cin>>n>>m;
  int x[m];
  rep(i,m) cin>>x[i];
  sort(x,x+m);
  int d[m-1];
  ll ans = 0;
  rep(i,m-1) {
    d[i] = x[i+1] - x[i];
  }
  sort(d, d + (m-1));
  rep(i, m-n) {
    ans += d[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int n;
	int a;
	int ans = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		if  (a % 2 == 0 &&
			(a % 3 != 0 && a % 5 != 0)) {
			ans = 0;
		}
	}
	printf(ans ? "APPROVED" : "DENIED");

	return 0;
}

Measured memory_bytes: 128
import Data.Array.IO
import Data.List
import Control.Monad

type Memo = IOUArray (Int, Int, Int) Int
type Index = (Int, Int)

infinite = maxBound :: Int

main = do
  [n,ma,mb] <- map read . words <$> getLine :: IO [Int]
  item <- map (map read . words) . lines <$> getContents :: IO [[Int]]
  memo <- newArray ((0, 0, 0), (n, 400, 400)) infinite :: IO Memo
  writeArray memo (0, 0, 0) 0
  dp memo [0..(n-1)] item
  let index = [(a, b) | a <- [1..400], b <- [1..400]]
  ans <- filter (/=infinite) <$> mapM (getAns memo n ma mb) index
  if ans /= [] then print $ minimum ans
               else print (-1)

dp :: Memo -> [Int] -> [[Int]] -> IO Memo
dp memo []     []     = return memo
dp memo (i:is) (m:ms) = do
  let index = [(a,b) | a <- [0..400], b <- [0..400]]
  memo' <- foldM (memoize m i) memo index
  dp memo' is ms >>= return

memoize :: [Int] -> Int -> Memo -> Index -> IO Memo
memoize [a,b,c] n memo (ma,mb) = do
  x <- readArray memo (n, ma, mb)
  if x /= infinite
    then do
      y <- readArray memo (n+1, ma, mb)
      writeArray memo (n+1, ma, mb) $ min x y
      z <- readArray memo (n+1, ma+a, mb+b)
      writeArray memo (n+1, ma+a, mb+b) $ min z $ x + c
      return memo
    else do
      return memo

getAns :: Memo -> Int -> Int -> Int -> Index -> IO Int
getAns memo n ma mb (a, b)
  | ma * b == mb * a = do
    ans <- readArray memo (n, a, b)
    return ans
  | otherwise        = return infinite


Measured memory_bytes: 66300
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
	int a, b, c, eq=0;
	scanf("%d %d %d", &a, &b, &c);
	eq= a*b;
	if(eq > c)
		printf("%d", c);
	else 
		printf("%d", eq);
	printf("\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
rest = []
for i in range(N):
    list_tmp = list(input().split())
    list_tmp[1] = int(list_tmp[1])
    list_tmp.append(i+ 1)
    rest.append(list_tmp)
rest = sorted(rest, key=lambda x:(x[0],-x[1]))
for i in range(N):
    print(rest[i][2])

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d %d %d",&a,&b,&c);
	if(a<b) swap(a,b);
	if(a<c) swap(a,c);
	if(b<c) swap(b,c);
	int ans=0;
	if((b-c)%2==0)
	{
		ans+=(b-c)/2;
		ans+=a-b;
		printf("%d",ans);
	}
	else
	{
		ans++;a++;b++;
		ans+=(b-c)/2;
		ans+=a-b;
		printf("%d",ans);
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    ans = [-1]*N
    
    while q:
        v = q.popleft()
        
        for nv in G[v]:
            if dist[nv]==-1:
                ans[nv] = v
                dist[nv] = dist[v]+1
                q.append(nv)
    
    return ans

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

ans = bfs()
print('Yes')

for i in range(1, N):
    print(ans[i]+1)

Measured memory_bytes: 92244
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
V = LIST()

ans = 0
tmp_sum = 0

for i in range(1, min(K, N)+1):
	left = K-i
	for j in range(i+1):
		tmp = V[:j] + V[N-(i-j):]
		tmp.sort()
		idx = bisect_left(tmp, 0)
		ans = max(ans, sum(tmp) - sum(tmp[:min(idx, left)]))

print(ans)


Measured memory_bytes: 9972
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,x;
   cin>>n>>m>>x;
   int cost[n];
   int a[n][m];
   for(int i=0;i<n;i++)
   {   cin>>cost[i];
       for(int j=0;j<m;j++)
        cin>>a[i][j];
   }
   int mask=pow(2,n)-1;
   int ans=1e17;
   for(int i=1;i<=mask;i++)
   {
       vi v;
       int sum=0;
       for(int j=0;j<n;j++)
       {
           if(i & (1<<j)){v.pb(j);sum+=cost[j];}
       }
       //debug(v);
       vi store(m,0);
       for(int j=0;j<v.size();j++)
       {
           for(int k=0;k<m;k++)
           {
               store[k]+=a[v[j]][k];
           }
       }
       bool ok=true;
       for(int k=0;k<m;k++)
       {
           if(store[k]<x)ok=false;
       }
       if(ok)ans=min(ans,sum);
   }
   if(ans == 1e17)
    cout<<-1<<endl;
   else
   cout<<ans<<endl;


}


Measured memory_bytes: 4096
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- listArray (1, n) . map (read::String -> Int) . words <$> getLine
  let diff = listArray (1, n) . sort . map (\i -> arr ! i - i) $ [1..n]
      intercept = (diff ! ((n + 2) `div` 2) + diff ! ((n + 1) `div` 2)) `div` 2
  print . sum . map (\i -> abs $ arr ! i - i - intercept) $ [1..n]


Measured memory_bytes: 117116
from itertools import accumulate


def solve(string):
    n, m, q, *lrpq = map(int, string.split())
    lr, pq = lrpq[:2 * m], lrpq[2 * m:]
    t = [[0] * (n + 1) for _ in range(n + 1)]
    for l, r in zip(lr[::2], lr[1::2]):
        t[l][r] += 1
    t = [list(accumulate(t_)) for t_ in zip(*(accumulate(_t) for _t in t))]
    ans = [
        str(t[q][q] - t[p - 1][q] - t[q][p - 1] + t[p - 1][p - 1])
        for p, q in zip(pq[::2], pq[1::2])
    ]
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, q = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, q) + '\n'.join([input() for _ in range(m + q)])))


Measured memory_bytes: 60236
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main() {
	string S;
	string T;
	cin >> S >> T;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == S) {
		a--;
	} else if (u == T) {
		b--;
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;

#define EPS 1e-9
#define PI 3.14159265358979323846264338327950
const int N = 1e5 + 5;


int L[N], R[N];
template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	int x;
	cin >> x;
	cout << (x / 500 * 1000 + (x % 500) / 5 * 5) << '\n';
	
}


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

char buf[100002];

bool dp[100002];

vector<string> v;
string s;
int main(){
	scanf("%s", buf);
	s = buf;
	v.push_back("dream");
	v.push_back("dreamer");
	v.push_back("erase");
	v.push_back("eraser");
	dp[0] = true;
	for (int i = 0; i < s.size(); i++){
		if (dp[i] == false)continue;
		int res = s.size() - i;
		for (int j = 0; j < v.size(); j++){
			if (res >= v[j].size()){
				if (s.substr(i, v[j].size()) == v[j]){
					dp[i + v[j].size()] = true;
				}
			}
		}
	}
	if (dp[s.size()]){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}

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

int main() {
	// your code goes here
	long long int n;
	cin>>n;
	string s;
	while(n>0)
	{
	    n--;
	    s+=char('a'+n%26);
	    n=n/26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

    if(a<b){
      System.out.println("a < b");
    }else if(a>b){
      System.out.println("a > b");
    }else{
      System.out.println("a == b");
    }
    scanner.close();
  }
  
}


Measured memory_bytes: 26292
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;


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

	ll N,K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N){
		cin >> A[i];
	}

	ans = (N-2) / (K-1) + 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
/***
 **   A S M Atikur Rahman
 **   Update: 26-03-2020
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
//ll Sqrt(ll a) { ll x=(ll)sqrt(a); if((x+1)*(x+1)==a) x++; return x; }



int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    ll x,ans;
    cin>>x;
    ans= (x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    pfll(ans),pn;




    return 0;
}
























Measured memory_bytes: 256
//
// Created by yamunaku on 2020/02/20.
//

#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

bool query(int x, int y){
    cout << "? " << x SP y << endl;
    char c;
    cin >> c;
    return c == 'Y';
}

int main(){
    //CFS;
    int a, b;
    cin >> a >> b;
    if(a <= b){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<queue<int>> q(100);
    rep(i, 2 * b + 1) q[0].push(i);
    rep(i, 100){
        while(q[i].size() >= 2){
            int x = q[i].front();
            q[i].pop();
            int y = q[i].front();
            q[i].pop();
            if(query(x, y)){
                q[i + 1].push(y);
            }
        }
    }
    int hon = -1;
    per(i, 100){
        if(!q[i].empty()){
            hon = q[i].front();
            break;
        }
    }
    string ans(a + b, '0');
    rep(i, a + b){
        ans[i] = (query(hon, i) ? '1' : '0');
    }
    cout << "! " << ans << endl;
    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll X,Y;cin>>X>>Y;
  ll cnt=1;
  for(ll i=0;i<60;i++){
    X*=2;
    if(X<=Y)cnt++;
    if(X>Y)break;
  }
  cout<<cnt<<endl;
}








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

int h(int a, int b){
	if(a==b){
		return 1;
	}
	else {
		return 0;
	}
}

int main(){
	int a[4], b[4];

	while (true)
	{
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];
		if (cin.eof()) { break; }
		int hit = 0, blow = 0;
		for(int i=0;i<4;i++){
			for (int j = 0;j<4;j++){
				if (i==j){
					hit += h(a[i], b[j]);
				}
				else{
					blow += h(a[i], b[j]);
				}
			}
		}
		cout << hit << " " << blow << endl;
	}

	return 0;
}

Measured memory_bytes: 3044
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct E {
  int v;
  bool vis;
  E *next, *rev;
};

const int N = 100010;

int n, m;
bool vis[N], par[N];
E* g[N];

E* adde(int u, int v) {
  static E pool[N * 2], *p = pool;
  ++p;
  p->v = v;
  p->next = g[u];
  g[u] = p;
  return p;
}

void dfs(int u) {
  vis[u] = true;
  for (E* p = g[u]; p; p = p->next)
    if (!p->vis) {
      p->vis = p->rev->vis = true;
      if (!vis[p->v]) {
        dfs(p->v);
        if (par[p->v]) {
          printf("%d %d\n", p->v, u);
        } else {
          printf("%d %d\n", u, p->v);
          par[u] ^= 1;
        }
      } else {
        printf("%d %d\n", u, p->v);
        par[u] ^= 1;
      }
    }
}

int main() {
  scanf("%d%d", &n, &m);
  if (m % 2) {
    puts("-1");
    return 0;
  }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    E *p = adde(u, v), *q = adde(v, u);
    p->rev = q;
    q->rev = p;
  }
  dfs(1);
  return 0;
}


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


int main() {

    int s;
    cin >> s;
    set<int> st;
    int x = s;
    while (st.count(x) == 0) {
        st.insert(x);
        if (x % 2 == 0) {
            x /= 2;
        } else {
            x = 3*x + 1;
        }
    }
    cout << st.size()+1 << endl;
    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

const int N = 1e6+2;
string s;
int n, dp[N][2], ssum[N];

int main()
{
  fastio;
  cin >> s; reverse(all(s)); 
  int n = s.size(); s = '#' + s;
  for (int i = n; i > 0; i--) ssum[i] = ssum[i + 1] + (9 - (s[i] - '0'));
  dp[0][0] = dp[0][1] = 0;
  int mn = ssum[1];
  for (int i = 1; i <= n; i++){
    dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + (s[i] - '0');
    dp[i][1] = mn - ssum[i + 1] + 2;
    mn = min(mn, dp[i][0] + ssum[i + 1]);
  }
  cout << min(dp[n][0], dp[n][1]); 
  return 0;
}

Measured memory_bytes: 13128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3 = y1 - y2 + x2;
	int y3 = x2 - x1 + y2;
	int x4 = y1 - y2 + x1;
	int y4 = x2 - x1 + y1;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 3616
N = gets.to_i
as = N.times.map{gets.to_i}
ans = 0
N.times do |i|
    ans += as[i] / 2
    as[i] %= 2
    if i < N-1 && as[i] == 1 && as[i+1] > 0
        ans += 1
        as[i] -= 1
        as[i+1] -= 1
    end
end

puts ans

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    int out = 1;
    rep(i, n)
    {
        if (out < k)
        {
            out *= 2;
        }
        else
        {
            out += k;
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

use proconio::marker::Usize1;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
    }
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        input! {
            a: Usize1, b: Usize1,
        }
        g[a].push(b);
        g[b].push(a);
    }
    let mut que = VecDeque::new();
    que.push_back(0);
    let mut ans = vec![None; n];
    ans[0] = Some(0);
    while let Some(s) = que.pop_front() {
        for &t in g[s].iter() {
            if ans[t] == None {
                ans[t] = Some(s);
                que.push_back(t);
            }
        }
    }
    println!("Yes");
    for a in ans.iter().skip(1) {
        println!("{}", a.unwrap() + 1);
    }
}


Measured memory_bytes: 14956
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    vector< pll > co;
    ll i, j;
    FOR0(i, n)
    {
        ii temp;
        cin>>temp.ff>>temp.ss;
        co.push_back(ii(temp.ff, temp.ss));
    }
    vector< pll > pos;
    FOR0(i, n)
    {
        FOR(j, i+1, n)
        {
            ll p, q;
            p = co[i].ff - co[j].ff;
            q  = co[i].ss - co[j].ss;
            pos.push_back(pll(p,q));
        }
    }
    ll si = pos.size();
    ll ans = inf;
    FOR0(i, si)
    {
        multiset<pll> s;
        multiset<pll>::iterator it;
        ll cur = 0;
        ll p = pos[i].ff, q = pos[i].ss;
        FOR0(j, n) s.insert(co[j]);
        FOR0(j, n)
        {
            if(s.find(co[j]) == s.end()) continue;
            cur++;
            pll front, back;
            front.ff = back.ff = co[j].ff;
            front.ss = back.ss = co[j].ss;
            while( 1 )
            {
                bool is = false;
                it = s.find(pll(front.ff + p, front.ss+q));
                if(it!=s.end())
                {
                    front.ff += p;
                    front.ss += q;
                    s.erase(it);
                    is = true;
                }
                it = s.find(pll(back.ff -p, back.ss - q));
                if(it!=s.end())
                {
                    back.ff -= p;
                    back.ss -= q;
                    s.erase(it);
                    is = true;
                }
                if(!is) break;
            }
        }
        ans = MIN2(ans, cur);
    }
    if(ans == inf) ans = 1;
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  char s[11] = { '\0' };
  scanf("%s", s);
  char ans[11] = { '\0' };
  int i = 0;
  int c = 1;
  int j = 0;
  while(s[c] != '\0') c++;
  while(c > 0){
    if(s[j] == '0'){
      ans[i] = '0';
      i++;
    }else if(s[j] == '1'){
      ans[i] = '1';
      i++;
    }else{
      if(i != 0){
	i--;
	ans[i] = '\0';
      }
    }
    c--;
    j++;
  }


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


struct UnionFind{
	vector<int> data;
	
	UnionFind(int n){
		data.assign(n,-1);
	}
	
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	
	int size(int k){
		return -data[find(k)];
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t,l;cin >> n >> t >> l;
	UnionFind uf1 = UnionFind(n), uf2 = UnionFind(n);
	rep(i,t){
		int p,q;cin >> p >> q;
		p--;q--;
		uf1.unite(p,q);
	}
	rep(i,l){
		int r,s;cin >> r >> s;
		r--;s--;
		uf2.unite(r,s);
	}
	map<pii,int> m;
	vector<int> ans(n);
	rep(i,n) m[mp(uf1.find(i), uf2.find(i))]++;
	rep(i,n) ans.at(i) = m[mp(uf1.find(i), uf2.find(i))];
	rep(i,n){
		if(i == n - 1) cout << ans.at(i) << endl;
		else cout << ans.at(i) << " ";
	}
}


Measured memory_bytes: 14336
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    T = list(iss())
    StoT = {}
    TtoS = {}
    for n in range(ord('a'), ord('z') + 1):
        StoT[chr(n)] = 0
        TtoS[chr(n)] = 0

    for st in zip(S, T):
        s, t = st
        if StoT[s] == 0 and TtoS[t] == 0:
            StoT[s] = t
            TtoS[t] = s
        elif StoT[s] != t or TtoS[t] != s:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 7080
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private void mainrun() {
		scan = new Scanner(System.in);

		int a,b;

		while(scan.hasNext()) {
			a = scan.nextInt();
			b = scan.nextInt();

			System.out.println(ketasujudge(a+b));
		}

		scan.close();

	}

	private int ketasujudge(int num) {
		int n = 1;

		while(num / 10 != 0) {
			n++;
			num /= 10;
		}

		return n;
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int k;
	string s;
	cin >> k >> s;

	int size = s.length();

	if (size <= k)
	{
		cout << s << endl;
	}
	else
	{
		cout << s.substr(0, k) << "..." << endl;
	}
	
}

int main()
{
	fastio;
	solve();

	return 0;
}

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




int main()
{
	int n;
	cin >> n;
	vector<int> stairs(n, 0);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &stairs[i]);
	}

	int maxStairHeight = stairs[0] - 1;
	for (auto stairHeight : stairs)
	{
		if (maxStairHeight < stairHeight)
		{
			maxStairHeight = max(maxStairHeight, stairHeight - 1);
		}
		else if (maxStairHeight > stairHeight)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 640
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  string S;
  cin >> S;
  int countA = 0;
  int countB = 0;
  rep(i, S.size()){
    (S[i] == '0' ? countA : countB)++;
  }
  int ans = min(countA, countB) * 2;
  cout << ans << endl;
  return 0;
}


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

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        var V = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).OrderBy(x => x).ToList();


        //検証
        for (int i = 0; i <= N - 2; i++) {
            //新たに、平均化した値をリストに加える
            V.Add(((V[0] + V[1]) / 2d));

            //頭の二つを削除する
            V.RemoveAt(0);
            V.RemoveAt(0);

            //昇順に並べる
            V.Sort();
        }

        //出力
        Console.WriteLine(V[0]);


    }
}

Measured memory_bytes: 13652
#include<bits/stdc++.h>
#define  __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;


int main()
{
    __;

    int a=0,b=0;
    string s;

    cin>>s;

    a=((s[0]-'0')*10) + (s[1]-'0');

    b=((s[2]-'0')*10) + (s[3]-'0');

    if((a>12 || a==0) && b<=12 && b>=1)  cout<<"YYMM";

    else if(a>=1 && a<=12 && (b>12 || b==0)) cout<<"MMYY";

    else if(a>=1 && a<=12 && b>=1 && b<=12) cout<<"AMBIGUOUS";

    else cout<<"NA";

    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  vector<string> N(4); REP(i, 4) cin >> N[i];
  string ans = "NO";
  sort(all(N));
  string tmp = "";
  REP(i, 4) tmp += N[i];
  if(tmp == "1479") ans = "YES";
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(0);
  std::cin.tie(0);
  ll N, ans{}, d{}, e{};
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  sort(begin(C), end(C));
  for (int i = 0; i != N; ++i) {
    while (d != N && A[d] < B[i]) ++d;
    while (e != N && B[i] >= C[e]) ++e;
    ans += d * (N-e);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int w = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();

			if (Math.abs(a - b) <= w) {
				System.out.println(0);
			} else if (a < b) {
				System.out.println(b - (a + w));
			} else {
				System.out.println(a - (b + w));
			}

		} finally {
			sc.close();
		}
	}
}

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;


int main(){
  string s;
  cin >> s;
  ll ans=0,sum=0,v;
  FOR(i,pow(2,s.size()-1)){
    v=s[0]-'0';
    sum=0;
    FOR(j,s.size()-1){
      
      if(i & (1<<j)){
        sum+=v;
        v=s[j+1]-'0';
        
      }else{
        v+=v*9+(s[j+1]-'0');
      }
    }
    sum+=v;
    ans+=sum;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int d,m;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w" ,stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>m>>d;
	int res=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j/10,d2=j%10;
			if(d1>=2&&d2>=2){
				if(d1*d2==i){
					res++;
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n-1)
	ans := make([]int, n)
	for i := 0; i < n-1; i++ {
		fmt.Scan(&nums[i])
	}

	for index, num := range nums {
		if index == 0 {
			ans[0] = num
			ans[1] = num
		} else {
			if ans[index] > num {
				ans[index] = num
				ans[index+1] = num
			} else {
				ans[index+1] = num
			}
		}
	}

	sum := 0
	for _, num := range ans {
		sum += num
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    LL n;
    cin >> n;
    vector<LL> v(5);
    rep(i, 5) {
        cin >> v[i];
    }

    printf("%lld\n", (LL)ceil( (double)n / *min_element(v.begin(), v.end()) ) + 4);
    return 0;
}


Measured memory_bytes: 256