akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <unordered_map>

long combi2(long n) {
  if (n < 2)
    return 0;
  return n * (n - 1) / 2;
}

int main(int argc, char *argv[]) {
  long N;
  std::cin >> N;
  long A[210000]{};
  std::unordered_map<long, long> a{};
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    ++a[A[i]];
  }

  long sum{};
  for (auto &i : a) {
    sum += combi2(i.second);
  }

  for (int i = 0; i < N; ++i) {
    long t = a[A[i]];
    std::cout << sum - combi2(t) + combi2(t - 1) << std::endl;
  }
}


Measured memory_bytes: 9160
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let b = {
        let mut b = a.clone();
        b.sort_by_key(|x| -x);
        b
    };
    let ans = (0..N).map(|i| if i % 2 == 0 { b[i] } else { -b[i] }).sum::<i64>();

    println!("{}", ans);
}

Measured memory_bytes: 4352
/*#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <set>*/
#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n;
    cin >> n;

    while (n > 0){
        cout << "ACL";
        n--;
    }
    cout << endl;
}

int main()
{
    /*int t;
    cin >> t;

    while (t--){
        solve();
    }*/
    solve();
    return 0;
}


Measured memory_bytes: 3504
<?php

$n = trim(fgets(STDIN));
$h = explode(' ', trim(fgets(STDIN)));

$c = 0;
$k = 0;
while(array_sum($h) > 0){
  
  if ($h[$k] == 0) {
    $k++;
  } else {
    for($i=$k; $i<$n; $i++){
       if($h[$i] > 0){
         $h[$i]--;
       } else {
         break;
       }
    }
    $c++;
  }
  if (array_sum($h) == 0) break;
}

echo $c;
  
?>

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  const int n = 13;
  string s;
  cin >> s;
  ll dp[n] = {0};
  dp[0] = 1;
  ll mul = 1;
  ll mod = 1e9 + 7;

  for (int i = s.size() - 1; i >= 0; --i) {
    ll nextdp[n] = {0};
    char c = s[i];
    if (c == '?') {
      for (int k = 0; k < 10; ++k) {
        for (int j = 0; j < n; ++j) {
          nextdp[(k * mul + j) % n] += dp[j];
          nextdp[(k * mul + j) % n] %= mod;
        }
      }
    } else {
      int k = s[i] - '0';
      for (int j = 0; j < n; ++j) {
        nextdp[(k * mul + j) % n] += dp[j];
        nextdp[(k * mul + j) % n] %= mod;
      }
    }
    mul *= 10;
    mul %= n;
    rep(i, n) dp[i] = nextdp[i];
  }
  cout << dp[5] << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

double calcY(int a,int b,int c,int d,int e,int f){
	return (double)(c*d-a*f)/(b*d-a*e);
}
double calcX(int a,int b,int c,int d,int e,int f){
	return (double)(c-b*calcY(a,b,c,d,e,f))/a;
}
int main(){
	int a,b,c,d,e,f;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		printf("%.3lf %.3lf\n",calcX(a,b,c,d,e,f),calcY(a,b,c,d,e,f));
	}
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}if(a>b){
		printf("a > b\n");
	}if(a==b){
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=INF;
	int cnt=0;
	cin >>n;
	Vi a(n);
	rep(i,n){
		cin>>a[i];
		cnt=0;
		while(a[i]%2==0){
			cnt++;
			a[i]/=2;
		}
		chmin(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define INF 0x3fffffff
using namespace std;
  
int n,m;
int d[10005];
struct node
{
    int e,len,cost;
    //node(){}
    node(int a,int b,int c)
    {
        e=a,len=b,cost=c;
    }
    bool operator < (const node &a) const
    {
        return len>a.len;
    }
};
vector <node> E[10005];
priority_queue <pair<int,int> > q;
  
int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    while(~scanf("%d%d",&n,&m)&&n)
    {
        for(int i=1;i<=n;i++)
            d[i]=INF,E[i].clear();
        for(int i=1;i<=m;i++)
        {
            int s,e,cost,len;
            scanf("%d%d%d%d",&s,&e,&len,&cost);
            E[s].push_back(node(e,len,cost));
            E[e].push_back(node(s,len,cost));
        }
        q.push(make_pair(1,0));
        d[1]=0;
        while(!q.empty())
        {
            pair <int,int> t=q.top();
            q.pop();
            int v=t.first;
            //printf("*%d-%d\n",t.first,t.second);
            if(d[v]<t.second)
                continue;
            for(int i=0;i<E[v].size();i++)
            {
                node e=E[v][i];
                if(d[e.e]>d[v]+e.len)
                {
                    d[e.e]=d[v]+e.len;
                    q.push(make_pair(e.e,d[e.e]));
                }
            }
        }
        int ans=0;
        for(int i=2;i<=n;i++)
        {
            int mine=INF;
            for(int j=0;j<E[i].size();j++)
                if(E[i][j].len+d[E[i][j].e]==d[i]&&mine>E[i][j].cost)
                    mine=E[i][j].cost;
            if(mine!=INF)
            ans+=mine;
        }
        printf("%d\n",ans);
    }
} 

Measured memory_bytes: 4704
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int A[2][N];

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

    int max = 0;

    for(int i = 0; i < N; i++){
        int c = 0;
        for(int j = 0; j <= i; j++){
            c += A[0][j];
        }
        for(int j = i; j < N; j++){
            c += A[1][j];
        }
        if(c > max){
            max = c;
        }
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m, f, r, point;
    
    for (int i = 0; i < 10000; i++){
        cin >> m >> f >> r;
        point = m + f;
        if (m == -1 && f == -1 && r == -1)
            break;
        if (m == -1 || f == -1 || point < 30)
            cout << "F" << endl;
        else if (point >= 80)
            cout << "A" << endl;
        else if (point >= 65)
            cout << "B" << endl;
        else if (point >= 50)
            cout << "C" << endl;
        else if (point >= 30){
            if (r >= 50)
                cout << "C" << endl;
            else
                cout << "D" << endl;
        }
    }
}



Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	N := sc.nextInt()
	An := sc.nextInts()
	Bn := sc.nextInts()
	Cn := sc.nextInts()
	var ans int
	prev := -100
	for i := 0; i < N; i++ {
		A := An[i] - 1
		ans += Bn[A]
		if prev+1 == A {
			ans += Cn[prev]
		}
		prev = A
	}
	fmt.Println(ans)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
nl = []; c = 0;
INF = 10**9+7; ans = 0;
while True:
    try:
        l = map(int, raw_input().split(','))
        nl.append(l)
        c += 1
    except EOFError:
        break
cn = (c + 1)/2
dp1, dp2 = [0], [0]
for i in xrange(1,cn):
    dp1 = [ max(dp1[j-1]+nl[i-1][j-1] if j>0 else 0, dp1[j]+nl[i-1][j] if j<i else 0) for j in xrange(i+1)]
for i in xrange(1,cn):
    dp2 = [ max(dp2[j-1]+nl[c-i][j-1] if j>0 else 0, dp2[j]+nl[c-i][j] if j<i else 0) for j in xrange(i+1)]
for i in xrange(cn):
    ans = max(ans, dp1[i] + dp2[i] + nl[cn-1][i])
print ans

Measured memory_bytes: 4280
#include <iostream>
#include <string.h>

using namespace std;
int main() {
	int h=1, w=1;
	while (h != 0 && w != 0) {
		cin >> h;
		cin >> w;
		if (h == 0 && w == 0) continue;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1) {
					cout << "#";
				}
				else {
					if (j == 0 || j == w - 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
					
				}
				
				
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import numpy as np

N,D = map(int,input().split())
X = np.empty((N,D))
for i in range(N):
    X[i]=np.array(list(map(int,input().split())))
c = 0
for i in range(N):
    for j in range(i,N):
        calc = np.linalg.norm(X[i]-X[j])
        if calc.is_integer() and not calc == 0:
            c+=1
print(c)

Measured memory_bytes: 12504
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function bsearch(a,x);l,r=1,length(a);while l<=r;m=l+div(r-l,2);if a[m]<x;l=m+1;else;r=m-1;end;end;return(l-1);end

function main()
	mod = 1000000007
	n = readline() |> parseInt
	c = Array{Int}(n)
	d = Dict{Int,Array{Int,1}}()
	for i in 1:n
		c[i] = readline() |> parseInt
		if haskey(d,c[i])
			push!(d[c[i]],i)
		else
			d[c[i]] = [i]
		end
	end
	dp = zeros(Int,n)
	e = Dict{Int,Int}()
	for i in keys(d)
		e[i] = 0
	end
	dp[1] = 1
	e[c[1]] = 1
	for i in 2:n
		if c[i] == c[i-1]
			dp[i] = dp[i-1]
		else
			dp[i] = (dp[i-1]+e[c[i]])%mod
			e[c[i]] = dp[i]
		end
	end
	println(dp[n])
end
main()

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

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

    int cnt = 0;

    while(B <= A) {
        B *= 2;
        cnt++;
    }
    while( C<=B){
        C*=2;
        cnt++;
    }

    string ans;
    if (cnt <= K) {
        ans = "Yes";
    }else{
        ans = "No";
    }

    cout << ans << endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(s * t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
import numpy as np

N=int(input())
A=np.array(input().split(),np.int32)

count=np.zeros((A.max()+1))
for a in A:
    if count[a]>1:
        continue
    count[::a]+=1
ans=0
for i in A:
    if count[i]==1:
        ans+=1
print(ans)

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
const LL mod=1e9+7;
int n,k;
vector<int>v[N];
LL ans=1;
void dfs(int now,int pre,int one=0,int two=0){
	int need=k-one-two;
	need=max(need,0);
	ans=ans*need;
	ans%=mod;
	int cnt=0;
	for(auto k:v[now]){
		if(k==pre)continue;
		dfs(k,now,1,one+cnt++);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		int s,t;
		cin>>s>>t;
		v[s].pb(t);
		v[t].pb(s);
	}
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

const int inf = 1<<24;

typedef double Weight;
typedef pair <int, int> PII;
typedef pair <Weight, PII> Node;
typedef priority_queue <Node, vector<Node>, greater<Node> > Queue;
typedef set <PII> Set;

const int size = 64;
int n, m, p, a, b;
int T[size];
int E[size][size];
int EC[size];
Weight G[size][size];

void init() {
    for ( int i = 0; i < size; i++ ) {
        for ( int j = 0; j < size; j++ ) {
            G[i][j] = inf;
        }
    }
    for ( int i = 0; i < size; i++ ) {
        EC[i] = 0;
    }
}

string solve( int s, int t ) {
    Queue Q = Queue();
    Node start( 0.0, PII( 0, s ) );
    Q.push( start );
    Weight M[1<<10][size];
    for ( int i = 0; i < 1<<10; i++ ) {
        for ( int j = 0; j < size; j++ ) {
            M[i][j] = inf;
        }
    }
    M[0][s] = 0.0;

    while ( !Q.empty() ) {
        Node node = Q.top();
        Q.pop();

        Weight weight = node.first;
        int tickets = node.second.first;
        int pos = node.second.second;

        if ( pos == t ) {
            ostringstream os;
            os << weight;
            return os.str();
        }

        for ( int i = 0; i < EC[pos]; i++ ) {
            int nextpos = E[pos][i];
            for ( int j = 0; j < n; j++ ) {
                if ( ( tickets & (1<<j) ) == 0 ) {
                    int nexttickets = ( tickets | (1<<j) );
                    Weight nextweight = weight + G[pos][nextpos] / (Weight)T[j];
                    Node nextnode( nextweight, PII( nexttickets, nextpos ) );
                    if ( nextweight >= M[nexttickets][nextpos] ) continue;
                    M[nexttickets][nextpos] = nextweight;
                    Q.push( nextnode );
                }
            }
        }
    }

    return "Impossible";
}

int main() {
    while ( cin >> n >> m >> p >> a >> b ) {
        if ( n == 0 && n == m && m == p && p == a && a == b ) break;
        init();
        a--;
        b--;
        for ( int i = 0; i < n; i++ ) {
            cin >> T[i];
        }
        sort(T,T+n);
        for ( int i = 0; i < p; i++ ) {
            int x, y, z;
            cin >> x >> y >> z;
            x--;
            y--;
            G[x][y] = G[y][x] = z;
            E[x][EC[x]++] = y;
            E[y][EC[y]++] = x;
        }
        cout << solve( a, b ) << endl;
    }
    return 0;
}

Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
long long N, M, a[100009][3], maxn = -(1LL << 60);
 
int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	 // 8 pattern
	for (int i = 0; i < 8; i++) {
		// Nに対して
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			// x, y, zに対して
			for (int k = 0; k < 3; k++) { 
        if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; 
      }
			vec.push_back(S);
		}
		
		// NをソートしてMタス
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void main()
{
   long N,D,i=0;
   scanf("%ld%ld",&N,&D);
   while(N--)
   {
       long x,y;
       scanf("%ld%ld",&x,&y);
       
       if(((x*x)+(y*y))<=(D*D))
       i++;
   }
   
   printf("%ld\n",i);
    
}

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

int main() {
  int x, y;
  cin >> x >> y;
  while (!(x == 0 && y == 0)) {
    if (x > y) {
      cout << y << " " << x << endl;
    } else {
      cout << x << " " << y << endl;
    }
    cin >> x >> y;
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> G(n);
	vector<pair<int, int>> vp;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
		vp.emplace_back(a, b);
	}

	int k = 0;
	map<pair<int, int>, int> I;//
	vector<int> cs(n, 0);//

	vector<int> used(n, 0);
	queue<int> que;
	used[0] = 1;
	que.emplace(0);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		if (k < (int)G[v].size()) k = G[v].size();
		int cur = 1;
		for (int u : G[v]) {
			if (used[u]) continue;
			if (cur == cs[v]) cur++;
			cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
			used[u] = 1;
			que.emplace(u);
		}
	}
	
	cout << k << endl;
	for (auto p : vp) cout << I[p] << endl;
	return 0;
}

Measured memory_bytes: 20088
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int dr[]={0,0,1,1,1,-1,-1,-1};
int dc[]={1,-1,0,1,-1,0,1,-1};
 
void solve();
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}  
 
int i, j, k, l, n, m, x, y, t;
void solve()
{ 
    // cin >> t; while(t--)
    {
        k=0;
        string s1, s2;
        cin >> s1 >> s2;
        f(i,3) if(s1[i]==s2[i]) k++;
        cout << k;
    }
}

Measured memory_bytes: 256
// 173

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    int n, d, buf_1, buf_2, count=0;
    cin >> n >> d;
    for(int i=0; i<n; i++){
        cin >> buf_1 >> buf_2;
        if(double(sqrt(pow(buf_1, 2)+pow(buf_2, 2))) <= d) count++;
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

int dp[200001];
int cnt = 1;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
        
    int n; cin >> n;
    vector<int> table(n);

    for (int i = 0; i < n; ++i)
        cin >> table[i];
 
    dp[0] = table[0];
    for (int i = 1; i < n; ++i)
    {
        if (table[i] <= dp[i - 1])
        {
            dp[i] = table[i];
            ++cnt;
        }
        else
            dp[i] = dp[i - 1];
    }
    
    cout << cnt;
}

Measured memory_bytes: 1792
#include <iostream>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;
typedef pair<Point, double> Circle;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

Point project(Segment s, Point p){
    Vector base = s.second - s.first;
    double r = dot(p - s.first, base) / norm(base);
    return s.first + base * r;
}

pair<Point, Point> getCrossPoints(Circle c, Line l){
    Vector pr = project(l, c.first);
    Vector e = (l.second - l.first) / abs(l.second - l.first);
    double base = sqrt(c.second * c.second - norm(pr - c.first));
    return make_pair(pr + e * base, pr - e * base);
}

int main(){
    double cx, cy, r; cin>>cx>>cy>>r;
    Circle c1 = {Point(cx, cy), r};
    int q; cin>>q;
    while(q--){
        double x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2;
        Line l1 = {Point(x1, y1), Point(x2, y2)};
        pair<Point, Point> ansp = getCrossPoints(c1, l1);
        Point p1 = min(ansp.first, ansp.second);
        Point p2 = max(ansp.first, ansp.second);
        printf("%.10f %.10f %.10f %.10f\n", p1.X, p1.Y, p2.X, p2.Y);
    }
}


Measured memory_bytes: 3288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    int[] _minValueCount;
    int[] _value;

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        const int ValueCount = 12;
        _value = new int[ValueCount] { (int)Math.Pow(9, 5), (int)Math.Pow(9, 4), (int)Math.Pow(9, 3), (int)Math.Pow(9, 2), (int)Math.Pow(9, 1),
            (int)Math.Pow(6, 6), (int)Math.Pow(6, 5), (int)Math.Pow(6, 4), (int)Math.Pow(6, 3), (int)Math.Pow(6, 2), (int)Math.Pow(6, 1), 1 };

        Array.Sort(_value);

        _minValueCount = new int[n + 1];
        for (int i = 1; i <= n; ++i)
        {
            _minValueCount[i] = int.MaxValue;
        }

        for (int sum = 1; sum <= n; ++sum)
        {
            int minValueCount = int.MaxValue;

            for (int valueIndex = 0; valueIndex < ValueCount; ++valueIndex)
            {
                int value = _value[valueIndex];

                if (sum < value) { break; }

                minValueCount = Math.Min(minValueCount, _minValueCount[sum - value] + 1);
            }

            _minValueCount[sum] = minValueCount;
        }

        int ans = _minValueCount[n];

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11220
// ?????¬???????????¬?????? (????°????)

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// s ????????????????????? t ?????¨??? u ????????????
string replace_user(string s, string t, string u) {
    reverse(t.begin(), t.end());
    size_t N = s.length(), M = t.length();
    if(N < M) return s;

    string ret = "", temp = "";
    for(size_t i=0; i<N; i++) {
        if(temp.length() == M) {
            ret += temp.back();
            temp.pop_back();
        }
        temp = s[i] + temp;
        if(temp == t) {
            ret += u;
            temp = "";
        }
    }
    reverse(temp.begin(), temp.end());
    s = ret + temp;
    return s;
}

map<string, int> m;

void solve(string s) {
    if(m.count(s)) return;
    m[s]++;
    s = replace_user(s, "ABC", "X");
    int cnt[3] = {};
    rep(i,0,s.length()) if(s[i] != 'X') cnt[ s[i] - 'A' ]++;
    rep(i,0,3) {
        if(cnt[i]) continue;
        replace(s.begin(), s.end(), 'X', (char)('A' + i));
        if(!m.count(s)) solve(s);
    }
}

signed main() {
    string s; cin >> s;
    solve(s);
    if(m.count("ABC")) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 22056
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  int a, b;
  a = N/10;
  b = N-a*10;
  if (a == 9 || b == 9) cout << "Yes" << endl;
  else cout << "No" << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Inf 1000000007
using namespace std;
int fun(int *dp,int *arr,int n,int k)
{
    dp[0]=0;

    for(int i=1;i<n;i++)
    {    
        dp[i]=Inf;
        for(int j=1;j<=k;j++)
        {
            if((i-j)>=0)
             dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);

        }
       
    }
    return dp[n-1];
}
 
 
int main()
{
    int arr[100005];
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[100005];
    for(int i=0;i<n+2;i++)
    dp[i]=-1;
    cout<<fun(dp,arr,n,k)<<endl;
    return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll ans = 0;
    ll cur = 1;
    while(H > 0){
        H /= 2;
        ans += cur;
        cur *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    if n % 111 == 0 {
        println!("{}", n);
    } else {
        println!("{}", (n / 111 + 1) * 111);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

ll mod=998244353;
vector <ll> factorials;
ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2)%mod;
}

ll choose(ll n, ll k)
{
    ll num = factorials[n];
    ll den=(modInv(factorials[n-k])*modInv(factorials[k]))%mod;
    return (num*den)%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, M, K;
    cin >> N >> M >> K;
    factorials.resize(N+1);
    factorials[0]=1;
    loop(i,1,N+1) factorials[i]=(factorials[i-1]*i)%mod;
    vector <ll> dp(N);
    dp[0]=M;
    for (int i=1; i<N; ++i) {
        dp[i]=(dp[i-1]*(M-1))%mod;
    }
    // for (int i=1; i<N; ++i)
    // {
    //     for (auto z: dp[i-1])
    //     {
    //         dp[i][z.first] += (dp[i-1][z.first]*(M-1))%mod;
    //         dp[i][z.first]%=mod;
    //         if (z.first+1 <=K) {
    //             dp[i][z.first+1] += (dp[i-1][z.first]);
    //             dp[i][z.first+1]%=mod;
    //         }
    //     }
    // }
    if (M==1 && K==N-1) {
        cout << 1 << "\n";
        return 0;
    }
    ll sum=0;
    for (ll i=0; i<=K; ++i)
    {
        sum += dp[N-1]*((modExp(modExp(M-1, i)%mod, mod-2)*choose(N-1,i))%mod);
        sum%=mod;
        // cout << sum << "\n";
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 6316
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
    int64_t a,b,x,count=0;
	cin>>a>>b>>x;
	count+=b/x;
	count-=(a/x);
	if(a%x==0){
    	count+=1;
    }
	cout<<count;
}


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

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

Measured memory_bytes: 3616
/**
    Find the number of integers between [1, n]
    satisfying the following condition:
    The sum of the digits is a multiple of D
*/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long 

vector<int> num;
ll DP[10004][103][2],d;

ll call(int pos, int sum, int flag)
{
    if(pos == (int)num.size())
        return sum%d==0;
    if(~DP[pos][sum][flag]) 
        return DP[pos][sum][flag];
    
    ll ans = 0;
    for(int i = 0; i<10; i++)
    {
        if(flag && i==num[pos]) 
        {
            ans = (ans + call(pos+1, (sum+i)%d, 1))%MOD;
            break;
        }
        ans = (ans + call(pos+1, (sum+i)%d, 0))%MOD;
    }
 
    return DP[pos][sum][flag]=ans;
}

ll solve(string& s)
{
    num.clear();
    for(int i=0; i<s.size(); i++)
        num.push_back(s[i]-'0');
    memset(DP, -1, sizeof(DP));
    return (call(0, 0, 1)-1+MOD)%MOD;
}

int main ()
{
    string n;
    cin>>n>>d;
    cout<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 17280
#include <iostream>

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

    if ((a % 2 != 0) && (b % 2 != 0))
    {
        std::cout << "Odd";
    }
    else
    {
        std::cout << "Even";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int a,b,c;
    cin>>a>>b>>c;
    set<int>p;
    p.insert(a);
    p.insert(b);
    p.insert(c);
    int n=p.size();
    (n==2)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
def operation(s,t):
    cnt = 0
    if s == t:
        return cnt
    for i in range(len(s)):
        if s[i]!=t[i]:
            cnt+=1
    return cnt

def main():
    s = str(input())
    t = str(input())
    print(operation(s,t))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9436
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

string s1,s2;

int main(){
	cin >> s1 >> s2;
	int len = s1.size();
	for(int i = 0; i < len; i++){
		if(s1 == s2){
			cout << "Yes";
			return 0;
		}
		char c = s1[0];
		for(int j = 0; j < len-1; j++)
			s1[j] = s1[j+1];
		s1[len-1] = c;
	}	
	cout << "No";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define in(x); { for (auto &qwertyhgfdsa : x) cin >> qwertyhgfdsa; }
#define out(x); { for (auto qwertyhgfdsa : x) cout << qwertyhgfdsa << ' '; cout << endl; }
#define int long long

typedef long long ll;

using namespace std;

const int INF = 1e9;
const long long INFll = 2e18;
const long long base1 = 239;
const long long base2 = 653;
const long long mod = 1e9 + 7;
const double eps = 1e-6;
const int len = 140;



void solve() {
    vector <int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k; cout << v[k - 1];
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
}


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

int main(void){
  char S[3];
  bool ans = true;
  scanf("%s",S);
  if(S[0] == S[1] && S[1] == S[2])
    ans = false;
  if(ans) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

#define MAX 101

int main(){
    int N;
    int a[MAX];
    int scnt,res=0;

    scanf("%d",&N);

    REPI(N)
        scanf("%d",&a[i]);

    scnt = 1;

    REPI(N-1){
        if(a[i]==a[i+1]){
            if(++scnt%2==0)
                res++;
        }else{
            scnt=1;
        }
    }

    printf("%d\n",res);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll m,n;
	cin>>m>>n;
	ll a[n];
	for(int i=0;i<n;i++){cin>>a[i];}
	int sum=m-a[n-1]+a[0];
	for(int i=1;i<n;i++){
		sum+=(a[i]-a[i-1]);
	}
	int ans=INT_MAX;
	for(int i=0;i<n;i++){
		if(i==0){
			ans=min(ans,sum-(a[i+1]-a[i]));
			ans=min(ans,sum-(m-a[n-1]+a[0]));
		}
		else if(i==n-1){
			ans=min(ans,sum-(a[i]-a[i-1]));
			ans=min(ans,sum-(m-a[n-1]+a[0]));
		}
		else{
			ans=min(ans,sum-(a[i]-a[i-1]));
			ans=min(ans,sum-(a[i+1]-a[i]));
		}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 5180
#include<stdio.h>
int d[10000];
int main()
{
	int n,m,p,i,j,temp,q,L,R,c1,c2,min;
	scanf("%d %d %d",&n,&m,&p);
	d[0]=p;
	min=n;
	for(i=1;i<m+1;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<m;i++){
		for(j=i+1;j<m+1;j++){
			if(d[i]>d[j]){
				temp=d[i];
				d[i]=d[j];
				d[j]=temp;
			}
		}
	}
	for(i=0;i<m+1;i++){
		q=d[i];
		L=d[(i-1+m+1)%(m+1)];
		R=d[(i+1)%(m+1)];
		c1=((q-p+n)%n)*2+(p-R+n)%n;
		c2=((p-q+n)%n)*2+(L-p+n)%n;
		if(c1<min){
			min=c1;
		}
		if(c2<min){
			min=c2;
		}
	}
	printf("%d\n",min*100);
	return 0;
}

Measured memory_bytes: 1060
from collections import defaultdict

#dpa[(0,0)] = 0

n = int(input())

a = list(map(int, input().split()))

d = {}
for i in range(n):
	d[i] = a[i]

dp = defaultdict(lambda: 0)

i = 0
x = 0
y = 0
maxr = 0
for k,v in sorted(d.items(), key=lambda x: -x[1]):
	i+=1
#	print(k,": ",v)
	for j in range(i+1):
		if j == 0:
			migi = 0
		else:
			migi = abs(n - j - k)*v
		
		if i - j == 0:
			hida = 0
		else:
			hida = abs(k - (i - j)+1)*v
		dp[(j,i-j)] = max(dp[(j-1,i-j)]+migi,dp[(j,i-j-1)]+hida)
		
		if i == n:
			maxr = max(maxr,dp[(j,i-j)])
#		print(j,i-j,k,hida,migi,dp[(j,i-j)])

print(maxr)

Measured memory_bytes: 315964
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL mod = 1e9 + 7;
const int maxn = 5e5 + 7;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);

LL f[maxn],inv[maxn];

void init() {
    inv[0] = f[0] = inv[1] = f[1] = 1;
    for(LL i = 2 ; i <= maxn ; i++) {
        inv[i] = ((mod - mod / i) * inv[mod%i]) % mod;
        f[i] = i;
    }
    for(LL i = 2 ; i <= maxn ; i++) {
        inv[i] = (inv[i] * inv[i-1]) % mod;
        f[i] = (f[i] * f[i-1]) % mod;
    }
}

LL C(LL x,LL y) {
    return f[x] * inv[y] % mod * inv[x-y] % mod;
}

LL A(LL x,LL y) {
    return f[x] * inv[x-y] % mod;
}
int main() {

#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	long _begin_time = clock();
#endif

    init();
    // rep(i,1,10) {
    //     rep(j,1,i) {
    //         cout << "i = " << i << " j = " << j << " A[i][j] = " << A(i,j) << endl;
    //     }
    // }
    // rep(i,1,10) {
    //     rep(j,0,i) {
    //         cout << "i = " << i << " j = " << j << " C[i][j] = " << C(i,j) << endl;
    //     }
    // }
    int n,m;
    sd(n),sd(m);
    LL ans = A(m,n);
    // cout << "ans = " << ans << endl;
    for(LL i = 1 ; i <= n ; i++) {
        LL res = C(n,i) * A(m - i , n - i) % mod;
        // cout << "i = " << i << " res = " << res << endl;
        if(i&1) ans = (ans - res + mod) % mod;
        else ans = (ans + res) % mod;
    }
    ans = ans * A(m,n) % mod;
    plld(ans);

#ifndef ONLINE_JUDGE
	long _end_time = clock();
	// cout << "time = " <<  _end_time - _begin_time << endl;
#endif
    return 0;
}

Measured memory_bytes: 11560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

typedef pair<ll,ll> pll;

int main(){
    int n,k;cin >> n >> k;
    vector<ll> x(n),y(n);
    vector<pll> p(n);

    rep(i,n){
        cin >> x[i] >> y[i];
        p[i].first = x[i];
        p[i].second = y[i];
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll res = (x[n-1]-x[0])*(y[n-1]-y[0]);
    for(int l=0;l<n;l++){
        for(int r=l+1;r<n;r++){
            for(int b=0;b<n;b++){
                for(int t=b+1;t<n;t++){
                    int num=0;
                    for(int i=0;i<n;i++){
                        if(x[l]<=p[i].first&&p[i].first<=x[r]&&y[b]<=p[i].second&&p[i].second<=y[t])num++;
                    }
                    if(num>=k)res = min(res,(x[r]-x[l])*(y[t]-y[b]));
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256