akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll H,W;
        cin>>H>>W;
        ll D=INF;
        if(W>=3){
            chmin(D,H*((W+2)/3-W/3));
        }
        if(H>=3){
            chmin(D,W*((H+2)/3-H/3));
        }
        {
            ll a=(H+2)/3;
            ll b=H-a;
            ll c=W/2;
            ll d=W-c;
            ll mini=min({W*a,b*c,b*d});
            ll big=max({W*a,b*c,b*d});
            chmin(D,big-mini);
        }
        {
            ll a=(W+2)/3;
            ll b=W-a;
            ll c=H/2;
            ll d=H-c;
            ll mini=min({H*a,b*c,b*d});
            ll big=max({H*a,b*c,b*d});
            chmin(D,big-mini);
        }
        if(H>2){
            ll a=H/3;
            ll b=H-a;
            ll c=W/2;
            ll d=W-c;
            ll mini=min({W*a,b*c,b*d});
            ll big=max({W*a,b*c,b*d});
            chmin(D,big-mini);
        }
        if(W>2){
            ll a=W/3;
            ll b=W-a;
            ll c=H/2;
            ll d=H-c;
            ll mini=min({H*a,b*c,b*d});
            ll big=max({H*a,b*c,b*d});
            chmin(D,big-mini);
        }
        cout<<D<<endl;
    }

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))
ans = sum(list(map(int,input().split())))
C_list = list(map(int,input().split()))

for i in range(N-1):
  if A_list[i]+1 == A_list[i+1]:
    ans += C_list[A_list[i]-1]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

void solve()
{
	int x;cin >> x; cout << 1 - x << "\n";
}
	
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a,b;
  cin >> a >> b;
  cout << abs(b - a) << endl;
  return 0;
}


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

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

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll X, Y;
    cin >> X >> Y;
    REP(i, X+1){
        if(2*i+4*(X-i)==Y){
            //dump(i)
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// int get_mode(unordered_map<int, int>& v) {
//   int ret, ret_c = -1;
//   for (auto e : v) {
//     if (ret_c < e.second) {
//       ret = e.first;
//       ret_c = e.second;
//     }
//   }
//   return ret;
// }

pair<int, int> get_mode_and_second(unordered_map<int, int>& v) {
  vector<pair<int, int>> a;
  for (auto e : v) {
    a.push_back(make_pair(e.second, e.first));
  }
  sort(a.begin(), a.end(), greater<pair<int, int>>());
  int first = a.front().second;
  int second;
  if (a.size() == 1)
    second = a.front().first;
  else
    second = a[1].second;
  return make_pair(first, second);
}

int solve(unordered_map<int, int>& e, int e_cnt, unordered_map<int, int>& o, int o_cnt) {
  auto e_p = get_mode_and_second(e);
  auto o_p = get_mode_and_second(o);
  if (e_p.first == o_p.first) {
    int p1 = e_cnt - e[e_p.first] + o_cnt - o[o_p.second];
    int p2 = e_cnt - e[e_p.second] + o_cnt - o[o_p.first];
    return min(p1, p2);
  }
  return e_cnt - e[e_p.first] + o_cnt - o[o_p.first];
}

int main() {
  int n, e_cnt{}, o_cnt{};
  unordered_map<int, int> e, o;
  cin >> n;
  REP(i, n) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      e[v]++;
      e_cnt++;
    }
    else {
      o[v]++;
      o_cnt++;
    }
  }
  cout << solve(e, e_cnt, o, o_cnt) << endl;
}


Measured memory_bytes: 5264
n = int(input())
a = list(map(int, input().split()))
chk = 1
bre = 0
for i in range(n):
  if a[i] == chk:
    chk += 1
  else:
    bre += 1
if chk == 1:
  print(-1)
else:
  print(bre)

Measured memory_bytes: 77516
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#define endl "\n"
#pragma GCC optimize(2)
using namespace std;
int n,m; string st[111];
int main(){cin>>n>>m; for(int i=1;i<=n;i++) cin>>st[i]; sort(st+1,st+1+n); for(int i=1;i<=n;i++) cout<<st[i];cout<<endl;}
/*大草我主程序一行*/

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct Vector {
	int *to;
	int len, alloced;
} Vector;
#define MAX_NODE (200000)
Vector train[MAX_NODE], road[MAX_NODE];
int parent[MAX_NODE], sizes[MAX_NODE] = {0};
int flags[MAX_NODE] = {0}, ans[MAX_NODE] = {0};

void add(Vector *v, int to){
	if(++(v->len) >= v->alloced){
		v->alloced = (v->alloced ? v->alloced*2 : 2);
		v->to = (int*)realloc(v->to, sizeof(int)*v->alloced);
	}
	v->to[v->len-1] = to;
}
void setParent(int p, int n){
	Vector *v = &road[n];
	int i, len = v->len, next;
	for(i=0;i<len;i++){
		next = v->to[i];
		if(parent[next]!=next || p==next){ continue; }
		parent[next] = p;
		setParent(p, next);
	}
}
void setSize(int n){
	Vector *v = &train[n];
	int i, len = v->len, next;
	flags[n] = 1;
	sizes[parent[n]]++;
	for(i=0;i<len;i++){
		next = v->to[i];
		if(flags[next]){ continue; }
		setSize(next);
	}
}
void getSize(int n){
	Vector *v = &train[n];
	int i, len = v->len, next;
	ans[n] = sizes[parent[n]];
	for(i=0;i<len;i++){
		next = v->to[i];
		if(ans[next]){ continue; }
		getSize(next);
	}
}
void resetSize(int n){
	Vector *v = &train[n];
	int i, len = v->len, next;
	flags[n] = 0;
	sizes[parent[n]] = 0;
	for(i=0;i<len;i++){
		next = v->to[i];
		if(!flags[next]){ continue; }
		resetSize(next);
	}
}

int main(void){
	int i, j;
	int N, K, L, from, to;
	scanf("%d%d%d", &N, &K, &L);
	for(i=0;i<N;i++){
		parent[i] = i;
	}
	for(i=0;i<K;i++){
		scanf("%d%d", &from, &to); from--; to--;
		add(&road[from], to);
		add(&road[to], from);
	}
	for(i=0;i<N;i++){ if(parent[i]==i){ setParent(i, i); } }
	
	for(i=0;i<L;i++){
		scanf("%d%d", &from, &to); from--; to--;
		add(&train[from], to);
		add(&train[to], from);
	}
	for(i=0;i<N;i++){
		if(ans[i]){ continue; }
		setSize(i);
		getSize(i);
		resetSize(i);
	}
	printf("%d", ans[0]);
	for(i=1;i<N;i++){
		printf(" %d", ans[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 15744
/**

   Author : sea_26

**/


#pragma GCC optimize("03")
#include <bits/stdc++.h>

using namespace std;

const int M = 1000000007;
const double PI = acos(-1.0);

// const double pi = atan2(0, -1);
// const double PI = 4 * atan(1);
// const double pi = 2*cos(0.0);

typedef long long ll;
typedef long double ld;

const int iinf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ln(x) (int)x.size()

#define bp(n)  __builtin_popcount(n)
#define bclz(n) __builtin_clzll(n)
#define bctz(n) __builtin_ctzll(n)
#define bip(n) __builtin_parity(n)

#define vsort(v) sort(v.begin(),v.end())
#define rvsort(v) sort(v.begin(),v.end(),greater<int>())

#define rep(n) for(int i=0; i<n; i++)
#define rrep(n) for(int i=n-1; i>=0; i--)
#define lrep(p,q) for(int i=p; i<=q; i++)
#define prep(n) for(int i=1; i*i<=n; i++)
#define it(a, x)  for(auto &a : x)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

priority_queue<int> pq;

#define fs   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

template< typename T> inline T lcm(T a, T b){ return (a / gcd(a,b)) * b; }
template< typename T> inline T MAX(T a, T b){ return a ^ ((a ^ b) & -(a < b)); }
template< typename T> inline T MIN(T a, T b){ return b ^ ((a ^ b) & -(a < b)); }
template< typename T> void tpns(T n){ rrep(30){ if(n & (1 << i)) pq.push(1 << i); } }
template< typename T> void SWAP(T &a, T &b){ a = ((a) ^= (b)),  b = ((b) ^= (a)),  a = ((a) ^= (b)); }
template< typename T> inline T ABS(T a){ int x = a >> sizeof(int) * CHAR_BIT - 1; return (a + x) ^ x; }
template< typename T> inline T mod(T a, T b){ return a >= b ? a % b : a; }
template< typename T> inline T gcd(T a, T b){ while (b) b ^= a ^= b ^= a %= b; return a; }

ll gcdextd(ll a, ll b, ll& x, ll& y) {
    if (!a) { x = 0; y = 1; return b; }
    ll y1,d;
    d = gcdextd(b % a, a, y, y1);
    x = y1 - (b / a) * y;
    return d;
}


/*
double WT() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void ReT(){

	cout << "\nTime = " << fixed << setprecision(3) << WT()  << " Sec"<< endl;

exit(0);
}

*/


int a[5];

int main(){

        fs;
        rep(5)
            cin >> a[i];

        int d = 0,mx = 0,res = 0;
        rep(5){
            if(a[i] % 10 != 0)
                d = 10 - a[i]%10;
            else
                d = 0;

            res += (d+a[i]);
            mx = max(mx,d);
        }
        cout << res - mx << endl;
     //   ReT();

}


Measured memory_bytes: 256
from collections import Counter

N, P = map(int, input().split())
S = list(map(int,list(input())))

def solve_2(S):
    ind = (i for i, x in enumerate(S, 1) if x % 2 == 0)
    return sum(ind)

def solve_5(S):
    ind = (i for i, x in enumerate(S, 1) if x % 5 == 0)
    return sum(ind)

def solve(S,P):
    if P == 2:
        return solve_2(S)
    if P == 5:
        return solve_5(S)
    S = S[::-1]
    T = [0] * len(S)
    T[0] = S[0] % P
    power = 1
    for i in range(1, len(S)):
        power *= 10
        power %= P
        T[i] = T[i-1] + power * S[i]
        T[i] %= P
    counter = Counter(T)
    return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]


print(solve(S,P))


Measured memory_bytes: 14968
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int L,R, d;
    cin >> L>> R>> d;

    int ans = 0;
    for(int i = L; i <= R; i++){
        if(i%d == 0)ans++;
    }

    cout << ans << endl;

}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right) {
  int i, j, k;
  llong cnt = 0;
  int n1 = mid - left;
  int 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] = R[n2] = SENTINEL;
  i = j = 0;
  for (k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }

  return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
  int mid;
  llong v1, v2, v3;
  if (left +1 < right) {
    mid = (left + right) / 2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  } else return 0;
}

int main() {
  int A[MAX], n, i;

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

  llong ans = mergeSort(A, n, 0, n);
  cout << ans << endl;

  return 0;
}



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

using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> p(N, vector<pair<int, int>>());
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            p[i].push_back({x, y});
        }
    }
    int max = 0;
    for (int i = 0; i < (1 << N); i++) { // 正直ものかどうかの組み合わせのループ
        int count = 0;
        vector<int> kind(N, -1);
        bool ok = true;
        for (int j = 0; j < N; j++) { // それぞれの人についてのループ
            if (i & (1 << j)) { // 正しいとする
                kind[j] = 1;
                count ++;
            } else { // 正しくないとする
                kind[j] = 0;
            }
        }
        for (int j = 0; j < N; j++) { // それぞれの人についてのループ
            for (auto& q : p[j]) { // それぞれの証言についてのループ
                if (kind[j] && kind[q.first] != q.second) {
                    // conflict!!
                    ok = false;
                    break;
                }
            }
            if (!ok) { // 矛盾があったらbreak
                break;
            }
        }
        // 矛盾がないので最大値を交信
        if (ok) {
            max = std::max(max, count);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e3 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

int h, w, k, mat[20][N], pr[20][N], ans = inf;
string s[20];

int main() {
	data();
	scanf("%d %d %d", &h, &w, &k);
	for (int i = 1; i <= h; ++i)
		cin >> s[i];
	for (int i = 1; i <= h; ++i)
		for (int j = 0; j < w; ++j)
			mat[i][j + 1] = (s[i][j] - '0');
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
			pr[i][j] = pr[i][j - 1] + mat[i][j];
	for (int mask = 0; mask < (1 << (h - 1)); ++mask) {
		int cnt = __builtin_popcount(mask);
		int last = 0;
		for (int i = 1; i <= w; ++i) {
			int col = 0;
			int mx = 0;
			for (int j = 1; j <= h; ++j) {
				col += pr[j][i] - pr[j][last];
				if (mask & (1 << (j - 1))) {
					mx = max(mx, col);
					col = 0;
				}
			}
			mx = max(mx, col);
			col = 0;
			if (mx > k && i - last == 1)
				cnt += 10000;
			if (mx > k) {
				last = i - 1;
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	printf("%d", ans);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


Measured memory_bytes: 384
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,x,y=map(int, readline().rstrip().split())
    ans = [0] * (n-1)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            d1 = abs(i-x) + abs(j-x)
            d2 = abs(i-y) + abs(j-y)
            d3 = abs(i-x) + abs(j-y) + 1
            d4 = abs(i-y) + abs(j-x) + 1
            d5 = abs(i-j)
            d=min(d1,d2,d3,d4,d5)
            ans[d-1]+=1
    for a in ans:
        print(a)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16152
import java.util.*;

public class Main {
	final int MOD = 100000000;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 100000;
	Scanner sc = new Scanner(System.in);


	void doIt() {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int w[] = new int[N + 1];
		int v[] = new int[N + 1];
		long dp[][] = new long[N + 1][100001];
		for(int i = 1; i <= N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		Arrays.fill(dp[0], (long)1e9 + 1);
		dp[0][0] = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j <= 100000; j++) {
				dp[i][j] = dp[i - 1][j];
				if(j - v[i] >= 0) {
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
				}
			}
		}
		//for(int i = 0; i <= N; i++) {
			//for(int j = 0; j < 150; j++) {
			//	System.out.println(j + " " + ((dp[N][j] > (int)1e9)?-1:dp[N][j]) + " ");
			//}
			//System.out.println();
		//}
		for(int i = 100000; i >= 0; i--) {
			if(dp[N][i] <= W) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(0);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}

Measured memory_bytes: 128468
#include<iostream>
using namespace std;
static const int MAX = 10000;

int main(){
  int N, K;
  cin >> N >> K;

  if ( N < 2*K ) {
    cout << -1 << endl;
    return 0;
  }

  int base[MAX], w, b;

  base[0] = 0;
  base[1] = 1;
  w = N-2;
  b = 1;
  for ( int i = 2; i < N; i++ ){
    base[i] = (base[i-1] + (w*b))%N;
    w--;
    b *= -1;
  }

  for ( int k = 0; k < K; k++ ){
    for ( int i = 0; i < N-1; i++ ){
      printf("%d %d\n",(base[i]+k)%N+1, (base[i+1]+k)%N+1);
    }
  }
  return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  ll n;
  ll ans = 0;
  cin >> n;
  ll l[n],r[n];
  
  rep(i,0,n){
    cin >> l[i] >> r[i];
    ans += r[i]-l[i]+1;
  }

  printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def d10(n):
    a = []
    while n:
        n, m = divmod(n, 10)
        a.append(m)

    return a

def resolve():
    N = int(input())

    if N == 1:
        print(1)
        return

    k = N // 10
    A = d10(N)

    a = A[-1]
    b = A[0]

    ans = k ** 2 + 8
    if b:
        c = len(A)
        d = d0 = 0
        for i in range(c-1):
            d, d0 = 10 ** i + d, d

        if a > b:
            ans += 2 * d * b
        else:
            e = k - a*10**(c-2)
            ans += 2 * d * (a-1)
            ans += 2 * (d0 + e + 1) + 1
            ans += 2 * d0 * (b - a)
    print(ans)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
if len(b) > 0:
    b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	cin>>n;

	cout<<n*n*n<<endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
P=tuple(map(lambda x: x-1,P))
Q=tuple(map(lambda x: x-1,Q))
l=list(permutations(range(N)))
print(abs(l.index(P)-l.index(Q)))

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}
template<class T>
constexpr T UP(T left, T div) {
    return (left + div - 1) / div;
}

int n, m;
int num[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int a, b;
        std::cin >> a >> b;
        --a, --b;

        ++num[a], ++num[b];
    }

    bool ok = true;
    for (int i = 0; i < n; ++i)
        if (num[i] % 2 != 0) {
            ok = false;
            break;
        }

    if (ok)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((b-a) == (c-b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< ll, ll > P;
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

int n;
ll a[200000], imos[200010];

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

    cin >> n;
    REP(i, n) {
        cin >> a[i];
        if (i > 0) imos[i] = imos[i - 1] + a[i];
        else imos[i] = a[i];
    }

    ll ans = LINF;
    FOR(i, 1, n - 1) {
        ll mae = imos[i] / 2;
        ll ushiro = (imos[n - 1] - imos[i]) / 2;
        
        int mae_idx = lower_bound(imos, imos + (i + 1), mae) - imos;
        ll mae_ma = LINF, mae_mi = -LINF;
        FOR(j, -1, 2) {
            int now_idx = mae_idx + j;
            if (now_idx <= 0 || now_idx > i) continue;
            //cout << "mae " << now_idx << endl;
            ll p = imos[now_idx - 1], q = imos[i] - imos[now_idx - 1];
            if (max(p, q) - min(p, q) < mae_ma - mae_mi) {
                mae_ma = max(p, q), mae_mi = min(p, q);
            }
        }
        
        int ushiro_idx = lower_bound(imos + (i + 1), imos + n, imos[i] + ushiro) - imos;
        ll ushiro_ma = LINF, ushiro_mi = -LINF;
        FOR(j, -1, 2) {
            int now_idx = ushiro_idx + j;
            if (now_idx <= i || now_idx >= n) continue;
            //cout << "ushiro " << now_idx << endl;
            ll r = imos[now_idx - 1] - imos[i], s = imos[n - 1] - imos[now_idx - 1];
            if (max(r, s) - min(r, s) < ushiro_ma - ushiro_mi) {
                ushiro_ma = max(r, s), ushiro_mi = min(r, s);
            }
        }

        //cout << mae_mi << ' ' << mae_ma << ' ' << ushiro_mi << ' ' << ushiro_ma << endl;
        ans = min(ans, max(ushiro_ma, mae_ma) - min(ushiro_mi, mae_mi));
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>s;
  if(n%2) {cout<<"No";return;}
  sort(s.begin(),s. end());
  rep(i,0,s.length())
  {
    if(s[i]==s[i+1] && i+1<n){i++;continue ;}
    else if(i+1<n)
    {
      cout<<"No";return;
    }
  }
  cout<<"Yes";
  
// cout<<n*n;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

template<typename T>
class SegTree {
  int n;
  vector<T> seg;
  
  // irrelevant value for query
  const T NIL = make_pair(1<<30, 0);  
  
  // binary operator for query
  T binop(T a, T b) {
    return min(a, b);
  }
  
  void update(int k, int l, int r, int p, T x) {
    if (p < l || r <= p)
      return;
    if (r - l == 1)
      seg[k] = x;
    else {
      update(2*k+1, l, (l+r)/2, p, x);
      update(2*k+2, (l+r)/2, r, p, x);
      seg[k] = binop(seg[2*k+1], seg[2*k+2]);
    }
  }
  T query(int k, int l, int r, int a, int b) {
    if (b <= l || r <= a)
      return NIL;
    if (a <= l && r <= b)
      return seg[k];
    else {
      T ret = NIL;
      ret = binop(ret, query(2*k+1, l, (l+r)/2, a, b));
      ret = binop(ret, query(2*k+2, (l+r)/2, r, a, b));
      return ret;
    }
  }
public:
  SegTree(int n): n(n), seg(4*n) {}
  void init() {
    for (int i = 0; i < 4*n; i++)
      seg[i] = NIL;
  }
  // update p-th value to x
  void update(int p, T x) {
    update(0, 0, n, p, x);
  }
  // query for range [l, r)
  T query(int l, int r) {
    return query(0, 0, n, l, r);
  }
};


int n, r, l;
int sum[100000];

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> r >> l;

  SegTree<pair<int, int> > tree(100000);
  int pre = 0;
  REP (i, r) {
    int d, t, x;
    cin >> d >> t >> x;
    sum[tree.query(0, n).second] += t-pre;
    int pt = -tree.query(d-1, d).first;
    tree.update(d-1, make_pair(-(pt+x), d-1));
    pre = t;
  }
  sum[tree.query(0, n).second] += l-pre;

  int ans = 0;
  REP (i, n) if (sum[i] > sum[ans]) ans = i;
  cout << ans+1 << endl;

  return 0;
}

Measured memory_bytes: 6236
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;


int main() {

    string line[3];

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

    cout << line[0][0] << line[1][1] << line[2][2] << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int res=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            res++;
        }
    }
    cout<<res<<endl;
}

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

int main() {
	// your code goes here
    int i,n;
    char s[105],t[105];
    cin >> n >> s >> t;
    for(i=0;i<n;i++){
        cout << s[i];
        cout << t[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> V;

int main() {
    int n;
    cin >> n;
    V a = V(n);
    for (int i = 1; i <= n; i++) {
        int j;
        cin >> j;
        a[j - 1] = i;
    }
    for (int i = 0; i < n; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << "\n";
}

Measured memory_bytes: 1152
// author: gary
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )
typedef pair<int, int> pii;
typedef long long ll;
template<class T> bool cmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool cmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }

int n, m;

int cnt[26];
char buf[1000];

bool solve() {
  int odd1 = 0;
  int odd2 = 0;
  for(int i = 0; i < 26; i++) {
    odd1 += cnt[i] % 2;
    odd2 += (cnt[i] % 4) / 2;
  }

  int pn = n % 2, pm = m % 2;

  if(!pn && !pm) 
    return odd1 == 0 && odd2 == 0;

  bool ok = true;
  if(pn ^ pm) {
    int need2 = ((pn * m + pm * n) % 4) / 2;
    int have2 = ((pn * m + pm * n) / 2);
    return odd1 == 0 && have2 >= odd2 && odd2 >= need2;
  } else {
    int need2 = ((n + m - 1) % 4) / 2;
    int have2 = ((n + m - 1) / 2);
    return odd1 == 1 && have2 >= odd2 && odd2 >= need2;
  }
}

int main() {
  while(scanf("%d%d", &n, &m) != EOF) {
    memset(cnt, 0, sizeof cnt);
    for(int i = 0; i < n; i++) {
      scanf("%s", buf);
      for(char* p = buf; *p; p++)
        cnt[*p-'a'] ++;
    }
    // printf(" %d %d, %d %d\n", odd1, need1, odd2, need2);
    puts(solve() ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        long sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += arr[i];
            if (sum * 2 >= arr[i + 1]) {
                count++;
            } else {
                count = 0;
            }
        }
        System.out.println(count + 1);
    }
}


Measured memory_bytes: 48672
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

// int search_xyz(int e);
int tree[100];

int root(int a);
bool is_same_set(int p, int q);
void joint(int x, int y);

int main()
{
    int n, tempa, k = 0;
    cin >> n;
    int e = n * (n - 1) / 2;
    pair<int, pair<int, int>

         >
        a[e];
    for (int i = 0; i < n; i++)
    {
        tree[i] = i;
        for (int j = 0; j < n; j++)
        {
            cin >> tempa;
            if (i < j)
            {
                a[k] = make_pair(tempa, make_pair(i, j));
                k++;
            }
        }
    }
    sort(a, a + e);
    int result = 0;
    for (int i = 0; i < e; i++)
    {
        if (a[i].first == -1)
            continue;

        if (is_same_set(a[i].second.first, a[i].second.second))
        {
            continue;
        }
        else
        {
            joint(a[i].second.first, a[i].second.second);
            result += a[i].first;
        }
    }
    cout << result << endl;
    return 0;
}

int root(int a)
{
    if (tree[a] == a)
    {
        return a;
    }
    else
    {
        tree[a] = root(tree[a]);
        return tree[a];
    }
}

bool is_same_set(int p, int q)
{
    return root(p) == root(q);
}

void joint(int x, int y)
{
    tree[root(x)] = root(y);
}



Measured memory_bytes: 3152
from collections import Counter

trade1 = Counter()
trade2 = Counter()
while 1:
    line = raw_input()
    if not line:
        break
    a, b = map(int, line.split(','))
    trade1[a] += 1

while 1:
    try:
        a, b = map(int, raw_input().split(','))
    except EOFError:
        break
    trade2[a] += 1

trade = trade1 + trade2
for k in sorted(trade1 & trade2):
    print k, trade[k]

Measured memory_bytes: 4592
#include <bits/stdc++.h>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
 
template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
const int MAX = 2e5 + 10;
int n;
string s;
int res[MAX];
int znaj(int a){
  while(1){
    a++;
    if(a == 2*n)a = 0;
    if(res[a] != 0)return a;
  }
}
int sumk[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> s;
  s+='1';
  int ost = 1;
  int ak = 1;
  int il = 2*n + 1;
  vector<int> spec;
  bool cz = 0;
  int ilx = 0;
  R(i,n*2){
    if(s[i] == '0'){
      cz = 0;
      if(ost == 0){
        res[i] = il / 2;
        il--;
      }else{
        res[i] = ak;
      }
      ost = 0;
    }else{
      if(ost == 0){
        res[i] = ak;
        ak++;
      }else{
        if(cz == 0){
          cz = 1;
          spec.PB(i);
        }
        ilx++;
      }
      ost = 1;
    }
  }
  if(ilx&1){
    cout << "No\n";
    return 0;
  }
  
  R(i,n*2){
    cerr << res[i] << " ";
  }
  cerr << "\n";
  debug(ilx);
  
  
    debug(spec);
  if(ilx % 4 == 2){
    debug(s[0],s[2 * n - 2]);
    if(s[0] == '1' && s[2 * n - 2] == '1'){
      spec.pop_back();
    }
    debug(spec);
    if(SZ(spec) <= 1){
      cout << "No\n";
      return 0;
    }
    res[spec[0]] = ak;
    res[spec[1]] = ak;
    ak++;
    int a = znaj(spec[0]);
    int b = znaj(spec[1]);
    swap(res[a],res[b]);
  }
  
  R(i,n*2){
    sumk[res[i]] += i;
  }
  cout << "Yes\n";
  
  R(i,n*2){
    cerr << res[i] << " ";
  }
  cerr << "\n";
  int x = 0;
  vector<int> pom;
  while(x != 2 * n){
    if(res[x] != 0){
      x = sumk[res[x]] - x;
    }
    if(res[x] == 0)
      pom.PB(x);
    x++;
  }
  debug(pom);
  for(int i = 0;i < SZ(pom);i+=4){
    res[pom[i]] = ak;
    res[pom[i+1]] = ak+1;
    res[pom[i+2]] = ak;
    res[pom[i+3]] = ak+1;
    ak+=2;
  }
  R(i,n*2){
    cout << res[i] << " ";
  }
  cout << "\n";
}

Measured memory_bytes: 4872
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

#define maxn 110
int n;
int a[maxn]; 

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n;
	enum(i, 1, n)
		cin >> a[i];
	int ans = 0;
	enum(i, 1, n)
	{
		if(a[i] == a[i - 1])
		{
			ans ++;
			a[i] = 10001;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
void main() {
	auto N = readAs!long;
	auto arr = getDivisors(N).sort().array;
	auto m1 = arr[$ / 2 - 1], m2 = arr[$ / 2];
	(m1 + m2 - 2).writeln;
}

ulong[] getDivisors(ulong N) {
	ulong[] res;
	foreach(i; 1..N.to!real.sqrt.ceil.to!ulong+1) {
		if(N % i == 0) {
			res ~= i;
			res ~= N / i;
		}
	}
	return res;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 380
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 924844033;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	char m[8][8];
	int h, w; cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> m[i][j];
		}
	}
	bool f = true;
	rep(s, h + w-1) {
		int cnt = 0;
		rep(i, s+1) {
			if (s - i < 0 || s - i >= w)continue;
			if (m[i][s - i] == '#')cnt++;
		}
		if (cnt != 1) {
			f = false; break;
		}
	}
	if (f) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n, m, a = 0, b;
    cin >> n >> m;

    while(m--) {
        cin >> b;
        a += b;
    }

    a = n - a;
    if(a < 0) {
        cout << -1;
    } else {
        cout << a;
    } 
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> lengs(5);
	for(int i= 0; i < 5; i++)
		cin >> lengs.at(i);
	int k;
	cin >> k;
	bool flag = 1;
	if(lengs.at(4)-lengs.at(0) > k)
		flag = 0;
	cout << (flag ? "Yay!" : ":(") << endl;
}

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x + r <= W && y + r <= H && x - r >= 0 && y -r >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>

int main(){
	char A[11] ,B[11], C[11];
	scanf("%s %s %s", &A, &B, &C);

	int x = strlen(A), y = strlen(B);
	if(A[x-1] == B[0] && B[y-1] == C[0]){
		puts("YES");
	}else {
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1656
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int c=0,d=0,k=0,n,h,w,l,r,ans;
    string s,s1,s2;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        c = max(a[i], c);
        if(a[i]>=c-1){
            continue;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main() {
	int n, m;
	cin>>n>>m;
	char graph[n][m];
	long long int dp[n][m];
	
	for(int i=0;i<n;i++){
	    for(int j=0;j<m;j++){
	        cin>>graph[i][j];
	    }
	}
	dp[0][0]=1;
	for(int i=1;i<m;i++){
	    if(graph[0][i] == '#'){
	        dp[0][i] = 0;
	    }
	    else 
	        dp[0][i] = dp[0][i-1];
	}
	
	for(int i=1;i<n;i++){
	    if(graph[i][0] == '#'){
	        dp[i][0] = 0;
	    }
	    else 
	        dp[i][0] = dp[i-1][0];
	}
	
	
	
	for(int i=1;i<n;i++){
	    for(int j=1;j<m;j++){
	        if(graph[i][j] == '#'){
	            dp[i][j] = 0;
	        }
	        else{
	            dp[i][j] =(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
	        }
	    }
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  double ans = l[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + l[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
t = a.slice(1,a[0])

(n-1).times do |i|
    a = gets.split.map(&:to_i)
    a = a.slice(1,a[0])
    t = t & a
end

# p t
p t.size

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

int main(){
    string A, B, C;
    cin >> A >> B >> C;

    int a = A.size();
    int b = B.size();

    if(A.at(a-1) == B.at(0) && B.at(b-1) == C.at(0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

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

vector<string> ans;
int n;
void fans(string s,int k)
{
    if(s.length()==n)
    {
        ans.push_back(s);
        return ;
    }
    for(int i=0;i<=k;i++)
    {
        s.push_back('a'+i);
        fans(s,max(k,s.back()-'a'+1));
        s.pop_back();
    }
    return ;
}

int main()
{
    cin >> n;
    string s="";
    fans(s,0);
    sort(ans.begin(),ans.end());
    for(auto it:ans)
        cout<<it<<"\n";
}

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

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

typedef long long ll;

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

int n;
int a[101];
int print(int a[],int n){
	for(int i=0;i<n;i++){
		if(i>0)cout<<' ';
		cout<<a[i];
	}
	cout<<endl;
}
int csort(int a[],int n){
	int v,j;
	for(int i=1;i<n;i++){
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
	print(a,n);
	}
	
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	print(a,n);
	csort(a,n);
	return 0;
}





Measured memory_bytes: 3080