akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int N,M,x;
        cin >> N >> M;
        vector<int> ans(N,0);
        for(int i=0;i<2*M;i++){
            cin >> x;
            ++ans[x-1];
        }
        for(int i=0; i<N; i++){
            cout << ans[i] << endl;
        }
    }

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

using namespace std;

int main() {
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    int count=0,min=n+1;
    for (int i=0;i<n;i++){
        if (arr[i]<min){
            count++;
            min=arr[i];
        }
    }
    cout<<count;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
using namespace std;


int main ()
{
__

int n;

cin >> n;

double a[n],ans=0.0;

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

sort(a,a+n);

ans = a[0];

for(int i=1;i<n;i++)
{
ans = (ans+a[i])/2.0;
}

printf("%.9f\n",ans);

return 0;
}


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

using namespace std;

int main(){
  vector <int> a;
  int sum=0;
  int N,r;
  cin >> N;

  for(int i = 0;i < N;i++){
    cin >> r;
    a.push_back(r);
    sum += a[i];
  }

  sort(a.begin(),a.end());
  int i = 0;
  while(sum%10 == 0 && i != a.size()){
    if((a[i]%10 != 0)){
      sum -= a[i];
    }
    i++;
  }
  if(sum % 10 > 0)
    cout << sum << endl;
  else
    cout << 0 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n , k;
const int maxn = 2e5 + 25;
long long a[maxn];
long long ans=1e18 + 7;
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for (int i = 1;i + k - 1 <= n ; i++)
    {
        long long tmp=a[i+k-1] - a[i];
        if ((a[i]<0) && (a[i+k-1]<0)) tmp += abs(a[i+k-1]);
        if ((a[i]>0) && (a[i+k-1]>0)) tmp += a[i];
        if ((a[i]<0) && (a[i+k-1]>0)) tmp += min(-a[i],a[i+k-1]);
        ans=min(ans,tmp);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
/* include */
#include <bits/stdc++.h>
#include <boost/algorithm/string/trim.hpp>
#include <boost/range/algorithm.hpp>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x)  \
    boost::sort(x); \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    string s;
    cin >> s;
    REP(i, 1, s.size())
    {
        if (s[i] == s[i - 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


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

int main(){
    int n, i, j;
    cin >> n;
    double result = 0.0;
    double x[n][2];
    for(i=0; i<n; i++){
        cin >> x[i][0] >> x[i][1];
    }
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            result += sqrt((x[i][0] - x[j][0])*(x[i][0] - x[j][0]) + (x[i][1] - x[j][1])*(x[i][1] - x[j][1]));
        }
    }
    result *= 2.0/n;
    printf("%.8lf", result);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    vector<ll> dp(n+1,1);
    rep(i,m){
        dp[a[i]]=0;
    }
    for(int i=1; i<n; ++i){
        if(dp[i+1]==0) continue;
        dp[i+1]=dp[i]+dp[i-1];
        dp[i+1]=dp[i+1]%1000000007;
    }
    cout << dp[n] << "\n";
    return 0;
}   

Measured memory_bytes: 4504
#include <stdio.h>

long main(){
  long n,i,j,anow,tnow,anew,tnew,atime,ttime,realtime;
  long t[1010],a[1010];
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&t[i],&a[i]);
  }
  anow = a[0];
  tnow = t[0];
  for(i=0;i<(n-1);i++){
    atime = anow/a[i+1];
    if(anow%a[i+1]!=0){
      atime++;
    }
    ttime = tnow/t[i+1];
    if(tnow%t[i+1]!=0){
      ttime++;
    }
    if(ttime <= atime){
      realtime = atime;
    }else{
      realtime = ttime;
    }
    anow = a[i+1]*realtime;
    tnow = t[i+1]* realtime;
  }
  printf("%ld\n",anow+tnow);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<int,int> P;
typedef set<int> S;
ll n;
int maze[55][55];
int attac[55][55];
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,1,1,-1,-1};
int w,h;
void bfs(int i,int j){
    queue<P> que;
    que.push({i,j});
    //cout<<"111"<<endl;
    while(!que.empty()){
        P now;
        now = que.front();
        que.pop();
        int x = now.first;
        int y = now.second;
        rep(k,8){
            //cout<<"aaa"<<endl;
            int nx = x + dx[k];
            int ny = y + dy[k];
            if(nx<h && nx>=0 && ny<w && ny>=0 && attac[nx][ny]==0 && maze[nx][ny]==1){
                //cout<<"ああ"<<endl;
                attac[nx][ny]=1;
                que.push({nx,ny});
            }
        }
    }
}
int main(){
    while (1){
        int ans=0;
        cin>>w>>h;
        if(w==0 && h==0) break;
        rep(i,55){
            rep(j,55) attac[i][j]=0;
        }
        rep(i,h){
            rep(j,w) cin>>maze[i][j];
        }
        rep(i,h){
            rep(j,w){
                if(maze[i][j]==1 && attac[i][j]==0){
                    ans++;
                    bfs(i,j);
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pii rot(pii v)
{
	pii r;
	r.first = -v.second;
	r.second = v.first;
	return r;
}

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	pii v(c - a, d - b);
	v = rot(v);
	pii p3(c + v.first, d + v.second);
	v = rot(v);
	pii p4(p3.first + v.first, p3.second + v.second);
	cout << p3.first << " " << p3.second << " " << p4.first << " " << p4.second << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

int main() {
  ll mod = 1000000007;
  ll N;
  cin >> N;
  map<pair<ll, ll>, pair<ll, ll>> m;//same, diff
  vector<ll> zero = {0, 0, 0};
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 || b == 0) {
      if (a == 0 && b == 0) {
        zero.at(2) += 1;
      }
      else if (a == 0) {
        zero.at(0) += 1;
      }
      else {
        zero.at(1) += 1;
      }
      continue;
    }
    ll gcd = __gcd(a, b);
    a /= gcd;
    b /= gcd;
    ll abs_a = abs(a), abs_b = abs(b);
    pair<ll, ll> temp = {abs_a, abs_b};
    if ((a < 0 && b > 0) || (a > 0 && b < 0)) {
      m[temp].second += 1;
    }
    else {
      m[temp].first += 1;
    }
  }
  ll ans = 1;
  ll pow2 = 0;
  if (zero.at(0) == 0 || zero.at(1) == 0) {
    // pow2 += zero.at(0) + zero.at(1);
    ans = (ans * modpow(2, zero.at(0) + zero.at(1), mod)) % mod;
  }
  else {
    ans = (modpow(2, zero.at(0), mod) + modpow(2, zero.at(1), mod) - 1) % mod;
  }
  map<pair<ll, ll>, bool> already;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    pair<ll, ll> now = (*itr).second;
    if (already[(*itr).first]) {
      continue;
    }
    pair<ll, ll> opp = m[{(*itr).first.second, (*itr).first.first}];
    already[(*itr).first] = true;
    already[{(*itr).first.second, (*itr).first.first}] = true;
    if (now.first * opp.second == 0) {
      // pow2 += now.first + opp.second;
      ans = (ans * modpow(2, now.first + opp.second, mod)) % mod;
    }
    else {
      ll temp = (modpow(2, now.first, mod) + modpow(2, opp.second, mod) - 1) % mod;
      ans = (ans * temp) % mod;
    }
    if ((*itr).first.first == (*itr).first.second) {
      continue;
    }
    if (now.second * opp.first == 0) {
      // pow2 += now.second + opp.first;
      ans = (ans * modpow(2, now.second + opp.first,  mod) % mod);
    }
    else {
      ll temp = (modpow(2, now.second, mod) + modpow(2, opp.first, mod) - 1) % mod;
      ans = (ans * temp) % mod;
    }
    // cout << "ans" << ans << "\n";
  }
  // ans = (ans * modpow(2, pow2, mod)) % mod;
  ans = (ans - 1 + zero.at(2)) % mod;
  // cout << (ans - 1 + zero.at(2)) % mod << "\n";
  if (ans < 0) {
    ans += mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 59812
#include <bits/stdc++.h>
using namespace std;
int n, a[1000001], cnt[30];
int main(){
    cin>>n;
    for (int j=1; j<=n; j++){
        cin>>a[j];
        for (int i=0; i<=29; i++){
            int b = (a[j]>>i) & 1;
            if (b==1) cnt[i]++;

        }
    }
    for (int i=0; i<=29; i++)
        if (cnt[i]%2 == 1){
            cout<<"No";
            return 0;
        }
    cout<<"Yes";
}


Measured memory_bytes: 640
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 50010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int main(){
    int T,i,j,k,ca=0,m,n;
    //cout<<setprecision(10)<<fixed;
    int l,r,ans=0;
    scanf("%d%d%d",&n,&l,&r);r--;
    rep(i,0,n){
    	scanf("%d",&k);if(k<l||k>r)ans++;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll n;
    cin >> n;

    if(n%2 || n==0){
        cout << 0 << endl;
        return 0;
    }

    n /= 2;
    ll most = 1;
    while(most <= n){
        most *= 5;
    }

    most /= 5;

    ll res = 0;
    while(most != 1){
        // cout << n/most << " " << n << " " << most << endl;
        res += n/most;
        most /= 5;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

typedef pair<int,int> P;

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> x,y;
  int a,b,c,d;
  REP(i,n){
    cin>>a>>b;
    x.push_back(P(a,b));
  }
  REP(i,n){
    cin>>c>>d;
    y.push_back(P(c,d));
  }
  sort(y.begin(),y.end());
  
  int mat=-1;//対応する赤い点のインデックスを入れたい。
  int may=-1;//対応する赤い点のy座標
  vector<bool> used(n,false);
  REP(i,n){
    mat = -1;
    may = -1;
    REP(j,n){
      if(x[j].first<y[i].first && x[j].second<y[i].second){
        if(used[j])continue;
        if(may<=x[j].second){
          mat = j;
          may = x[j].second;
        }
      }
    }
    if(mat==-1){
      continue;
    }else{
      used[mat]=true;
    }
  }
  
  int ans=0;
  REP(i,n){
    if(used[i]){
      ans++;
    }
  }
  cout<<ans<<endl; 
  return 0; 
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextFloatVec() []float64 {
  L := strings.Split(NextLine(), " ")
  N := make([]float64, len(L))
  for i := range N {
    N[i], _ = strconv.ParseFloat(L[i], 64)
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Dist(A, B *[]float64) float64 {
  D := 0.0
  for i, a := range (*A) {
    x := (*B)[i] - a
    D += x * x
  }
  return math.Sqrt(D)
}
func CrossPoint(A, B *[]float64, R float64) []*[]float64 {
  AB := Dist(A, B)
  C := math.Sqrt(4.0 * R * R / (AB * AB) - 1)
  x1 := (((*A)[0] + (*B)[0]) + ((*A)[1] - (*B)[1]) * C) / 2.0
  y1 := (((*A)[1] + (*B)[1]) - ((*A)[0] - (*B)[0]) * C) / 2.0
  x2 := (((*A)[0] + (*B)[0]) - ((*A)[1] - (*B)[1]) * C) / 2.0
  y2 := (((*A)[1] + (*B)[1]) + ((*A)[0] - (*B)[0]) * C) / 2.0
  p1 := []float64{x1, y1}
  p2 := []float64{x2, y2}
  return []*[]float64{&p1, &p2}
}

func main() {
  N := NextInt()
  P := make([]*[]float64, N)
  for i := range P {
    p := NextFloatVec()
    P[i] = &p
  }
  D := make([][]float64, N)
  for i := range D {
    D[i] = make([]float64, N)
    for j := range D[i] {
      D[i][j] = Dist(P[i], P[j])
    }
  }
  R := math.Sqrt(2.0 * 500.0 * 500.0)
  r := 0.0
  diff := float64(1e-7)
  for diff < R - r {
    _r := (R + r) / 2.0
    Include := 0
    for i := 0; i < N - 1 && Include == 0; i++ {
      for j := i + 1; j < N && Include == 0 ; j++ {
        if 2.0 * _r < D[i][j] {
          Include = -1
          break
        }
        CP := CrossPoint(P[i], P[j], _r)
        if D[i][j] < _r {
          CP = append(CP, []*[]float64{P[i], P[j]}...)
        }
        for _, cp := range CP {
          inc := true
          for _, p := range P {
            if _r + diff < Dist(p, cp) {
              inc = false
              break
            }
          }
          if inc {
            Include = 1
            break
          }
        }
      }
    }
    if Include < 1 {
      r = _r
    } else {
      R = _r
    }
  }
  Write(R)
  Output()
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int h, w, k;
    cin >> h >> w >> k;
    char c[h][w];
    int t = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j <  w; j++) {
            cin >> c[i][j];
            if (c[i][j] == '#') t++;
        }
    }
    int fans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            int ans = 0;
            set<pii> s;
            for (int ii = 0; ii < h; ii++) {
                if (i & (1 << ii)) {
                    for (int jjj = 0; jjj < w; jjj++)
                        s.insert({ii, jjj});
                }
            }
            for (int jj = 0; jj < w; jj++) {
                if (j & (1 << jj)) {
                    for (int iii = 0; iii < h; iii++)
                        s.insert({iii, jj});
                }
            }
            for (auto i : s)
                ans += (c[i.fi][i.se] == '#');
            if (t - ans == k) {
                dbg(i, j)
                fans++;
            }
        }
    }
    cout << fans << endl;
    return 0;
}

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

int main(){

int N, mx=0, sum=0;
string ans;
cin >> N;
int L[N];

for(int i=0; i<N; i++){
  cin >> L[i];
  sum += L[i];
  mx = max(mx, L[i]);
}

ans = sum - mx > mx ? "Yes" : "No" ;

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

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

using namespace std;

string str;
int l;
bool res = false;

void solve(int g) {

	if (l - g < 5 && l - g != 0) return;
	else if (l - g == 0) {
		res = true;
		return;
	}

	if (str.find("dreamer", g) == g) solve(g + 7);

	if (str.find("eraser", g) == g) solve(g + 6);

	if (str.find("erase", g) == g) solve(g + 5);

	if (str.find("dream", g) == g) solve(g + 5);
	return;
}


int main() {
	cin >> str;
	l = str.size();

	int g = 0;
	int j = 0;
	/*while (1) {
		cout << g << endl;

		if (l - g < 5 && l-g !=0)break;
		else if (l - g == 0) {
			j = 1;
			break;
		}

		if (str.find("dreamer", g) ==g) {
			g += 7;
			continue;
		}
		else if (str.find("eraser", g) ==g) {
			g += 6;
			continue;
		}
		else if (str.find("erase", g) ==g) {
			g += 5;
			continue;
		}
		else if (str.find("dream", g) ==g) {
			g += 5;
			continue;
		}
		else break;
		
		
	}*/
	solve(0);
	if (res)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 896
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
// fscanf(STDIN, "%d %d %d", $n, $x, $t);
// fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $n);

# 処理部
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
for ($i = 0; $i * 1000 < $n; $i++) {
}

# 出力部
// echo $r . "\n";
echo ($i * 1000) - $n . "\n";


Measured memory_bytes: 16148
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= 9; ++i)
	{
		if (n % i != 0)
		{
			continue;
		}

		if (n / i <= 9)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main(){
    char a;
    cin >>a ;
    int d = a + '0';
    if(145<= d && d<=170) cout << "a" << endl;
    if(113<= d && d<=138) cout << "A" << endl;
}


Measured memory_bytes: 3632
using System;
using System.Text;

namespace Simultaneous_Equation
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            try
            {
                
                while (true)
                {
                    double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);


                    input[1] = input[1] / input[0];
                    input[2] = input[2] / input[0];

                    input[4] = input[4] - input[3] * input[1];
                    input[5] = input[5] - input[3] * input[2];

                    input[5] = input[5] / input[4];
                    input[2] = input[2] - input[5] * input[1];
                    sb.AppendLine(string.Format("{0:f3} {1:f3}", input[2], input[5]));
                }
                
                
                
            }
            catch
            {
                sb.Remove(sb.Length - 1, 1);
                Console.WriteLine(sb);
                Console.ReadLine();
            }
        }
    }
}



Measured memory_bytes: 9240
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

double a, b;

int main(){

    cin >> a >> b;

    cout << ceil((a+b)/2);







}

//g++ -std=c++14 comp.cpp -o b; ./b.exealso

Measured memory_bytes: 384
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-16 16:43:08
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=60,mod=1000000007;
i64 n,f[N][N],C[N][N];
i64 &Add(i64 &a,i64 b){ return a=(a+b)%mod; }
int main()
{
	n=read();
	fr(i,0,n) C[i][0]=C[i][i]=1;
	fr(i,1,n) fr(j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	f[1][n-1]=f[1][n]=1;
	fr(i,1,n-1) fr(j,-i,i) if(f[i][j+n])
		fr(k,i+std::max(std::abs(j),1),n) fr(d,0,k-i) if((j+d-(k-i-d))%2==0)
			Add(f[k][(j+d-(k-i-d))/2+n],f[i][j+n]*C[k][i]%mod*C[k-i][d]);
	printf("%d\n",int(f[n][n]));
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a == b) {
    cout << "Draw" << endl;
    return 0;
  }

  if (a == 1) a += 13;
  if (b == 1) b += 13;
  cout << (a > b ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
b = []
for i in range(N):
    b.append(N - bisect.bisect_left(C,B[i]+1))
b.append(0)
for i in range(N-1,-1,-1):
    b[i] += b[i+1]
ans = 0
for i in range(N):
    ans += b[bisect.bisect_left(B, A[i]+1)]
print(ans)

Measured memory_bytes: 23156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;


int main(){
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll t1 = A*C, t2 = A*D, t3 = B*C, t4 = B*D;
    cout << max(t1, max(t2, max(t3, t4))) << endl; 
}



Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int data[4];
  int tmp = N % 10;
  N = N / 10;
  data[0] = tmp;
  for (int i = 0; i < 3; i++)
  {
    tmp = N % 10;
    N = N / 10;
    data[i + 1] = tmp;
  }
  if(data[1]==data[0]&&data[1]==data[2])
    cout << "Yes" << endl;
  else if(data[2]==data[3]&&data[2]==data[1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char map[13][13];

void dfs(int x, int y)
{
	
	map[x][y] = '0';
	
	if (0 <= x + 1 && x + 1 < 12 && map[x + 1][y] == '1'){
		dfs(x + 1, y);
	}
	if (0 <= x - 1 && x - 1 < 12 && map[x - 1][y] == '1'){
		dfs(x - 1, y);
	}
	if (0 <= y + 1 && y + 1 < 12 && map[x][y + 1] == '1'){
		dfs(x, y + 1);
	}
	if (0 <= y - 1 && y - 1 < 12 && map[x][y - 1] == '1'){
		dfs(x, y - 1);
	}
	
	return;
}


int main(void)
{
	
	int w, l, island;
	char c;
	
	
	while (1){
		
		island = 0;
		for (w = 0; w < 12; w++){
			if (scanf("%s", map[w]) == EOF){
				return (0);
			}
		}
		
		
		for (w = 0; w < 12; w++){
			for (l = 0; l < 12; l++){
				
				if (map[w][l] == '1'){
					dfs(w, l);
					island++;
				}
			}
		}
		printf("%d\n", island);
		
	}
	
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> edge(N+1);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back({b, i});
        edge[b].push_back({a, i});
    }
    int M;
    cin >> M;
    vector<ll> route(M);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        queue<pair<pair<int, int>, ll>> q;
        q.push({{u, -1}, 0});
        while (!q.empty()) {
            int now = q.front().first.first;
            int par = q.front().first.second;
            ll r = q.front().second;
            q.pop();
            if (now == v) {
                route[i] = r;
                break;
            }
            for (auto p : edge[now]) {
                if (p.first == par) continue;
                q.push({{p.first, now}, r+(1LL<<p.second)});
            }
        }
    }
    vector<ll> bit(1LL << M, 0);
    for (int i = 1; i < (1LL<<M); i++) {
        for (int j = 0; j < M; j++) {
            if ((i>>j)&1) {
                bit[i] = bit[i-(1LL<<j)] | route[j];
                break;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1LL<<M); i++) {
        int t = 0, u = 0;
        for (int j = 0; j < N; j++) {
            if ((bit[i]>>j)&1) t++;
        }
        for (int j = 0; j < M; j++) {
            if ((i>>j)&1) u++;
        }
        if (u%2 == 0) ans += (1LL << (N-1-t));
        else ans -= (1LL << (N-1-t));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8448
#ABC114 D
#N!の約数のうち, ちょうど約数を75個もつものは何個あるか?
#ただしNは1以上100以下
#
#愚直な方針1:
#Nを素因数分解する
#N!を素因数分解する
#それぞれの約数をDiとおき,Diの約数の個数を求める
#Diの約数の個数が75個であるものを数える
#
#考える(1):
#ある整数Mに対し,Mの約数の個数は?
#こたえはM=Π(pi**qi)と素因数分解できたとき,Π(qi+1)
#ところで75 = 3 * 5 * 5である
#つまり整数Mが約数を75個もつならば,Mの素因数分解は
#	M = p1**2 * p2**4 * p3**4
# M = p1**4 * p2**14
# M = p1**2 * p2**24
# M = p1**74
#のどれかになるはずである(各pの大小は問わない)
#
#
#愚直な方針2:
#Nを素因数分解する
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
nprimes = {}
for prime in primes:
	nprimes[prime] = 0

#N!を素因数分解する
for N in range(int(input())):
	if N==0:
		continue
	else:
		M = N+1
		for prime in primes:
			if M < prime:
				break
			else:
				while True:
					if M % prime != 0:
						break
					else:
						M = int(M / prime)
						nprimes[prime] += 1

#N!を素因数分解した結果をΠ(pi**qi)とおく
#print(list(nprimes.values()))

#次の場合の数を合計する
#[1]M = p1**74 とするときの素数p1の選び方
#			これはqi>=74をみたすiの個数に等しい
#[2]M = p1**2 * p2**24 とするときの素数p1,p2の選び方
#			素数p2の選び方は, qi>=24をみたすiの個数に等しい
#		  素数p1の選び方は, qj>=2をみたすjの個数-1に等しい
#			よってこたえはこれら2つの積
#[3]M = p1**4 * p2**14 とするときの素数p1,p2の選び方
#			素数p2の選び方は, qi>=14をみたすiの個数に等しい
#		  素数p1の選び方は, qj>=4をみたすjの個数-1に等しい
#			よってこたえはこれら2つの積
#		  (qj>=4 であるすべてのj(ただしj!=i)に対して,qj-3の合計)
#[4]M = p1**2 * p2**4 * p3**4 とするときの素数p1,p2,p3の選び方
#			素数p2,p3の選び方は, qi>=4をみたすiの個数をIとするとI*(I-1)/2
#		  素数p1の選び方は, qj>=2をみたすjの個数-2に等しい
#			よってこたえはこれらの積
#
#準備として,
#qiが2-3であるiの個数をxとする
#qiが4-13であるiの個数をyとする
#qiが14-23であるiの個数をzとする
#qiが24-73であるiの個数をwとする
#qi>=74をみたすiの個数をvとする

nums = [0,0,0,0,0] #x,y,z,w,v

for i in list(nprimes.values()):
	if i >= 74:
		nums[4] += 1
	elif i >= 24:
		nums[3] += 1
	elif i >= 14:
		nums[2] += 1
	elif i >= 4:
		nums[1] += 1
	elif i >= 2:
		nums[0] += 1

x,y,z,w,v = nums

#[1]M = p1**74 とするときの素数p1の選び方
#			これはqi>=74をみたすiの個数に等しい
result = 0
result += v
#[2]M = p1**2 * p2**24 とするときの素数p1,p2の選び方
#			素数p2の選び方は, qi>=24をみたすiの個数に等しい
#		  素数p1の選び方は, qj>=2をみたすjの個数-1に等しい
#			よってこたえはこれら2つの積
result += (w+v)*(x+y+z+w+v-1)
#[3]M = p1**4 * p2**14 とするときの素数p1,p2の選び方
#			素数p2の選び方は, qi>=14をみたすiの個数に等しい
#		  素数p1の選び方は, qj>=4をみたすjの個数-1に等しい
#			よってこたえはこれら2つの積
#		  (qj>=4 であるすべてのj(ただしj!=i)に対して,qj-3の合計)
result += (z+w+v)*(y+z+w+v-1)
#[4]M = p1**2 * p2**4 * p3**4 とするときの素数p1,p2,p3の選び方
#			素数p2,p3の選び方は, qi>=4をみたすiの個数をIとするとI*(I-1)/2
#		  素数p1の選び方は, qj>=2をみたすjの個数-2に等しい
#			よってこたえはこれらの積
result += (y+z+w+v)*(y+z+w+v-1)*(x+y+z+w+v-2)/2
print(int(result))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define lb lower_bound
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
#define pc __builtin_popcount
using namespace std;

void solve()
{
    ll i,j=0,r=200,p,q,k,d,y=0,h,flag=1,n,m=0,a=hell,b=hell,h1,h2,a1,b1,a2,w,x,u,f,l,c,z;
    cin>>n>>m;
    cout<<max(0LL,n-2*m);


}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuffer s = new StringBuffer();
		s.append(sc.next());
		String S = s.reverse().toString();
		S = S.replaceAll("resare", "");
		S = S.replaceAll("esare", "");
		S = S.replaceAll("remaerd", "");
		S = S.replaceAll("maerd", "");
		if(S.length() != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


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

// 
// auto mod int
//
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint d[100005];

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

    d[0] = -1;
    for(int i=1; i<=k; i++) {
        mint x = k/i;
        d[i] = x.pow(n);
    }

    for(int i=k-1; i>=1; i--) {
        for(int j=2*i; j<=k; j+=i) {
            d[i] -= d[j];
        }
    }

    mint ans = 0;
    for (int i=1; i<=k; i++) {
        mint x = 1;
        x *= i;
        x *= d[i];
        ans += x;
    }

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


Measured memory_bytes: 4376
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==5 && B==5 && C==7)
        printf("YES\n");
    else if(A==5 && B==7 && C==5)
        printf("YES\n");
    else if(A==7 && B==5 && C==5)
        printf("YES\n");
    else
        printf("NO\n");
}


Measured memory_bytes: 128
#include <iostream>
    #include <vector>
    #include <algorithm>
     
    const int MAX_N = 200000;
    int N, Q;
    std::vector<int> v[MAX_N];
    std::vector<int> w[MAX_N];
    std::vector<long long> count(MAX_N,0);
     
    void add(int p, int x){
       count[p] += x;
       for(int i=0; i<v[p].size(); ++i){
          add(v[p][i], count[p]);
       }
    }
     
    int main(){
       std::cin >> N >> Q;
       int a, b;
       for(int i=0; i<N-1; ++i){
          std::cin >> a >> b;
          a--; b--;
          v[a].push_back(b);
          //v[b].push_back(a);
       }
     
       int p;
       int x;
       for(int i=0; i<Q; ++i){
          std::cin >> p >> x;
          p--;
          count[p] += x;
       }
       add(0, 0);
     
       for(int i=0; i<N; ++i)
          std::cout << count[i] << ' ';
       std::cout << std::endl;
       return 0;
     
    }

Measured memory_bytes: 28928
#include <iostream>
#include <string>
using namespace std;
int main(){
  string a,b;
  cin>>a;
  cin>>b;
  if(a[0]==b[2]&&a[2]==b[0]&&a[1]==b[1]){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
 
}



Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

}


Measured memory_bytes: 35980
import sys
import math
from collections import deque


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = instrl()

B = deque()

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.insert(0,A[i])
else:
    for i in range(n):
        if i % 2 == 0:
            B.insert(0,A[i])
        else:
            B.append(A[i])

print(" ".join(B))

Measured memory_bytes: 116840
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long maxn = 200005;

    static void solve() {
        char a[] = sn().toCharArray();
        char b[] = sn().toCharArray();
        char c[] = sn().toCharArray();
        int n = a.length;
        int m = b.length;
        int k = c.length;
        Stack<Character> arr[] = new Stack[3];
        for (int i = 0; i < 3; i++) {
            arr[i] = new Stack<>();
        }
        for (int i = n - 1; i >= 0; i--)
            arr[0].push(a[i]);
        for (int i = m - 1; i >= 0; i--)
            arr[1].push(b[i]);
        for (int i = k - 1; i >= 0; i--)
            arr[2].push(c[i]);
        int cur = 0;
        char ans[] = {'A', 'B', 'C'};
        while (!arr[0].isEmpty() || !arr[1].isEmpty() || !arr[2].isEmpty()) {
            if (arr[cur].isEmpty()) {
                out.println(ans[cur]);
                return;
            }
            char ch = arr[cur].pop();
            cur = (ch == 'a') ? 0 : ((ch == 'b') ? 1 : 2);
        }

    }
}

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

using namespace std;

int main()
{

   int a, b, c;

   cin >> a >> b >> c;

   int cnt = 0;

   if(a == b)
     cnt++;
    if(b == c )
       cnt++;
    if(a == c)
      cnt++;

      if(cnt >= 1 && cnt < 3)
        cout << "Yes" << endl;
      else
         cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
  return;
}
void maxHeapify(int i){
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l<=H && A[l]>A[i])largest = l;

  else largest = i;
  if(r<=H && A[r] > A[largest])largest = r;
  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;
 scanf("%d",&H);

  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){

    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3684
n,k = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

# dp = Array.new(n, 0)
dp = [0,0]

for i in 2..n
  # dp[i] = dp[i-1] + (hs[i-2] - hs[i-1]).abs
  # dp << dp[i-1] + (hs[i-2] - hs[i-1]).abs
  min = dp[i-1] + (hs[i-2] - hs[i-1]).abs
  for j in (1..[i-1,k].min)
    tmp = dp[i-j] + (hs[i-j-1] - hs[i-1]).abs
    # dp[i] = tmp if dp[i] > tmp
    # if dp[i] > tmp
    #   dp[i] = tmp
    # end
    if min > tmp
      min = tmp
    end
  end
  dp << min
end

puts dp[n]


Measured memory_bytes: 13220
using System;
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long sum = 0;
            sum += n / 500 * 1000;
            sum += (n % 500) / 5 * 5;
            System.Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> ans(N);
    for(int i=2; i<=N; i++) {
        int A;
        cin >> A;
        ans[--A]++;
    }

    for(auto e: ans){
        cout << e << '\n';
    }
    return 0;
}


Measured memory_bytes: 4024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
        mut t: chars
    }
    let mut flag = false;

    for _ in 0..s.len() {
        if s == t {
            flag = true;
        }
        rotate(&mut t);
    }

    println!("{}", if flag {"Yes"} else {"No"});
    
    fn rotate(cs: &mut Vec<char>) {
        let c = cs.pop().unwrap();
        cs.insert(0, c);
    }
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n - 1, -1, -1):
    c = min(a[i + 1], b[i])
    ans += c
    d = min(a[i], b[i] - c)
    ans += d
    a[i] -= d
print(ans)


Measured memory_bytes: 82020
N = int( input() )
memo = [-1] * (N+1)

def LucasNumber( i ):
    if i == 0: return 2
    if i == 1: return 1
    if memo[i] == -1:
        memo[i] = LucasNumber( i-1 ) + LucasNumber( i-2 )
    return memo[i]

print( LucasNumber(N) )

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	vector<int> a(10);
	for(int i = 0; i < 4; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	bool can = true;
	for(int i = 0; i < 10; i++) {
		if(i == 4 || i == 9 || i == 7 || i == 1) {
			if(!a[i]) can = false;
		}
	}
	cout << (can ? "YES" : "NO" ) << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n ,o[100005] ,s[100005];
int main() 
{	
	while(cin>>n)
	{
		int ok=1;
		for(int i=0 ;i<n ;i++) cin>>o[i] ,s[i]=o[i];
		if(is_sorted(o ,o+n)){cout<<"Yes\n"; continue;}
		sort(s ,s+n);
		for(int i=0 ;i<n ;i++)		
			if(abs(o[i]-s[i])>1){ok=0; break;}
		if(ok) cout<<"Yes\n";
		else cout<<"No\n";
	}	
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
int k,n;int a[1100000];
signed main(){
  cin>>k>>n;
  rep(i,n)cin>>a[i];
  int sum = 0;
  rep(i,n-1)sum += a[i+1] - a[i];
  sum += a[0]+k-a[n-1];
  int ans = sum;
  rep(i,n-1){
    chmin(ans, sum-(a[i+1]-a[i]));
  }
  chmin(ans, sum-(a[0]+k-a[n-1]));
  cout << ans << endl;
}


Measured memory_bytes: 1920
package main

import "fmt"

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

	var x, max int
	for _, v := range s {
		switch v {
		case 'I':
			x++
		case 'D':
			x--
		}

		if x > max {
			max = x
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
char s[101];
int main(void){
    scanf("%s",s);
    int res=0;
    int n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-1-i]) res++;
    }
    printf("%d\n",res/2);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(void){
    int H,W,dp[50][50]={};
    char ch[50][50];
    cin>>H>>W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin>>ch[i][j];
            ch[i][j]-='0';
        }
    }
    for(int i=1; i<H; i++){
        dp[i][0]=dp[i-1][0]+ch[i][0];
    }
    for(int j=1; j<W; j++){
        dp[0][j]=dp[0][j-1]+ch[0][j];
    }
    for(int i=1; i<H; i++){
        for(int j=1; j<W; j++){
            dp[i][j]=min(dp[i-1][j],dp[i][j-1])+ch[i][j];
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 3132
r, c = map(int, input().split())
R = [0] * (c + 1)
i = 0
while i < r:
    n = list(map(int, input().split()))
    n.append(sum(n))
    R = [x + y for (x, y) in zip(R, n)]
    print(' '.join(map(str, n)))
    i += 1
print(' '.join(map(str, R)))

Measured memory_bytes: 7700
#include<stdio.h>
int main(void){
  char s[11];
  char t[12];
  int count=1;
  scanf("%s",s);
  scanf("%s",t);
  int i;
  for(i=0;s[i]!='\0';i++){
    if(s[i]!=t[i]){
    count=0;
    break;
    }
  }
  if(count==0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	var a,v,b,w,t int64

	fmt.Scan(&a)
	fmt.Scan(&v)
	fmt.Scan(&b)
	fmt.Scan(&w)
	fmt.Scan(&t)
	dist := a - b
	if dist < 0 {
		dist *= -1
	}
	// 最初から追いついていたら速度関係なし
	if (dist == 0) {
		fmt.Print("YES")
	}
	vec := v - w
	// 逃げる速さの方が早いなら追いつけない
	if vec <= 0 {
		fmt.Print("NO")
		return
	}
	if vec * t >= dist {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

Measured memory_bytes: 1816