akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
using namespace std;

//-----------------------------------LIBRARY OF INPUT-----------------------------------
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}

#pragma warning(disable:4996)
int n, m, q, dist[110000], mark[110000], u[210000], v[210000];
vector<pair<int, int>>x[110000], y[110000], z[110000]; bool used[210000];
bool isgood(int f) {
	for (int i = 0; i < z[f].size(); i++) {
		if (mark[z[f][i].first] == 0 && used[z[f][i].second] == false)return true;
	}
	return false;
}
int main() {
	scanf("%d%d%d", &n, &m, &q); queue<int>Q;
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b); 
		u[i + 1] = a; v[i + 1] = b;
		x[a].push_back(make_pair(b, i + 1)); x[b].push_back(make_pair(a, i + 1));
	}
	Q.push(1); for (int i = 1; i <= n; i++)dist[i] = 999999; dist[1] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			if (dist[x[a1][i].first] > dist[a1] + 1) { dist[x[a1][i].first] = dist[a1] + 1; Q.push(x[a1][i].first); }
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < x[i].size(); j++) {
			if (dist[i] < dist[x[i][j].first]) { y[i].push_back(x[i][j]); }
			if (dist[i] > dist[x[i][j].first]) { z[i].push_back(x[i][j]); }
		}
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int a; 
		scanf("%d", &a); 
		used[a] = true;
		int E1 = u[a], E2 = v[a];
		if (dist[E1] == dist[E2]) { cnt += 0; }
		else {
			int a1 = 0; if (dist[E1] < dist[E2])a1 = E2; else a1 = E1;
			if (isgood(a1) == false && mark[a1] == 0) {
				queue<int>Q; Q.push(a1); cnt++; mark[a1] = 1;
				while (!Q.empty()) {
					int a2 = Q.front(); Q.pop();
					for (int j = 0; j < y[a2].size(); j++) {
						if (mark[y[a2][j].first] == 0 && isgood(y[a2][j].first) == false) {
							mark[y[a2][j].first] = 1; Q.push(y[a2][j].first); cnt++;
						}
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 25700
package main

import (
	"fmt"
)

// 解法はこちらを参考
// https://drken1215.hatenablog.com/entry/2020/04/29/171300

func main() {
	var S string
	var ans int
	fmt.Scan(&S)
	val := make([]int, 2019)
	digit := 1
	cur := 0
	val[cur]++
	N := len(S)
	for i := 0; i < N; i++ {
		add := int(S[N-1-i] - '0')
		cur = (cur + digit*add) % 2019
		digit = (digit * 10) % 2019
		val[cur]++
	}
	for _, v := range val {
		ans += v * (v - 1) / 2
	}
	fmt.Println(ans)
}


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

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

#define fr first
#define sc second

ll f(ll a,ll k){
	if(k == 1)return a;
	ll x = a/k;
	if(x == 0)return 0;
	ll y = a%k;
	y %= (x+1);
	if(y == 0)return x;
	return f(k*x+y-(x+1),k);
}

int main(){
	ll n;
	ll ret = 0;
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		ll a,k;
		cin >> a >> k;
		ret ^= f(a,k);
	}
	if(ret == 0)puts("Aoki");
	else puts("Takahashi");
}

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

int main()
{
    int w,a,b,ans;
    cin >> w >> a >> b;

    if(a < b + w && b < a + w) cout << 0 << endl;
    else cout << (a + w <= b ? b - (a + w) : a - (b + w));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,m,x,y,t=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        t+=x-1;
    }
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
int N, R[100];
int S[100], P[100], C[100];
 
 
bool ck()
{
  int pt[101] = {};
 
  vector< pair< int, int > > vs;
  rep(i, N) vs.emplace_back(S[i], i);
  vector< int > rank(N, 0);
  rep(i, N) rep(j, N) if(vs[i].first < vs[j].first) ++rank[vs[i].second];
  rep(i, N) pt[i] += R[rank[i]];
 
  vs.clear();
  rep(i, N) vs.emplace_back(P[i], i);
  rank.assign(N, 0);
  rep(i, N) rep(j, N) if(vs[i].first < vs[j].first) ++rank[vs[i].second];
  rep(i, N) pt[i] += R[rank[i]];
 
  vs.clear();
  rep(i, N) vs.emplace_back(C[i], i);
  rank.assign(N, 0);
  rep(i, N) rep(j, N) if(vs[i].first < vs[j].first) ++rank[vs[i].second];
  rep(i, N) pt[i] += R[rank[i]];
 
  vs.clear();
  rep(i, N) vs.emplace_back(pt[i], i);
  rank.assign(N, 0);
  rep(i, N) rep(j, N) if(vs[i].first < vs[j].first) ++rank[vs[i].second];
 
  return (rank[0] <= 7);
}
 
int main()
{
  cin >> N;
  rep(i, N) cin >> R[i];
  rep(i, N) cin >> S[i] >> P[i] >> C[i];
 
  int ret = 114514;
  rep(i, 101) {
    S[0] += i;
    if(ck()) ret = min(ret, i);
    S[0] -= i;
  }
  rep(i, 101) {
    P[0] += i;
    if(ck()) ret = min(ret, i);
    P[0] -= i;
  }
 
  rep(i, 101) {
    C[0] += i;
    if(ck()) ret = min(ret, i);
    C[0] -= i;
  }
 
  if(ret == 114514) cout << "Saiko" << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 3100
use proconio::input;

fn main() {
    input! {
        n: usize,
    }
    let mut ret: Vec<String> = Vec::new();
    let mut v: Vec<char> = vec!['a'; 1];
    dfs(n, 'a', &mut v, &mut ret);
    for s in ret.iter() {
        println!("{}", s);
    }
}

fn dfs(n: usize, last: char, v: &mut Vec<char>, ret: &mut Vec<String>) {
    if v.len() == n {
        let s = v.iter().collect::<String>();
        ret.push(s);
        return;
    }

    for ch_u8 in 'a' as u8..=last as u8 + 1 {
        let ch = ch_u8 as char;
        v.push(ch);
        let next_last = if (last as u8) < ch_u8 { ch } else { last };
        dfs(n, next_last, v, ret);
        v.pop();
    }
}


Measured memory_bytes: 8380
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    vector<int> indeg(n), visited(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d",  &a, &b);
        G[a-1].emplace_back(b-1);
        indeg[b-1]++;
    }

    int ok = 1;
    vector<int> ans;
    for (int i = 0; i < n; ++i) {
        if(indeg[i] == 0 && !visited[i]){
            queue<int> Q;
            Q.emplace(i);
            visited[i] = 1;
            while(!Q.empty()){
                int x = Q.front(); Q.pop();
                ans.emplace_back(x);
                for (auto &&y : G[x]) {
                    visited[y] = visited[x]+1;
                    if(visited[y] == n) ok = 0;
                    indeg[y]--;
                    if(!indeg[y]) Q.emplace(y);
                }
            }
        }
    }
    for (auto &&j : ans) {
        printf("%d\n", j+1);
    }
    printf("%d\n", ok);
    return 0;
}


Measured memory_bytes: 3924
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
template <typename T>
inline void w(T x) {
	if (x > 9) w(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
	w(x);
	putchar(c);
}
template <typename T>
inline void read(T &x) {
	x = 0;
	T f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
int main(){
	char s[N];
	cin >> s;
	for(int i = 0; i < strlen(s); i++){
		if(s[i] == '7'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

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

using namespace std;

#define INF 0x3f3f3f3f
#define ll long long

int main() {
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	int A[N];
	ll ss[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ss[i] = A[i];
		if (i > 0) {
			ss[i] += ss[i-1];
		}
	}


	int size = (N * (N + 1)) / 2;
	ll S[(N * (N + 1)) / 2];
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			S[cnt++] = ss[j] - ss[i] + A[i];
			// cout << S[cnt-1] << endl;
		}
	}

	bool used[size] = {false};
	ll ans = 0;
	for (ll k = 40; k >= 0; k--) {
		int num = 0;
		bool used2[size] = {false};
	// 	if (ans != 0) {
	// for (int i = 0; i < size; i++)
	// 	cout << boolalpha << used[i] << " ";

	// 	}
		for (int i = 0; i < size; i++) {
			if (ans != 0) {
				if (((S[i] & (1LL << k)) != 0) && used[i]) {
					used2[i] = true;
					num++;
				}
			} else {
				if ((S[i] & (1LL << k)) != 0) {
					used[i] = true;
					num++;
				}
			}
		}

	// 	if (ans != 0)
	// for (int i = 0; i < size; i++) {
	// 	cout << boolalpha << used[i] << " ";

	// 	}
		if (num >= K) {
			if (ans != 0) {
				copy(used2, used2 + size, used);
			}
			ans |= (1LL << k);
		}
		if (ans == 0) {
			fill(used, used + size, false);
		}
	}

	cout << ans << endl;


    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * node;

#define NIL NULL

void insert(int);
void inorder(node );
void preorder(node );
node treeSearch(node , int );

node T;

int main(){
  int n;
  char read[8];
  int k;
  int i;
  int x;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    if(scanf("%s",read)==EOF)break;
    if(read[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(read[0]=='p'){
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
    if ( read[0] == 'f' ){
      scanf("%d", &x);
      node t = treeSearch(T, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void insert(int k){

  node y = NIL;
  node x = T;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;


  
 
  y=NIL;
  x=T;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;

  }
  z->p=y;
  if(y==NIL){
    T=z;
  }
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
	       
}
void preorder(node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

node treeSearch(node u, int k){
  if(u==NIL){
    return u;
  }
  if(u->key==k){
    return u;
  }
  if(u->key>k){
    treeSearch(u->left,k);
  }
  else  treeSearch(u->right,k);
}



Measured memory_bytes: 25140
from collections import defaultdict

d = defaultdict(int)
d=[0]*3
n = int(input())

for i in list(map(int, input().split())):
  if i % 4 == 0:
    d[2] += 1
  elif i % 2 == 0:
    d[1] += 1
  else:
    d[0] += 1
t = d[2] - d[1]
if (d[0] <= d[2]) or ((d[0] == d[2] + 1) and (d[1] == 0)):
  print("Yes")
else:
  print("No")
  

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

int min(int a,int b){
 	if(a<b){
     	return a; 
    }
  	else{
     	return b; 
    }
}

int main() {
	int N;
  	cin>>N;
  	vector<int> P(N);
    int count=0;
  	int minimum=10000000;
  
  	for(int i=0;i<N;i++){
     	 cin>>P.at(i);
    }
  	
  	for(int i=0;i<N;i++){
     	if(P.at(i)<minimum){
         	count++;
          	minimum=P.at(i);
        }
    }
  	
  	
  
  	
  	cout<<count<<endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(100000)

def solve(x, y, char):
    for deltaX in [1, -1]:
        if 0 <= x + deltaX and x + deltaX < w and matrix[y][x + deltaX] == char:
            matrix[y][x + deltaX] = "."
            solve(x+deltaX, y, char)

    for deltaY in [1, -1]:
        if 0 <= y + deltaY and y + deltaY < h and matrix[y + deltaY][x] == char:
            matrix[y+deltaY][x] = "."
            solve(x, y+deltaY, char)


while (True):
    line = sys.stdin.readline().rstrip()
    if line == "" or line == "0 0":
        break

    h, w = (int(i) for i in line.split())

    matrix = []
    count = 0
    for i in range(h):
        matrix.append(list(input().rstrip()))

    for j, row in enumerate(matrix):
        for i, cell in enumerate(row):
            char = matrix[j][i]
            if (char != "."):
                matrix[j][i] = "."
                count += 1
                solve(i, j, char)
    
    print(count)
    


Measured memory_bytes: 16020
#include <stdio.h>
int yagamiraito(int n)
{
    int count = 0;
    while(n%2==0)
    {
        count++;
        n/=2;
    }
    return count;
}
int main (void)
{
    int n;
    int a[300];
    while(scanf("%d",&n)!=EOF)
    {
        int min = 100;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            if(min>yagamiraito(a[i]))
                min = yagamiraito(a[i]);
        }
        printf("%d\n",min);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	string S; cin >> S;

	for (int i = 0; i < S.size(); i++) {
		S[i] = 'x';
	}

	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(abs(b - a) <= d && abs(b - c) <= d || abs(c - a) <= d) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;
	
	string year = s.substr(0, 4);
	string month = s.substr(5, 2);
	string day = s.substr(8, 2);
	
	//cout << "year: " << year << endl;
	//cout << "month: " << month << endl;
	//cout << "day: " << day << endl;
	
	int a = stoi(year);
	int b = stoi(month);
	int c = stoi(day);
	
	//cout << "a: " << a << endl;
	//cout << "b: " << b << endl;
	//cout << "c: " << c << endl; 
	
	if(a < 2020 && b < 5 && c < 31){
		cout << "Heisei" << endl;
	}
	else cout << "TBD" << endl;
	
	
	
	
	
	

						
	return 0;
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const LL mod = 1000000007;

int main()
{
    int N;
    cin >> N;
    VI a(N);
    int l = 100, r = -100;
    REP(i, N) {
        cin >> a[i];
        if (l > a[i]) l = a[i];
        if (r < a[i]) r = a[i];
    }

    int ans = 0;
    REP(i, N) ans += (a[i]-l)*(a[i]-l);
    FOR(i, l+1, r+1) {
        int d = 0;
        REP(j, N) d += (a[j]-i)*(a[j]-i);
        if (ans > d) ans = d;
    }    

    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

int main(){
    int ans=0;
    for(int i=0;i<3;i++){
        int a;
        cin >> a;
        ans+=a;
    }

    if(ans>=22){
        puts("bust");
    }else{
        puts("win");
    }

}

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

int main()
{
  int n;
  cin>>n;
  int a=n%10;
  if(a==2||a==4||a==5||a==7||a==9)
  cout<<"hon";
  if(a==0||a==1||a==6||a==8)
  cout<<"pon";
  if(a==3)
  cout<<"bon";

    return 0;
}

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

int main() {
  long long n;
  cin >> n;
  long long maxd, mind = 10000000000;
  for (int i = 1; i <= n / i; i++) {
    if (n % i == 0) {
      maxd = n / i;
      mind = min (mind, maxd);
    }
  }
  string s = to_string(mind);
  cout << s.size() << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True
ans=math.log(3,3)
an=0
k=0
s=list(input())
n=len(s)
d=[['R','U','D'],['L','U','D']]
for i in range(n):
    if s[i] in d[k]:
        0
    else:
        an=1
    k=1-k
    
print(YN[an])


Measured memory_bytes: 38764
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
int gcd(int a, int b) { while (a) { b %= a; swap(a, b); } return b; }
bool is_swappable(int a, int b) { return gcd(a, b) == 1; }
int main() {
    // input
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    // rearrange
    whole(sort, a);
    vector<int> b;
    vector<bool> used(n);
    function<void (int)> go = [&](int i) {
        used[i] = true;
        b.push_back(a[i]);
        repeat (j,n) if (not used[j] and not is_swappable(a[i], a[j])) {
            go(j);
        }
    };
    repeat (i,n) if (not used[i]) {
        go(i);
    }
    // insertion sort
    repeat (i,n) {
        int j = i;
        for (int k = i-1; k >= 0 and is_swappable(b[k], b[i]); -- k) {
            if (b[k] < b[i]) j = k;
        }
        rotate(b.begin() + j, b.begin() + i, b.begin() + i + 1);
    }
    // output
    for (auto it : b) cout << it << ' '; cout << endl;
    return 0;
}


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

using namespace std;
const int N = 3e5 + 3;
int n, b[N], c[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", b + i);
	vector<int> v;
	for (int i = n; i; --i) {
		if (b[i] != c[i] % 2) {
			++c[i];
			v.push_back(i);
			for (int j = 1; j * j <= i; ++j) {
				if (i % j == 0) {
					++c[j];
					int x = i / j;
					if (j * j != i)
						++c[x];
				}
			}
		}
	}
	printf("%d\n", v.size());
	for (auto a: v)
		printf("%d ", a);
	return 0;
}

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include<bits/stdc++.h>
#include<iomanip>
#define inf  (int)1e18
#define EPS   1e-9
#define mod 1000000007
#define all(k) sort(k.begin(),k.end())
#define Pi 3.14159
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define ll long long
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define vc vector<char>
#define vl vector<ll>
#define mi map<int,int>
#define ml map<ll,ll>
#define umap unordered_map<ll,int>
using namespace std;

ll int togglebit(ll int n)
{
	if (n == 0)
		return 1;


	ll int i = n;

	n |= n >> 1;


	n |= n >> 2;
	n |= n >> 4;
	n |= n >> 8;
	n |= n >> 16;

	return i ^ n;
}

void sol() {
	ll n; cin >> n;

	vpl v;
	ll x, y;
	rep(i, 0, n) {

		cin >> x >> y;
		v.pb(pl(x, y));
	}

	double sum = 0.0;
	rep(i, 0, n - 1 ) {
		rep(j, i + 1, n) {
			sum += sqrt((double)pow((v[i].F - v[j].F), 2) + (double)pow((v[i].S - v[j].S), 2));
		}
	}


	cout << fixed;
	cout << setprecision(10) << sum * 2.0 / n;

}
int main() {


	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i)
		sol();


	return 0;
}



Measured memory_bytes: 3724
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N = I()

ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

   
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21728
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, tmp;
	cin >> nn;
	vector<int64> memo(nn + 1);
	for(int64 ii = 0;ii <= nn;ii++)
	{
		memo[ii] = ii;
	}
	tmp = 1;
	while(tmp <= nn)
	{
		tmp *= 6;
		for(int64 jj = 0;jj <= nn;jj++)
		{
			if(jj + tmp <= nn)
			{
				if(memo[jj + tmp] > memo[jj] + 1)
				{
					memo[jj + tmp] = memo[jj] + 1;
				}
			}
		}
	}
	tmp = 1;
	while(tmp <= nn)
	{
		tmp *= 9;
		for(int64 jj = 0;jj <= nn;jj++)
		{
			if(jj + tmp <= nn)
			{
				if(memo[jj + tmp] > memo[jj] + 1)
				{
					memo[jj + tmp] = memo[jj] + 1;
				}
			}
		}
	}
	cout << memo[nn] << endl;
	return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 1010
using namespace std;

int m,n,k,J[MAX][MAX],O[MAX][MAX],I[MAX][MAX];
string s[MAX];

void solve(){
 cin>>n>>m;
 cin>>k;
 ZERO(J); ZERO(O); ZERO(I);
 FOR(i,n) cin>>s[i];
 FOR(i,n){
  FOR(j,m){
   int jj=0,oo=0,ii=0;
   if(s[i][j]=='J') jj=1;
   else if(s[i][j]=='O') oo=1;
   else ii=1;
   J[i+1][j+1]=jj+J[i][j+1]+J[i+1][j]-J[i][j];
   O[i+1][j+1]=oo+O[i][j+1]+O[i+1][j]-O[i][j];
   I[i+1][j+1]=ii+I[i][j+1]+I[i+1][j]-I[i][j];
  }
 }
 int a,b,c,d;
 FOR(i,k){
  cin>>a>>b>>c>>d;
  a--; b--;
  int jj=J[c][d]-J[c][b]-J[a][d]+J[a][b];
  int oo=O[c][d]-O[c][b]-O[a][d]+O[a][b];
  int ii=I[c][d]-I[c][b]-I[a][d]+I[a][b];
  cout<<jj<<" "<<oo<<" "<<ii<<endl;
 }
}

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

Measured memory_bytes: 16016
N = gets.to_i
 
ans = Float::INFINITY
 
def digit_sum(n)
  n.to_s.chars.map(&:to_i).inject(:+)
end
 
(1...N).each do |a|
  b = N - a
  c = digit_sum(a) + digit_sum(b)
 
  ans = c if ans > c
end
 
puts ans

Measured memory_bytes: 1916
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    li = list(input().rstrip())

    r = []
    g = []
    b = []

    for i in range(n):
        if li[i] == 'R':
            r.append(i)
        elif li[i] == 'G':
            g.append(i)
        elif li[i] == 'B':
            b.append(i)

    if (len(r) < 1 or len(g) < 1) or len(b) < 1:
        print(0)
    else:
        all_c = len(r) * len(g) * len(b)

        for i in range(n):
            for j in range(i+1,n):
                k = 2*j-i
                if k >= n:
                    continue

                if (li[i] != li[j] and li[j] != li[k]) and li[i] != li[k]:
                    all_c -= 1

        print(all_c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9348
//----------------------------------------------------------------
//K

#include <iostream>
#include <vector>
using namespace std;

// DP テーブル (配列全体が false に自然に初期化される)
bool dp[110000]; // 局面数は最大 100001 だが少し余裕もたせる

int main() {
    // 入力受け取り
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // DP
    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }

    // 答え
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}



Measured memory_bytes: 3700
#include <stdio.h>


int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H')
    {
        if(b=='H')                  //hh
            printf("H\n");
        else
            printf("D\n");      //important    hd
    }
    else
    {
        if(b=='D')                // dd
            printf("H\n");
        else
            printf("D\n");           //dh
    }

    return 0;
}


Measured memory_bytes: 128
from math import gcd

k = int(input())

total = 0
for i in range(1,k+1):
    for j in range(i+1,k+1):
        tmp = gcd(i,j)
        total += tmp * 6
        for m in range(j+1,k+1):
            total += gcd(tmp,m) * 6
total += k*(k+1)//2

print(total)


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define  ll long long int 
#define pb push_back 

#define lim  1000000007 
ll hrr[21][21]  ;

    ll n ;
bool visi[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][21];
ll    grr[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][21] ;
ll solve(ll arr[] )
{
    if(visi[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]])
    {
        return grr[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]] ;
    }
    ll  m = 0 ; 
    
    if(arr[21] == n-1)
    {
        ll mn =0 ;
    for( ll i =0 ; i < 21 ; i++)
    {
        if(arr[i]==1 && hrr[i][arr[21]] ==1  )
        {
            mn+=1 ;
            break ;
        }
        mn = (mn)%lim ;
    }
    visi[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]] = true ;
    grr[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]] =mn%lim ;
    return  mn%lim;
        
    }
    for( ll i =0 ; i < 21 ; i++)
    {
        if(arr[i]==1 && hrr[i][arr[21]] ==1)
        {
            arr[i] = 0 ;
            arr[21] = arr[21] +1 ;
            m= ((m%lim )+ ((solve(arr))%lim))%lim ;
            arr[i]=1 ;
            arr[21] = arr[21] -1 ;
            
        }
    }
    visi[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]] =true ;
   
    grr[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]][arr[16]][arr[17]][arr[18]][arr[19]][arr[20]][arr[21]] = m ;
    return m ;
    
    
}
int main()
{   ll arr[22]={0} ;
    cin >> n ;
    for(ll i =0 ; i < n ;i++)
    {
        arr[i] = 1 ;
        for( ll j =0 ;j < n ; j++ )
        {
            cin>>hrr[i][j] ;
        }
    }
    
    
   
    cout << solve(arr) ;
    return 0 ;
    
}

Measured memory_bytes: 387328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;


int main()
{
  ll N,ans=0,temp=0,same=0;
  cin >> N;
  vector<ll> A(N), sum(N);
  rep(i,N)
  {
    cin >> A[i];
  }

  sum[0] = A[0];
  for (int i = 1; i < N; i++)
  {
    sum[i] = sum[i - 1] + A[i];
  }

  sort(all(sum));

  rep(i,N)
  {
    if (sum[i]==0)
    {
      ans++;
    }
    if(sum[i]>0)
      {
        break;
      }
  }



  for (int i = 0; i < N-1; i++)
  {
      if (sum[i] == sum[i+1])
        {
          temp++;
        }
      if(sum[i]!=sum[i+1]||(i==(N-2)))
        {
          ans += (temp + 1) * temp / 2;
          temp = 0;
        }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6344
n, k = map(int, input().split())

pos = [int(x) for x in input().split()]

ans = abs(pos[0])+abs(pos[0]-pos[k-1])

for i in range(n-k+1):
    val = 0
    val += abs(pos[i] - pos[i+k-1])
    val += min(abs(pos[i]), abs(pos[i+k-1]))

    if val < ans:
        ans = val
print(ans)


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

int main() {
  string s;
  cin >> s;
  vector<bool> app(26);
  for(int i=0;i<26;++i){
    app[i]=false;
  }
  for(int i=0;s[i]!='\0';++i){
    app[s[i]-'a']=true;
  }
  for(int i=0;i<26;++i){
    if(!app[i]){
      cout << char(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
n = int(input())
v = list(map(int,input().split()))

c = n*(n-1)/2
ans = []

for i in range(n-1):
	v.sort()
	m1 = v.pop(0)
	m2 = v.pop(0)
	m = (m1+m2)/2
	v.append(m)

print(v[0])


Measured memory_bytes: 2940
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
    d[i+1] += 1
    d[i-1] += 1
d = list(d.values())
print(max(d))
"""

#D
n = I()
a = LI()
b = [a[i] for i in range(n)]
k = 0
l = 0
for i in range(n-1):
    if a[i] == i+1:
        x = a[i]
        a[i] = a[i+1]
        a[i+1] = x
        k += 1
if a[n-1] == n:k += 1
for i in range(1,n)[::-1]:
    if b[i] == i+1:
        x = b[i]
        b[i] = b[i-1]
        b[i-1] = x
        l += 1
if b[0] == 1:l += 1
print(min(k,l))
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 57304
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M;
vector<ll> fav;

int main() {
	cin >> N >> M;
	fav.resize(M);
	for (ll m = 0; m < N; m++) {
		ll K;
		cin >> K;
		for (ll k = 0; k < K; k++) {
			ll a;
			cin >> a;
			fav[--a]++;
		}
	}
	ll count = 0;
	for (ll n = 0; n < M; n++) {
		if (fav[n] == N)count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,k,s; cin >> n >> k >> s;
  if(s < 1e9){
    rep(i,k) cout << s << " ";
    rep(i,n-k) cout << s+1 << " ";
  }else{
    rep(i,k) cout << s << " ";
    rep(i,n-k) cout << 1 << " ";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
typedef pair<int,int> P;
int n,m,p[N];

multiset<ll> r[N];
multiset<ll>::iterator ir;
void Merge(int x,int y){
    r[y].erase(r[y].begin());
    ir=r[x].begin();ir++;
    while(ir!=r[x].end()){
	r[y].insert(*ir);
	++ir;
    }
}

ll ans=0;
bool Units(int x,int y){
    int a=x,b=y;
    while(p[a]!=a)a=p[a];
    while(p[b]!=b)b=p[b];
    if(r[a].size()>r[b].size())swap(a,b);
    p[a]=b;
    while(x!=b){int t=x;x=p[x],p[t]=b;}
    while(y!=b){int t=y;y=p[y],p[t]=b;}
    
    if(r[a].size()==0||r[b].size()==0)return false;
    ans+=*r[a].begin()+*r[b].begin();
    Merge(a,b);
    return true;
}

bool Solve(){
    priority_queue<P>Q;
    lol(i,n){
	int x=i;
	while(x!=p[x])x=p[x];
	p[i]=x;
	if(i==x){
	    Q.push(make_pair(r[i].size(),i));
	}
    }
    int bef=Q.top().second;Q.pop();
    while(!Q.empty()){
	int now=Q.top().second;Q.pop();
	if(Units(now,bef)==false)return false;
    }
    return true;
}

unordered_multiset<ll> s[N];
unordered_multiset<ll>::iterator it;
void MergeSet(int x,int y){
    it=s[x].begin();
    while(it!=s[x].end()){
	s[y].insert(*it);
	++it;
    }
    s[x].clear();
}

void Unite(int x,int y){
    int a=x,b=y;
    while(p[a]!=a)a=p[a];
    while(p[b]!=b)b=p[b];
    if(s[a].size()>s[b].size())swap(a,b);
    p[a]=b;
    while(x!=b){int t=x;x=p[x],p[t]=b;}
    while(y!=b){int t=y;y=p[y],p[t]=b;}
    
    MergeSet(a,b);
}

int main(){
    cin>>n>>m;
    lol(i,n){
	p[i]=i;
	ll a;cin>>a;
	s[i].insert(a);
    }
    lol(i,m){
	int x,y;cin>>x>>y;
	Unite(x,y);
    }
    lol(i,n){
	it=s[i].begin();
	while(it!=s[i].end()){
	    r[i].insert(*it);
	    ++it;
	}
    }

    if(Solve())cout<<ans<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}


Measured memory_bytes: 25212
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > Pi;
vector < int > order;
vector < int > G[10005];
vector < int > NG[10005];
vector < int > rev[10005];
vector < int > Nrev[10005];
bool flag[10005] = {};
int cmp[10005];
int N, M;
void dfs(int v)
{
    if(flag[v]) return;
    flag[v] = true;
    for(int i = 0; i < G[v].size(); i++) dfs(G[v][i]);
    order.push_back(v);
    return;
}
void rdfs(int v, int c)
{
    if(~cmp[v]) return;
    cmp[v] = c;
    for(int i = 0; i < rev[v].size(); i++) rdfs(rev[v][i], c);
    return;
}
int main()
{
    int NN = 0;
    int S[100005], T[100005];
    memset(cmp, -1, sizeof(cmp));
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> S[i] >> T[i];
        G[S[i]].push_back(T[i]);
        rev[T[i]].push_back(S[i]);
    }
    for(int i = 0; i < N; i++) dfs(i);
    reverse(order.begin(), order.end());
    for(int i = 0; i < N; i++) {
        if(cmp[order[i]] == -1) {
            rdfs(order[i], NN);
            NN++;
        }
    }
    set < Pi > st;
    for(int i = 0; i < M; i++) {
        int a = cmp[S[i]], b = cmp[T[i]];
        if(a != b && st.find(Pi(a, b)) == st.end()) {
            st.insert(Pi(a, b));
            NG[a].push_back(b);
            Nrev[b].push_back(a);
        }
    }
    int acnt = 0, bcnt = 0;
    for(int i = 0; i < NN; i++) {
        if(NG[i].size() == 0) acnt++;
        if(Nrev[i].size() == 0) bcnt++;
    }
    if(NN == 1) cout << 0 << endl;
    else cout << max(acnt, bcnt) << endl;

    return (0);
}

Measured memory_bytes: 12304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String station = sc.next();
        char[] s = new char[3];
        String word = "No";

        for (int i = 0; i < 3; i++) {
            s[i] = station.charAt(i);
            if (i !=0 && s[i - 1] != s[i])
                word = "Yes";
        }

        System.out.println(word);


    }
}


Measured memory_bytes: 21716
#include <stdio.h>
int main(void){
    int D,N;
    scanf("%d %d",&D,&N);
    if(D==0){
        if(N==100)printf("101");
        else printf("%d",N);
    }
    if(D==1){
        if(N==100)printf("10100");
        else printf("%d00",N);
    }
    if(D==2){
        if(N==100)printf("1010000");
        else printf("%d0000",N);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::string s;
	std::cin >> s;
	std::cout << s;
	std::cout << (s.back() == 's' ? "es" : "s") << std::endl;
	return 0;
}

Measured memory_bytes: 3656
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut s: Vec<Option<i64>> = (0..1<<n).map(|_| Some(sc.cin())).collect();
    s.sort();
    s.reverse();
    let mut t = vec![];
    {
        t.push(s[0].unwrap());
        s[0] = None;
    }
    for _ in 0..n {
        t.sort(); t.reverse();
        let mut dt = vec![];
        let mut i = 0;
        for &x in t.iter() {
            while i < s.len() {
                if let Some(y) = s[i] {
                    if x > y {
                        dt.push(y);
                        s[i] = None;
                        break;
                    }
                }
                i += 1;
            }
        }
        if dt.len() != t.len() {
            put!("No");
            return;
        }
        for &y in dt.iter() {
            t.push(y);
        }
        s = s.iter().filter(|&item| item.is_some()).map(|&item| item).collect();
        // trace!(&t, &s);
    }
    put!("Yes");
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 24764
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/


int main() {
	string a;
	cin >> a;
	a[5] = ' ';
	a[13] = ' ';
	cout << a << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
ll int gcd (ll int a,ll int b) { return b ? gcd (b, a % b) : a; }

int main()
{
	int n;
	cin>>n;
	std::vector<int> v(n+1);
	v[0]=0;
	for (int i = 1; i <= n; ++i)
	{
		cin>>v[i];
	}
	int dp[n+1];
	dp[1]=0;dp[2]=abs(v[2]-v[1]);
	for(int i=3;i<=n;i++)
	{
		//cout<<i<<" "<<v[i]-v[i-1]<<" "<<v[i]-v[i-2]<<"\n";
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
		//cout<<dp[i]<<" --\n";
	}
	cout<<dp[n]<<"\n";

}


Measured memory_bytes: 4020
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
a = reads()
a.append(-1)

ans = 0

prev = -1
cont = 1
for i in range(N+1):
  if prev == a[i]:
    cont += 1
  else:
    prev = a[i]
    ans += cont // 2
    cont = 1
print(ans)


Measured memory_bytes: 38384
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] ABCK = Console.ReadLine().Split(' ');
            int A = int.Parse(ABCK[0]);
            int B = int.Parse(ABCK[1]);
            int C = int.Parse(ABCK[2]);
            int K = int.Parse(ABCK[3]);
            int answer = 0;

            int tmp = A - K;
            if(tmp < 0){
                K -= A;
                answer += A;
                tmp = B - K;
                if(tmp < 0){
                    K -= B;
                    answer -= K;
                }
                else {}
            }
            else answer += K;
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27564