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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL k;
  cin >> k;
  if(k==0){
    cout << 2 << endl;
    cout << "1 1" << endl;
    return 0;
  }
  if(k==1){
    cout << 3 << endl;
    cout << "1 0 3" << endl;
    return 0;
  }
  if(k<=50){
    cout << k << endl;
    cout << k;
    for(int i=1;i<k;i++){
      cout << " " << k;
    }
    cout << endl;
    return 0;
  }
  cout << 50 << endl;
  if(k%50){
    for(int i=0;i<49;i++){
      if(i<k%50)  cout << 50+(k/50)  << " ";
      else  cout << (50-1)+(k/50)-k%50  << " ";
    }
    cout << 50+k/50-1-k%50  << endl;
  }else{
    for(int i=0;i<49;i++){
      cout << (50-1)+(k/50)  << " ";
    }
    cout << 50+k/50-1  << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

vvi m(8, vi(8, 0));
vvi mm(8, vi(8, 0));
vi dr = {1, 1, 1, 0, 0, -1, -1, -1};
vi dc = {-1, 0, 1, 1, -1, -1, 0, 1};

bool is_OK(int r, int c){
  if(m.at(r).at(c) != 0) return false;

  bool flag = true;
  for(int i = 0; i < 8; i++){
    for(int j = 1; j <= 7; j++){
      int cc = c + j*dc.at(i);
      int rr = r + j*dr.at(i);
      if(cc < 0 || cc >= 8 || rr < 0 || rr >= 8) continue;
      if(m.at(rr).at(cc) == 2){
        flag = false;
        break;
      }
    }
  }
  return flag;
}

void putQ(int r, int c){
  m.at(r).at(c) = 2;
  for(int i = 0; i < 8; i++){
    for(int j = 1; j <= 7; j++){
      int cc = c + j*dc.at(i);
      int rr = r + j*dr.at(i);
      if(cc < 0 || cc >= 8 || rr < 0 || rr >= 8) continue;
      m.at(rr).at(cc) = 1;
    }
  }
}

int main(){
  int k;
  cin >> k;
  vector<P> queen(0);
  vector<bool> usedr(8, false), usedc(8, false);
  for(int i = 0; i < k; i++){
    int r, c;
    cin >> r >> c;
    queen.push_back(P(r,c));
    putQ(r, c);
    usedr.at(r) = true;
    usedc.at(c) = true;
  }
  mm = m;

  vi allr(0), allc(0);
  for(int i = 0; i < 8; i++){
    if(!usedr.at(i)) allr.push_back(i);
    if(!usedc.at(i)) allc.push_back(i);
  }

  
  do{
    m = mm;
    bool flag = true;
    for(int i = 0; i < 8-k; i++){
        if(is_OK(allr.at(i), allc.at(i))){
          putQ(allr.at(i), allc.at(i));
        }
        else{
          flag = false;
          break;
        }
      if(!flag) break;
    }
    if(flag) break;
  }while(next_permutation(ALL(allc)));

  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      if(m.at(i).at(j) == 2) cout << 'Q';
      else cout << '.';
      if(j == 7) cout << endl;
    }
  }
}


Measured memory_bytes: 3180
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
INF  = float("inf") # 正の無限大

N = int(input())						# 5
X =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=INF

for b in range(102):
	a=0
	for x in X:
		a+=(x-b)**2
		
		#p("x,b,x-b,a ",x,b,x-b,a)
		
	ans=min(ans,a)
	#p(ans,a,b)

print(ans)
	

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	count := 0
	for i := 0; i < m; i++ {
		A := nextInt()
		count += A
	}
	if n-count < 0 {
		fmt.Print("-1")
	} else {
		fmt.Print(n - count)
	}
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        int h, m, s;
        h = S / 3600;
        m = (S % 3600) / 60;
        s = S % 60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26388
import Data.Array.IO
import Data.IORef
import Control.Monad

main :: IO ()
main = do
  [h, w] <- (map read . words) <$> getLine
  table <- newListArray (0, h - 1) [] :: IO (IOArray Int (IOArray Int Char))
  forM_ [0..h - 1] $ \i -> do
    row <- newListArray (0, w - 1) =<< getLine :: IO (IOArray Int Char)
    writeArray table i row

  let check (i, j) = 0 <= i && i <= h - 1 && 0 <= j && j <= w - 1
  let incr cnt = modifyIORef cnt (+ 1)

  forM_ [0..h - 1] $ \i -> do
    row <- readArray table i
    forM_ [0..w - 1] $ \j -> do
      cell <- readArray row j
      when (cell == '.') $ do
        count <- newIORef 0
        let dirs = [
                    (i - 1, j - 1), (i - 1, j), (i - 1, j + 1),
                    (i,     j - 1),             (i,     j + 1),
                    (i + 1, j - 1), (i + 1, j), (i + 1, j + 1)
                   ]
        forM_ dirs $ \d ->
          when (check d) $ do
            c <- get table d
            when (c == '#') $ incr count

        num <- readIORef count
        writeArray row j $ (head . show) num

  rows <- getElems table
  result <- mapM getElems rows

  forM_ result putStrLn


get arr (i, j) = do
  row <- readArray arr i
  readArray row j


Measured memory_bytes: 1020
import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long arr[]=new long[(int)n+1];
        for(int i=1;i<n+1;i++)
        {
            for (int j = i; j < n+1; j=j+i)
            {
                arr[j]=arr[j]+1;
            }
        }

        long ans=0;
        for(int i=1;i<n+1;i++)
        {
            ans=ans+i*arr[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 116192
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
ll dp[100009];
ll arr[100009] = {0};
int n = 0;

ll solve(int i)
{
    if(i == n-1)
        return 0;

    if(dp[i] != -1)
        return dp[i];

    ll op1,op2;
    op1 = abs(arr[i] - arr[i+1]) + solve(i+1);
    op2 = INT_MAX;
    if(i+2<n)
       op2 = abs(arr[i] - arr[i+2]) + solve(i+2);

       return dp[i] = min(op1,op2);
}



int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
        memset(dp,-1,sizeof(dp));
        cout<<"\n"<<solve(0);
        return 0;
}


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

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int d = in.nextInt();
		int t = in.nextInt();
		int s = in.nextInt();
		
		if(s * t < d) System.out.println("No");
		else System.out.println("Yes");
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}





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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<ll> x;
    ll l;
    ll N, X;
    cin >> N >> X;
    x.resize(N);
    for(ll i = 0;i < N;i++) cin >> x[i];
    x.push_back(X);
    sort(x.begin(), x.end());
    l = x[1] - x[0];
    for(ll i = 2;i < N + 1;i++) l = __gcd(l, x[i] - x[i - 1]);
    cout << l << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    map<char, long> table;
    map<char, long>::iterator it;
    vector<long> v;
    string s;
    long ans = 1;

    cin >> s;

    long i, j, len = s.size();

    for (i = 0; i < len; i++) table[s[i]]++;

    for (it = table.begin(); it != table.end(); it++) v.push_back(it->second);

    if (v.size() != 1) {
        len = v.size();
        for (i = 0; i < len; i++) {
            for (j = i + 1; j < len; j++) {
                ans += v[i] * v[j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
bool know[100][100];
int main() {
    int N;
    while(scanf("%d",&N),N) {
        memset(know,0,sizeof(know));
        for(int i=0;i<N;i++) {
            int M;
            scanf("%d",&M);
            for(int j=0;j<M;j++) {
                int p;
                scanf("%d",&p);p--;
                know[i][p]=1;
            }
        }
        int K;
        scanf("%d",&K);
        vector<int> v;
        for(int i=0;i<K;i++) {
            int l;
            scanf("%d",&l);l--;
            v.push_back(l);
        }
        vector<int> m;
        for(int i=0;i<N;i++) {
            bool OK=1;
            for(int j=0;j<v.size();j++) {
                if(!know[i][v[j]]) {OK=0;break;}
            }
            if(OK) m.push_back(i);
        }
        if(m.size()==1) {
            printf("%d\n",m[0]+1);
        }else {
            printf("-1\n");
        }
    }
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
ll ceildiv(ll x, ll y) {
    return (x + y - 1) / y;
}
void solve(long long N, long long D, long long A, std::vector<long long> X, std::vector<long long> H) {
    vector<int> I(N);
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](int i, int j) { return X[i] < X[j]; });
    vector<pair<int, ll>> bombs;
    ll sum_bombs = 0;
    int L = 0, R = 0;
    for(int i : I) {
        while(L < bombs.size() and X[i] - bombs[L].first > D) {
            sum_bombs -= bombs[L].second;
            L++;
        }
        while(R < bombs.size() and bombs[R].first - X[i] <= D) {
            sum_bombs += bombs[R].second;
            R++;
        }
        if(sum_bombs * A < H[i]) {
            bombs.push_back({X[i] + D, ceildiv(H[i] - sum_bombs * A, A)});
        }
        
    }
    ll ans = 0;
    for(auto& p : bombs) {
        ans += p.second;
    }
    cout << ans << endl;
}
int main() {
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> X(N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&H[i]);
    }
    solve(N, D, A, std::move(X), std::move(H));
    return 0;
}


Measured memory_bytes: 8944
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef node* Node;
#define NIL NULL

node array[500000];
int size=0;

Node root = NIL;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}
 
Node treeSearch(Node u, int k){
  Node i=u;
  while(i!=NIL){
    if(i->key==k)return i;
    else if(i->key<k)i=i->right;
    else i=i->left;     
  }
  return NIL;
}
 
Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
   
  if(y->left!=NIL)x=y->left;
  else x=y->right;
 
  if(x!=NIL)x->parent=y->parent;
   
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;
 
  if(y!=z)z->key=y->key;
   
  //free(y);
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = &array[size++];
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=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);
}


int main(){
  int n,x;
  char str[20];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s", str);
    if(str[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if (t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(str[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(str[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }

  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

//AtCoder解説動画(https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be)からもらった
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {} //このコロンってなんですか
	int find(int x){
		if (d[x] < 0) return x; //x:根
		return d[x] = find(d[x]);//x:子 -> xの親の根を返す
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//根同士をくっつける。
		if ( x ==  y) return false ; 
		/*連結成分が一致してるんだったらfalse返す。
			minimum spanning tree (クラスカル法と言うのをやるときに、くっつけたかどうかを取れると嬉しい.
			chmin/chmaxみたいなノリかな
		 */
		if ( d[x] > d[y]) swap(x,y);//xの方が大きいようにする（ただしサイズは負デモっているので不等号が逆）
		d[x] += d[y] ; //xにyをくっつける.
		d[y] = x;
		return true; 
	}
	bool same(int x, int y) { return find(x) == find(y) ; }
	int size(int x) { return -d[find(x)];}
};
int main()
{
	int n, m;
	cin >> n >> m;
	// UnionFindの島の数が答え
	UnionFind uf(n);
	rep(i,m){
			int x, y, z;
			cin >> x >> y >> z;
			x--, y--;
		uf.unite(x,y);
	}
	ll cost = 0;
	map<int,int> mp;
	rep(i,n){
		if(mp[uf.find(i)]); //;
		else {
			mp[uf.find(i)] = true;
			cost ++;
		}
	}
	cout << cost << endl;
}


Measured memory_bytes: 5376
use proconio::{input, fastout};
// use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut hp: [(i32, i32, i32); n],
    }

    hp.insert(0, (0, 0, 0));
    let mut dp = vec![[0;3]; n+1];

    for day in 1..=n {
        dp[day][0] = dp[day-1][1].max(dp[day-1][2]) + hp[day].0;
        dp[day][1] = dp[day-1][0].max(dp[day-1][2]) + hp[day].1;
        dp[day][2] = dp[day-1][0].max(dp[day-1][1]) + hp[day].2;
        // for act in 0..3 {
        //     let oa = (0..3).filter(|&n| n != act).collect::<Vec<usize>>();
        //     dp[day][act] = max(dp[day-1][oa[0]], dp[day-1][oa[1]]) + hp[day][act];
        // }
    }

    println!("{:?}", dp[n].iter().max().unwrap());
}


Measured memory_bytes: 6124
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int result = 0;
		Arrays.sort(a);
		for (int i = 0; i < N && x > 0; i++) {
			x -= a[i];
          	if (x < 0) {
				break;
			}
			result++;
		}
		if (x > 0) {
			result--;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

int n;

i64 a[100010];

int main()
{
	cin >> n;
	rep(i,1,n) cin >> a[i];
	int result = 0;
	rep(i,1,n - 1)
		if(a[i] == i)
		{
			result++;
			swap(a[i],a[i + 1]);
		}
  if(a[n] == n) result++;
	cout << result << endl;
}



Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   string s;
   cin >> s;
   int a = s.size();
   REP(i, a){
       s[i]='x';
   }
   cout << s << endl;
   }

    



Measured memory_bytes: 256
/*
 * 1st.cpp
 *
 *  Created on: Sep 6, 2017
 *      Author: Nirav
 */


#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
     int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    int swap1=0;
   
    for(int i=1;i<n;i++)
    { 
        if(a[i]==i)
        {
            swap(a[i],a[i+1]);
            i++;
            swap1++;
        }
        
      }
    if(a[n]==n)
    {
        swap(a[n-1],a[n]);
        swap1++;
    }
    cout<<swap1;
                    
	return 0;
}

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}









Measured memory_bytes: 640
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n, m;
    cin>>n>>m;
    ll f = 1, s = n;
    bool ok = false;
    if(n&1){
        ll cur = 0;
        while(m--){
            cout<<f<<" "<<s<<"\n";
            ++f, --s;
        }
    }
    else{
        while(m--){
            cout<<f<<" "<<s<<"\n";
            ++f, --s;
            if(s-f <= n/2&& !ok)
                --s, ok = true;
        }
    }
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>


#define fs first
#define sc second

using namespace std;

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

int a[101000];

#define MAX_N 250002

ll bit[MAX_N+1];

void init(int n){
    for(int i = 0; i < n; i++){
        bit[i] = 0;
    }
}

// indexが0~iまでの和を求める。
ll sum(int i){
    i++;
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & (-i);
    }
    return s;
}

// iがindex, xが加える値, nが全体の配列の大きさ
void add(int i, ll x, int n){
    i++;
    while(i <= n){
        bit[i] += x;
        i += i & (-i);
    }
}

int b[100100];
map<int, int> m;

int main(){
    ll N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+N);
    m[b[0]] = 0;
    int ind = 1;
    for(int i = 1; i < N; i++){
        if(b[i] == b[i-1]){
            continue;
        }
        else{
            m[b[i]] = ind;
            ind++;
        }
    }

    ll l = 0, r = N;
    while(r - l > 1){
        int mid = (l + r) / 2;
        int x = b[mid];
        int s[100100];
        fill(s, s+N, 0);
        for(int i = 0; i < N; i++){
            if(a[i] >= x){
                s[i+1] = 1;
            }
            else{
                s[i+1] = -1;
            }
        }
        for(int i = 1; i <= N; i++){
            s[i] += s[i-1];
        }
        ll res = 0;
        init(2*N+10);
        for(int i = 0; i <= N; i++){
            res += sum(s[i]+N);
            add(s[i]+N, 1, 2*N);
        }
        if(res >= (N*(N+1)/2+1)/2){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    cout << b[l] << endl;


    return 0;

}


Measured memory_bytes: 7680
N,K = map(int,input().split())
S = list(input())
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
S = ''.join(S)
print(S)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main(){
	string str;
	cin >> str;
	int n = str.length();
	bool ch = true;
	int cnt = 0,cnt2=0;
	for(auto &i : str){
		if(i == '0'){++cnt;}
	}
	for(auto &i : str){
		if(i == '1'){++cnt2;}
	}
	int ans = cnt < cnt2 ? cnt:cnt2;
	cout << (ans * 2) << endl;
}

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

typedef std::complex <double> C;
const int N = 3054;

int n, L;

int main() {
	int i, arg; double unit; C c, s1(0, 0), s2(0, 0), ret;
	scanf("%d%d", &n, &L), unit = M_PI / L;
	for (i = 1; i <= n; ++i)
		scanf("%d", &arg), c = std::polar(1., unit * arg),
		ret += (double(n - 2 * i) * s1 + 2. * s2) * c, s1 += c, s2 += (double)i * c;
	ret /= n * (n - 1ll) * (n - 2ll) / 6;
	printf("%.12lg %.12lg\n", ret.real(), ret.imag());	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using pr = pair<int, int>;

int N, A[55];

int main() {
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d", A+i);
    if(is_sorted(A+1, A+N+1)) return puts("YES"),0;
    for(int i=1; i<=N; i++) for(int j=i+1; j<=N; j++) {
        swap(A[i], A[j]);
        if(is_sorted(A+1, A+N+1)) return puts("YES"),0;
        swap(A[i], A[j]);
    }
    puts("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,gd[100010],h[100010],ans=0;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&h[i]),gd[i]=1;
	for(int i=1,x,y;i<=m;++i) {
		scanf("%d%d",&x,&y);
		if(h[x]<=h[y]) gd[x]=0;
		if(h[y]<=h[x]) gd[y]=0;
	}
	for(int i=1;i<=n;++i)
		if(gd[i]==1)
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4600
def search_atcg(data):
    atcg = ['A', 'T', 'C', 'G']
    co = 0
    max_co = 0
    for s in data:
        if s in atcg:
            co += 1
            if co > max_co:
                max_co = co
        else:
            co = 0
    return max_co


if __name__ == "__main__":
    data = input()
    print(search_atcg(data))


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

const int mod = 1000000007;
signed main(void)
{
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	long long ans;
	vector<int> c(n + 1);

	ans = 1;
	c[0] = 3;
	rep(i, n)
	{
		ans *= c[a[i]];
		ans %= mod;
		c[a[i]]--;
		c[a[i] + 1]++;
	}
	cout << ans << endl;
	return 0;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, m, bit;

inline void printEdge(int u, int v) {//输出无向边 u -> v
	write(u);
	putchar(' ');
	write(v);
	putchar('\n');
}

int main() {
	read(n);
	for (int i = 0; (1 << i) <= n; ++i)
		if (n == (1 << i)) {
			puts("No");
			return 0;
		}
	puts("Yes");
	for (int i = 2; i + 1 <= n; i += 2) {
		printEdge(1, i), printEdge(i, i + 1);
		printEdge(1, i + n + 1), printEdge(i + n + 1, i + n);
		//对于每组 { x, x ^ 1 } 连边 
	}
	printEdge(3, n + 1);//把 n + 1 接在 3 的下面 
	if (!(n & 1)) {// n 是偶数 
		for (int i = 0; (1 << i) <= n; ++i)
			if (n & (1 << i)) bit = i;
		printEdge(((1 << bit) ^ 1) + n, n << 1), printEdge(n ^ (1 << bit), n);
	}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>

using namespace std;

int n;
vector<int> a;


int ans = 0;



void func(int tmp){
    if(a[tmp] == 2){
        cout<<ans + 1;
        return ;
    } else if(ans>n){
        cout<< -1;
        return;
    }
    else{
        ans++;
        func(a[tmp]-1 );
    }
}

int main(){

cin >>n;
a.resize(n);
for(int i=0; i<n; i++){
    cin >> a[i];
}
    func(0);
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;
int main() {
	long long L, R;
	scanf("%d", &L);
	scanf("%d", &R);
	int min = 2018;
	int ans = 1;
	long long i = L;
	long long j = i + 1;
	for (;j <= R; j++) {
		for (i = L;i < j; i++) {
			ans = (i * j) % 2019;
			if (ans == 0) {
				printf("%d\n", ans);
				return 0;
			}
			if (min > ans) {
				min = ans;
			}
		}
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

int main()
{
    ll n, a[5], a_min = 1000000000000000000;
    cin >> n;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
        if (a_min > a[i])
        {
            a_min = a[i];
        }
    }
    ll result = ll(ceil(double(n) / a_min)) + 4;
    cout << result;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
ll n,num,q,x,y,ans;
map<ll,ll> mp;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		num=read();
		++mp[num];
		ans+=num;
	}
	q=read();
	while(q--){
		x=read(),y=read();
		ans+=(y-x)*mp[x];
		mp[y]+=mp[x];
		mp[x]=0;
		printf("%lld\n",ans);	
	}
	return 0;
}

Measured memory_bytes: 9484
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m,vis[100001],u,s;
deque<int>a;
vector<int>link[100001];
int main(void){
	register int i,x,y;
	n=read(),m=read();
	for(i=1;i<=m;++i)
		x=read(),y=read(),link[x].push_back(y),link[y].push_back(x);
	a.push_front(1),vis[1]=1;
	if(link[1].size()==0){
		puts("1"),
		puts("1");
		return 0;
	}
	a.push_back(link[1][0]),vis[link[1][0]]=1;
	while(1){
		u=a.front(),s=1;
		for(i=0;i<link[u].size();++i)
			if(!vis[link[u][i]]){
				vis[link[u][i]]=1,s=0;
				a.push_front(link[u][i]);
				break;
			}
		if(s==1)break;
	}
	while(1){
		u=a.back(),s=1;
		for(i=0;i<link[u].size();++i)
			if(!vis[link[u][i]]){
				vis[link[u][i]]=1,s=0;
				a.push_back(link[u][i]);
				break;
			}
		if(s==1)break;
	}
	printf("%d\n",a.size());
	while(!a.empty())
		printf("%d ",a.front()),a.pop_front();
	return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
bool del[500010],u[500010];
LL ans,fac[100010],inv[100010],f[610][310][310];
int n,t,tmp[500010],a[500010],ts,M[500010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
	fac[0]=1;
	FOR(i,1,100000) fac[i]=fac[i-1]*i%MO;
	inv[100000]=pw(fac[100000],MO-2);
	FORD(i,99999,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>n;
	FOR(i,1,n*2) getint(a[i]);
	FOR(i,1,n) if (a[i*2]!=-1 && a[i*2-1]!=-1){
		del[a[i*2]]=1;
		del[a[i*2-1]]=1;
	}
	FOR(i,1,n*2) if (!del[i]){
		t=0;
		FOR(j,1,i) if (!del[j]) ++t;
		M[i]=t;
	}
	if (t==0) return puts("1"),0;
	FOR(i,1,n)
		if ((a[i*2]==-1)^(a[i*2-1]==-1))
			tmp[++ts]=(a[i*2]==-1?0:M[a[i*2]])+(a[i*2-1]==-1?0:M[a[i*2-1]]);
	FOR(i,1,ts) u[tmp[i]]=1;
	//f[i][j][k]:1~i,j ge left for later,need k later
	f[0][0][0]=1;
	FOR(i,0,t-1)
		FOR(j,0,min(i,t/2))
			FOR(k,0,min(i,t/2))
				if (f[i][j][k]){
					LL t=f[i][j][k];
					if (u[i+1]){
						if (j){
							(f[i+1][j-1][k]+=t*j)%=MO;
						}
						(f[i+1][j][k+1]+=t)%=MO;
					}
					else{
						(f[i+1][j+1][k]+=t)%=MO;
						if (k){
							(f[i+1][j][k-1]+=t)%=MO;
						}
						(f[i+1][j][k+1]+=t)%=MO;
					}
				}
	ans=f[t][0][0]*fac[t/2-ts]%MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 459520
using System;

namespace _2582
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                string[] s = Console.ReadLine().Split();
                int[] step = new int[2];
                bool left = true;
                int ret = 0;
                for (int i = 0; i < n; i++)
                {
                    if (s[i][0] == 'l')
                    {
                        step[0] += s[i][1] == 'u' ? 1 : -1;
                        if (step[0] == step[1] && !left) ret++;
                        left = true;
                    }
                    else
                    {
                        step[1] += s[i][1] == 'u' ? 1 : -1;
                        if (step[0] == step[1] && left) ret++;
                        left = false;
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 9392
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInteger
getInt = readInt <$> BS.getLine

solve n
  | n `mod` 1000 == 0 = 0
  | otherwise         = 1000 - n `mod` 1000

main = do
  n <- getInt
  print $ solve n


Measured memory_bytes: 3808
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    double x,t;
    cin>>t>>x;
    cout<<fixed<<setprecision(12)<<t/x<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/
bool solve(string a, string b)
{
    int n=a.length();
    for (int i=0;i<n;i++)
    {
        if (a[i]!=b[i])
        {
            return false;
        }
    }
    return true;
}
int main()
{
    start();

    string a, b;
    cin>>a>>b;
    int n=a.length();
    for (int i=0;i<n;i++)
    {
        if (solve(a, b))
        {
            cout<<"Yes";
            return 0;
        }
        string c=a;
        a=c[n-1];
        a+=c.substr(0, n-1);
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3656
N,M = map(int,input().split())
T = [[] for i in range(N+1)]
for i in range(M):
    p,y = map(int,input().split())
    T[p].append([y, i])
result = [0] * M
for i in range(1, N+1):
    t = T[i]
    t.sort()
    if len(t) == 0:
        continue
    for j in range(len(t)):
        result[t[j][1]] =  str('{0:06}'.format(i)) + str('{0:06}'.format(j+1))
for ans in result:
    print(ans)


Measured memory_bytes: 39064
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}
ll xlcm(ll a, ll b){return (a/__gcd(a, b))*b;}

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





void SOLVE(){
    inp(n);
    inpv(a, n);
    sort(all(a));
    reverse(all(a));
    ll ans = a[0];
    ll cnt = 2;
    for(ll i=1; i<n; i++){
        if(cnt<n){
            ans+=a[i];
            cnt++;
            if(cnt<n){
                ans += a[i];
                cnt++;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}


ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<pair<ll,ll>> v;
    ll after=0;
    rep(i,n){
        pair<ll,ll> p;
        cin>>p.first>>p.second;

        if(p.first==0 and p.second==0){
            after++;
        }
        else{
            v.push_back(p);
        }
    }
    n-=after;

    // やくぶｎ，(分子，分母)　負なら，分子を負
    auto f=[](ll si,ll bo){
        if(si==0)return make_pair(0ll,1ll);
        if(bo==0)return make_pair(1ll,0ll);
        ll g=gcd(abs(si),abs(bo));
        si/=g;bo/=g;

        if(si>0 and bo>0) return make_pair(si,bo);
        if(si<0 and bo<0) return make_pair(abs(si),abs(bo));
        else return make_pair(-abs(si),abs(bo));
    };

    map<pair<ll,ll>,ll> cnt;
    for(int i=0;i<n;i++){
        cnt[f(v[i].second,v[i].first)]++;  
        auto p=f(v[i].first,v[i].second);
        p.first=-p.first;
    }

    vector<pair<ll,ll>> yabai;
    for(auto pp:cnt){
        auto p=pp.first;
        ll lf=pp.second;

        if(lf==0) continue;

        pair<ll,ll> target;
        if(p.first<0) target=make_pair(p.second,-p.first);
        else target=make_pair(-p.second,p.first);

        if(cnt.count(target)){

            if(cnt[target]) yabai.push_back(make_pair(lf,cnt[target]));
            cnt[target]=0;
        }
    }
    ll s=0;
    for(auto p:yabai) s+=p.first+p.second;
    ll ans=pow_mod(2,n-s);
    for(auto p:yabai){
        ll res=(pow_mod(2,p.first)+pow_mod(2,p.second)-1)%mod;
        // ll res=(pow_mod(2,p.first+p.second)+mod-(pow_mod(2,p.first)-1)*(pow_mod(2,p.second)-1)%mod)%mod;
        ans=ans*res%mod;
    }
    ans+=after-1;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll out,cnt,sum;
    cnt = 0;
    bool odd  = true;
    sum = 0;
    rep(i,n){
        bool j_odd = true;
        if(i%2==0) j_odd = false;
        sum+=a[i];
        if(j_odd){
            if(sum>=0){
                cnt += sum + 1;
                sum = -1;
            }
        }else{
            if(sum<=0){
                cnt += -sum + 1;
                sum = 1;            
            }
        }
    }
    out = cnt;
    cnt = 0;
    sum = 0;
    rep(i,n){
        bool j_odd = true;
        if(i%2==1) j_odd = false;
        sum+=a[i];
        if(j_odd){
            if(sum>=0){
                cnt += sum + 1;
                sum = -1;
            }
        }else{
            if(sum<=0){
                cnt += -sum + 1;
                sum = 1;            
            }
        }
    }
    out = min(out,cnt);
    cout << out << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,a,i;main(){string s;cin>>s;n=s.size();while(i<n){int m[80]={};for(auto c:"JOI")for(;i<n&&s[i]==c;m[c]++,i++);if(m[74]>=m[79]&&m[79]<=m[73])a=max(a,m[79]);}cout<<a<<endl;}

Measured memory_bytes: 3920
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n, h, w; cin >> n >> h >> w;
	int ans = 0;
	rep(i, n/2) {
		int a, b; cin >> a >> b;
		int le = min(a, w - b);
		int ri = max(w + a, 2 * w - b);
		ans += h * (2 * w - (ri - le));
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3148
def shiftOnly():
	n = int(input())
	A = list(map(int,input().split()))
	count = 0
	while True:
		for a in A:
			flag = True
			if a % 2 != 0:
				flag = False
				break
		if flag:
			count += 1
			A = [a/2 for a in A]
		else:
			break
	print(count)

shiftOnly()

Measured memory_bytes: 38768