akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <uint_fast64_t Mod>
struct modint {
  using u64 = uint_fast64_t;
  u64 n;

  modint(const u64 x = 0) : n(x % Mod) {}
  modint operator+(const modint r) const { return modint(*this) += r; }
  modint operator-(const modint r) const { return modint(*this) -= r; }
  modint operator*(const modint r) const { return modint(*this) *= r; }
  modint operator/(const modint r) const { return modint(*this) /= r; }
  modint &operator+=(const modint r) {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  modint &operator-=(const modint r) {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  modint &operator*=(const modint r) {
    n = n * r.n % Mod;
    return *this;
  }
  modint &operator/=(const modint r) { return *this *= r.inv(); }
  modint pow(u64 x) const {
    modint<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  modint inv() const { return pow(Mod-2); }
  friend ostream& operator<<(ostream& os, const modint& obj) { return os << obj.n; }
  friend istream& operator>>(istream& is, modint& obj) { return is >> obj.n; }
};
constexpr ll mod = 1000000007;
using mint = modint<mod>;

// T modint
template<class T>
struct Combination {
  vector<T> fact, inv_fact;
  Combination(ll n) : fact(n+1), inv_fact(n+1) {
    fact[0] = T(1);
    for (ll i = 1; i <= n; i++) fact[i] = fact[i-1] * static_cast<T>(i);
    inv_fact[n] = fact[n].inv();
    for (ll i = n; i > 0; i--) inv_fact[i-1] = inv_fact[i] * static_cast<T>(i);
  }

  T P(ll n, ll k) const {
    return fact[n] * inv_fact[n-k];
  }

  T C(ll n, ll k) const {
    return fact[n] * inv_fact[n-k] * inv_fact[k];
  }

  T H(ll n, ll k) const {
    return C(n+k-1, n-1);
  }
};

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

  ll k;
  mint n, m;
  cin >> n >> m >> k;
  mint ans(0);
  Combination<mint> comb(n.n*m.n);
  rep(i, n.n) {
    mint dis(i);
    ans += dis * m*m * (n-dis) * comb.C(n.n*m.n-2, k-2);
  }
  rep(i, m.n) {
    mint dis(i);
    ans += dis * n*n * (m-dis) * comb.C(n.n*m.n-2, k-2);
  }
  cout << ans << endl;

}











































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


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

    int n,k;
    cin >> n >> k;
    if( 2*k-1 <= n ){
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S[0] == S[1] | S[1] == S[2] | S[2] == S[3])
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, d1, d2;
  cin >> N;
  bool f = false;
  int c = 0;
  for (int i=0; i<N; i++){
    cin >> d1 >> d2;
    if (d1 == d2) c++;
    else c = 0;
    
    if (c >= 3) f = true;
  }
  cout << (f ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 3632
from functools import reduce
N,X=map(int,input().split())
Lx=list(map(int,input().split()))
Lxabs=[]
for i in Lx:Lxabs.append(abs(i-X))

def gcd(a,b):
    while b:a,b=b,a%b
    return a

def multigcd(List):
    return reduce(gcd,List)
        
print (multigcd(Lxabs))


Measured memory_bytes: 14596
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> x(n),count(m,0),max(m,0);
  rep(i,0,n)std::cin>>x[i];

  std::sort(all(x));

  ll prv=x[0],temp=0;
  rep(i,0,n){
    if(prv!=x[i]){
      max[prv%m]+=temp/2;
      temp=1;
      prv=x[i];
    }else{
      temp++;
    }
    count[x[i]%m]++;
  }
  max[prv%m]+=temp/2;

  ll ans=count[0]/2+((m%2==0)?count[m/2]/2:0);

  rep(i,1,(m+1)/2){
    ll temp1,temp2,same;
    if(count[i]>count[m-i]){
      temp1=count[m-i];temp2=count[i];
      same=max[i];
    }else{
      temp1=count[i];temp2=count[m-i];
      same=max[m-i];
    }

    ans+=temp1;
    ans+=std::min((temp2-temp1)/2,same);
  }

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 2560
import fractions
import math
A, B = map(int,input().split())
cf=fractions.gcd(A,B)
a =[1]
tmp = int(math.sqrt(cf)) + 1
for i in range(2,tmp):
    while cf% i ==0:
        cf//=i
        a.append(i)
a.append(cf)
#print(a)
print(len(set(a)))

Measured memory_bytes: 5048
function main(input) {
  var S = input[0];
  var N = S.length;

  var resCount = 0;
  if(palindrome(N, S)){
  	resCount +=1;
  };
  
  var headS = S.slice(0, (N-1)/2);
  if(palindrome(headS.length, headS)){
    resCount +=1;
  }
  
  var TailS = S.slice((N +3)/2 -1, N);
  if(palindrome(TailS.length, TailS)){
    resCount +=1;
  }
  
  if(resCount === 3){
  	console.log('Yes');
  }else{
  	console.log('No');
  }  
}

function palindrome(N, S){
  
    var mid = Math.floor(N/2);
	for ( var i = 0; i < mid; i++ ) {
    if (S[i] !== S[N - 1 - i]) {
      return false;
    }
  }

  return true;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> coins(m);
    for(int i = 0; i < m; i++){
        cin >> coins[i];
    }
    vector<vector<ll>> dp(m + 1, vector<ll>(n + 1, INF));
    for(int i = 0; i <= m; i++) dp[i][0] = 0;
    for(int i = 1; i <= m; i++){
        int coin = coins[i - 1];
        for(int j = 1; j <= n; j++){
            if(coin > j){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = min(dp[i - 1][j], dp[i][j - coin] + 1);
            }
        }
    }
    /*for(int i = 0; i <= m; i++){
        cout << "\n";
        for(int j = 0; j <= n; j++){
            cout << dp[i][j] << " ";
        }
    }*/
    cout << dp[m][n] << "\n";
}


Measured memory_bytes: 11536
n = int(input())
a = list(map(int,input().split()))

sum1 = abs(a[0]) + abs(a[-1])
for i in range(n-1):
    sum1 += abs(a[i] - a[i+1])

for i in range(n):
    ans = sum1
    if i == 0:
        ans -= abs(a[0]) + abs(a[1] - a[0])
        ans += abs(a[1])
        print(ans)
    elif i == n-1:
        ans -= abs(a[-1]) + abs(a[-1] - a[-2])
        ans += abs(a[-2])
        print(ans)
    else:
        ans -= abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])
        ans += abs(a[i-1] - a[i+1])
        print(ans)


Measured memory_bytes: 14048
<?php
// Your code here!
$ans = 0;
$input=array(); // 道の情報配列
$max = array(); // 各つながる展望台の最大高さ

fscanf(STDIN,"%d %d",$N,$M);
$H=explode(' ',trim(fgets(STDIN)));

// 配列の初期値を0に設定
for($i=0; $i<$N; ++$i){
    $max[$i]=0;    
}

for($i=0; $i<$M; ++$i){
    fscanf(STDIN,"%d %d",$a,$b);
    $max[$a-1] = max($max[$a-1], $H[$b-1]);
    $max[$b-1] = max($max[$b-1], $H[$a-1]);
}

for($i=0;$i<$N;++$i){
    if($H[$i]>$max[$i]){
        $ans+=1;
    }
}

echo $ans;
?>

Measured memory_bytes: 28036
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const ull INF3 = 18000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	ll n, p, a[51], odd = 0, even = 0, ans = 0;
	std::cin >> n >> p;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
		if (a[i] % 2 == 0)even++;
		else odd++;
	}
	if (odd==0) {
		if (p == 1)ans = 0;
		else ans = std::pow(2, even);
	}
	else {
		ans = std::pow(2, n - 1);
	}
	std::cout << ans << std::endl;
}

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

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

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;

int main() {
	int W, H, x, y; cin >> W >> H >> x >> y;

	double ans = (double)W * H / 2;
	double halfX = (double)W / 2;
	double halfY = (double)H / 2;
	if (halfX == (double)x && halfY == (double)y) {
		cout << fixed << setprecision(15) << ans << " " << 1;
	}
	else cout << fixed << setprecision(15) << ans << " " << 0;
}

Measured memory_bytes: 256
import math
x,n=map(int,input().split())
if n==0:
  p=[]
else:
  p=list(map(int,input().split()))
p_sort=sorted(p)
result={}
for i in range(100+2):
  if not i in p_sort:
    result[i]=abs(x-i)
print(min(result, key=result.get))


Measured memory_bytes: 9192
#include <iostream>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<int, int> pii;
int const dx[] = {1,0,-1,0};
int const dy[] = {0,1,0,-1};

char mat[20][20];
int dis[11][20][20];
int m;
vector<int> px, py;
int done[11];
int ans;
int sp;

void rec(int n, int np, int len)
{
  if (n == m) {
    
    ans = min(len, ans);
    return;
  }
  for (int i=0; i<m; i++) {
    if (!done[i]) {
      if (len+dis[np][px[i]][py[i]] < ans) {
        done[i] = 1;
        rec(n+1, i, len+dis[np][px[i]][py[i]]);
        done[i] = 0; 
        // cout << ret << endl;;
      }
    }
  }
  return;
}

int main()
{
  int w, h;
  while (cin >> w >> h && (w || h)) {
    int sx, sy, sp;
    // char mat[w][h];
    px.clear(); py.clear();
    string str;
    m = 0;
    for (int i=0; i<h; i++) {
      cin >> str;
      for (int j=0; j<w; j++) {
        char x = str[j];
        if (x == 'o') {
          sx = j; sy = i;
          sp = m;
          x = '*';
        }
        if (x == '*') {
          px.push_back(j);
          py.push_back(i);
          m++;
        }
        mat[j][i] = x;
      }
    }
    // for (int i=0; i<h; i++) {
    //   for (int j =0; j<w; j++) {
    //     cout << mat[j][i];
    //   }
    //   cout << endl;
    // }
    // cout << endl;
    // ツ仰猟猟」ツ行ツ療アツづ個催ャツ青ャ
    // int dis[10][w][h];
    memset(dis, 0, sizeof(dis));
    for (int i=0; i<m; i++) {
      queue<pii> Q;
      Q.push(pii(px[i],py[i]));
      while (!Q.empty()) {
        int x = Q.front().first;
        int y = Q.front().second;
        Q.pop();
        for (int k=0; k<4; k++) {
          int xx = x + dx[k];
          int yy = y + dy[k];
          if ((xx < 0 || xx >= w) || (yy < 0 || yy >= h)) continue;
          if (mat[xx][yy] == 'x') continue;
          if (dis[i][xx][yy] != 0 || (xx == px[i] && yy == py[i])) continue;
          dis[i][xx][yy] = dis[i][x][y] + 1;
          Q.push(pii(xx,yy));
        }
      }
    }
    // for (int k = 0; k<m; k++) {
    //   for (int i=0; i<h; i++) {
    //     for (int j =0; j<w; j++) {
    //       cout << dis[k][j][i] << " ";
    //     }
    //     cout << endl;
    //   }
    //   cout << endl;
    // }
    int f = 0;
    for (int i = 0; i < m; i++) {
      if (dis[sp][px[i]][py[i]] == 0 && (i != sp)) {
        cout << -1 << endl;
        f = 1;
        break;
      }
    }
    if (f) continue;
    
    memset(done,0,sizeof(done));
    done[sp] = 1;
    ans = 10000;
    rec(1, sp, 0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 948
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()

	val, err := strconv.Atoi(sc.Text())

	if err != nil {
		fmt.Println(err)
	}
	return val
}

func main() {
	N := next()
	ans := make([]int, 10050)

	n := math.Sqrt(float64(10050))

	for x := 1.0; x < n; x++ {
		for y := 1.0; y < n; y++ {
			for z := 1.0; z < n; z++ {
				v := math.Pow(x, 2.0) + math.Pow(y, 2.0) + math.Pow(z, 2.0) + x*y + y*z + x*z
				if v < 10050 {
					ans[int(v)]++
				}
			}
		}
	}

	for i := 1; i < N+1; i++ {
		fmt.Println(ans[i])
	}
}

Measured memory_bytes: 2012
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1e9+7)
#define mset(a,k) memset(a,k,sizeof(a))
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
#define vvii vector<vii>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void out(vi a)							{for (int i = 0; i < (ll)a.S; i++) { cout << a[i] << " "; } cout << endl;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void out1(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
const ll MAXN = (ll)(1 * 1e6 + 5 ), level = 22;

void solve()
{
	ll n, x, k;
	cin >> n >> x >> k;
	cout << ((ll)ceil(n / (x * 1.0)))*k << '\n';
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen ("inp4.txt", "r", stdin);
	freopen ("out4.txt", "w", stdout);
#endif
	fast();
	ll t = 1;
	//cin >> t;
	fr(i, 0, t)
	{
		solve();
	}
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
   bool checkt1=false;
   bool checkt2=false;
   // YYMM
   if (s[2]=='1')
        if (s[3] <= '2') checkt1 = true;
    if (s[2]=='0')
        if (s[3]<='9' && s[3]>'0') checkt1 = true;
    // MMYY
   if (s[0]=='1')
        if (s[1] <= '2') checkt2 = true;
    if (s[0]=='0')
        if (s[1] <= '9' && s[1]>'0') checkt2 = true;
    if (checkt1==checkt2){
        if (checkt1==true) cout << "AMBIGUOUS";
        if (checkt1==false) cout << "NA";
    } else {
        if (checkt1==true) cout << "YYMM"; else cout << "MMYY";
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
    // end

    return 0;
}


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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solver() {
  int p = input();
  
  vector< int > a(p);
  cin >> a;

// 入力時modに対応しようね！
  vector< int > fact(p + 1), finv(p + 1), invs(p + 1);
  invs[1] = 1;
  fact[0] = fact[1] = finv[0] = finv[1] = 1;
  range(i, 2, p + 1) {
    invs[i] = p - invs[p % i] * (p / i) % p;
    fact[i] = 1ll * fact[i - 1] * i % p;
    finv[i] = finv[i - 1] * invs[i] % p;
  }

  auto Ct = [&](int a, int b) {
    if (a < b) return 0;
    return int(1ll * fact[a] * (1ll * finv[b] * finv[a - b] % p) % p);
  };

  auto mod_pow = [&](int a, int x) {
    int64 res = 1;
    for (; x; x >>= 1) {
      if (x & 1) (res *= a) %= p;
      (a *= a) %= p;
    }
    return int(res);
  };


  vector< int > b(p);

  range(i, 0, p) {
    if (a[i] == 0) continue;
    
    range(j, 0, p) {
      (b[j] -= 1ll * mod_pow(-i, p - 1 - j) * Ct(p - 1, j) % p) %= p;
      if (b[j] < 0) b[j] += p;
    }

    (b[0] += 1) %= p;
  }

  cout << b << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    vector<int> a(N);
    ll s = 0;
    REP(i, N) {
        cin >> a[i];
        s += a[i];
    }
    sort(ALL(a), greater<>());

    if (4 * M * a[M-1] < s) cout << "No" <<endl;
    else cout << "Yes" << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
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;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
bool check(ll s){
    bool sev=false,five,three;
    five=sev;three=sev;
    while(s){
        if(s%10==3)three=true;
        else if(s%10==5)five=true;
        else if(s%10==7)sev=true;
        s/=10;
    }
    return (three&&five&&sev);
}
int main( ){
    int n;
    cin>>n;
    ll cnt=0;
    queue<pair<ll,bool>> q;
    int res[]={3,5,7};
    q.emplace(0,false);
    while(!q.empty()){
        pair<ll,bool>t=q.front();
        bool b=t.second;
        ll s=t.first;
        q.pop();
        if(s>n)break;
        if(b)cnt++;
        rep(i,0,3){
            ll alt=s*10+res[i];
            bool c=b;
            if(b==false)c=check(alt);
            q.emplace(alt,c);
        }
    }
    cout<<cnt<<endl;
    return 0;
}




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

int main(){
	ll n, k; cin >> n >> k;
	ll po[(int)1e5] = {};
	for(ll i = 0; i < n; ++i){
		ll a, b; cin >> a >> b;
		po[--a] += b;
	}
	ll sum = 0;
	for(ll i = 0; i < (int)1e5; ++i){
		sum += po[i];
		if(sum >= k){
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
n, *a = map(int, open(0))
if a[0] or any(c - b > 1 for b, c in zip(a, a[1:])):exit(print(-1))
b = ans = 0
for c in a[1:]:
  ans += b * (c - b != 1)
  b = c
print(ans + b)

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

int main(){
    int N, M, Q;
    scanf("%d %d %d\n", &N, &M, &Q);
    vector<string> grid(N+1, "0");
    grid[0].resize(M);
    for (int i = 1; i <= N; i++) {
        char s[M];
        scanf("%s\n", s);
        grid[i] += s;
    }
    vector<vector<int>> psum(N+1, vector<int>(M+1, 0));
    vector<vector<int>> horsum(N+1, vector<int>(M+1, 0));
    vector<vector<int>> versum(N+1, vector<int>(M+1, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (grid[i][j] == '1') {
                psum[i][j]++;
                if (grid[i][j-1] == '1') horsum[i][j]++;
                if (grid[i-1][j] == '1') versum[i][j]++;
            }
            psum[i][j] += psum[i][j-1] + psum[i-1][j] - psum[i-1][j-1];
            horsum[i][j] += horsum[i][j-1] + horsum[i-1][j] - horsum[i-1][j-1];
            versum[i][j] += versum[i][j-1] + versum[i-1][j] - versum[i-1][j-1];
        }
    }
    
    for (int z = 0; z < Q; z++) {
        int x1, x2, y1, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int ps = psum[x2][y2] - psum[x1-1][y2] - psum[x2][y1-1] + psum[x1-1][y1-1];
        int hors = horsum[x2][y2] - horsum[x1-1][y2] - horsum[x2][y1] + horsum[x1-1][y1];
        int vers = versum[x2][y2] - versum[x1][y2] - versum[x2][y1-1] + versum[x1][y1-1];
        printf("%d\n", ps - hors - vers);
    }
    
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pic = pair<int, char>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

ll mod = 1e9+7;

vector<ll> fac(2010); //n!(mod mod)
vector<ll> ifac(2010); //k!^{mod-2} (mod mod)

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<2005; i++){
        fac[i+1] = fac[i]*(i+1) % mod; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{M-2} (mod M)
    }

    ll n,k;
    cin>>n>>k;
    for (ll ope = 1; ope <= k; ope++)
    {
        ll bkouho = ope;
        ll rkouho = ope-1;
        ll bamari = k-ope;
        ll aamari = (n-k) - (ope-1);
        if(bamari<0 || aamari<0)
        {
            cout<<0<<endl;
            continue;
        }
        ll bcmb = max(1LL,comb(bamari + ope-1, ope-1)%mod);
        ll acmb = max(1LL, comb(aamari+ope, ope)%mod);
        ll ans = acmb*bcmb;
        ans%=mod;
        //cout<<acmb<<" "<<bcmb<<endl;
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
using namespace std;
typedef pair<int,int> P;

const int W_MAX = 1000;
const int N_MAX = 1000;

int v[N_MAX + 1], w[N_MAX + 1];
int N,W;
P memo[N_MAX + 1][W_MAX +1];

P bfs(int i, int j)
{
	if(i == N)return P(0,0);
	if(memo[i][j] >= P(0,0)){
		return memo[i][j];
	}
	P p;
	if(w[i] > j){
		p = bfs(i+1,j);
	}
	else{
		P p1,p2;
		p1 = bfs(i + 1,j);
		p2 = bfs(i + 1,j - w[i]);
		p2.first += v[i];p2.second += w[i];
		if(p1.first == p2.first){
			if(p1.second < p2.second){
				p = p1;
			}
			else{
				p = p2;
			}
		}
		else{
			p = max(p1,p2);
		}
	}
	return memo[i][j] = p;
}

int main()
{
	int c = 1;
	while(cin >> W,W){
		cin >> N;
		fill((P*)memo,(P*)(memo+N_MAX+1),P(-1,-1));
		for(int i = 0; i < N; ++i){
			cin >> v[i]; cin.ignore(1,','); cin >> w[i];
		}
		cout << "Case " << c++ << ':' << endl;
		P p = bfs(0,W);
		cout << p.first << endl << p.second << endl;
	}
}

Measured memory_bytes: 9092
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x) {
		if (a + b >= x) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if((i&1)&&(a[i]&1))cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,k; cin >> n >> k;
  double res=0;
  vector<ll> d(65,1);
  rep(i, SIZE(d)-1){
    d[i+1]=d[i]*2;
    debug(d[i+1]);
  }
  repz(i,1,n+1){
    ll point=(i+k-1)/i;
    debug(i,point);
    rep(j,SIZE(d)){
      if(point<=d[j]){
        res+=1/double(n*d[j]);
        debug(i, d[j]);
        break;
      }
    }
  }
  cout << fixed << setprecision(15) <<  res << endl;
  return 0;
}


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

namespace Keyence
{
    class D
    {
        static void Main(string[] args)
        {
            const int _Mod = 1000000007;
            string[] s0 = Console.ReadLine().Split(' ');
            int N = int.Parse(s0[0]);
            int M = int.Parse(s0[1]);
            List<int> A = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToList();
            List<int> B = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToList();
            A.Sort();
            B.Sort();

            for(int i = 0; i < N - 1; i++)
            {
                if (A[i] == A[i + 1])
                {
                    Console.WriteLine("0");
                    return;
                }
            }
            for (int i = 0; i < M - 1; i++)
            {
                if (B[i] == B[i + 1])
                {
                    Console.WriteLine("0");
                    return;
                }
            }

            HashSet<int> SA = new HashSet<int>(A);
            HashSet<int> SB = new HashSet<int>(B);
            

            int amax = SA.Last(), bmax = B.Last();
            if (amax != bmax)
            {
                Console.WriteLine("0");
                return;
            }
            int max = amax;

            long counter = 1;
            int occupied = 0;
            int[,] c = new int[N, M];
            int x = 0, y = 0;

            for (int i = max; i > 0; i--)
            {
                if (SA.Count>0 && SA.Last() == i && SB.Count>0 && SB.Last() == i)
                {
                    x++; y++;
                    occupied++;
                    SA.Remove(i);SB.Remove(i);
                }
                else if (SA.Count>0 && SA.Last() == i)
                {
                    counter = counter*y;
                    occupied++;
                    x++;
                    SA.Remove(i);
                }
                else if (SB.Count>0 && SB.Last() == i)
                {
                    counter = counter * x; // (x - ox);
                    occupied++;
                    y++;
                    SB.Remove(i);

                }
                else
                {
                    if (occupied >= x*y)
                    {
                        goto label1;
                    }
                    counter = counter * (x * y - occupied);
                    occupied++;
                }
                counter %= _Mod;
            }



            Console.WriteLine(counter);
            return;

        label1:
            Console.WriteLine("0");

        }
    }
}


Measured memory_bytes: 15584
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)
     { if(s[i]==s[i+1])
     {cout<<i+1<<" "<<i+2;return 0;}
     if(s[i]==s[i+2])
     { cout<<i+1<<" "<<i+3;
      return 0;}}
    if(s[s.size()-1]==s[s.size()-2])
       cout<<s.size()-1<<" "<<s.size();
    else
       cout<<-1<<" "<<-1;

    return 0;
}


Measured memory_bytes: 512
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
        k: usize,
    }

    let mut ans = 0;
    let mut cnt = k;
    for i in 0..s.len() {
        if s[i]=='1' {
            ans = 1;
            cnt -= 1;
            if cnt==0 {
                break;
            }
        } else {
            ans = s[i].to_digit(10).unwrap();
            break;
        }
    }
    if ans==0 {
        ans = 1;
    }

    println!("{}", ans);

}


Measured memory_bytes: 2168
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var p = new List<int>();
        var ret = new int[n];
        GeneratePrime(p, 55555);
        var count = 0;
        foreach (var x in p)
        {
            if (x % 5 == 1) ret[count++] = x;
            if (count == n) break;
        }
        Console.WriteLine(string.Join(" ",ret));
    }
    public static void GeneratePrime(List<int> primeList, int m)
    {
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            primeList.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        primeList.AddRange(searchList);
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long int

const int val = (1e5) + 5;
const int inf = (1e9) + 7;
double eps = 0.000000001;

using namespace std;

int a[val], d[val];

int solve(){
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i){
        cin >> a[i];
        d[i] = inf;
    }
    d[1] = 0;
    d[2] = abs(a[1] - a[2]);
    for(int i=3; i<=n; ++i){
        d[i] = min(d[i-1]+abs(a[i]-a[i-1]), d[i-2]+abs(a[i]-a[i-2]));
    }
    cout << d[n] << endl;
}

int main(){
    //in out
	ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll A,B;
ll func(ll x){
    if(x%4==0) return x;
    if(x%4==1) return 1;
    if(x%4==2) return x+1;
    if(x%4==3) return 0;
    return 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>A>>B;
    cout << ((A==0?0:func(A-1))^func(B))<<"\n";
}

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

struct SCC{
    int N;
    vector<bool> used;
    vector<int> vs;
    vector<int> cmp;

    void dfs(int v, const vector<vector<int>>& G){
        used[v] = true;
        for(auto u : G[v]){
            if(!used[u]) dfs(u, G);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k, const vector<vector<int>>& rG){
        used[v] = true;
        cmp[v] = k;
        for(auto u : rG[v]){
            if(!used[u]) rdfs(u, k, rG);
        }
    }

    SCC(int N, const vector<vector<int>>& G):N(N){
        vector<vector<int>> rG(N);
        for(int i=0; i<N; i++) for(int j : G[i]) rG[j].push_back(i);
        used.resize(N);
        fill(used.begin(), used.end(), false);
        for(int v=0; v<N; v++){
            if(!used[v]) dfs(v, G);
        }

        fill(used.begin(), used.end(), false);
        cmp.resize(N);
        int k = 0;
        for(int i = vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++, rG);
        }
    }

    vector<vector<int>> dump_graph(const vector<vector<int>>& G){
        int sz = *max_element(cmp.begin(), cmp.end()) + 1;
        vector<vector<int>> edges2(sz);
        for(int i=0; i<N; i++){
            for(auto j : G[i]){
                if(cmp[i] != cmp[j]){
                    edges2[cmp[i]].push_back(cmp[j]);
                }
            }
        }
        return edges2;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
    }
    SCC scc(N, edges);
    int sz = *max_element(scc.cmp.begin(), scc.cmp.end()) + 1;
    vector<vector<int>> ans(sz);
    for(int i=0; i<N; i++) ans[scc.cmp[i]].push_back(i);
    cout << sz << endl;
    for(auto& v : ans){
        cout << v.size();
        for(int a : v) cout << " " << a;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 57888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  string ans = "";
  ans += s1.front();
  ans += s2.front();
  ans += s3.front();
  
 transform(ans.begin(),ans.end(),ans.begin(),::toupper);
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(void){
    int n;
    ll max=-100000000,min=100000000;
    ll a[10000];
    ll sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(a[i]>max) max=a[i];
        if(a[i]<min) min=a[i];
    }
    printf("%lld %lld %lld\n",min,max,sum);
   
    return 0;
}


Measured memory_bytes: 3292
n = int(input())
a = list(map(int, input().split()))

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

def geta(b):
    un=0
    for i in range(n):
        un+=abs(sub[i]-b)
    return un

med = sub[n//2]
ans=geta(med)
print(ans)

Measured memory_bytes: 99796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(int i = 0; i < n; i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
    }
    cout<<cnt;
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    reverse(ALL(s));
    bool flag = false;
    while(!s.empty()){
        if(s[0] == 'r' && s[1] == 'e' && s[2] == 'm' && s[3] == 'a' && s[4] == 'e' && s[5] == 'r' && s[6] == 'd'){
            if(s.size() == 7){
                flag = true;
                break;
            }
            s = s.substr(7);
        }
        else if(s[0] == 'r' && s[1] == 'e' && s[2] == 's' && s[3] == 'a' && s[4] == 'r' && s[5] == 'e'){
            if(s.size() == 6){
                flag = true;
                break;
            }
            s = s.substr(6);
        }
        else if(s[0] == 'm' && s[1] == 'a' && s[2] == 'e' && s[3] == 'r' && s[4] == 'd'){
            if(s.size() == 5){
                flag = true;
                break;
            }
            s = s.substr(5);
        }
        else if(s[0] == 'e' && s[1] == 's' && s[2] == 'a' && s[3] == 'r' && s[4] == 'e'){
            if(s.size() == 5){
                flag = true;
                break;
            }
            s = s.substr(5);
        }
        else break;
    }
    if(flag) YES();
    else NO();
}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi A(n);
  ll ans = 0;
  for(auto &a:A)cin>>a;
  for(int i=0;i<n;i++){
    for(int j=n;j>=i;j--){
      ll num = i + n-j;
      if(num > k)continue;
      vi ju;
      for(int ii=0;ii<i;ii++){
	ju.pb(A[ii]);
      }
      for(int ii=n-1;ii>=j;ii--){
	ju.pb(A[ii]);
      }
      sort(ALL(ju),greater<ll>());
      ll cnt = 0;
      while(cnt < k-num && ju.size()){
	if(ju.back() < 0)ju.pop_back();
	else break;
	cnt++;
      }
      ll sum = 0;
      for(auto a:ju){
	sum += a;
      }
      ans = max(sum,ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
n=int(input())
a=["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"]
ans=[]
while n>=1:
    ans.append(a[(n-1)%26])
    n=int((n-1)/26)
ans.reverse()
name=""
for i in range(0,len(ans)):
    name+=ans[i]
print(name)

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

int n;
vector < pair < string, int> > vec;
map < pair <string, int>, int > mp;

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

    for(int i = 0, p; i < n; i++){
        string str;
        cin >> str >> p;

        pair <string, int> pr = make_pair(str, p * -1);

        vec.push_back(pr);
        mp[pr] = i + 1;
    }

    sort(vec.begin(), vec.end());

    for(int i = 0; i < n; i++){
        printf("%d\n", mp[vec[i]]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int power[1<<16];
long long a[20][20];
long long dp[1<<16],ans[1<<16];
int main(){
	cin>>n;
	for(int i=0;i<16;++i){
		power[1<<i]=i;
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<(1<<n);++i){
		int lb=i&(-i),x=power[lb],pre=i^lb;
		dp[i]=dp[pre];
		for(int j=0;j<n;++j){
			if(pre&(1<<j)){
				dp[i]+=a[j][x];
			}
		}
	}
	for(int i=1;i<(1<<n);++i){
		for(int j=i;j;j=i&(j-1)){
			ans[i]=max(ans[i],ans[i^j]+dp[j]);
		}
	}
	cout<<ans[(1<<n)-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
int n;
int main(){
	scanf("%d",&n);
	if((n&(-n))==n)return puts("No"),0;
	puts("Yes");
	puts("1 2");
	puts("2 3");
	printf("%d %d\n",3,1+n);
	printf("%d %d\n",1+n,2+n);
	printf("%d %d\n",2+n,3+n);
	for(int i=4;i<n;i+=2)
		printf("%d %d\n%d %d\n%d %d\n%d %d\n",1,i,i,i+1,1,n+i+1,n+i+1,n+i);
	if(n%2==1)return 0;
	int x=n+1;
	for(int i=1;i<=100;i++){
		if(x&(1<<i)){
			int X=1<<i,Y=x-X;
			printf("%d %d\n",X,n);
			printf("%d %d\n",Y+n,2*n);
			break;
		}
	}
}

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

int main() {
  int n,m;
  int ans = 0;
  cin >> n >> m;
  ans += 1900*m + 100*(n-m);
  ans *= pow(2,m);
  cout << ans << endl;

}

Measured memory_bytes: 4048
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int  main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long int  a,b,c,k;
	cin>>a>>b>>c>>k;
	long long int  x = a + b;
	if(k <= x)
	{
		cout<<min(a,k)<<"\n";
	}
	else
	{
		long long int  ans = a;
		ans -= (k-x);
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3620
s=input()
n=int(input())
l=len(s)
ct=0
for i in range(l-1):
 if s[i]==s[i+1]:
  ct=ct+0.5
 else:
  ct=int(ct+0.5)
ct=int(ct+0.5)
s1=s*3
l1=l*3
ct1=0
for i in range(l1-1):
 if s1[i]==s1[i+1]:
  ct1+=0.5
 else:
  ct1=int(ct1+0.5)
ct1=int(ct1+0.5)
ans=int((ct1-ct*3)/2*(n-1)+0.5)+ct*n
print(ans)

Measured memory_bytes: 3064
n = gets.chomp.to_i
a = gets.chomp.split.push(0).map(&:to_i)
b = gets.chomp.split.push(0).map(&:to_i)

monsters = (0..n).inject(0) do |counter, i|
  if a[i] <= b[i]
    c = b[i] - a[i]
    if a[i+1] > c
      a[i+1] -= c
    else
      c = a[i+1]
      a[i+1] = 0
    end
    counter += a[i] + c
  else
    counter += b[i]
  end
end

puts monsters

Measured memory_bytes: 17556
#include<stdio.h>

int main() {

   int i, j, n, m, flag;
   int A[100];
   int c = 0;

   scanf("%d", &n);

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

   flag = 1;
   while (flag) {
      flag = 0;
      for (i = 1; i < n; i++) {
         if (A[i] < A[i - 1]) {
            m = A[i];
            A[i] = A[i - 1];
            A[i - 1] = m;
            flag = 1;
            c++;
         }
      }
   }
   for (j = 0; j < n; j++) {
      printf("%d", A[j]);
      if(j != n - 1)
         putchar(' ');
   }
   printf("\n");
   printf("%d\n", c);

   return 0;
}



Measured memory_bytes: 1992
#include <iostream>
#include <vector>
using namespace std;
const int N = 20;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int doubling[N][n];
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') doubling[0][i] = i + 1;
        if(s[i] == 'L') doubling[0][i] = i - 1;
    }

    for(int i = 0; i < N - 1; i++) {
        for(int j = 0; j < n; j++) {
            doubling[i + 1][j] = doubling[i][doubling[i][j]];
        }
    } 

    int ans[n] = {};
    for(int i = 0; i < n; i++) {
        ans[doubling[N - 1][i]]++;
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 8832