akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
using namespace std;

string join(vector<int> v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += to_string(v[0]);
    for (int i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += to_string(v[i]);
    }
  }
  return s;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    const char* delim_ = " ";
    string answer = join(vec, delim_);
    answer.erase(answer.size() - std::char_traits<char>::length(delim_)+1);
    answer.erase(0, answer.find_first_not_of(" \n\r\t"));
    cout << answer << endl;

    for (int i =1; i < N; i++) {
        int v = vec[i];
        int j = i - 1;
        while (j >= 0 && vec[j] > v) {
            vec[j+1] = vec[j];
            j--;
        }

        vec[j + 1] = v;
        string answer = join(vec, delim_);
        answer.erase(answer.size() - std::char_traits<char>::length(delim_) + 1);
        answer.erase(0, answer.find_first_not_of(" \n\r\t"));
        cout << answer << endl;
    }


    return 0;
}


Measured memory_bytes: 3244
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vector<ulong> A(N);
  REP(i, 0, N) {
    cin >> A[i];
  }

  ulong s = A[0];
  REP(i, 1, N) {
    s ^= A[i];
  }

  cout << (s ^ A[0]);
  REP(i, 1, N) {
    cout << " " << (s ^ A[i]);
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 4768
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  long long N; cin >> N;
  long long res = 1;
  const long long LARGE = 1000000007;
  for(long long i = 1; i <= N; i++) res = (res * i) % LARGE;
  cout << res << endl;
}


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

k = int(input())
ans = (k+1)*k//2

for i in range(1,k+1):
    for j in range(i+1,k+1):
        ans += 6*gcd(i,j)

for a in range(1,k+1):
    for b in range(a+1,k+1):
        for c in range(b+1,k+1):
            ans += 6*gcd(gcd(a,b),c)


print(ans)

Measured memory_bytes: 68632
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
static int v = int.Parse(input[0]);
static int e = int.Parse(input[1]);
static bool[] checkedVertex = new bool[v];//頂点が確認済みか？
static List<int> answers = new List<int>();
static List<int>[] nextList = new List<int>[v];
static int[] inDegree = new int[v];//入次数


	static void Main()
	{
    
    for(int i = 0; i < v; i++) 
    {
      nextList[i] = new List<int>();//リストの宣言が必要
    }

    for(int i = 0; i < e; i++)
    {
      string[] inputa = Console.ReadLine().Split(' ');
      int b = int.Parse(inputa[0]);
      int c = int.Parse(inputa[1]);
      nextList[b].Add(c);//隣接リストの作成
    }

    TopologicalSort();
	}

  static void TopologicalSort()//トポロジカルソート
  {
    for(int i = 0; i < v; i++) inDegree[i] = 0;//初期化
    
    for(int i = 0; i < v; i++)
    {
      for(int j = 0; j < nextList[i].Count(); j++)
      {
        inDegree[nextList[i][j]]++;//入次数の計算
      }
    }

    for(int i = 0; i < v; i++)
    {
      if(inDegree[i] == 0 && !(checkedVertex[i])) BFS(i);
    }

    var answerText = new StringBuilder();
    for(int i = 0; i < answers.Count(); i++)
    {
      answerText.AppendLine(answers[i].ToString());
    }
    Console.Write(answerText);
  }

  static void BFS(int startVertex)//幅優先探索
  {
    Queue<int> que = new Queue<int>();
    que.Enqueue(startVertex);//追加
    checkedVertex[startVertex] = true;
    while(que.Count > 0)
    {
      int poppedMemo = que.Peek();//一番上を見る
      que.Dequeue();//取り出し
      answers.Add(poppedMemo);//追加
      for(int i = 0; i < nextList[poppedMemo].Count(); i++)
      {
        int aimVertex = nextList[poppedMemo][i];
        inDegree[aimVertex]--;
        if(inDegree[aimVertex] == 0 && !(checkedVertex[aimVertex]))
        {
          checkedVertex[aimVertex] = true;
          que.Enqueue(aimVertex);
        }
      }
    }
  }
  
}


Measured memory_bytes: 25332
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;


typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

void chmax(P &a, P b) {
    if (a.first < b.first) a.second = max(a.first, b.second), a.first = b.first;
    else a.second = max(a.second, b.first);
}


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

    vector<ll> a(1 << n);
    vector<P> dp(1 << n);

    for (int bit = 0; bit < (1 << n); bit++) {
        cin >> a[bit];
        dp[bit] = {a[bit], -INF};
    }

    for (int i = 0; i < n; i++) {
        for (int bit = 0; bit < (1 << n); bit++) {
            if (bit & (1 << i)) chmax(dp[bit], dp[bit ^ (1 << i)]);
        }
    }
    ll ans = -INF;
    rep(bit, 1 << n) {
        ll tmp = dp[bit].first + dp[bit].second;
        cmax(ans, tmp);
        if (bit) cout <<ans << endl;
    }

}


Measured memory_bytes: 9216
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem136b(n))
}

fun problem136b(n: Long): Int {

    return (1..n).count { i ->
        i.toString().length % 2 != 0
    }
}

Measured memory_bytes: 36376
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-22-20.02.21 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

char s[120];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> (s+1);
    int len = strlen(s+1);
    int fp = (len-1)/2;
    int sp = (len+3)/2;
    bool ok = true;
    string a = "";
    string b = "";
    for (int i = 1; i <= fp; ++i) {
        a += s[i];
    }
    for (int i = fp; i >= 1; --i) {
        b += s[i];
    }
    ok &= a==b;
    a = b = "";
    for (int i = sp; i <= len; ++i) a += s[i];
    for (int i = len; i >= sp; --i) b += s[i];
    ok &= a==b;
    a = b = "";
    for (int i = 1; i <= len; ++i) a += s[i];
    for (int i = len; i >= 1; --i) b += s[i];
    ok &= a==b;
    cout << (ok?"Yes":"No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  bool ans = false;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= M; j++){
      int t = M * i + j * N - 2 * i * j;
      if(t == K){
        ans = true;
      }
    }
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
w = list(input())

store = [0 for i in range(26)]
for i in range(len(w)):
    store[ord(w[i]) - 97] += 1

for i in range(len(store)):
    store[i] = store[i] % 2

if sum(store) == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld double
    #define vv vector<ll>
    #define pp pair<ll,ll>
    #define ff first
    #define ss second
    #define vp vector<pp>
    #define pb push_back
    #define mp make_pair
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define maxn 105
    const ll mod=1e9+7;
    #define N 2750135
    bool prime[N];
    ll p[N];
    ll n,m;
    void isprime()
    {
        memset(prime,true,N);
        memset(p,-1,sizeof(p));
        for(ll i=2;i<N;i++)
        {
            if(p[i]==-1)
            {
            	p[i]=i;
                for(ll j=i*i;j<N;j+=i)
                {
                    if(p[j]==-1)
                    {
                    	p[j]=i;
					}
                }
            }
        }
    }
    ll power(ll a,ll n)
    {
        ll ans=1;
        a=a%mod;
        while(n>0)
        {
            if(n&1)
            {
                ans=(ans*a)%mod;
            }
            n=n>>1;
            a=(a*a)%mod;
        }
        return ans;
    }
    ll gcd(ll a,ll b)
    {
        if(b==0)
        return a;
        
        return gcd(b,a%b);
    }
    

    int main()
    {
    	fast;
       ll l, r;
    cin>>l>>r;
    if(r-l>2020){
        cout<<0<<endl;
        return 0;
    }
    ll ans=2018;
    for(ll i=l; i<=r; i++){
        for(ll j=i+1; j<=r; j++){
            ans=min(ans, i*j%2019);
        }
    }
  cout<<ans<<endl;
    return 0;
		return 0;
	}

Measured memory_bytes: 256
/// 01:37 08/09/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll d, t, s;
    cin >> d >> t >> s;
    s = s * t;
    if (s >= d) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>x(n), y(n); for (auto&& i : x)cin >> i;
	y = x;
	sort(y.rbegin(), y.rend());
	int L = y[y.size() / 2 - 1], R = y[y.size() / 2];
	for (auto&& cur : x) {
		if (cur < L)cout << L << endl; else cout << R << endl;
	}

	return 0;
}

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

int main() {
  int L,R;
  cin >> L >> R;
  if(R-L>2020){
    cout << 0 << endl;
    return 0;
  }
  L %= 2019;
  R %= 2019;
  int ans=1e9;
  for(int i=L;i<=R;i++){
    for(int j=i+1;j<=R;j++){
      ans=min(ans,(i*j)%2019);
    }
  }
  cout << ans << endl;
}
    
      


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

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

int main(){
  string a, b;
  cin >> a >> b;
  int ia,ib;
  ia = stoi(a); ib = stoi(b);
  string A = "", B = "";
  rep(i,ia) B += b;
  rep(i,ib) A += a;
  if(A > B){
    cout << B << endl;
  }else{
    cout << A << endl;
  }

  return 0;
}

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

int main () {

    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);

    char S[N+1];
    scanf("%s", S);

    int passed = 0, abroad_rank = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == 'a') {
            if (passed < A + B) {
                printf("Yes\n");
                passed++;
            } else {
                printf("No\n");
            }
        } else if (S[i] == 'b') {
            if (passed < A + B && abroad_rank < B) {
                printf("Yes\n");
                passed++;
                abroad_rank++;
            } else {
                printf("No\n");
            }
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int t,cnt=0;
	string s;
	cin>>s>>t;
	while(t--){
		int op;
		cin>>op;
		if(op==2){
			int f;
			char c;
			cin>>f>>c;
			if(f==1) cnt&1?s.insert(s.end(),c):s.insert(s.begin(),c);
			else cnt&1?s.insert(s.begin(),c):s.insert(s.end(),c);	
		}
		else cnt++;
	}
	if(cnt&1) reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 912
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String t = scanner.next();
		int ans = solve(s.toCharArray(), t.toCharArray());
		System.out.println(ans);
	}

	public static int solve(char[] s, char[] t) {
		int ans = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] != t[i]) {
				ans++;
			}
		}
		return ans;
	}
}


Measured memory_bytes: 41492
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0)
		cout<<0;
	else
		cout<<min(a*b,min(b*c,c*a));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 long int sub(long int a,long int b){
   if(a<b){
     return 0;
   }
 long  int c=a/b;
   
   return c+sub(a,b*5);
 }
int main() {
long int a,b,c=0;
  cin>>a;
  if(a%2==1){
    cout<<0;
    return 0;
  }
  c=sub(a/2,5);

 cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
		if(s[i]!=t[i])  ans++;
	cout<<ans;
	return 0;
}

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

const int N = (int)1e5;

char s[N+5];
pair<int,int> dat[N+5];

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

    deque<int> q; while (!q.empty()) q.pop_front();
    q.push_back(n);

    for (int i=n-1; i>=0; i--) {
        while (!q.empty() && q.front() - i > m) {
            q.pop_front();

            while ((int)q.size() >= 2) {
                int first = q.front(); q.pop_front();
                int second = q.front();
                q.push_front(first);
                if (dat[first].second != dat[second].second) break;
                q.pop_front();
            }
        }

        if (s[i] == '0' && !q.empty()) {
            q.push_back(i);
            dat[i].first = q.front() - i;
            dat[i].second = dat[q.front()].second + 1;
        } else {
            dat[i] = make_pair(-1, -1);
        }
    }

    if (dat[0].first == -1) {
        printf("-1\n");
        return 0;
    }

    vector<int> res; res.clear();
    for (int pos=0; pos!=n; pos+=dat[pos].first) {
        res.push_back(dat[pos].first);
    }

    int sz = (int)res.size();
    for (int i=0; i<sz; i++) printf("%d%c", res[i], " \n"[i==sz]);
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<stack>
#include<queue>
#include<unordered_map>
bool isexist = true;
const int infty = 100000000;
const int vmax = 100000;
typedef int vname;
struct vertex;
struct edge {
	int weight;
	vertex *to;
	edge(int w, vertex *v) :weight(w), to(v) {};
};
struct vertex {
	std::vector<edge> adj;
	int distance;
	vname name;
	vertex(vname s) :name(s) {}
};
class graph {
private:
	std::unordered_map<vname, vertex*> work;
public:
	int vertexsize, edgesize;
	void addvertex(const vname& name) {
		if (work.count(name) == 0) work[name] = new vertex(name);
	}
	void addedge(vname from, vname to, int cost) {
		if (work.count(from) > 0 && work.count(to) > 0) {
			(work[from]->adj).push_back(edge(cost, work[to]));
		}
	}
	void bfs() {
		std::unordered_map<vname, bool> visited;
		std::stack<vertex *> st;
		for (auto i : work)visited[i.first] = false;
		for (auto i : work) {
			if (!visited[i.first]) {
				visited[i.first] = true;
				work[i.first]->distance = 0;
				st.push(work[i.first]);
				while (!st.empty()) {
					vertex *v = st.top();
					st.pop();
					for (auto e : v->adj) {
						if (!visited[e.to->name]) {
							visited[e.to->name] = true;
							e.to->distance = v->distance + e.weight;
							st.push(e.to);
						}
						else {
							if (e.to->distance != v->distance + e.weight)isexist = false;
						}
					}
				}
			}
		}
	}
};
int main() {
	graph g;
	vname a, b;
	int d;
	scanf("%d%d", &g.vertexsize, &g.edgesize);
	for (int i = 0; i < g.edgesize; i++) {
		std::cin >> a >> b >> d;
		g.addvertex(a);
		g.addvertex(b);
		g.addedge(a, b, d);
		g.addedge(b, a, -d);
	}
	g.bfs();
	if (isexist)printf("Yes");
	else printf("No");
	return 0;
}

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

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  long long all = 1;
  long long noNine = 1;
  long long neither = 1;
  for(int i = 0; i < N; i++){  
    all *= 10;
    all %= MOD;
    noNine *= 9;
    noNine %= MOD;
    neither *= 8;
    neither %= MOD;
    //cout << all << " " << noNine << " " << neither <<endl;
  }
  long long ans = ((all % MOD - ((noNine - neither) % MOD * 2) % MOD) % MOD - neither) % MOD;
  if(ans < 0) cout << ans + MOD <<endl;
  else cout << ans <<endl;
}


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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a1 = n%100;
		int a2 = n/100;
		if((a1>12 || a1==0) && (a2>12 || a2==0)){
			System.out.println("NA");
		}else if(a1>0 && a1<13 && a2>0 && a2<13){
			System.out.println("AMBIGUOUS");
		}else if((a1>12 || a1==0) && (a2>0 && a2<13)){
			System.out.println("MMYY");
		}else{
			System.out.println("YYMM");
		}
	}
}

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N, K);

  vector<i64> x(N);
  rep(i, N) {
    input(x[i]);
  }

  i64 minv = LINF;
  for (int l = 0; l < N - K + 1; ++l) {
    int r = l + K - 1;

    i64 norm;
    if (x[r] < 0) norm = abs(x[l]);
    else if (x[l] <= 0 && 0 <= x[r]) norm = min(abs(2 * x[l]) + abs(x[r]), abs(x[l]) + abs(2 * x[r]));
    else if (x[l] > 0) norm = abs(x[r]);

    chmin(minv, norm);
  }

  outl(minv);

  return 0;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		temp += n % 10;
		n = n / 10;
		// temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}


int main() {
	int i, m, n, k, c = 0, sum = 0;
	c_p_c();
	// cout<<"Sd"<<endl;>
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	if(s<t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;







	

}

Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys

def main():
    S = input()
    T = 'abcdefghijklmnopqrstuvwxyz'
    if len(S) < 26:
        U = set(T) - set(S)
        print(S + sorted(U)[0])
    else:
        if S == T[::-1]:
            print(-1)
        else:
            count = 1
            for i in range(25):
                if S[25-i] > S[24-i]:
                    break
                else:
                    count += 1
            #print(S[26-count:])
            for s in sorted(S[26-count:]):
                if s > S[25-count]:
                    print(S[:25-count] + s)
                    exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    string s, t; cin >> s >> t;
    int ans=0;
    rep(0,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200009];
ll b[200009];
ll su[200009];
main(){
    ll n, s1 = 0, s2 = 0;
    cin >> n;
    vector<ll> S;
    for(ll i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        S.push_back(a[i]);
        S.push_back(b[i]);
        s1 += a[i];
        s2 += b[i];
    }
    sort(S.begin(), S.end());
    for(ll i = 1; i <= 2*n; i++)
        su[i] = su[i - 1] + S[i-1];
    ll ans =min(s1, s2);
    for(ll i = 1; i <= n; i++){
        ll k = 0, t = 0;
        if(a[i] <= S[n-1])
            {k ++, t += a[i];
            if(b[i] <= S[n])
                k++, t += b[i];
            }
            else
         if(b[i] <= S[n-1])
            {k ++, t += b[i];
            if(a[i] <= S[n])
                k++, t += a[i];
            }
        ans = min(ans, su[n + k] - t);

    }
    cout << ans << endl;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long fpb(long long x, long long y) { 
    return (y == 0) ? x : fpb(y, x % y); 
}
long long kpk(long long x, long long y) { 
    return x * (y / fpb(x, y)); 
}
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 3648
#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 mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[3005][3005];

int main() {
  int N, S;
  cin>>N>>S;
  int A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  DP[0][0] = 2;
  DP[0][A[0]] = 1;
  for(int i=0;i<N-1;++i) {
    for(int j=0;j<=S;++j) {
      DP[i+1][j] += DP[i][j]*2;
      DP[i+1][j] %= mod1;
      if(j+A[i+1]<=S) {
        DP[i+1][j+A[i+1]] += DP[i][j];
        DP[i+1][j+A[i+1]] %= mod1;
      }
    }
  }
  cout<<DP[N-1][S]<<endl;
}



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

int A,B,C,X;

int solve(){
    int ans=0;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                int tmp = i*500 + j*100 + 50*k;
                if(tmp == X)ans++;
            }
        }
    }
    return ans;
}

int main(){
    cin>>A>>B>>C>>X;
    cout<<solve()<<endl;
    return 0;  
}

Measured memory_bytes: 256
n,W = map(int,input().split())
w,v = [0] * n ,[0] * n
for i in range(n):
    w[i] ,v[i] = map(int,input().split())

import numpy as np
ndp = np.zeros(W+1,dtype= np.int64)

for w,v in zip(w,v):
    np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:])
print(ndp[-1])

Measured memory_bytes: 14584
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int W, H;
	static int[][] map;
	static int[] DX = new int[] { 0, 1, 0, -1 };
	static int[] DY = new int[] { 1, 0, -1, 0 };

	public static void main(String[] args) {
		while (true) {
			W = sc.nextInt();
			if (W == 0) break;
			H = sc.nextInt();
			map = new int[H + 2][W + 2];
			for (int[] a : map) {
				Arrays.fill(a, 1);
			}
			int sy = 0;
			int sx = 0;
			int cy = 0;
			int cx = 0;
			int gy = 0;
			int gx = 0;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					map[i + 1][j + 1] = sc.nextInt();
					if (map[i + 1][j + 1] == 2) {
						cy = i + 1;
						cx = j + 1;
						map[i + 1][j + 1] = 0;
					} else if (map[i + 1][j + 1] == 3) {
						gy = i + 1;
						gx = j + 1;
						map[i + 1][j + 1] = 0;
					} else if (map[i + 1][j + 1] == 4) {
						sy = i + 1;
						sx = j + 1;
						map[i + 1][j + 1] = 0;
					}
				}
			}
			boolean[][][] visited = new boolean[H + 2][W + 2][4];
			boolean[] cand = walk(sx, sy, cx, cy);
			ArrayList<State> cur = new ArrayList<State>();
			for (int i = 0; i < 4; ++i) {
				if (cand[i]) {
					visited[cy][cy][i] = true;
					cur.add(new State(cx, cy, i));
				}
			}
			int ans = Integer.MAX_VALUE;
			int t = 1;
			OUT: while (!cur.isEmpty()) {
				ArrayList<State> next = new ArrayList<State>();
				for (State st : cur) {
					int ncx = st.cx + DX[st.dir];
					int ncy = st.cy + DY[st.dir];
					if (ncx == gx && ncy == gy) {
						ans = t;
						break OUT;
					}
					cand = walk(st.cx, st.cy, ncx, ncy);
					for (int i = 0; i < 4; ++i) {
						if (cand[i] && !visited[ncy][ncx][i]) {
							visited[ncy][ncx][i] = true;
							next.add(new State(ncx, ncy, i));
						}
					}
				}
				cur = next;
				++t;
			}
			System.out.println(ans == Integer.MAX_VALUE ? -1 : ans);
		}
	}

	static boolean[] walk(int sx, int sy, int cx, int cy) {
		boolean[] ret = new boolean[4];
		boolean[][] visited = new boolean[H + 2][W + 2];
		dfs(sx, sy, cx, cy, ret, visited);
		return ret;
	}

	static void dfs(int sx, int sy, int cx, int cy, boolean[] ret, boolean[][] visited) {
		if (visited[sy][sx]) return;
		visited[sy][sx] = true;
		for (int i = 0; i < 4; ++i) {
			int nx = sx + DX[i];
			int ny = sy + DY[i];
			if (map[ny][nx] == 1) continue;
			if (nx == cx && ny == cy) {
				if (map[ny + DY[i]][nx + DX[i]] == 0) {
					ret[i] = true;
				}
			} else {
				dfs(nx, ny, cx, cy, ret, visited);
			}
		}
	}

	static class State {
		int cx, cy;
		int dir;

		State(int cx, int cy, int d) {
			this.cx = cx;
			this.cy = cy;
			this.dir = d;
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//template<typename A, size_t N, typename T>
//void Fill(A(&array)[N], const T &val) {
	//std::fill((T*)array, (T*)(array + N), val);
//}

//変数

//解法
void solve() {

	ll N;
	cin >> N;

	if (N == 1) {
		cout << "Yes";
		return;
	}

	vector<ll> vec(N);
	rep(i, N) cin >> vec[i];

	ll high = vec[N - 1];
	ll ans = 0;

	for (ll i = N - 2; i >= 0; i--) {

		if (high + 1 < vec[i]) {
			cout << "No";
			return;
		}
		else if (high > vec[i]) {
			high = vec[i];
		}

	}

	cout << "Yes";

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>dates(N + 1, vector<int>(N + 1));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cin >> dates[i][j];
				dates[N][j] += dates[i][j];
				dates[i][N] += dates[i][j];
				dates[N][N] += dates[i][j];
			}
		}
		for (int i = 0; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) {
				printf("%5d", dates[i][j]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 1; i <= k; ++i) {
        ans += a[i];
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
typedef struct Tree{
  int key;
  int parent;
  int left;
  int right;
}Tree;

int main(){
  int H,i;
  Tree *T;
  scanf("%d",&H);
  T=(Tree*)malloc(sizeof(Tree)*H);
  for(i=0;i<H;i++){
    T[i].key=2000000001;
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }
  for(i=0;i<H;i++){
    scanf("%d",&T[i].key);
    T[i].parent=(i+1)/2-1;
    if(2*i+1<H){
      T[i].left=2*i+1;
      if(2*i+2<H)
	T[i].right=2*i+2;
    }
  }
  for(i=0;i<H;i++){
    printf("node %d: key = %d, ",i+1,T[i].key);
    if(T[i].parent!=-1)
      printf("parent key = %d, ",T[T[i].parent].key);
    if(T[i].left!=-1)
      printf("left key = %d, ",T[T[i].left].key);
    if(T[i].right!=-1)
      printf("right key = %d, ",T[T[i].right].key);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
	int counter=0;
	char str[3];
	fgets(str, 3, stdin);
	for (int i = 0; i < strlen(str); i++)
	{
		if (str[i]=='9')
		{
			counter++;
		}
	}
	if (counter == 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, K;
    scan(N, K);
    auto h = readln.split.to!(int[]);

    auto dp = new int[](N);
    dp[] = inf;
    dp[0] = 0;

    foreach (i ; 1 .. N) {
        foreach (j ; max(0, i - K) .. i) {
            chmin(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    auto ans = dp[N - 1];
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4128
import math

N,D=input().split()

x=[list(map(int,input().split(" "))) for i in range(int(N))]

count=0

for i in range(int(N)):
    for j in range(i+1,int(N)):
        result1=0
        for k in range(int(D)):
            result1+=pow(x[i][k]-x[j][k],2)

        diff=math.sqrt(result1)
        if diff.is_integer():
            count+=1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    
    int n,di,x;
    x=0;
    scanf("%d",&n);
    
    for(int i=1; i<=n; i+=2){
        di=0;
        for(int j=1; j<=i; j++){
            if(i%j==0)
                di++;
        }
        if(di==8)
            x++;
    }
    printf("%d",x);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
  
P project(P b,P c){
  return b*real(c/b);
}
  
int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=project(P(bx-ax,by-ay),P(cx-ax,cy-ay));
    printf("%.8f %.8f\n",ax+p.real(),ay+p.imag());
  }
  return 0;
}

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

const int MAXL = 200;
const int MAXN = 100100;

int jump[MAXN][MAXL];
int ans[MAXN];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      jump[i][0] = i + 1;
    } else {
      jump[i][0] = i - 1;
    }
  }
  for(int k = 0; k  + 1 < MAXL; ++k) {
    for(int i = 0; i < n; ++i) {
      int cur = i;
      for(int j = 0; j < 10; ++j) {
        cur = jump[cur][k];
      }
      jump[i][k + 1] = cur;
    }
  }
  
  for(int i = 0; i < n; ++i) {
    ++ans[jump[i][100]];
  }

  for(int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 79232
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif




int main() {
	int n=rd();
	vector<pii> v;
	REP(i,1,n) {
		int t = rd();
		if (v.empty()||v.back().x!=t) v.pb(pii(t,1));
		else ++v.back().y;
	}
	int ans = 0;
	for (auto &&t:v) ans += t.y/2;
	printf("%d\n", ans);
}








Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
static const int MAX=1000;
static const int VMAX=10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
	int ans=0;
	bool V[MAX];
	for (int i = 0; i < n; ++i) {
		B[i]=A[i];
		V[i]=false;
	}
	sort(B,B+n);
	for (int i = 0; i < n; ++i) {T[B[i]]=i;	}
	for (int i = 0; i < n; ++i) {
		if(V[i])continue;
		int cur=i;
		int S=0;
		int m=VMAX;
		int an=0;
		while(1){
			V[cur]=true;
			an++;
			int v=A[cur];
			m=min(m,v);
			S+=v;
			cur=T[v];
			if(V[cur])break;
		}
		ans+=min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}




int main(){
	cin>>n;
	s=VMAX;
	for (int i = 0; i < n; ++i) {
		cin>>A[i];
		s=min(s,A[i]);
	}
	int ans =solve();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string N;
    io.read(N);
    string ans = "No";
    if(N[0] == N[1] && N[1] == N[2]){
        ans = "Yes";
    }
    if(N[1] == N[2] && N[2] == N[3]){
        ans = "Yes";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MOD (1000000007ULL)
 
using namespace std;
 
typedef unsigned long long ull;
 
string line,parse;
int pos;
int n;
 
ull exp();
 
ull fact()
{
  ull res = 0;
  if(line[pos] == 'S')
    {
      pos+=2;
      res = exp();
      res = res * res % MOD;
      pos++;//now, the position is '>' and go to next
    }
  else
    {
      while(pos < n && '0' <= line[pos] && line[pos] <= '9')
	{
	  res *= 10ULL;
	  res += (line[pos]-'0');
	  pos++;
	}
    }
  return res;
}
 
ull exp()
{
  ull p = fact();
  while(line[pos] == '*' && line[pos+1] == '*')
    {
      pos += 2;
      ull q = fact();
      //here, the variable 'pos' indicates the position after the 'S' or 'num'
      //cout << "calc : " << p << " >> " << q << endl;
      p = p >> (ull)min(q,(ull)(log2(p))+1ULL);
      //cout << "p " << p << endl;
    }
 
  return p;
}
 
void preDo(string &line)
{
  stringstream ss;
  ss << line;
  line.clear();
  string pre;
  while(!(ss>>pre).fail())line += pre;
 
  rep(i,n)
    {
      if(('0' <= line[i] && line[i] <= '9') || line[i] == 'S')
	{
	  if(i-2 >= 0)
	    {
	      if(line[i-1] == '>' && line[i-2] == '>')
		{
		  line[i-1] = line[i-2] = '*';
		  while(i < n && '0' <= line[i] && line[i] <= '9')i++;
		}
	    }
	}
    }
  //cout << "before : " << line << endl; 
}
 
int main()
{
  while(true)
    {
      getline(cin,line);
      if(line[0] == '#')break;
      preDo(line);
      pos = 0;
      n = line.size();
      preDo(line);
      cout << exp() << endl;
    }
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define ll long long
#define inf LLONG_MAX
using namespace std;
int n,ans;
string s;
int ruiseki[200004];
signed main(){
	cin>>n>>s;
	if(s[0]=='#')ruiseki[0]++;
	for(int i=1;i<n;i++){
		if(s[i]=='#')ruiseki[i]++;
		ruiseki[i]+=ruiseki[i-1];
	}
	ans=inf;
	int k=0;
	k=n-ruiseki[n-1];
	if(s[0]=='.')k--;
	ans=min(k,ans);
	for(int i=1;i<n;i++){
		int karians=0;
		karians+=ruiseki[i];
		karians+=n-ruiseki[n-1]+ruiseki[i]-i-1;
		ans=min(ans,karians);
	}
	cout<<ans<<endl;
}


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

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

    int n; cin >> n;

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        mp[a-1]++;
        mp[a]++;
        mp[a+1]++;
    }

    int ans = 0;
    for (auto m : mp) ans = max(ans, m.second);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
program kadai
implicit none
integer  ::  w,h,x,y
real(8)  ::  ans_1
integer  ::  ans_2
read(*,*) w,h,x,y
ans_1=dble(w)*dble(h)/2.0_8
if (x*2==w .and. y*2==h) then
    ans_2=1
else
    ans_2=0
end if
write(*,*) ans_1,ans_2
end program kadai


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	lint N, A, B;
	lint ac;
	lint loops, additional;
	cin >> N >> A >> B;
	loops = N / (A + B);
	additional = N % (A + B);
	ac = loops * A;
	if (additional >= A) {
		ac += A;
	}
	else {
		ac += additional;
	}
	cou(ac);
}

Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
L = []
for i in range(N):
    a,b = input().split()
    L.append([i,a,int(b)])
L = sorted(L, key=itemgetter(2), reverse=True)
L = sorted(L, key=itemgetter(1))
for j in range(N):
    print(L[j][0]+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(x >= a[i]){
      if(i == n-1){
        if(x == a[i]) ans++;
      }else{
        x -= a[i];
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    for (; a <= b; a++) {
        if (c % a == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3136
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
const int MAXN=1e5+3;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
int arr[MAXN];
signed main()
{
    int n,x;
    scanf("%d%d",&n,&x);
    int ans=1,sum=0;
    for(int i=0;i<n;++i)
    {
        int tmp;
        scanf("%d",&tmp);
        sum+=tmp;
        if(sum<=x)
            ans++;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N;

int main(){
	cin>>N;
	int ans = (N+2-1)/2;
	cout<< ans <<endl;
	// printf("%f\n",solve());
}


Measured memory_bytes: 256