akhauriyash/Code-Regression huggingface dataset:
//124B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0;
    int cnt =1;
    bool flag = true;
    cin >> n;
    vector<int>L(n,0);
    rep(i, n) cin >> L[i];
    for(int i=n-1; i>=1; i--){
        flag = true;
        for(int j=i; j>=0; j--){
            if(L[i]<L[j]){
                flag=false;
                break;
            }
        }
        if(flag==true) cnt+=1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int z = 0;
    int o = 0;
    int ans = 0;
    for (int i = 0; i <s.size() ; ++i) {
        if(s[i] == '0') o++;
        if(s[i] == '1') z++;
    }
    ans = min(z,o);
    cout << ans * 2;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   char s[5];scanf("%s",s);
   int ans=0;
   for(int i = 0;i < 4;i++){
      if(s[i]=='+')ans++;
      else ans--;
   }
   printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int A, B;
    cin >> A >> B;
    int res = 0;
    for (int i = A; i <= B; i++)
    {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if (s == t)
            res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;



int main(){
    ll k; cin >> k;
    vector<vpl> G(k);
    rep(i,k){
        if(i<k-1) G[i].emplace_back(i+1,1);
        else G[k-1].emplace_back(0,1);
    } 
    ll tmp = 1;
    rep(i,12){
        tmp *= 10;
        rep(j,k){
            ll t = j*(tmp%k)%k;
            if(j==t) continue;
            G[j].emplace_back(t,0);
        }
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.emplace(1,1);
    vl d(k,inf);
    d[1] = 1;
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        ll u = p.second;
        for(auto v : G[u]){
            if(d[v.first] > d[u] + v.second){
                d[v.first] = d[u] + v.second;
                pq.emplace(d[v.first],v.first);
            }
        }
    }
    cout << d[0] << endl;
}


Measured memory_bytes: 32888
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<int> A, B, C;
int ANS = 0;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		a--;
		A.push_back(a);
	}
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}
	for (int i = 0; i < N - 1; i++) {
		int c;
		cin >> c;
		C.push_back(c);
	}
	for (int i = 0; i < N; i++) {
		ANS += B[A[i]];
		if (i >= 1) {
			if (A[i - 1] + 1 == A[i]) {
				ANS += C[A[i - 1]];
			}
		}
	}

	cout << ANS << endl;
	return 0;
}

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

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

  string a = to_string(n);

  if (a[0] == '7' || a[1] == '7' || a[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){

int A, B, C;
cin >> A >> B >> C;
if(A==B && B==C)
cout << "No" << endl;
else if(A!=B && B!=C && C!=A)
cout << "No" << endl;
else
cout << "Yes" << endl;

}

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

using namespace std;

int n,visine[100009];
long long memo[100009];

long long dp(int x){
	if(x==n-1){
        return 0;
	}
	if(x==n-2){
        return abs(visine[x] - visine[x + 1]);
	}
    if(memo[x]==-1){
        memo[x] = min(abs(visine[x]-visine[x+1])+dp(x+1),abs(visine[x]-visine[x+2])+dp(x+2));
    }
    return memo[x];
}

int main(){
	cin >> n;
	for(int i = 0;i<n;i++){
		int a;
		cin >> a;
		visine[i] = a;
	}
	memset(memo,-1,sizeof(memo));
	cout << dp(0);
	return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll n, u, d, v, cnt = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		cin >> u >> v;
		ll val = u*u + v*v;
		if(val <= d*d){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3636
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#ifdef ARYANC403
    #include "/home/aryan/codes/PastCodes/template/header.h"
#else
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
    #pragma GCC optimize ("-ffloat-store")
    #include<iostream>
    #include<bits/stdc++.h>
    #define dbg(args...)
#endif

using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m;
    vector<vi> ed(2*m+1);
    vi ans(2*m+1),st(2*m+1);
    lli sum=0,mx=-INF;
    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }

    dbg(a);
    for(lli i=0;i+1<n;++i)
    {
        const lli l=a[i];
        const lli r=(l<a[i+1]?a[i+1]:a[i+1]+m);
        dbg(a[i],a[i+1],l,r);
        sum+=r-l;
        st[l]++;
        ed[r].pb(l);
    }

    lli psum=0,cnt=0;
    for(lli i=1;i<=2*m;++i)
    {
        ans[i]=cnt*(i-1)-psum;
        for(auto x:ed[i])
        {
            psum-=x;
            cnt--;
        }
        psum+=i*st[i];
        cnt+=st[i];
    }

    for(lli i=1;i<=m;++i)
        mx=max(mx,ans[i]+ans[i+m]);

    cout<<sum-mx<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 14168
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int h,w;cin>>w>>h;
        if(h==0&&w==0)return 0;
        int a[h][w];
        rep(i,0,h)rep(j,0,w)cin>>a[i][j];
        bool used[h][w];
        memset(used,false,sizeof used);
        int ans=0;
        rep(i,0,h){
            rep(j,0,w){
                //cout<<i<<" "<<j<<" "<<used[i][j]<<endl;
                if(used[i][j]==true)continue;
                if(a[i][j]==0)continue;
                queue<pii> q;
                ans++;
                q.push({i,j});
                used[i][j]=true;
                while(q.size()>0){
                    pii p=q.front();q.pop();
                    int nh=p.first,nw=p.second;
                    
                    rep(k,0,8){
                        int nnh=nh+ddh[k],nnw=nw+ddw[k];
                        //if(i==0&&j==0)cout<<nnh<<" "<<nnw<<endl;
                        if(nnh<0||nnh>=h||nnw<0||nnw>=w)continue;
                        if(a[nnh][nnw]==0)continue;
                        if(used[nnh][nnw])continue;
                        
                        q.push({nnh,nnw});
                        used[nnh][nnw]=true;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}










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

int main(){
    int N;
    string str;

    cin >> N;
    
    set<string> s;
    for(int i=0; i<N; i++){
        cin >> str;
        s.insert(str);
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 19060
package main

import (
	"fmt"
)

func main() {
	var N, M, K, r int
	fmt.Scan(&N, &M)
	//ta := make([][]int, N, M)
	var ta [][]int
	for i := 0; i < N; i++ {
		fmt.Scan(&K)
		va := make([]int, M)
		wa := make([]int, K)
		for j := 0; j < K; j++ {
			fmt.Scan(&wa[j])
		}
		for k := 0; k < len(wa); k++ {
			va[wa[k]-1] = 1
		}
		ta = append(ta, va)
	}
	for j := 0; j < M; j++ {
		b := true
		for i := 0; i < N; i++ {
			if ta[i][j] == 0 {
				b = false
			}
		}
		if b {
			r++
		}
	}
	fmt.Println(r)

}

Measured memory_bytes: 640
import sys
def main():
    MOD = 10**9+7
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    count = [0] * 61
    ans = 0
    for a in A:
        for i, c in enumerate(format(a, 'b')[::-1]):
            if c == '1':
                count[i] += 1

    for i, c in enumerate(count):
        tmp = (c*(N-c) * pow(2, i, MOD))%MOD
        ans = (ans + tmp)%MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 123132
from typing import NoReturn


def main() -> NoReturn:
    a, b, c, k = map(int, input().split())  # type: int, int, int, int
    if a >= k:
        print(k)
    elif a + b >= k:
        print(a)
    else:
        print(2 * a + b - k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10260
//abc131_e.cpp
//Mon Oct  7 21:36:18 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int init = (n-1)*(n-2)/2;
	if (k>init){
		cout << -1 << endl;
		return 0;
	}
	int firstedge = 2;
	int nextedge = 3;
	cout << n-1+init-k << endl;
	for (int i=2;i<=n;i++){
		cout << 1 << " " << i << endl;
	}

	while (init>k){
		if (nextedge>n){
			firstedge++;
			nextedge = firstedge+1;
		}
		cout << firstedge << " " << nextedge << endl;
		nextedge++;
		init--;
	}
}

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

int main(void){
	int n, a[100], ans = 0;
	double sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sum /= n;
	sum = round(sum);

	for (int i = 0; i < n; i++){
		ans += pow(((int)sum - a[i]), 2);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int N = s.size();
  if(s[N-1] == '1' || s[0] == '0' || s[N-2] == '0') {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> bo(N);
  REP(i, N) {
    if(i <= N-i-2) {
      if((s[i] == '1' && s[N-i-2] == '0') || (s[i] == '0' && s[N-i-2] == '1')) {
        cout << -1 << endl;
        return 0;
      } else if(s[i] == '1' && s[N-i-2] == '1') {
        bo[i] = true;
      }
    }
  }
  int last = 1;
  REP(i, N-1) {
    cout << last << " " << (i+2) << "\n";
    if(bo[i]) last = i+2;
  }
}

Measured memory_bytes: 1616
void main() {
    string[] s = readln.split(',');
    s.join(" ").writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

int solve()
{
  int n, l, r;
  char c;
  char buf[1000];
  string s;
  queue<char> q;
 
  cin >> n;
  while (n > 0) {
    cin >> s;
    for (int i = 0; i < s.size(); i++) q.push(s[i]);

    for (int i = 0; i < n; i++) {
      int j = 0;
      l = q.size();
      while (j < l) {
        r = 0;
        c = q.front();
        while (q.front() == c && j < l) {
          q.pop();
          r++;
          j++;
        }
        sprintf(buf, "%d", r);
        for (int k = 0; k < strlen(buf); k++) q.push(buf[k]);
        q.push(c);
      }
    }
    while (q.size() > 0) {
      cout << q.front();
      q.pop();
    }
    cout << endl;
    cin >> n;
  }
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans;
	int k,s;
	scanf("%d%d",&k,&s);
	for(int x=0;x<=k;x++)
	{
		for(int y=0;y<=k;y++)
		{
				if(s-x-y>=0&&s-x-y<=k)
				{
					ans++;
				}
		}
	}
	cout<<ans;
	//printf("%d",ans);
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=2e5+10;
vector<int> p[MAXN];int n,m;

#define mid ((l+r)>>1)
#define ls k<<1
#define rs k<<1|1
#define lc k<<1,l,mid
#define rc k<<1|1,mid+1,r
int mx[MAXN<<2],add[MAXN<<2];
void pushup(int k)
{mx[k]=add[k]+max(mx[ls],mx[rs]);}
void build(int k,int l,int r)
{
    if(l==r){mx[k]=l;return;}
    build(lc);build(rc);pushup(k);
}
void update(int a,int b,int k,int l,int r)
{
    if(a<=l&&r<=b)
    {mx[k]++;add[k]++;return;}
    if(a<=mid) update(a,b,lc);
    if(b>mid) update(a,b,rc);
    pushup(k); 
}
int query(int a,int b,int k,int l,int r)
{
    if(a<=l&&r<=b) return mx[k];
    int ret=-1<<28;
    if(a<=mid) ret=max(ret,query(a,b,lc));
    if(b>mid) ret=max(ret,query(a,b,rc));
    return ret+add[k];
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        p[l].pb(r);
    }
    build(1,0,m+1);int res=0;
    for(int i=0;i<=m+1;i++)
    {
        for(auto j:p[i]) update(0,j,1,0,m+1);
        res=max(res,query(i+1,m+1,1,0,m+1)-m-i-1);
    }
    printf("%d",max(res,n-m));
    return 0;
}

Measured memory_bytes: 14720
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[2030],c[110];

int main(void){
	          int i;

	          cin.tie(0);  ios_base::sync_with_stdio(false);

	          int N,M;
	          cin >> N;
	          for(i=1;i<=N;i++){
	        	  int x;
	        	  cin >> x;
	        	  a[x]=i;
	        	  c[i]=x;
	          }

	          cin >> M;
	          for(i=1;i<=M;i++){
	        	  int n;
	        	  cin >> n;
	        	  if(a[c[n]+1]==0 && (c[n]+1)!=2020 ){
	        		 a[c[n]+1]=n;
	        		 a[c[n]]=0;
	        		 c[n]++;
	        	  }
	          }

	          for(i=1;i<=N;i++) cout << c[i] << endl;

	          return 0;
}



Measured memory_bytes: 3228
#include<stdio.h>
int main(){
  int x,y,r;
  scanf("%d%d",&x,&y);
  if(x < y){
    r=x;
    x=y;
    y=r;
  }
  while(y > 0){
    r= x % y;
    x = y;
    y = r;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
# coding: utf-8
# Your code here!
N=int(input())

def saiki(tgt,i,count,ans):
    #print(tgt,i,count,ans,temp[i])

    if i==0 or tgt==0:
        ans=min((tgt+count),ans)
        return ans
        
    num=tgt//temp[i]
    while num>=0:
        ans=saiki(tgt-num*temp[i],i-1,count+num,ans)
        if ans<(count+num):
            return ans
        num-=1
    return ans

temp=[1]
n=1
while N>=6**n:
    temp.append(6**n)
    n+=1
    
n=1
while N>=9**n:
    temp.append(9**n)
    n+=1

temp.sort()
#print(temp)

print(saiki(N,len(temp)-1,0,10**9))


Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc132/tasks/abc132_b

#include <stdio.h>
#define forn(i,L,R) for (int i = L; i < R; i++)
#define wez(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)

int main(){
    wez(n);
    int arr[20], cnt = 0;
    forn(i, 0, n)
        getInt(arr[i]);
    forn(i, 1, n - 1)
        if ((arr[i - 1] > arr[i] && arr[i + 1] < arr[i]) || (arr[i - 1] < arr[i] && arr[i + 1] > arr[i]))
            cnt++;
            
    printf("%d\n", cnt);
}

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

const long long INF = 10000000000;

int main(){
    //input
    long long N;
    cin >> N;
    vector<tuple<long long, long long, long long> > jun;
    long long H,P;
    long long i,j;
    for(i=0; i<N; i++){
        cin >> H >> P;
        jun.push_back(make_tuple(H+P,H,P));
    }

    //calc
    sort(jun.begin(),jun.end());
    long long dp[N+1][N+1];
    for(j=1; j<=N; j++){
        dp[0][j]=INF;
    }
    for(i=0; i<=N; i++){
        dp[i][0]=0;
    }
    for(i=1; i<=N; i++){
        H = get<1>(jun[i-1]);
        P = get<2>(jun[i-1]);
        for(j=1; j<=N; j++){
            if(dp[i-1][j-1]<=H){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+P);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    for(j=N; j>=0; j--){
        if(dp[N][j]<INF) break;
    }

    //answer
    cout << j << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 199160
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <ll> v(n);
    set <int> v1, v2;
    for (int i = 0; i < n; i++) cin >> v[i];
    map <int,int> m1, m2;
    for (int i = 0; i < n; i++){
        v1.insert(i+v[i]);
        v2.insert(i-v[i]);
        m1[i+v[i]]++;
        m2[i-v[i]]++;
    }
    ll ans = 0;
    for (auto it = v1.begin(); it != v1.end(); it++){
        ans += 1ll*m1[*it]*1ll*m2[*it];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 47812
def trace(A,input_num):
    for i in range(input_num):
        if i != input_num - 1:
            print(A[i],end = " ")
        else:
            print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)


Measured memory_bytes: 5980
def dig_sum(N):
    ans=0
    while N>0:
        ans+=N%10
        N=N//10
    return ans

N=int(input())
ans=100
for i in range(1,N):
    tmp=dig_sum(i)+dig_sum(N-i)
    if tmp<ans:
        ans=tmp
print(ans)


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

const long long int llinf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define Endl endl
#define pr(x) cout << x << endl
#define FOR(i,a,b) for(int i = a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define atcoder int(1e9) +7;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
#define all(x) x.begin,x.end();

int main() {

	string s;
	cin >> s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';

	if (a + b + c + d == 7)cout << a << '+' << b << '+' << c << '+' << d << '=' << 7 << endl;
	else if (a + b + c - d == 7)cout << a << '+' << b << '+' << c << '-' << d << '=' << 7 << endl;
	else if (a + b - c + d == 7)cout << a << '+' << b << '-' << c << '+' << d << '=' << 7 << endl;
	else if (a - b + c + d == 7)cout << a << '-' << b << '+' << c << '+' << d << '=' << 7 << endl;
	else if (a + b - c - d == 7)cout << a << '+' << b << '-' << c << '-' << d << '=' << 7 << endl;
	else if (a - b + c - d == 7)cout << a << '-' << b << '+' << c << '-' << d << '=' << 7 << endl;
	else if(a - b - c + d == 7)cout << a << '-' << b << '-' << c << '+' << d << '=' << 7 << endl;
	else if (a - b - c - d == 7)cout << a << '-' << b << '-' << c << '-' << d << '=' << 7 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  ll W;
  cin>>n>>W;
  ll w[n+1]={},v[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }

  ll ans=0;
  map<ll,ll> dp;
  dp[0]=0;
  for(int i=1;i<=n;i++){
    auto tmp=dp;
    for(auto p:tmp){
      auto x=p.first+w[i];
      auto y=p.second+v[i];
      if(x<=W){
        dp[x]=max(dp[x],y);
        ans=max(ans,dp[x]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
NOT_FOUND = 'UNRESTORABLE'


def m():
    S = list(str(input()))
    T = list(str(input()))
    first = 0
    end = 0
    for i in range(len(S) + 1 - len(T)):
        for k in range(len(T)):
            if S[i + k] != T[k] and S[i + k] != '?':
                break
            if k == len(T) - 1:
                first = i
                end = i + k
    if (end - first) < len(T) - 1:
        return NOT_FOUND

    j = 0
    while first <= end:
        S[first] = T[j]
        first += 1
        j += 1
    ans = "".join(S)
    r = ans.replace('?', 'a')
    return r


print(m())


Measured memory_bytes: 3064
import re
s = input()
K = int(input())

D = []
m = []

chars = list(set(list(s)))
chars.sort()

for n in range(3):
    if chars != []:
        m.append(min(chars))
        chars = chars[1:]

m.reverse()

t = m.pop()
D.append(t)

while len(D) < K:
    p = re.compile(t + '[a-z]')
    ma = list(set(p.findall(s)))
    ma.sort()
    if ma == []:
        if D.index(t) < len(D)-1:
            t = D[D.index(t)+1]
        else:
            t = m.pop()
            D.append(t)
    else:
        D.append(ma[0])
        t = ma[0]

D.sort()
print(D[K-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 1e18;
    cin >> n;
    for(int d = 1; d * d <= n; d++) {
        if(n % d == 0) {
            int cur = d + n / d - 2;
            ans = min(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int f(lli a){
  int count=0;
  while(a/10!=0){
    count++;
    a/=10;
  }
  return count+1;
}


int main(){
  lli n;
  scanf("%lld",&n);
  
  int min=f(n);
  for(lli i=1;i*i<=n;i++){
    if(n%i==0){
      int digitnum=max(f(i),f(n/i));
      if(digitnum<min){
        min=digitnum;  
      }
    }
  }
  printf("%d",min);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] freq = new int[N];
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt() - 1;
      freq[a]++;
    }
    Arrays.sort(freq);
    long[] cumsum = new long[N];
    cumsum[0] = freq[0];
    for (int i = 1; i < N; i++) {
      cumsum[i] = cumsum[i - 1] + freq[i];
    }

    long[] res = new long[N];
    for (int i = 0; i < N; i++) res[N - i - 1] = upperBound(freq, cumsum, i, N);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) sb.append(res[i]).append('\n');
    System.out.print(sb.toString());
  }

  public static long upperBound(int[] freq, long[] cumsum, int offset, int N) {
    long left = freq[offset];
    long right = cumsum[N - 1] + 1;
    while (right - left > 1) {
      long mid = (left + right) / 2;
      int idx = upperBound(freq, mid);
      if (cumsum[idx] >= (idx - offset + 1) * mid) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }

  public static int upperBound(int[] a, long k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] < k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }
}


Measured memory_bytes: 93436
#include <iostream>
using namespace std;
int main() {
    string s, t; cin >> s >> t;
    int sa[100001], ta[100001];
    sa[0] = 0; ta[0] = 0;
    for (int i = 0; i < s.size(); i++) sa[i+1] = sa[i] + (s[i] == 'A');
    for (int i = 0; i < t.size(); i++) ta[i+1] = ta[i] + (t[i] == 'A');
    int q; cin >> q;
    while (q--) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        cout << ((2*(b - a) - sa[b] + sa[a-1] - (2*(d - c) - ta[d] + ta[c-1])) % 3 == 0 ? "YES" :"NO") << endl;
    }
}

Measured memory_bytes: 1664
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 m = sc.nextInt();
        Map<Integer, List<Integer>> graph = new HashMap<>();

        for(int i = 1; i <= n; i++)
            graph.put(i, new ArrayList<>());

        for(int i = 0; i < m; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            graph.get(u).add(v);
            graph.get(v).add(u);
        }
        Set<Integer> visited = new HashSet<>();
        visited.add(1);
        System.out.println(dfs(graph, visited, 1));
    }

    private static int dfs(Map<Integer, List<Integer>> graph, Set<Integer> visited, int cur) {
        if(visited.size() == graph.size())
            return 1;

        int sum = 0;
        for(int adj : graph.get(cur)) {
            if(visited.contains(adj)) continue;
            visited.add(adj);
            sum += dfs(graph, visited, adj);
            visited.remove(adj);
        }
        return sum;
    }

}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(20000000)
n = int(input())

def dfs(num, l):
    if num == 0:
        return l
    l_new = []
    for s, set_size in l:
        for i in range(set_size+1):
            s_size = set_size if i < set_size else set_size + 1
            l_new.append((s + chr(ord('a') + i), s_size))
    return dfs(num-1, l_new)


ans = dfs(n-1, [("a", 1)])
ans = list(map(lambda x: x[0], ans))
ans.sort()
print("\n".join(ans))


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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 2);
  A[0] = 0, A[N + 1] = 0;
  for (int i = 1; i < N + 1; i++)
  {
    cin >> A[i];
  }
  vector<long long int> ans(N);
  long long int sum = 0;
  for (int i = 1; i < N + 2; i++)
  {
    sum += abs(A[i] - A[i - 1]);
  }
  for (int i = 0; i < N; i++)
  {
    ans[i] = sum - abs(A[i + 1] - A[i]) - abs(A[i + 2] - A[i + 1]) + abs(A[i + 2] - A[i]);
  }
  for (int i = 0; i < N; i++)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x=1000000;
    cin>>n;
    unordered_map<ll,ll>nw,ne;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='W')nw[i]=1+nw[i-1];
        else nw[i]=nw[i-1];
        if(s[n-i-1]=='E')ne[n-i-1]=1+ne[n-i];
        else ne[n-i-1]=ne[n-i];
    }
    for(int i=0;i<n;i++){
        x=min(x,(nw[i-1]+ne[i+1]));
        //cout<<nw[i-1]<<" "<<ne[i+1]<<endl;
    }
    cout<<x;
}


Measured memory_bytes: 30400
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	string a[3] = { "Sunny", "Cloudy", "Rainy" };
	string b;
	cin >> b;
	for (int i = 0; i < 3; ++i) {
		if (b == a[i]) {
			PRI(a[(i + 1) % 3]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3572
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
    int N,K;
    cin>>N>>K;
    int h[N];
    int count = 0;
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    for(int j=0;j<N;j++){
        if(h[j]>=K){
            count ++;
        }
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
using namespace std;

// A Point in a Triangle(0012)
double area(const double x1, const double y1, const double x2, const double y2, const double x3, const double y3)
{
	double s = x1*y2 - x1*y3 + x2*y3 - x2*y1 + x3*y1 - x3*y2;
	if (s < 0)
		s = -s;
	return s / 2.0;
}

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		double St = area(x1, y1, x2, y2, x3, y3);

		double S1 = area(x1, y1, x2, y2, xp, yp);
		double S2 = area(x2, y2, x3, y3, xp, yp);
		double S3 = area(x3, y3, x1, y1, xp, yp);

		if (S1 != 0 && S2 != 0 && S3 != 0 && S1+S2+S3 == St)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i<1000010;i++)
    {
       ll count=0;
        while(n%i==0)
        {
            n/=i;
            count++;
        }
        
        for(ll j=1;j<10000;j++)
        {
            if(count<j)
             break;
            ans++;

            count-=j;
            
        }
        
    }
    
    if(n>1)
    { ans++;}
    
    cout<<ans<<endl;
    
    
}



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

int main() {
  int n;
  vector<int> v;
  int t;
  cin >> n;
  rep(i,n) {
    cin >> t;
    v.push_back(t);
  }
  reverse(v.begin(), v.end());

  rep(i,v.size()-1) {
    cout << v[i] << " ";
  }
  cout << v[v.size()-1];
  cout << endl;

  return 0;
}



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


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    print(0 if N<=K else sum(H[:N-K]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28928
function Main(input){
	input = input.split(" ");
	nums = input.map(input=>parseInt(input,10));
    ans = nums[0] % nums[1];
    if(ans != 0){
    console.log(1);
    }else{
    console.log(0);
    }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <queue>
#include <iostream>
using namespace std;
#define lol long long
lol a,b;

inline lol read()
{
	lol x = 0 , f = 1;char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1;ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
	return x * f;
}
inline void out(lol x)
{
	if (x < 0) putchar('-'),x=-x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + 48);
}

int main()
{
	a=read();b=read();
	if (b%a == 0) out(a+b);
	else out(b-a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    ll ans = inf;
    rep(i,n-k+1){
        ll sa = v[i+k-1] - v[i];
        //cout<<i<<" "<<i+k-1<<endl;
        //cout<<v[i]<<" "<<v[i+k-1]<<endl;
        ans = min(ans,sa);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=101;
int a[N],n;
int main()
{
//freopen("input.txt","r",stdin);
ios::sync_with_stdio(false);
cin >>n;
//cout <<n<<endl;
for(int i=1;i<=n;i++)
	{
	cin >>a[i];
	//cout <<a[i]<<endl;
	}
int now=2,ans=0;
while(now<=n)
	{
	if(a[now]==a[now-1])
		{
		now+=2;
		ans++;
		}
	else now++;
	//cout <<now;
	}
cout <<ans;
return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 06:30:41 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  L, R = list(map(int, input().split()))

  if R-L+1 >= 2019:
    print(0)
    return
  else:
    mods = []
    for i in range(L, R+1):
      mods.append(i)
  mods = sorted(mods)
  min_ = float('inf')
  for i in mods:
    for j in mods:
      if i==j:
        continue
      min_ = min(min_, (i*j) % 2019)

  print(min_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 65044
#include<stdio.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-b)%c<<endl;
}

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

int main() {
    int k, x;
    int max, min;
    cin >> k >> x;
    max = x + k - 1;
    min = x - k + 1;
    for(int i = min; i <= max; i++) {
      if(i == max) {
        cout << i << endl;
        break;
      }
      cout << i << " ";
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
for i in s:
    dic[i] += 1

for i in t:
    dic[i] -= 1

ans = 0
for k, v in dic.items():
    ans = max(ans, v)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  sort(S.begin(),S.end());
  bool flag=true;
  for(int i=1;i<S.size();i++){
    if(S.at(i)==S.at(i-1)){
      flag=false;
    }
  }
  if(flag){
    cout<<"yes"<<endl;
  }
  else{
    cout<<"no"<<endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int64_t A;
  string B;
  cin>>A>>B;
  B.erase(1,1);
  int b=stoi(B);
  cout<<A*b/100<<endl;
  return 0;  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
    co("Yes")
  }
  else if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]){
    co("Yes")
  }
  else if(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[2]){
    co("Yes")
  }
  else{
    co("No")
  }
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N): par(N) {
        for (int i=0; i<N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size() {
        for (int i=0; i<par.size(); i++) root(i);
        set<int> s(par.begin(), par.end());
        return s.size();
    }
};

int main() {
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    for (int i=0; i<M; i++) {
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }
    cout << uf.size() << endl;
}

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


int main() {
	int n,m, max, min;
	cin >> n;
	cin >> m;
	max = m;
	min = m;
	for (int i = 1; i < n; i++) {
		int l;
		cin >> l;
		if (l > max) {
			max = l;
			continue;
		}
		if (l < min) {
			min = l;
		}
	}
	cout << max - min;
	return 0;
}

Measured memory_bytes: 256