akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    long long res = 0;
    long long N, C;
    cin >> N >> C;
    vector<long long> x(N);
    vector<long long> v(N);
    vector<long long> lrui(N);
    vector<long long> lmax(N);
    vector<long long> rrui(N);
    vector<long long> rmax(N);
    rep(i, 0, N) { cin >> x[i] >> v[i]; }
    lrui[0] = -x[0] + v[0];
    lmax[0] = lrui[0];
    rep(i, 1, N) {
        lrui[i] = lrui[i - 1] - (x[i] - x[i - 1]);
        lrui[i] += v[i];
        if(lmax[i - 1] < lrui[i]) {
            lmax[i] = lrui[i];
        } else {
            lmax[i] = lmax[i - 1];
        }
    }
    rrui[0] = -(C - x[N - 1]) + v[N - 1];
    rmax[0] = rrui[0];
    rep(j, 1, N) {
        int i = N - 1 - j;
        rrui[j] = rrui[j - 1] - (x[i + 1] - x[i]);
        rrui[j] += v[i];
        if(rmax[j - 1] < rrui[j]) {
            rmax[j] = rrui[j];
        } else {
            rmax[j] = rmax[j - 1];
        }
    }
   // rep(i, 0, N) { cout << "lrui:" << lrui[i] << ",lmax:" << lmax[i] << endl; }
   // rep(i, 0, N) { cout << "rrui:" << rrui[i] << ",rmax:" << rmax[i] << endl; }
    chmax(res, lmax[N - 1]);
    chmax(res, rmax[N - 1]);
    rep(i, 0, N - 1) {
        long long tmp = lrui[i];
        tmp -= x[i];
        tmp += rmax[N - 2 - i];
        chmax(res, tmp);
    }
    rep(i, 0, N - 1) {
        long long tmp = rrui[i];
        tmp -= C - x[N - 1 - i];
        tmp += lmax[N - 2 - i];
        chmax(res, tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 4992
fun main(args: Array<String>) = yorukatsu19c()

fun yorukatsu19c() {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toCharArray().sorted() }

    val answer = sList.groupBy { it }
        .map { it.value.size.toLong() }.map { (it - 1) * it / 2 }
        .fold(0L, Long::plus)

    println(answer)
}


Measured memory_bytes: 77416
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t m, d;
    cin >> m >> d;

    if (21 >= d) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = 0;
    for (auto mm : irange(1L, m + 1)) {
        for (auto day : irange(22L, d + 1)) {
            if (day % 10 < 2) {
                continue;
            }

            if (mm == (day / 10) * (day % 10)) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
mat G(300010);
int BFS(int s,int t){
    vec d(300010,-1);
    d[3*s]=0;
    queue<int> que;
    que.push(3*s);
    while(!que.empty()){
        int p=que.front();que.pop();
        for(int q:G[p]){
            if(d[q]!=-1)continue;
            d[q]=d[p]+1;
            if(q==3*t) return d[q]/3;
            que.push(q);
        }
    }
    return -1;
}
int main(){
    int N,M;cin>>N>>M;
    int u,v;
    for(int i=0;i<M;i++){
        cin>>u>>v;
        G[3*u].push_back(3*v+1);
        G[3*u+1].push_back(3*v+2);
        G[3*u+2].push_back(3*v);
    }
    int S,T;cin>>S>>T;
    cout<<BFS(S,T)<<endl;
    return 0;
}

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int n;
    cin >> n;
    vector<i64> v(1 << n);
    multiset<i64, greater<i64>> nok;
    for(auto& x : v){
        cin >> x;
        nok.emplace(x);
    }
    sort(v.begin(), v.end(), greater<i64>());
    vector<i64> kakutei{v[0]};
    nok.erase(v[0]);
    for(int i = 0; i < n; ++i){
        multiset<i64> s;
        for(auto& x : kakutei)
            s.emplace(x);

        int cnt = 0;
        for(auto it = nok.begin(); it != nok.end();){
            auto it2 = s.upper_bound(*it);
            if(it2 != s.end()){
                s.erase(it2);
                kakutei.emplace_back(*it);
                it = nok.erase(it);
                if(++cnt == (1 << i))
                    break;
            }else{
                ++it;
            }
        }
        if(cnt != (1 << i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 17784
import heapq
n, m = map(int, input().split())
albeits = [[] for _ in range(m+1)]
for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        albeits[a].append(b)

ans = 0
queue = []
heapq.heapify(queue)
# (M-1)日後から逆算して考える
for i in range(1, m+1):
    for item in albeits[i]:
        heapq.heappush(queue, -item)
    try:
        ans += -heapq.heappop(queue)
    except:
        pass

print(ans)


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


int main(){
    set<long long> s;

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

    bool flag = true;
    for(int i=0; i<N; ++i){
        if( s.count(A[i]) > 0 ){
            flag = false;
            break;
        }

        s.insert(A[i]);
    }

    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 13964
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
        	int a = sc.nextInt();
            int b = sc.nextInt();
            if(a > b) {
            	System.out.println("a > b");
            }else if(a < b) {
            	System.out.println("a < b");
            }else {
            	System.out.println("a == b");
            }
        }
    }
}



Measured memory_bytes: 26280
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    vi ans;
    int index = n-1;
    rep(i,n) {
        ans.emplace_back(a[index]);
        if(i < (n-1)/2) index -= 2;
        else if(i > (n-1)/2)index += 2;
        else{
            if(index == 0) index = 1;
            else index = 0;
        }
    }

    rep(i,n) cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 5068
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void agc_a_wanna_go_back_home(void) {
	string s;
	cin >> s;
	int s_cnt = 0, e_cnt = 0, n_cnt = 0, w_cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case 'N': {
			n_cnt++;
			break;
		}
		case 'W': {
			w_cnt++;
			break;
		}
		case 'S': {
			s_cnt++;
			break;
		}
		case 'E': {
			e_cnt++;
			break;
		}
		}
	}
	if ((e_cnt > 0) && (w_cnt == 0))      cout << "No" << endl;
	else if ((e_cnt == 0) && (w_cnt > 0)) cout << "No" << endl;
	else if ((s_cnt > 0) && (n_cnt == 0)) cout << "No" << endl;
	else if ((s_cnt == 0) && (n_cnt > 0)) cout << "No" << endl;
	else                                  cout << "Yes" << endl;
}

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

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}

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

int main(){
	int a,b;

	cin>>a>>b;
	if(a<b)
	{
		cout<<"a < b"<<endl;
	}
	else if(a>b)
	{
		cout<<"a > b"<<endl;
	}
	else
	{
		cout<<"a == b"<<endl;
	}
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
List = []
for c in range(100//4 + 1):
  for d in range((100-4*c)//7 + 1):
    if 4*c + 7*d == N:
      List.append(c+d)
    else:
      continue
if bool(List) == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	map<int, vector<int> > can;
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		if(a > m) continue;
		can[a].push_back(b);
	}
	int ans = 0;
	multiset<int> vals;
	for(int i = 1; i <= m; i++){
		for(int v : can[i]) vals.insert(v);
		if(!vals.empty()){
			ans += *(--vals.end());
			vals.erase(--vals.end());
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13172
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string s,t;
cin>>N>>s>>t;
  int count=0;
for(int i=0;i<N;i++){
  if(s.at(i)==t.at(0)){
    for(int j=0;i+j<N;j++){
      if(s.at(i+j)==t.at(j)){
        count++;
      }
      else{
        count=0;
        break;
      }
    }
  }
  if(count>0){
   break; 
  }
}
  cout<<2*N-count;
}


Measured memory_bytes: 256
import copy
N = int(input())
sp = [[] for _ in range(N)]
for i in range(N):
    sp[i] = list(input().split())
    sp[i][1] = int(sp[i][1])
alf = []
for v in sp:
    alf.append(v[0])
set(alf)

alf.sort(reverse=True)
for v in sp:
    for i, _v in enumerate(alf):
        if v[0] == _v:
            v[0] = i
_sp = copy.copy(sp)
_sp.sort(reverse=True)

for v in _sp:
    for i, _v in enumerate(sp):
        if v == _v:
            print(i+1)

Measured memory_bytes: 3700
#include<stdio.h>

int main(){
  int N,i,j,A[100],L,p=0;

  scanf("%d",&N);

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

  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
	L=A[j-1];
	A[j-1]=A[j];
	A[j]=L;
	p++;
      }
    }
  }
  for(i=0;i<N;i++){
    if(i==N-1) printf("%d",A[i]);
    else printf("%d ",A[i]);
    
  }
  printf("\n");
  printf("%d",p);
  printf("\n");
}



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

const ll INF = 1LL << 60;

int main(void) {
  ll N;
  cin >> N;
  vector<string> W(N);
  REP(i, 0, N) cin >> W[i];

  vector<ll> v(256, -1);
  vector<ll> nxt(N);
  for (ll i = N - 1; i >= 0; i--) {
    char c = W[i][0];
    nxt[i] = v[c];
    v[c] = i;
  }

  vector<ll> dp(N + 1, INF);
  dp[0] = 0;
  REP(i, 0, N) {
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    if (nxt[i] >= 0) dp[nxt[i]] = min(dp[nxt[i]], dp[i]);
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 10864
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define inf -100000000
#define ordered_set tree<pair<ll int,ll int>, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    ll int n;
    cin>>n;
    ll int k;
    cin>>k;
    ll int a[k+1][n+1];
        ll int i,d,x,count=0,fin=0;
    ll int j;
    for(i=0;i<=k;i++)
    {
    	for(j=0;j<=n;j++)
    		a[i][j]=0;
    }

    for(i=1;i<=k;i++)
    {
    	cin>>d;
    	for(j=0;j<d;j++)
    	{
    		cin>>x;
    		a[i][x]++;
    	}
    }
    for(i=1;i<=n;i++)
    {count=0;
    	for(j=1;j<=k;j++)
    	{
    		if(a[j][i]>0)
    			count++;
    	}
    	if(count==0)
    		fin++;
    }
    cout<<fin<<endl;
}


Measured memory_bytes: 3696
a =int(input())
b =int(input())
c =int(input())
x =int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

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

using namespace std;
typedef long long ll;
int a[7];
ll ans;
ll ans2;
int main() {
  for(int i = 0; i < 7; i++) cin >> a[i];
  ans += a[0] / 2 * 2;
  ans += a[3] / 2 * 2;
  ans += a[4] / 2 * 2;
  ans += a[1];
  if(a[0] > 0 && a[3] > 0 && a[4] > 0) {
    ans2 += 3;
    a[0]--; a[3]--; a[4]--;
    ans2+= a[0] / 2 * 2;
    ans2+= a[3] / 2 * 2;
    ans2+= a[4] / 2 * 2;
    ans2+= a[1];
  }
 
 
  cout << max(ans,ans2) <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];

ll gao(int l,int r){
    return sum[r]-sum[l-1];
}

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

    int n ;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i];
    ll l=1,r=3;
    ll ans=1e18+8;
    for(int i=2;i<=n-2;i++){
         while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))
            l++;
         while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))
            r++;
//         cout << i <<" "<<l<<" "<<r<<" ";
         set<ll>st;
         st.insert(gao(1,l));
         st.insert(gao(l+1,i));
         st.insert(gao(i+1,r));
         st.insert(gao(r+1,n));
         ans=min(ans,abs(*st.begin()-*prev(st.end())));
//         cout << abs(*st.begin()-*prev(st.end()))<<endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N,0);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

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

  priority_queue<long long> que;

  long long sum = 0;

  que.push(a[N-1]);

  for (int i = N-2; i >= 0; --i) {
    long long top = que.top();
    que.pop();
    que.push(a[i]);
    que.push(a[i]);
    sum += top;
  }
  cout << sum <<endl;
  return 0;
}

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

ll gcd(ll a, ll b){
    if(b == 0){ return a;}
    else {
        return gcd(b, a % b);
    }
}

ll gcdVect(vector<ll> & vals){
    int size = vals.size();
    ll gcdVal = vals[0];
    for(int i = 1 ; i < size; i++){
        gcdVal = gcd(max(vals[i], gcdVal), min(vals[i], gcdVal));
    }
    return gcdVal;
}

int main(void)
{
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N, 0);
    
    
    for (ll i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    vector<ll> distX(N, 0);

    for( ll i = 0; i < N; i++){
        distX[i] = abs(X - x[i]);
    }

    ll val = gcdVect(distX);

    cout << val << endl;
    return 0;
}


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

int main(){
    int n, k, b;
    cin >> n >> k;
    vector<int> subset(k);
    for(int i = 0; i < k; i++)  cin >> subset[i];

    for(int i = 0; i < 1<<n; i++){
        bool includes = true;
        for(int j : subset) if(~i & 1<<j)   includes = false;
        if(!includes)   continue;
        
        vector<int> res;
        for(int j = 0; j < n; j++)  if(i & 1<<j)    res.push_back(j);
        
        cout << i << ":";
        for(int j : res)    cout << " " << j;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3152
#include<stdio.h>

static const int N=100;

int main() {
  int M[N][N];
  int n,u,k,v,i,j;

  scanf("%d\n", &n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i = 0;i<n;i++) {
    scanf("%d%d\n",&u,&k );
    u--;
    for(j=0;j<k;j++) {
      scanf("%d\n", &v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      if(j)printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n" );
  }

  return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
void func(int ,int);
int w,h,cnt;
int a[102][102];
int dx[2][6]={{-1,0,1,0,-1,-1},
				{0,1,1,1,0,-1}};
int dy[2][6]={{-1,-1,0,1,1,0},
				{-1,-1,0,1,1,0}};
int main(void)
{
	int i,j,x;
	scanf("%d %d",&w,&h);
	for(i=0;i<=h+1;i++)	{
		for(j=0;j<=w+1;j++)	{
			a[i][j]=0;
		}
	}

	for(i=1;i<=h;i++)	{
		for(j=1;j<=w;j++)	{
			scanf("%d",&a[i][j]);
		}
	}
	cnt=0;
	func(0,0);
	printf("%d\n",cnt);
    return 0;
}
void func(int x,int y)
{
	int i,j,k,xx,yy;
	
//	printf("x=%d y=%d\n",x,y);
	
	k=y%2;
	a[y][x]=-1;
	for(i=0;i<6;i++)	{
		xx=x+dx[k][i];
		yy=y+dy[k][i];
		if(xx>=0 && xx<=w+1 && yy>=0 && yy<=h+1 && a[yy][xx]==1)	{
			cnt++;
		}
		if(xx>=0 && xx<=w+1 && yy>=0 && yy<=h+1 && a[yy][xx]==0)	{
			func(xx,yy);
		}
	}
}


Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define RREP(i, a, n) for(int i=n-1; i>=a; --i)

int x, rate;
int main(void)
{
    cin>>x;
    if(x<600){
        rate=8;
    }
    else if(x<800){
        rate=7;
    }
    else if(x<1000){
        rate=6;
    }
    else if(x<1200){
        rate=5;
    }
    else if(x<1400){
        rate=4;
    }
    else if(x<1600){
        rate=3;
    }
    else if(x<1800){
        rate=2;
    }
    else{
        rate=1;
    }

    cout<<rate<<endl;
    return 0;
}

Measured memory_bytes: 3648
n = gets.to_i
line = []
(1..n).each{ |i| line[i] = gets.split.map(&:to_i)[2..-1] }
h = 0
visited = Array.new(n+1, -1)
visited[1] = 0
while true
  f = false
  (1..n).each do |i|
    if visited[i] == h
      f = true
      line[i].each{ |j| visited[j] = h+1 if visited[j] == -1 }
    end
  end
  break unless f
  h += 1  
end
(1..n).each{ |i| puts "#{i} #{visited[i]}" }

Measured memory_bytes: 8716
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() //single long
private fun readDouble() = readLn().toDouble() //single double

private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map{it.toLong()} // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(){
    val (n, k) = readInts()
    val height = readInts()

    val dp = IntArray(n){Int.MAX_VALUE}
    dp[0] = 0
    dp[1] = abs(height[1] - height[0])

    for(i in 2 until n){
        if(i - k < 0){
            for(j in 0 until i){
                dp[i] = min(dp[i], abs(height[i] - height[j])+ dp[j])
            }
        }else{
            for(j in i-k until i){
                dp[i] = min(dp[i], abs(height[i] - height[j]) + dp[j])
            }
        }
    }

    println(dp[n-1])
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int get(string s, int i, int j) {
  int res = 0;
  for (int k=i; k<j; k++) {
    res=res*10;
    res += (s[k]-'0');
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  //2019/04/30
  string s; cin>>s;
  int year = get(s,0,4);
  if (year>2019) out("TBD");
  if (year<2019) out("Heisei");
  int month = get(s,5,7);
  if (month>4) out("TBD");
  if (month<4) out("Heisei");
  int day = get(s,8,10);
  if (day<=30) out("Heisei");
  out("TBD");

  

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 19 22:37:09 2019

@author: lucifer
"""
k,n=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
max=k+a[0]-a[n-1]
sum=max
for i in range(n-1):
    if a[i+1]-a[i]>max:
        max=a[i+1]-a[i]
    sum=sum+a[i+1]-a[i]
sum=sum-max
print(sum)

Measured memory_bytes: 26060
#include<stdio.h>
#define MAX 100000
typedef struct{
    char name[100];
    int time;
} queue;
 
void enqu(queue);
queue dequ(void);
 
int head=0,tail=0;
queue C[MAX];
 
    main(){
    int n,m,i,sum=0;
    queue D;

    scanf("%d%d",&n,&m);
        for(i=0;i<n;i++){
            scanf("%s%d",D.name,&D.time);
            enqu(D);
        }
        while(1){
            if(head == tail) break;
            if(C[head].time > m){
                D = dequ();
                D.time -= m;
                enqu(D);
                sum += m;
            }
            else{
                D = dequ();
                printf("%s %d\n",D.name,D.time+sum);
                sum += D.time;
            }
        }
return 0;
}
 
void enqu(queue p){
C[tail] = p;
if(tail+1 == MAX) tail = 0;
else tail++;
}
 
queue dequ(){
    queue x;
    x = C[head];
 
    if(head+1 == MAX) head = 0;
    else head++;
    return x;
}

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 

	int n, x, t;
	cin >> n >> x >> t;
	
	if (n%x == 0) {
		cout << (n/x) * t << endl;
	}
	else {
		cout << ((n/x)+1)*t << endl;
	}
}

/*
int tt;
	cin >> tt;
	while (tt--) {
	
		
	}
*/


Measured memory_bytes: 3608
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    s = S()
    s[k-1] = s[k-1].lower()
    print("".join(s))

    return

#B
def B():
    s = S()
    a = int("".join(s[:2]))
    b = int("".join(s[2:]))
    if 0 < a <= 12:
        if 0 < b <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    elif a == 0:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")
    else:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")
    return

#C
def C():
    n, k = LI()
    ans = 0
    if k == 1:
        print(1)
        return
    nibuiti = [None for i in range(int(math.log2(k) + 1))]
    for num in range(int(math.log2(k) + 1)):
        if num == 0:
            nibuiti[num] = 1 / 2
            continue
        nibuiti[num] = nibuiti[num-1]/2
        
    for i in range(1, n + 1):
        if i >= k:
            ans += 1
            continue
        b = nibuiti[int(math.log2((k - 1) // i))]
        ans += b
    print(ans/n)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 3764
h, w, k = map(int, input().split())
s = [list(input()) for i in range(h)]


stack1 = []
stack2 = []
ans = [[0]*w for i in range(h)]
n = 1
fff = True
for i in range(h):
    first = True
    if s[i] == ["."]*w:
        if fff: stack1.append(i)
        else: stack2.append(i)
        continue
    else: fff = False
    for j in range(w):
        if s[i][j]==".":
            ans[i][j] = n
        else:
            if first:
                ans[i][j] = n
                first=False
            else:
                n += 1
                ans[i][j] = n
    n += 1

for i in stack1[::-1]:
    for j in range(w): ans[i][j] = ans[i+1][j]
for i in stack2:
    for j in range(w): ans[i][j] = ans[i-1][j]

for i in ans: print(*i)

Measured memory_bytes: 8272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int a,b,c;
ll k;
int main() {
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	if (k%2==0) printf("%d\n",a-b); else printf("%d\n",b-a);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll MOD = 998244353;
ll INF = 1e15;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

ll mod(ll a, ll m){
  return (a+m)%m;
}

ll inverse(ll a, ll m){
  a = mod(a, m);
  if (a <= 1)return a;
  return mod((1 - inverse(m, a) * m) / a,m);
}

ll N,K,tmp,l;
ll memo[2020][2020][2];
stack<ll> st;

ll ask(ll a, ll b, ll c){
  // cout<<"Ask " << a << ' ' << b << '\n';
  if (memo[a][b][c] != -1)return memo[a][b][c];
  return memo[a][b][c] = (MOD + 2*ask(a-1,b-1,c) - ask(a-2,b-1,c)) % MOD;
}

int main(){
  // freopen("input.txt","r",stdin);
  cin>>K>>N;
  memset(memo,-1,sizeof(memo));
  tmp = 1;
  memo[0][0][0] = 0;
  memo[1][0][0] = 1;
  for (int i=2;i<=K;++i){
    tmp = (tmp * (i+N-1)) % MOD;
    tmp = (tmp * inverse(i-1, MOD)) % MOD;
    memo[i][0][0] = tmp;
    // cout<<i<<' '<<tmp<<'\n';
  }
  tmp = 1;
  memo[0][0][1] = 0;
  memo[1][0][1] = 1;
  for (int i=2;i<=K;++i){
    tmp = (tmp * (i+N-2)) % MOD;
    tmp = (tmp * inverse(i-1, MOD)) % MOD;
    memo[i][0][1] = tmp;
    // cout<<i<<' '<<tmp<<'\n';
  }

  for (int i=2;i<=K+1;++i){
    if (i % 2 == 0){
      l = ask(K-1,(i-1)/2,0) + ask(K-1,(i-1)/2,1);
      l %= MOD;
    }
    else l = ask(K,i/2,0);
    cout<<l<<'\n';
    st.push(l);
  }
  st.pop();
  while(SZ(st)){cout<<st.top()<<'\n';st.pop();}
}


Measured memory_bytes: 64128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        int[] input;

        public void ParseLines()
        {
            n = int.Parse(InputReader.ReadLine());
            input = InputReader.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        public string Resolve()
        {
            var max = input.ToList().OrderBy(x => -x).ToList();
            if (max[0] < max.GetRange(1, n - 1).Sum()) return "Yes";

            return "No";
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13396
N=int(input())
s=input()

rcnt=s.count("R")
gcnt=s.count("G")
bcnt=s.count("B")
sum=rcnt*gcnt*bcnt#条件1を満たす組み合わせの数

for i in range(N):
    for d in range(N):
        j=i+d
        k=j+d
        if k>=N:
            break
        if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:#等間隔の組み合わせを除く
            sum-=1
print(sum)

Measured memory_bytes: 68144
def read_int():
    return int(input())

def read_ints():
    return map(int, input().split())

def read_lines(N):
    return [input() for i in range(N)]

def main():
    N, K = read_ints()
    towns = [int(t) -1  for t in input().split() ]
    #print(N, K , towns)

    loop = []
    loop_set = set()
    next_town = towns[0]
    while next_town not in loop_set:
        #print(f"next_t={next_town}")
        loop.append(next_town)
        loop_set.add(next_town)
        next_town = towns[next_town]

    i = loop.index(next_town)
    all_loop = loop
    pre_loop = loop[:i]
    loop = loop[i:]
    pre_length = len(pre_loop)
    loop_length = len(loop)

    """
    for k in range(1, 10):
        if k - 1  < len(all_loop):
            print(f"k={k}", all_loop[k-1] + 1)
        else:
            i = ((k -1 - len(pre_loop)) % loop_length)
            print(i, pre_loop, loop)
            print(f"k={k}", loop[i]+1)
    """

    #print(pre_loop, loop)
    if K - 1  < len(all_loop):
        print(all_loop[K-1] + 1)
    else:
        i = ((K -1 - pre_length) % loop_length)
        #print(i, pre_loop, loop)
        print(loop[i]+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32484
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    int max = 0;
    int min = 1000000000;

    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> A[i];
        if(max < A[i]){
            max = A[i];
        }
        if(A[i] < min){
            min = A[i];
        }
    }

    cout << max - min << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int m, k;
    cin >> m >> k;

    int n = pow(2, m);

    if (pow(2, m) <= k) {
        cout << -1 << "\n";
        return 0;
    }

    if (m == 1) {
        if (k == 1) {
            cout << -1 << "\n";
            return 0;
        } else {
            cout << "0 0 1 1\n";
            return 0;
        }
    }

    cout << k << " ";
    for (int i = 0; i < n; i++) {
        if (i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for (int i = n-1; i >= 0; i--) {
        if (i == k) continue;
        cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 1792
a, b = gets.chomp.split(' ').map(&:to_i)

i = 0
ans = 0
while true
  if i == 0
    ans = 1 
  else
    ans = a + (a - 1) * (i - 1)
  end
  if ans >= b
    break
  end
  i += 1
end
puts "#{i}"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N),b(N);
    REP(i,N) cin>>a[i]>>b[i];

    int A=a[0],B=b[0];
    REP(i,N){
        int k=max((A+a[i]-1)/a[i],(B+b[i]-1)/b[i]);
        A=k*a[i]; B=k*b[i];
    }
    cout<<A+B<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+500;
struct Edge{int v,w;}e[N];
int fst[N],nxt[N],cnt[5],vis[N],col[N],siz,en,fail,n,m,mm=1,evis[N];
long long ans;
void ade(int u,int v,int w){e[++mm]=(Edge){v,w},nxt[mm]=fst[u],fst[u]=mm;}
void dfs(int u,int c)
{
    vis[u]=1;col[u]=c;++cnt[c];++siz;
    for(int i=fst[u];i;i=nxt[i])
    {
        int v=e[i].v;if(!evis[i])evis[i]=evis[i^1]=1,++en;
		int t=c+e[i].w;if(t==4)t=1;if(t==0)t=3;
        if(vis[v])
        {
            if(col[v]!=t)fail=1;
            continue;
        }
        dfs(v,t);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),ade(u,v,1),ade(v,u,-1);
    for(int i=1;i<=n;i++)
        if(!vis[i])
        {
            siz=en=cnt[1]=cnt[2]=cnt[3]=fail=0;
            dfs(i,1);
            if(fail)ans+=1ll*siz*siz;
            else if(cnt[1]&&cnt[2]&&cnt[3])ans+=1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[3]+1ll*cnt[3]*cnt[1];
            else ans+=en;
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 14160
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, t;
	cin >> n >> t;
	ll s[200200];
	cin >> s[0];
	ll time = t;
	for (ll i = 1;i < n;i++) {
		cin >> s[i];
		if (s[i] - s[i - 1] < t)time += s[i] - s[i - 1];
		else time += t;
	}
	cout << time << endl;
}

Measured memory_bytes: 1792
ABCD = input()

for i in range(1 << 3):
    total = int(ABCD[0])
    equation = ABCD[0]
    for j in range(3):
        if i & (1 << j):
            total += int(ABCD[j+1])
            equation += "+"
        else:
            total -= int(ABCD[j+1])
            equation += "-"    
        equation += ABCD[j+1]
    if total == 7:
        equation += "=7"
        print(equation)
        break

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N, A, B;
    cin>>N>>A>>B;
    if(A%2==B%2) cout<<(B-A)/2<<endl;
    else{
        cout<<min((2*N-A-B+1)/2, (A+B-2+1)/2)<<endl;
    }
    return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N;



int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    vector<u64> Red(N, 0), White(N, 0);
    
    for (u64 i = 0; i < N; i++) {
        char color;
        cin >> color;
        if (color == 'R') {
            if (i == 0) {
                Red[i] = 1;
            } else {
                Red[i] = Red[i - 1] + 1;
                White[i] = White[i - 1];
            }
        } else {
            if (i == 0) {
                White[i] = 1;
            } else {
                White[i] = White[i - 1] + 1;
                Red[i] = Red[i - 1];
            }
        }
    }
    
    u64 min_value = Red[N - 1];
    
    for (u64 i = 0; i < N; i++) {
        u64 r = White[i];
        u64 w = (Red[N - 1] - Red[i]);
        min_value = min(min_value, max(w, r));
    }
    
    cout << min_value << endl;
    
    return 0;
}


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




    int main(){
        int n;
        std::cin >> n;
        int count = 0;
        rep(i, n){
            if (to_string(i + 1).size() % 2 == 1)
            {
                count++;
            }
        }
        std::cout << count << "\n";
        return 0;
    }


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;
  for (int i = 0; i < dy; i++) cout << 'U';
  for (int i = 0; i < dx; i++) cout << 'R';
  for (int i = 0; i < dy; i++) cout << 'D';
  for (int i = 0; i < dx; i++) cout << 'L';
  cout << 'L';
  for (int i = 0; i <= dy; i++) cout << 'U';
  for (int i = 0; i <= dx; i++) cout << 'R';
  cout << "DR";
  for (int i = 0; i <= dy; i++) cout << 'D';
  for (int i = 0; i <= dx; i++) cout << 'L';
  cout << 'U' << endl;
  return 0;
}

Measured memory_bytes: 384
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    string s,t;
    cin>>s>>t;
    int u,v;
    cin>>u>>v;
    string tmp;
    cin>>tmp;
    if(tmp==s) u--;
    if(tmp==t) v--;
    cout<<u<<" "<<v<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
   t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
vector <int> bi[N];
int ok;
int dfs(int t, int f = 0)
{
    int c = 0;
    for (int i = 0; i < bi[t].size(); ++ i)
        if (bi[t][i] != f)
        {
            int w = dfs(bi[t][i], t);
            if (w == 0) c ++;
        }
    if (c <= 1) return c;
    else ok = 1;
    return -1;
}
int main()
{
    cin >> n;
    for (int i = 1; i < n; ++ i)
    {
        int a, b;
        cin >> a >> b;
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    ok = 0;
    if (dfs(1) == 0) ok = 1;
    if (ok) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    int a[n]; rep(i,n) cin>>a[i];
    int ans=0,co=101;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            a[i+1]=co; co++;ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a);
        b >>= 1;
        if (!b)
            break;
        a = (a*a);
    }
    return result;
}
int main()
{
	IOS;
	lli a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int tmp[5], n[2], ans;

int main(){

	rep(i, 3)cin >> tmp[i];
	rep(i, 2)cin >> n[i];

	sort(tmp, tmp + 3);
	sort(n, n + 2);
	ans = tmp[0] + n[0] - 50;

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
using namespace std;
int n;
vector<double> cnt(4);
double memo[305][305][305];
double solve(int a, int b, int c){
    if(a==0 && b==0 && c==0)
        return 0;
    double &res = memo[a][b][c];
    if(res >= 0)
        return res;
    double s = a+b+c;
    res = (n/s);
    if(a)
        res += a/s*solve(a-1, b, c);
    if(b)
        res += b/s*solve(a+1, b-1, c);
    if(c)
        res += c/s*solve(a, b+1, c-1);
    return res;
}
int main(){
    IO;
    cin >> n;
    memset(memo, -1, sizeof memo);
    for(int i = 0; i < (int)n; ++i){
        int x;
        cin >> x;
        cnt[x]++;
    }
    cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]);
    return 0;
}


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

using namespace std;

#define ll long long

void solve(){

    int n, m; cin >> n >> m;
    ll k; cin >> k;
    ll arr[n]; ll brr[m];
    int ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        arr[i] += (i==0 ? (ll)0 : arr[i-1]);
        if(arr[i] <= k) ans = i+1;
    }
    for(int i = 0; i < m; ++i){
        cin >> brr[i];
        brr[i] += (i==0 ? (ll)0 : brr[i-1]);
        if(brr[i] <= k) ans = max(ans, i+1);
    }
    for(int i = 0; i < n; ++i){
        if(arr[i] > k) break;
        int pos = lower_bound(brr, brr+m, (ll)k-arr[i]) - brr;
        if(pos == m || brr[pos] > k-arr[i]) --pos;
        if(pos < 0) continue;
        ans = max(ans, i+pos+2);
    }
    cout << ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	solve();
	return 0;
}



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

int arr[1 << 10][1 << 10] , N , M;

int main(){
	cin >> N >> M;
	for(int i = 1 ; i < 1 << N ; ++i , putchar('\n'))
		for(int j = 1 ; j < 1 << M ; ++j){
			arr[i][j] = (__builtin_popcount(i & j) % 2);
			putchar((arr[i][j] ^ arr[i - 1][j] ^ arr[i][j - 1] ^ arr[i - 1][j - 1]) + '0');
		}
	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>
#define M 500000

int con = 0;
int l[M/2+2],r[M/2+2];

void merge(int*,int,int,int,int);
void mergesort(int*,int,int,int);

int main(){
  int n,i;
  int a[M];

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

  for(i = 0;i < n;i++){
    if(i != 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",con);
}

void merge(int *a,int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0;i < n1;i++){
    l[i] = a[left + i];
  }
  for(i = 0;i < n2;i++){
    r[i] = a[mid + i];
  }
  l[n1] = 1000000000;
  r[n2] = 1000000000;
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    con++;
    if(l[i] <= r[j]){
      a[k] = l[i];
      i += 1;
    }
    else{
      a[k] = r[j];
      j += 1;
    }
  }
}


void mergesort(int *a,int n,int left,int right){
  int mid,i,c=0;
  if(left + 1 < right){
    mid = (left + right)/ 2;
    mergesort(a, n, left, mid);
    mergesort(a, n, mid, right);
    merge(a, n, left, mid, right);
    c++;
  }
}



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

//要求MOD是质数，预处理时间复杂度O(n)
typedef long long ll;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
int f[N], finv[N], inv[N];

void init() {
    inv[1] = 1;
    for (int i=2; i<N; ++i) {
        inv[i] = (MOD - MOD / i) * 1ll * inv[MOD%i] % MOD;
    }
    f[0] = finv[0] = 1;
    for (int i=1; i<N; ++i) {
        f[i] = f[i-1] * 1ll * i % MOD;
        finv[i] = finv[i-1] * 1ll * inv[i] % MOD;
    }
}

//C(n, k) % p
int comb(int n, int k)  {
    if (k < 0 || k > n) return 0;
    return (ll)f[n] * finv[n-k] % MOD * finv[k] % MOD;
}

int n;
int a[N];
int cnt[N];

int main() {
	ios::sync_with_stdio(false);
	init();
	cin >> n;
	int v = 0;
	for (int i=1; i<=n+1; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] > 1) v = a[i];
	}
	int x = 0, y = 0;
	for (int i=1; i<=n+1; ++i) {
        if (a[i] == v) break;
        x++;
	}
	for (int i=n+1; i>=1; --i) {
        if (a[i] == v) break;
        y++;
	}
	for (int k=1; k<=n+1; ++k) {
		cout << (comb(n+1, k)-comb(x+y, k-1)+MOD) % MOD << '\n';
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
void func(string s){
    int ma=-1;
    if(s.size()==n){
        cout<<s<<endl;
        return;
    }
    for(char c:s){
        chmax(ma,(int)c-'a');
    }
    for(char i='a';i<='a'+ma+1;i++){
        func(s+i);
    }
}
signed main(){
    cin>>n;
    func("");
    return 0;
}


Measured memory_bytes: 1536