akhauriyash/Code-Regression huggingface dataset:
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//


#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (unsigned long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define VL vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second

using namespace std;

signed main()
{

	ll N = 0;
	cin >> N;
	VL A(N);
	FOR(i, 0, N) {
		cin >> A[i];
	}

	LL C = 0;

	map<LL, LL> m;
	FOR(i, 0, N) {
		m[A[i]] = i;
	}


	VL a(A);
	sort(ALL(a));
	FOR(i, 0, N) {
		if (i % 2 != m[a[i]] % 2)
			C++;
	}
	C /= 2;

	cout << C;

	return 0;
}



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

int main() {
    string s;
    cin >> s;
    map<string, int> ans;
    ans["SUN"] = 7;
    ans["MON"] = 6;
    ans["TUE"] = 5;
    ans["WED"] = 4;
    ans["THU"] = 3;
    ans["FRI"] = 2;
    ans["SAT"] = 1;
    cout << ans[s] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  double left,right;
  int lA=0,lB=0,lC=0,lD=0;
  int rA=0,rB=0,rC=0,rD=0;
  
  while(scanf("%lf %lf",&left,&right)!=EOF){

      if(left>=1.1)lA++;
      else if(left>=0.6 && left<1.1)lB++;
      else if(left>=0.2 && left<0.6)lC++;
      else if(left<0.2)lD++;

      if(right>=1.1)rA++;
      else if(right>=0.6 && right<1.1)rB++;
      else if(right>=0.2 && right<0.6)rC++;
      else if(right<0.2)rD++;
    }
  printf("%d %d\n",lA,rA);
  printf("%d %d\n",lB,rB);
  printf("%d %d\n",lC,rC);
  printf("%d %d\n",lD,rD);
  
  return 0;
}

Measured memory_bytes: 0
#!/usr/local/gnu/bin/bash
read n
declare -A p
for i in `seq $n`
do
    read s
    p[$s]=$((p[$s]+1))
done
read m
for i in `seq $m`
do
    read t
    p[$t]=$((p[$t]-1))
done
echo 0 ${p[@]} | tr ' ' '\n' | sort -nr | head -1


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

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

using namespace std;

string s[101];
int count = 0;
int n,m;
bool flag = true;

void dfs(char c,int i,int j)
{
	s[i][j] = '.';
	if(i+1 < n && s[i+1][j] == c)
	{
		dfs(c,i+1,j);
	}
	if(i-1 >= 0 && s[i-1][j] == c)
	{
		dfs(c,i-1,j);
	}
	if(j+1 < m && s[i][j+1] == c)
	{
		dfs(c,i,j+1);
	}
	if(j-1 >= 0 && s[i][j-1] == c)
	{
		dfs(c,i,j-1);
	}
	
}

int main()
{
	while(cin >> n >> m)
	{
		if(n == 0 && m == 0) break;

		count = 0;
		rep(i,n) cin >> s[i];

		
		rep(i,n)
		{
			rep(j,m)
			{
				if(s[i][j] != '.')
				{
					dfs(s[i][j],i,j);
					count++;
				}
			}
		}
		
		cout << count << endl;
	}

	return 0;
}

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

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;
    vector<vector<lint>> dist(N, vector<lint>(N, LINF));
    vector<lint> K(N + 1, 0);
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            dist[i][j] = min(dist[i][j], (long long)j - i);
            dist[i][j] = min(dist[i][j], abs(i - X) + 1ll + abs(j - Y));
            dist[i][j] = min(dist[i][j], abs(i - Y) + 1ll + abs(j - X));
            K[dist[i][j]]++;
        }
    }
    for (int k = 1; k <= N - 1; k++) {
        cout << K[k] << endl;
    }
    return 0;
}


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

void LCS(string&s1, string&s2){
    if(s1.size() > s2.size()) s1.swap(s2);
    int m = s1.size();
    int n = s2.size();
    
    int dp[m+1][n+1] = {};
    
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(s1[i-1] == s2[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    

    string s = "";
    
    int i = m, j = n;
    while(i > 0 && j > 0){
        if(s1[i-1] == s2[j-1]){
            s += s1[i-1];
            i--;j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    
    if(s.size() == 0) s = ' ';
    reverse(s.begin(),s.end());
    cout << s;
}

int main() {
	string s1,s2;
	cin >> s1 >> s2;
	LCS(s1,s2);
	return 0;
}

Measured memory_bytes: 38776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> iv; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
#define mp make_pair
#define pb push_back
#define MAX 300
//This is DP.

int W[MAX];
int dp[MAX+10][MAX+10];
int n, M;
int main()
{
  while(true)
    {
      scanf("%d", &n);
      if(n==0)break;

      
      rep(i,n)
	{
	  scanf("%d", &W[i]);
	}
      
      memset(dp, 0, sizeof(dp));
  
      rep(k,n+1)
	{
	  if(k==0)continue;
	  rep(i,n)
	    {
	      if(i + k > n)continue;
	      M=0;
	      if(dp[i+1][i+k-2]==k-2)
		{
		  if(abs(W[i]-W[i+k-1])<=1)
		    {
		      dp[i][i+k-1]=k;
		      continue;
		    }
		}
	      repi(j,i,i+k-1)
		 {
		   M=max(M,dp[i][j]+dp[j+1][i+k-1]);
		 }
	       
	      dp[i][i+k-1]=M;
	    }
	}
      /*rep(i,n)
	{
	  rep(j,n)
	    {
	      printf("%d ",dp[i][j]);
	    }
	  printf("\n");
	  }*/
      printf("%d\n", dp[0][n-1]);
    }
  return 0;
}

Measured memory_bytes: 3536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {


        bool IsPrime(int x)
        {
            for (var i = 2; i < x; i++)
            {
                if (x % i == 0)
                {
                    return false;
                }

            }

            return true;

        }

        public void Calc()
        {

            var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var N = p[0];
            var K = p[1];
            p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var R = p[0];
            var S = p[1];
            var P = p[2];

            var T = Console.ReadLine();

            var dic = new Dictionary<char, int> { { 'r', P }, { 's', R }, { 'p', S } };

            long score = 0;
            var isBeforeWin = new bool[K];
            for (var i = 0; i < K; i++)
            {
                isBeforeWin[i] = false;
            }

            for (var i = 0; i < N; i++)
            {

                if (i < K || T[i] != T[i - K] || !isBeforeWin[i % K])
                {
                    score += dic[T[i]];
                    isBeforeWin[i % K] = true;
                }
                else
                {
                    isBeforeWin[i % K] = false;

                }
            }

            Console.WriteLine(score);


        }
    }
}

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

using namespace std;

typedef long long lint;

lint a, b, i;
lint ans, now, x, y;

int main()
{
    //freopen("f.in", "r", stdin);
    //freopen("f.out", "w", stdout);

    scanf("%lld%lld", &a, &b);

    if((((b + 1) / 2) - ((a) / 2)) % 2 == 1)
        ans += 1;

    x += (a & 1);
    y += (b & 1);

    for(i = 1; (1LL << i) <= b; i ++) {
        now = 0;
        if((a & (1LL << i)) != 0)
            now += ((1LL << i) - x);
        if((b & (1LL << i)) != 0)
            now += (y + 1);
        if(now % 2 == 1) {
            ans |= (1LL << i);
        }

        x += (a & (1LL << i));
        y += (b & (1LL << i));
    }

    printf("%lld\n", ans);

    /*lint real = 0;
    for(i = a; i <= b; i ++) {
        real ^= i;
    }

    printf("%lld\n", real);
    */

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
	N, K = map(int, input().split())
	A = list(input())
	ans = 0

	if (N-1)%(K-1) == 0:
		ans = (N-1)//(K-1)
	else:
		ans = (N-1)//(K-1) + 1

	print(ans)
	

if __name__ == '__main__':
	main()


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

template <int Mod, bool IsPrime = false>
class mod_int {
    using ll = long long;

public:
    constexpr mod_int() : n(0) {}
    constexpr mod_int(int n_) : n(n_) {
        if(n >= Mod)     n %= Mod;
        else if(n < 0) n = (n % Mod + Mod) % Mod;
    }
    constexpr mod_int(ll n_) : n(n_) { n = (n + Mod) % Mod; }

    constexpr operator int() const { return n; }
    constexpr operator ll() const  { return n; }

    constexpr bool operator==(mod_int const& other) const { return n == other.n; }
    constexpr mod_int& operator+=(mod_int const& other) {
        if((n += other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator-=(mod_int const& other) {
        if((n += Mod - other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator*=(mod_int const& other) {
        n = (unsigned long long)n * other.n % Mod;
        return *this;
    }
    constexpr typename std::enable_if<IsPrime, mod_int>::type& operator/=(mod_int const& other) {
        return *this *= other.inverse();
    }
    constexpr mod_int operator+(mod_int other) const { return mod_int(*this) += other; }
    constexpr mod_int operator-(mod_int other) const { return mod_int(*this) -= other; }
    constexpr mod_int operator*(mod_int other) const { return mod_int(*this) *= other; }
    constexpr mod_int operator/(mod_int other) const { return mod_int(*this) /= other; }

    constexpr typename std::enable_if<IsPrime, mod_int>::type inverse() const {
        ll a = n, b = Mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        return mod_int(u);
    }

private:
    ll n;
};

template <int Mod, bool IsPrime>
std::ostream& operator<<(std::ostream& os, mod_int<Mod, IsPrime> const& n) {
    os << (int)n;
    return os;
}

constexpr int default_mod = 1000000007;

template <int Mod = default_mod>
mod_int<Mod, true> fact(int n) {
    static std::vector<mod_int<Mod, true>> v = {1};
    if(n >= static_cast<int>(v.size())) {
        const int from = v.size(), to = n + 1024;
        v.reserve(to);
        for(int i = from; i < to; ++i) {
            v.push_back(v.back() * mod_int<Mod, true>(i));
        }
    }
    return v[n];
}

template <int Mod = default_mod>
mod_int<Mod, true> comb(int n, int r) { // nCr
    if(r < 0 || r > n) return 0;
    return fact<Mod>(n) / fact<Mod>(r) / fact<Mod>(n - r);
}

using mint = mod_int<default_mod, true>; // default

int main() {
    int x, y; cin >> x >> y;
    mint ans;
    for(int c1 = 0; c1 <= x; ++c1) {
        int rx = x - c1, ry = y - 2 * c1;
        if(rx == ry * 2) {
            ans += comb(c1 + ry, c1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7424
<?php

$n = intval(trim(fgets(STDIN)));
for($i=0;$i<$n;$i++){
	$arr[$i] = explode(" ",fgets(STDIN));
}
$t = trim(fgets(STDIN));
$time = 0;
$ju = 0;
foreach ($arr as  $value) {
	if($value[0] == $t){
		$ju = 1;
		continue;
	}
	if($ju == 1){
		$time += intval(trim($value[1]));
	}
}
echo $time;

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

int main()
{
	char c[3][3];
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	cout << c[0][0] << c[1][1] << c[2][2] << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;


LL dp[2005];

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

    int s;
    cin >> s;
    dp[0] = 1;
    for (int i = 1; i <= s; ++i) {
        for (int j = 0; j <= i-3; ++j) {
            dp[i] = (dp[i] + dp[j]) % MOD;
        }
    }

    cout << dp[s] << endl;

    return 0;
}


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

ll dsum(ll n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main(void){
    ll n;
    cin>>n;
    ll d = 10;
    ll res = dsum(n);
    while(d<=n){
        res = max(res,dsum(n - n%d - 1));
        d *= 10;
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;

int main() {
	int N,ans,result;
  cin >> N;
  int A[100010],L[100010],R[100010];

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

  for(int i=0;i<N-1;i++){
    L[i+1]=__gcd(A[i], L[i]);
  }

  for(int i=N-1;i>0;i--){
    R[i-1]=__gcd(A[i], R[i]);
  }

  for(int i=0;i<N;i++){
      int tmp=__gcd(L[i],R[i]);
      ans=max(ans,tmp);
  }

    cout<<ans<<endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int ANS[10];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int H, W, N;
	cin >> H >> W >> N;
	int A, B;
	map<pii, int> pmap;
	ANS[0] = (H - 2) * (W - 2);
	rep(i, 0, N)
	{
		cin >> A >> B;
		A--, B--;
		static const int dx[] = { 0,1,1,0,-1,-1,-1,0,1 };
		static const int dy[] = { 0,0,-1,-1,-1,0,1,1,1 };
		rep(j, 0, 9)
		{
			int nx = B + dx[j];
			int ny = A + dy[j];
			if (1 <= nx && nx < W-1 && 1 <= ny && ny < H-1)
			{
				ANS[pmap[mp(nx, ny)]]--;
				pmap[mp(nx, ny)]++;
				ANS[pmap[mp(nx, ny)]]++;
			}
		}
	}

	rep(i, 0, 10)
	{
		cout << ANS[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 56576
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int flag=0;
    for(int i=0; i<=N/7; i++){
        if((N-7*i)%4==0){
            flag=1;
            break;
        }
    }
    if(flag)cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <array>
using namespace std;

int dp[202][202][6];
int obs[202][202];

typedef array<int,4> T; //cost, x, y, t
priority_queue<T,vector<T>, greater<T>> Q;
int sx,sy,gx,gy,n,lx,ly;

int main(){
    cin>>sx>>sy>>gx>>gy>>n;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        obs[x+100][y+100]=1;
    }
    cin>>lx>>ly;
    fill(dp[0][0],dp[202][0],1000000);
    dp[sx+100][sy+100][0]=0;
    Q.push(T{0,sx,sy,0});
    while(!Q.empty()){
        auto q = Q.top(); Q.pop();
        int cost=q[0],x=q[1],y=q[2],t=q[3];
        if(x==gx&&y==gy){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>dp[x+100][y+100][t]) continue;
        int dir = (x*y*t>=0?x*y*t:-x*y*t)%6;
        array<int,7> dx, dy;
            dx={0,1,1,0,-1,-1,0};
        if(x%2==0){
            dy={1,0,-1,-1,-1,0,0};
        }else{
            dy={1,1,0,-1,0,1,0};
        }
        for(int d=0;d<=6;d++){
            int nx=x+dx[d],ny=y+dy[d],nt=(t+1)%6;
            if(nx<-lx||lx<nx||ny<-ly||ly<ny) continue;
            if(obs[nx+100][ny+100]) continue;
            int c = cost + (d==dir?0:1);
            if(dp[nx+100][ny+100][nt]>c){
                dp[nx+100][ny+100][nt]=c;
                Q.push(T{c,nx,ny,nt});
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 4260
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int A[N];
  int sumA = 0;
  for(int i=0;i<N;++i) {
    cin>>A[i];
    sumA += A[i];
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(A[i]*4*M>=sumA) ans++;
  }
  if(ans>=M) {
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}



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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;

  string ans = "Yes";

  for (int i = 0; i < N - 1; i++) {
    int H;
    cin >> H;
    if (H > M) M = H - 1;
    if (H == M) M = H;
    if (H < M) {
      ans = "No";
      break;
    } 
  }

  cout << ans << "\n";
}

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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	int N, M; cin >> N >> M;
	V as(N);
	rep(i, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		as[a]++;
		as[b]++;
	}
	bool ok = true;
	rep(i, N) {
		if (as[i] % 2 != 0) ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int ls = s.length();
    int lt = t.length();
    int ans = INT_MAX;
    for(int i=0;i<=ls-lt;i++){
        string temp = s.substr(i,lt);
        int loc_ans = 0;
        for(int j=0;j<lt;j++){
            if(temp[j]!=t[j])
                loc_ans++;
        }
        ans = min(ans,loc_ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>

template <int N, int mod>
struct combination{
    long long int power[N + 1];
    long long int inverse_power[N + 1];
    static constexpr long long int pow_mod(int a, int n){
        int res = 1;
        while(n){
            if(n & 1) res = static_cast<long long int>(a) * res % mod;
            a = static_cast<long long int>(a) * a % mod;
            n >>= 1;
        }
        return res;
    }
    static constexpr long long int inverse(int a){ return pow_mod(a, mod - 2); }
    constexpr combination():power(), inverse_power(){
        power[0] = 1; power[1] = 1; 
        for(int i = 2; i <= N; ++i) power[i] = i * power[i - 1] % mod;
        inverse_power[N] = inverse(power[N]);
        for(int i = N; i > 0; --i) inverse_power[i - 1] = i * inverse_power[i] % mod;
    }
    constexpr long long int comb(int n, int k) const {
        if(k < 0 or n < k) return 0;
        return (power[n] * inverse_power[k] % mod) * inverse_power[n - k] % mod;
    }
};

constexpr int mod = 1000'000'007;
constexpr int MAX_STR_SIZE = 2'000'000;
combination<MAX_STR_SIZE, mod> shuumai;
constexpr int alpha_size = 'z' - 'a' + 1;

int main(void){
    std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
    int n; std::string S;
    std::cin >> n >> S;
    const int m = S.size(), l = n + m;
    constexpr int x = combination<0, mod>::inverse(alpha_size);
    constexpr int y = alpha_size - 1;
    long long res = 0;
    long long int subx = 1, suby = 1;
    for(int i = 0; i < n; ++i) (subx *= alpha_size) %= mod;
    
    for(int i = 0; i <= n; ++i){
        (res += (shuumai.comb(i + m - 1, m - 1) * subx % mod) * suby) %= mod;
        (subx *= x) %= mod; (suby *= y) %= mod;
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 35480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	double v[n];
	rep(i,n) cin>>v[i];
	sort(v,v+n);
	
	double s=v[0];
	for(int i=0;i<n;i++){
		s=(v[i]+s)/2;
	}

	cout<<fixed<<setprecision(15)<<s<<"\n";
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;

  int day = 0;
  int coins = 0;

  while (coins < c) {
    day++;
    coins += a;
    if (day % 7 == 0) {
      coins += b;
    }
  }

  cout << day << endl;
}




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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]==t[i])cnt++;
    }
    cout<<cnt;
}

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

int main() {
	int x,y;
    cin >> x >> y;
    int sum=0;
    if(x==3){
      sum += 100000;
    }
    else if(x==2){
      sum += 200000;
    }
    else if(x==1){
      sum += 300000;
    }
    if(y==3){
      sum += 100000;
    }
    else if(y==2){
      sum += 200000;
    }
    else if(y==1){
      sum += 300000;
    }
    if(x==1 && y==1){
      sum += 400000;
    }
    cout << sum << endl; 
}


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)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n, k; cin >> n >> k; k--;
    string s; cin >> s;
    if(s[k] == 'A') s[k] = 'a';
    if(s[k] == 'B') s[k] = 'b';
    if(s[k] == 'C') s[k] = 'c';
    cout << s;
    }



Measured memory_bytes: 256
string=[]
W = input()#単語入力
while True:
    T = input()#入力
    if T == 'END_OF_TEXT':#EOT入力のときループぬける
        break
    string.append(T)#list追加
count=0
for i in range(len(string)):
    string[i]=string[i].lower()
    string[i] = string[i].split(" ")
    for j in range(len(string[i])):
        if W == string[i][j]:
            count+=1
print(count)


Measured memory_bytes: 5564
import java.util.*

fun main(args: Array<String>) {
  val (a, b, c) = Triple(ni(), ni(), ni())
  if (b - a == c - b) {
    println("YES")
  } else {
    println("NO")
  }
}

val sc = Scanner(System.`in`)

fun ni(): Int {
  return Integer.parseInt(sc.next())
}


Measured memory_bytes: 21672
# Standard module
import math

# 3rd party's module

# Original module  

class CalcVal():
    def set_num(self, num):
        self._num = num
        self._calc_ord()
        
    def get_sum_pow(self):
        max_rng = math.ceil(self._ord/2.)
        sum_data = 0
        for i in range(max_rng):
            sum_data += 9*10**(i*2)
        return sum_data
    
    def get_remain_cal(self):
        self._ord = math.floor(math.log10(self._num))
        if self._ord == 0:
            #DO NOT count 0
            return self._num
        else:
            return self._num - 10**self._ord + 1
        
    def do(self):
        sum_data = self.get_sum_pow()
        if self._ord%2 == 0:
            sum_data += self.get_remain_cal()
        return sum_data
        
    
    def _calc_ord(self):
        self._ord = math.floor(math.log10(self._num))


def main_func():
    cv = CalcVal()
    cv.set_num(int(input()))
    print(cv.do())
        

main_func()

Measured memory_bytes: 3064
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0

for i in range(n):
    if 0<=i-1<n:
        dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if 0<=i-2<n:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 52208
import java.util.Scanner;
class Main{
 
    public void solve(){
		Scanner sc = new Scanner(System.in);
       int a, b, c, d;
       	   a = sc.nextInt();
		   b = sc.nextInt();
		   c = a * b;
		   d = (a * 2) + ( b * 2);
		  System.out.print(c+" "+d);
		  System.out.println();
    }
		   
	   
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17356
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
  
using namespace std;
  
double EPS = 1e-6;
  
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
  return a+b;
}
  
struct point{
  double x,y;
  point() {}
  point(double x,double y):x(x),y(y){
  }
  point operator + (point p){
    return point(add(x,p.x),add(y,p.y));
  }
  point operator - (point p){
    return point(add(x,-p.x),add(y,-p.y));
  }
  point operator * (double d){
    return point(x*d,y*d);
  }
  point operator / (double d){
    return point(x/d,y/d);
  }
};
  
double dist(point a,point b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int main(void){
    int n,x,y,v;
    vector<point>P;
    vector<double>V;
     
    while(cin >> n,n){
        P.clear();
        V.clear();
         
        for(int i=0;i<n;i++){
            cin >> x >> y >> v;
            P.push_back(point(x,y));
            V.push_back(v);
        }
        
        double r=0.98;
        point now(0,0);
         
        for(double d=10;d>EPS;d*=r){
            int mx=0;
            double mxd=0;
             
            for(int j=0;j<P.size();j++)
                if(dist(now,P[j])/V[j]>mxd)
		  mx=j,mxd=dist(now,P[j])/V[j];
             
            now=now+((P[mx]-now)/dist(P[mx],now)*d);
        }
         
        double ans=0;
        for(int i=0;i<P.size();i++){
	  ans=max(ans,dist(now,P[i])/V[i]);
        }
        printf("%.8f\n",ans);
    }
    return 0;
}

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

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

using namespace std;

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans   = 0;
  rep(i,A+1){
    rep(j,B+1){
      rep(k,C+1){
        if(X == i * 500 + j * 100 + k * 50) ans ++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,c = map(int,input().split())
d = [list(map(int,input().split())) for i in range(c)]
l = [list(map(int,input().split())) for i in range(n)]

ll = [[0]*c for i in range(3)]

for i in range(n):
    for j in range(n):
        x = (i+j+2)%3
        ll[x][l[i][j]-1] += 1

ans = float("INF")

for i in range(c):
    for j in range(c):
        if i == j:
            continue
        for k in range(c):
            if i == k or j == k:
                continue
            count = 0
            ch = [i,j,k]
            for m in range(3):
                for t in range(c):
                    count += ll[m][t]*d[t][ch[m]]
            ans = min(ans,count)
print(ans)

Measured memory_bytes: 5492
import sys
R1 = input().split()
R2 = input().split()
K = int(R1[0])
T = int(R1[1])
answer = int(0)
A = []
for i in range (0, T):
    A.append(int(R2[i]))
A.sort()
A.reverse()
if T == 1:
    print(A[0] - 1)
    sys.exit()
if T == 2:
    print(A[0] - A[1] - 1)
    sys.exit()
for i in range (0, K):
    C = A[0]
    if C - 1 > A[1]:
        if A[1] == 0:
            answer += 1
        if A[1] != 0:
            K -= 1
            D = int(A[1])
            A.remove(D)
            F = int(1)
            left = int(0)
            right = int(T - 2)
            while (left <= right):
                mid = int(left + (right - left) / 2)
                if A[mid] >= D - 1:
                    left = mid + 1
                    F = max(F, mid + 1)
                else:
                    right = mid - 1
            A.insert(F, D - 1)
        A[0] -= 1
    if C - 1 == A[1]:
        A[0] -= 1
    if C == A[1]:
        F = int(0)
        left = int(0)
        right = int(T - 1)
        while (left <= right):
            mid = int(left + (right - left) / 2)
            if A[mid] == C:
                left = mid + 1
                F = max(F, mid + 1)
            else:
                right = mid - 1
        A.insert(F, C - 1)
        A.remove(C)
print(answer)

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

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

	int c = (a+b) / 2;
	double d = (a+b) / 2.0;

	int ans = c;
	if (d-c>0) {
		ans++;
	} 
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

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

    vector<ll> l(n+1);
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++){
        l[i]=l[i-1]+l[i-2];
    }

    cout << l[n] << endl;

    return 0;
}


Measured memory_bytes: 3616
//minamoto
#include<bits/stdc++.h>
#define R register
#define vec vector<int>
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]=' ';
}
const int N=1e5+5;
vec p,q,ip,iq,a[9];int n,k;
vec Inv(const vec &A){
	vec B(n);
	fp(i,0,n-1)B[A[i]]=i;
	return B;
}
vec Mul(const vec &A,const vec &B){
	vec C(n);
	fp(i,0,n-1)C[i]=A[B[i]];
	return C;
}
vec ksm(vec x,int y){
	vec res(n);fp(i,0,n-1)res[i]=i;
	for(;y;y>>=1,x=Mul(x,x))if(y&1)res=Mul(res,x);
	return res;
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(),k=read(),p.resize(n),q.resize(n);
	fp(i,0,n-1)p[i]=read()-1;
	fp(i,0,n-1)q[i]=read()-1;
	ip=Inv(p),iq=Inv(q),a[1]=p,a[2]=q;
	fp(i,3,6)a[i]=Mul(a[i-1],Inv(a[i-2]));
	int len=(k-1)/6;
	vec cir=ksm(Mul(q,Mul(ip,Mul(iq,p))),len);
	vec res=Mul(cir,Mul(a[k-len*6],Inv(cir)));
	fp(i,0,n-1)print(res[i]+1);
	return Ot(),0;
}

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

using namespace std;

int N, M, a[100009], ans[100009], st[100009], dr[100009];
bool type[100009];
vector < int > v[100009];

void Bad ()
{
    printf ("No\n");
    exit (0);
}

void dfs (int nod, int tata)
{
    vector < pair < pair < int, int >, bool > > curr;
    bool free = 1;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        if (*it != tata)
        {
            dfs (*it, nod), curr.push_back ({{st[*it], dr[*it]}, type[*it]});
            if (type[*it] != 0) free = 0;
        }
    if (free)
    {
        if (a[nod] != -1) st[nod] = dr[nod] = a[nod], type[nod] = 1;
        else st[nod] = dr[nod] = type[nod] = 0;
    }
    else
    {
        bool initialized = 0;
        int mini, maxi;
        type[nod] = 1;
        for (auto it = curr.begin (); it != curr.end (); it ++)
        {
            int l = it->first.first, r = it->first.second;
            bool t = it->second;
            if (t == 0) continue;
            if (!initialized) mini = l, maxi = r, initialized = 1;
            else
            {
                if (l % 2 != mini % 2) Bad ();
                if (l > mini) mini = l;
                if (r < maxi) maxi = r;
            }
        }
        mini --, maxi ++;
        if (mini > maxi) Bad ();
        if (a[nod] != -1)
        {
            if (a[nod] < mini || a[nod] > maxi || a[nod] % 2 != mini % 2) Bad ();
            st[nod] = dr[nod] = a[nod];
        }
        else st[nod] = mini, dr[nod] = maxi;
    }
}

void solve (int nod, int tata)
{
    if (st[nod] <= ans[tata] + 1 && ans[tata] + 1 <= dr[nod]) ans[nod] = ans[tata] + 1;
    else ans[nod] = ans[tata] - 1;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        if (*it != tata)
            solve (*it, nod);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    a[i] = -1;
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
scanf ("%d", &M);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    a[x] = y;
}
dfs (1, -1);
ans[1] = st[1];
for (auto it = v[1].begin (); it != v[1].end (); it ++)
    solve (*it, 1);
printf ("Yes\n");
for (int i=1; i<=N; i++)
    printf ("%d\n", ans[i]);
return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	string s;
	cin>>s;
	if (SZ(s) < 4)
	{
		cout<<"No"<<endl;
		return 0;
	}

	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}


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

using namespace std;


void solve() {
    int X, N; cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    int d = 1000;
    int ans;
    for (int i = -100; i <= 200; i++) {
        bool flag = true;
        if (abs(i - X) < d) {
            for (int j = 0; j < N; j++) {
                if (p[j] == i) flag = false;
            }
            if (flag) {
                d = abs(i - X);
                ans = i;
            }
        }
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

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

typedef struct{
    int number;
    int num;
}NUMBER;
bool checker(NUMBER a, NUMBER b);
int main(){
    int N;
    int *v;
    NUMBER *number_odd;
    NUMBER *number_even;
    int odd,even;
    int i;
    int max;
    
    cin >> N;
    v = new int[N];
    
    max = 0;
    for(i=0;i<N;i++){
        cin >> v[i];
        if( max < v[i])
            max = v[i];
    }
    number_odd = new NUMBER[max];
    number_even = new NUMBER[max];
    for(i=0;i<max;i++){
        number_odd[i].number = i+1;
        number_odd[i].num = 0;
        number_even[i].number = i+1;
        number_even[i].num = 0;
    }
    for(i=0;i<N;i+=2){
        number_odd[v[i]-1].num++;
    }
    for(i=1;i<N;i+=2){
        number_even[v[i]-1].num++;
    }
    sort(number_odd,number_odd + max,checker);
    sort(number_even,number_even + max,checker);
    
    /*
    cout << "Odd" << endl;
    for(i=0;i<10;i++){
        cout << number_odd[i].number << ":" << number_odd[i].num << endl;
    }
    cout << "even" << endl;
    for(i=0;i<10;i++){
        cout << number_even[i].number << ":" << number_even[i].num << endl;
    }
     */
    
    odd = even = 0;
    if( number_odd[odd].number == number_even[even].number){
        if( number_odd[odd+1].num + number_even[even].num > number_odd[odd].num + number_even[even+1].num ){
            odd++;
        }else{
            even++;
        }
    }
    cout << ( N / 2) - number_odd[odd].num + ( N / 2) - number_even[even].num << endl;
}
bool checker(NUMBER a, NUMBER b){
    if( a.num > b.num){
        return true;
    }else{
        return false;
    }
}


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=1; i<=b; i++)
  {
    if((a*i)%b==c)
    {
      cout<<"YES\n";
      return 0;
    }
    else continue;
  }
  cout<<"NO\n";
  return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

s = s()

bi = [0,0,0,1,1,0,0,0,1,1,0,1]
gr = itertools.groupby(s)
cnt = 0
for key, group in gr:
    if key == "R":
        r = len(list(group))
    else:
        l = len(list(group))
        for i in range(r + l):
            if i == r - 1:
                if r % 2 == 1:
                    ansli.append((r + l + 2 - 1) // 2)
                else:
                    ansli.append((r + l) // 2)
            elif i == r:
                if r % 2 == 1:
                    ansli.append((r + l) // 2)
                else:
                    ansli.append((r + l + 2 - 1) // 2)
            else:
                ansli.append(0)

print(*ansli)

Measured memory_bytes: 8916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B, C;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B >> C;
  int X = max({A, B, C});
  if ((3*X-(A+B+C))%2) X++;
  cout << ((3*X-(A+B+C))/2) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  cout<<(n+1)/2;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int INF = 5*1e8;

class UnionFind{
  vi p,r;
public:
  UnionFind(int n):p(n,-1),r(n,0){ }
  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
};

inline int MSB(int x){ return x>0?31-__builtin_clz(x):-1; }

struct LCA{
  vector<vi> par,w;
  vi depth;
  int ln;
  
  LCA(void){}
  LCA(const vector<vi> &t, const vi &weight, int root){
    int n = t.size(); ln = MSB(n)+1;
    depth.resize(n); par.resize(ln,vi(n));
    w.resize(ln,vi(n)); w[0] = weight;

    stack< pair<int,int> > s;
    s.push(make_pair(root,-1));
    while(s.size()){
      int v = s.top().first, p = s.top().second; s.pop();
      par[0][v] = p;
      depth[v] = ((p<0)?0:(depth[p]+1));

      for(int u : t[v]){
	if(u != p)s.push(make_pair(u,v));
      }
    }

    rep(k,ln-1)rep(v,n){
      if(par[k][v]<0){
	par[k+1][v] = -1;
	w[k+1][v] = INF;
      }else{
	par[k+1][v] = par[k][par[k][v]];
	w[k+1][v] = min(w[k][v], w[k][par[k][v]]);
      }
    }
  }

  inline int min_lca(int u, int v){
    int res = INF;
    if(depth[u] > depth[v])swap(u,v);
    rep(k,ln){
      if((depth[v]-depth[u])>>k & 1){
	res = min(res, w[k][v]);
	v = par[k][v];
      }
    }

    if(u==v)return min(res, w[0][u]);
    for(int k = ln-1;k>=0;k--){
      if(par[k][u] != par[k][v]){
	res = min(res, min(w[k][u], w[k][v]));
	u = par[k][u]; v = par[k][v];
      }
    }
    return min(res, min(w[1][u], w[1][v]));
  }
};

int main(){
  int n,m,k,Q;
  scanf("%d%d%d%d",&n,&m,&k,&Q);
  vector< vector<pii> > g(n);
  rep(i,m){
    int a,b,l;
    scanf("%d%d%d",&a,&b,&l); a--; b--;
    g[a].push_back(pii(b,l));
    g[b].push_back(pii(a,l));
  }

  vi dis(n,INF);
  priority_queue<pii> q;
  rep(i,k){
    int f;
    scanf("%d",&f); f--;
    dis[f] = 0;
    q.push(pii(0,f));
  }

  while(q.size()){
    pii p = q.top(); q.pop();
    int d = -p.first, v = p.second;
    if(dis[v] < d)continue;
   
    for(pii nxt : g[v]){
      int u = nxt.first, cost = d+nxt.second;
      if(dis[u] > cost){
	dis[u] = cost;
	q.push(pii(-cost,u));
      }
    }
  }

  vector<pii> order(n);
  rep(i,n)order[i] = pii(dis[i],i);

  sort(all(order)); reverse(all(order));
  UnionFind uf(n);

  vector<vi> tree(n);
  rep(i,n){
    int v = order[i].second;
    priority_queue<pii> nxt;
    for(pii p : g[v]){
      int u = p.first;
      nxt.push(pii(dis[u],u));
    }

    while(nxt.size() && nxt.top().first>=dis[v]){
      int u = nxt.top().second; nxt.pop();
      if(!uf.same(v,u)){
	tree[u].push_back(v);
	tree[v].push_back(u);
	uf.unite(v,u);
      }
    }
  }
 
  LCA query(tree, dis, 0);
  rep(i,Q){
    int u,v;
    scanf("%d%d",&u,&v); u--; v--;
    printf("%d\n",query.min_lca(u,v));
  }
}

Measured memory_bytes: 31012