akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            while(A[i]%2 == 0)
            {
                ans++;
                A[i] /= 2;
            }
        }
        Console.WriteLine(ans);
    }
    
}




class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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



Measured memory_bytes: 13792
#include <bits/stdc++.h>
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;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;

void debug_vector(vector<int>& v)
{
    int n = v.size();
    for (int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

void solve()
{
    int N;
    std::cin >> N;
    std::vector<ll> A(N);
    std::vector<ll> B(N);
    std::vector<ll> C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0;
    for (auto b : B) {
        auto c_iter = upper_bound(all(C), b);
        ll c_cnt = C.end() - c_iter;

        auto a_iter = lower_bound(all(A), b);
        ll a_cnt = a_iter - A.begin();

        ans += a_cnt * c_cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int edge[4];

int main(){
	for(int i=0;i<4;i++) edge[i] = 0;
	for(int i=0;i<3;i++){
		int a,b;cin>>a>>b;
		a--;b--;
		edge[a]++;
		edge[b]++;
	}
	for(int i=0;i<4;i++){
		if(edge[i] == 3){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n, t int
	fmt.Scan(&n, &t)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([][]int, n)
	for i := range as {
		as[i] = make([]int, 2)
		sc.Scan()
		as[i][0], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		as[i][1], _ = strconv.Atoi(sc.Text())
	}
	sort.Slice(as, func(i, j int) bool { return as[i][0] < as[j][0] })

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, t+1)
	}

	for i := 1; i <= n; i++ {
		a, b := as[i-1][0], as[i-1][1]
		for j := 0; j < t; j++ {
			dp[i][j] = dp[i-1][j]
			if j-a >= 0 {
				dp[i][j] = max(dp[i][j], dp[i-1][j-a]+b)
			}
		}
		dp[i][t] = max(dp[i-1][t], dp[i-1][t-1]+b)
	}
	fmt.Println(dp[n][t])
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 77084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>

double borgomool(double x)
{
    int n = 64;
    double l = 0, r = x, m;
    while(n--){
        m = (l + r)/2;
        if(m*m < x){
            l = m;
        }
        else{
            r = m;
        }
    }

    return m;
}

int main() {
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b < c){
        cout << "No" << "\n";
    }
    else cout << "Yes" << "\n";

    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define N 100010
#define ll long long
#define pa(a, b) (data){a, b}
using namespace std;

int n, m, l;
ll L[N], tim[N], ext[N], x, y, ans[N], s, xx, d[N], cl;

map<ll, ll>mp;
set<ll>q;
set<ll>::iterator it;

int main(){
	scanf("%d%d", &n, &m);
	l=0; L[0]=n; tim[0]=1; ext[0]=0;
	for(int i=1; i<=m; i++){
		scanf("%lld", &x);
		y=L[l]*tim[l]+ext[l];
		if(x>y){l++; L[l]=y; tim[l]=x/y; ext[l]=x%y; continue;}
		if(x==y)continue;
		while(l){
			if(x>=L[l]){tim[l]=x/L[l]; ext[l]=x%L[l]; break;}
			l--;
		}
		if(!l)L[0]=x;
	}
	
	mp.clear(); q.clear();
	mp[L[l]*tim[l]+ext[l]]=1; q.insert(L[l]*tim[l]+ext[l]);
	for(int i=l; i; i--){
		it=q.end(); it--; cl=0;
		while(1){
			x=(*it);
			if(x<=L[i])break;
			s=x/L[i]; xx=x%L[i];
			if(!mp[L[i]]){mp[L[i]]=mp[x]*s; q.insert(L[i]);}
			else mp[L[i]]+=mp[x]*s;
			if(!mp[xx]){mp[xx]=mp[x]; q.insert(xx);}
			else mp[xx]+=mp[x];
			d[++cl]=x;
			if(it==q.begin())break; it--;
		}
		for(int j=1; j<=cl; j++){mp[d[j]]=0; q.erase(d[j]);}
	}
	memset(ans, 0, sizeof(ans));
	for(it=q.begin(); it!=q.end(); it++){
		x=(*it);
		ans[x]+=mp[x];
	}
	for(int i=n-1; i; i--)ans[i]+=ans[i+1];
	for(int i=1; i<=n; i++)printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 33920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;

int h,w;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
string board[55];

int main(int argc,char const* argv[])
{
  cin >> h >> w;
  for(int i=0;i<h;i++)
    {
      cin >> board[i];
    }
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  if(board[i][j]=='.') continue;
	  bool ok=false;
	  for(int k=0;k<4;k++)
	    {
	      int ny=i+dy[k];
	      int nx=j+dx[k];
	      if(ny<0 || ny>h || nx>w || nx<0) continue;
	      else
		{
		  if(board[i][j] == board[ny][nx]) ok=true;
		}
	    }
	  if(!ok)
	    {
	      cout << "No" << endl;
	      return 0;
	    }
	}
    }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long long ans = 0;
  map<int, int> M;  // i + A[i] と その個数
  // j について全探索
  for (int i = 0; i < N; i++) {
    // j - A[j] = X とする
    int X = i - A.at(i);

    // i + A[i] = X となる i (i < j) の個数を加算
    if (M.count(X)) ans += M[X];

    // map に参加者 i の i + A[i] を追加
    if (M.count(i + A.at(i))) M[i + A.at(i)]++;
    else M[i + A.at(i)] = 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 13432
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int P = Integer.parseInt(sc.next());
		
		int ans = (A*3 + P) / 2;
		System.out.println(ans);
		
	}
	
	
	
}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch X | diff X.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address X.cpp && ./a.out

/*
 
 8/15/2019
 
 14:09-
 
 */

int A,B;

void solve() {
  cout<<max({A+B,A-B,A*B})<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int A,B;
    cin >> A >> B;
    if(A>=13){
        cout << B << endl;
    }else if(A>=6){
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int w[101][101];
int N, M, ans;
bitset<101> use;
void dfs(int depth) {
    if(depth == N) {
        if(use.count() < 2) return;
        int sum = 0;
        rep(i, N) if(use[i]) {
            int mi = INF;
            rep(j, N) if(i != j && use[j])
              mi = min(mi, w[i][j]);
            sum += mi;
        }
        ans = max(ans, sum);
        return;
    }
    bool ok = true;
    rep(i, depth)
      if(use[i] && !w[i][depth]) ok = false;
    dfs(depth + 1);
    if(ok) {
        use[depth] = 1;
        dfs(depth + 1);
        use[depth] = 0;
    }
    return;
}
int main() {
    scanf("%d%d", &N, &M);
    int u_, v_, w_;
    memset(w, 0, sizeof(w));
    rep(i, M) {
        scanf("%d%d%d", &u_, &v_, &w_);
        --u_; --v_;
        w[u_][v_] = w[v_][u_] = w_;
    }
    ans = 0;
    dfs(0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1244
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


# --------------------------------------------

dp = None

F_MODE = 1
S_MODE = 2

N = None
D = None
D_from_1, D_from_N = [], []


def dfs(v, prev, depth, mode):
    global D_from_1
    global D_from_N

    for next in D[v]:
        if next != prev:
            if mode == F_MODE:
                D_from_1[next] = depth
            else:
                D_from_N[next] = depth

            dfs(next, v, depth + 1, mode)


def main():
    global D
    global N
    global D_from_1
    global D_from_N

    N = int(input())
    D = [[] for _ in range(N + 1)]

    for i in range(N - 1):
        a, b = li_input()
        D[a].append(b)
        D[b].append(a)

    D_from_1 = [-1] * (N + 1)
    D_from_1[1] = 0
    D_from_N = [-1] * (N + 1)
    D_from_N[N] = 0

    dfs(1, -1, 1, F_MODE)
    dfs(N, -1, 1, S_MODE)

    fennec, snuke = 0, 0

    for i in range(1, N + 1):
        if D_from_1[i] <= D_from_N[i]:
            fennec += 1
        else:
            snuke += 1

    if fennec > snuke:
        print("Fennec")
    else:
        print("Snuke")


main()


Measured memory_bytes: 119000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		double ans = 0;

		for (int i = 0; i < n; i++) {
			ans += (double) 1 / a[i];
		}

		System.out.println((double) 1 / ans);
		sc.close();

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
	ll N; SCLLD(N);
	vector<ll> a;
	vector<ll> b;
	ll ans = 0;
	REP(i,N){
		ll A; SCD(A);
		a.PB(A);
	}
	REP(i,N){
		ll B; SCD(B);
		b.PB(B);
	}

	sort(b.begin(),b.end());
		
	for (ll p = 1;p <= 268435456;p = 2*p){
		vector<ll> pa,pb;
		REP(i,N){
			pa.PB(a[i] % (2*p));
			pb.PB(b[i] % (2*p));
		}

		sort(pb.begin(),pb.end());
		ll count = 0;

		REP(i,N){
			auto it1 = lower_bound(pb.begin(),pb.end(),2*p-pa[i]);
			auto it2 = lower_bound(pb.begin(),pb.end(),p-pa[i]);
			auto it3 = lower_bound(pb.begin(),pb.end(),4*p-pa[i]);
			auto it4 = lower_bound(pb.begin(),pb.end(),3*p-pa[i]);
			
			count += (ll)((it1 - pb.begin()) - (ll)(it2 - pb.begin()));
			count += (ll)((it3 - pb.begin()) - (ll)(it4 - pb.begin()));
		}
		//printf("count = %d\n",count);
		if (count % 2 == 1) ans += p;
	}

	PRINTLLD(ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n, m, q; cin >> n >> m >> q;
    vector<tuple<int, int, int, int>> infos(q);
    for (int i = 0; i < q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        infos[i] = {a, b, c, d};
    }
    queue<vector<int>> que;
    int mx = 0;
    que.push(vector<int>({1}));
    while (!que.empty()) {
        auto vec = que.front();
        que.pop();
        if ((int)vec.size() == n) {
            int sm = 0;
            for (auto i : infos) {
                int a = get<0>(i);
                int b = get<1>(i);
                int c = get<2>(i);
                int d = get<3>(i);
                if (vec[b - 1] - vec[a - 1] == c)
                    sm += d;
            }
            mx = max(mx, sm);
        } else {
            for (int i = vec[vec.size() - 1]; i <= m; i++) {
                auto nvec = vec;
                nvec.push_back(i);
                que.push(nvec);
            }
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 6560
def count_primes(n)
  primes = (n + 1).times.map { 1 }
  primes[0] = primes[1] = 0

  count = 0

  for p in (2..n)
    if (primes[p] != 0)
      count += 1
      (p * p).step(n, p) do |q|
        #puts "q = #{q}"
        primes[q] = 0
      end
    end
  end

  return count
end

while (line = gets)
  n = line.chop.to_i
  puts count_primes(n)
end

Measured memory_bytes: 28152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

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

/*
 update : [s,t) に xを加算
 query  : [s,t) の　最大(小)値を出力する
 */

/* [0..N-1] */
const ll INIT = 0; // 問題に合わせる
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    void lazy_evaluate(int l, int r,int k){
        node[k] += lazy[k];
        if(r - l > 1){
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    void update(int a, int b, ll x) { update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, ll x) {
        lazy_evaluate(l,r,k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_evaluate(l,r,k);
        }
        else {
            update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            node[k] = min(node[2 * k + 1],node[2 * k + 2]);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        lazy_evaluate(l, r, k);
        if (r <= a || b <= l) return LLONG_MAX; // min : LLONG_MAX , max : LLONG_MIN
        if (a <= l && r <= b) {
            return node[k];
        }
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    
    SegTree ST(n);
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
           ST.update(s-1,t,x);
            //add(s,t+1,x);
        }else{
            int i; cin >> i;
            cout << ST.query(i-1,i) <<endl;
            //cout << getMin(s,t+1) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 7072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

map<string, int> S;

int main()
{
	int N;
	cin >> N;
	for(int i = 0;i < N;i++){
		string s;
		cin >> s;
		S[s] += 1;
	}
	int max = 0;
	for(auto& it : S){
		int v = it.second;
		if(max < v)
			max = v;
	}
	
	for(auto it = S.begin();it != S.end();it++){
		if(it->second == max) cout << it->first <<endl;
	}

	
  return 0;
}


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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 3e5 + 100;
const int maxM = 3e5 + 10;
const long long oo = 1e15;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}
struct Point {
    double x, y;
    Point(){
        x = 0.0;
        y = 0.0;
    };
    Point (double _x, double _y) {
        x = _x;
        y = _y;
    }
};
Point Tru(Point A, Point B) {
    Point Res;
    Res.x = A.x - B.x;
    Res.y = A.y - B.y;
    return Res;
}
Point Cong(Point A, Point B) {
    Point Res;
    Res.x = A.x + B.x;
    Res.y = A.y + B.y;
    return Res;
}
Point TinhTien(Point A, double k) {
    Point Res;
    Res.x = A.x * k;
    Res.y = A.y * k;
    return Res;
}
double Dist(Point A, Point B) {
    double x = A.x - B.x;
    double y = A.y - B.y;
    return sqrt(x * x + y * y);
}
void Print(Point A) {
    cout << fixed << setprecision(10) << A.x << " " << A.y << '\n';
}
Point DinhGiua(Point A, Point B) {
    Point AB = Tru(B, A);
    Point nAB = Point(0.0 - AB.y, AB.x);
    Point MedianAB = Point((A.x + B.x) / 2.0, (A.y + B.y) / 2.0);
    double D = Dist(A, B);
    D = D * sqrt(3.0) / 2.0;
    double K = (D * D) / (nAB.x * nAB.x + nAB.y * nAB.y);
    K = sqrt(K);
    return Cong(MedianAB, TinhTien(nAB, K));
}
void Get(Point A, Point B, int n) {
    if (n == 0) {
        Print(A);
        return;
    }
    Point AB = Tru(B, A);
    Point S = Cong(A, TinhTien(AB, 1.0 / 3.0));
    Point T = Cong(A, TinhTien(AB, 2.0 / 3.0));
    Point U = DinhGiua(S, T);
    Get(A, S, n - 1);
    Get(S, U, n - 1);
    Get(U, T, n - 1);
    Get(T, B, n - 1);
}
void solve() {
    int n;
    cin >> n;
    Point A = Point(0.0, 0.0);
    Point B = Point(100.0, 0.0);
    Get(A, B, n);
    Print(B);
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}




Measured memory_bytes: 3244
import sys

sys.setrecursionlimit(10**6)

n = int(input())
tr = [list() for _ in range(n)]
num = [None]*n
ran = [0]*n
dep = [0]*n
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b -= 1
  tr[a].append(b)
  tr[b].append(a)
k = int(input())
root,c = map(int,input().split())
root -= 1
num[root] = c
def dfs(v,p,dep):
  for x in tr[v]:
    if x == p:
      continue
    dep[x] = dep[v] + 1
    dfs(x,v,dep)
  return
dfs(root,-1,dep)
for _ in range(k-1):
  v,c = map(int,input().split())
  v -= 1
  if abs(c-num[root]) > dep[v] or dep[v]%2 != (c-num[root])%2:
    print("No")
    exit(0)
  num[v] = c

def dfs2(v,p,ran):
  cur = [-10**9,10**9] if num[v] is None else [num[v],num[v]]
  if tr[v] == [p]: 
    ran[v] = tuple(cur)
    return
  for x in tr[v]:
    if x == p:
      continue
    dfs2(x,v,ran)
    if ran[x][0] > cur[0]:
      cur[0] = ran[x][0]
    if ran[x][1] < cur[1]:
      cur[1] = ran[x][1]
  cur[0] -= 1; cur[1] += 1
  ran[v] = tuple(cur)
  return

dfs2(root,None,ran)
  
q = [(root,None)]
while q:
  v,p = q.pop()
  for x in tr[v]:
    if x == p:
      continue
    if ran[x][0]<=num[v]+1<=ran[x][1]:
      num[x] = num[v] + 1
    elif ran[x][0]<=num[v]-1<=ran[x][1]:
      num[x] = num[v] - 1
    else:
      print("No")
      exit(0)
    q.append((x,v))
print("Yes")
for c in num:
  print(c)


Measured memory_bytes: 125224
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s, p;
signed main() {
	int n;
	cin >> s >> n;
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> p;
		if (p == "reverse") {
			cin >> a >> b;
			string h = "";
			for (int j = a; j <= b; j++) {
				h += s[j];
			}
			for (int j = 0; j < h.size() / 2; j++) {
				swap(h[j], h[h.size() - j - 1]);
			}
			for (int j = a; j <= b; j++) {
				s[j] = h[j - a];
			}
		}
		else if (p == "replace") {
			cin >> a >> b >> p;
			for (int j = a; j <= b; j++) {
				s[j] = p[j - a];
			}
		}
		else {
			cin >> a >> b;
			for (int j = a; j <= b; j++) {
				cout << s[j];
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3208
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <vector>
using namespace std;
int d[500];
int sum[100];
int n;
vector<int>ans[1148576];
int cnt;
bool vis[1148576];
int dis[500];
int num[500];
bool check(int l,int r,int id,int val)
{
	bool flag=true;
	dis[id]=val;
	for(int i=1;i<=l;i++)
	{
	    num[dis[id]-dis[i]]--;
        if(num[dis[id]-dis[i]]<0)
        {
            flag=false;
        }
	}
	for(int i=r;i<=n;i++)
    {
        num[dis[i]-dis[id]]--;
        if(num[dis[i]-dis[id]]<0)
        {
            flag=false;
        }
    }
	if(flag) return true;
	return false;
}
void dfs(int l,int r)
{
    if(l==r-1)
    {
        for(int i=1;i<=n;i++)
        {
            ans[cnt].push_back(dis[i]);
        }
        cnt++;
        return ;
    }
    int k=1;
	while(num[d[k]]==0) k++;
	if(check(l,r,l+1,dis[n]-d[k]))dfs(l+1,r);
	for(int i=1;i<=l;i++)
    {
        num[dis[l+1]-dis[i]]++;
    }
	for(int i=r;i<=n;i++)
    {
        num[dis[i]-dis[l+1]]++;
    }
	if(check(l,r,r-1,d[k]))dfs(l,r-1);
	for(int i=1;i<=l;i++)
	{
	    num[dis[r-1]-dis[i]]++;
	}
	for(int i=r;i<=n;i++)
    {
        num[dis[i]-dis[r-1]]++;
    }
}
int main()
{
    while(~scanf("%d",&n))
    {
        if(n==0)break;
        cnt=0;
        memset(vis,0,sizeof(vis));
        memset(num,0,sizeof(num));
        for(int i=0;i<300000;i++)
        {
            ans[i].clear();
        }
        for(int i=0;i<n*(n-1)/2;i++)
        {
            scanf("%d",d+i);
            num[d[i]]++;
        }
        dis[n]=d[0];
        num[d[0]]--;
        memset(sum,0,sizeof(sum));
        dfs(1,n);
        for(int i=0;i<cnt;i++)
        {
            if(vis[i])continue;
            for(int j=i+1;j<cnt;j++)
            {
                int len=ans[i].size();
                int k;
                for(k=0;k<len;k++)
                {
                    if(ans[i][k]!=ans[j][k])break;
                }
                if(k==len)
                {
                    vis[j]=1;
                }

            }
        }
       // cout<<"~~"<<cnt<<endl;
        for(int i=0;i<cnt;i++)
        {
            if(vis[i])continue;
            int len=ans[i].size();
            for(int k=1;k<len;k++)
            {
                if(k==len-1)
                printf("%d\n",ans[i][k]-ans[i][k-1]);
                else
                printf("%d ",ans[i][k]-ans[i][k-1]);
            }
        }
        printf("-----\n");
    }
}

Measured memory_bytes: 29344
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	L := sc.nextIntSlice(N)
	sort.Ints(L)
	count := 0
	for i := len(L) - 1; i > 0; i-- {
		for j := i - 1; j >= 0; j-- {
			lower := L[i] - L[j] + 1
			lowerIndex := sort.Search(len(L), func(i int) bool {
				return L[i] >= lower
			})
			upperIndex := j - 1
			if lowerIndex <= upperIndex {
				count += upperIndex - lowerIndex + 1
			}
		}
	}
	fmt.Println(count)
}


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

int main(){


  int N;
  cin >> N;
  long long A[N], ans=0;
  int num[60];
  for(int i=0; i<61; i++) num[i]=0;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<61; j++){
      if(A[i] & 1) num[j]++;
      A[i] >>= 1;
    }
  }
  for(int i=0; i<61; i++){
    long long tmp;
    tmp = pow(2, i);
    tmp %= M0D;
    tmp *= N-num[i];
    tmp %= M0D;
    tmp *= num[i];
    tmp %= M0D;
    ans += tmp;
    ans %= M0D;
  }
  cout << ans << endl;

  return 0;
}


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

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

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	llong n;
	cin>>n;
	
	llong i=(llong)sqrt(n);
	for(i;i>0;--i){
		if(n%i==0){
			cout<<i+n/i-2<<endl;
			return 0;
		}
	}
}

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

using namespace std;

#ifdef LOCAL_DEFINE
  #include "../../library/DEBUG.hpp"
#else
  #define debug(...) 0
#endif

const long long maxn = 1e7 + 10;
vector<long long> prime;
vector<bool> is_prime;

void seive() {
  prime.resize(maxn);
  is_prime.resize(maxn, true);
  iota(prime.begin(), prime.end(), 0LL);
  is_prime[0] = is_prime[1] = false;
  for (long long i = 2; i < maxn; i++) {
    if (is_prime[i]) {
      for (long long j = 2 * i; j < maxn; j += i) {
        is_prime[j] = false;
        prime[j] = i;
      }
    }
  }
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  seive();
  auto F = [&](long long val) {
    if (val == 1) return 1LL;
    map<long long, long long> times;
    while (val != 1) {
      times[prime[val]]++;
      val /= prime[val];
    }
    long long ret = 1LL;
    for (auto& x : times) {
      ret *= (long long) (x.second + 1);
    }
    return ret;
  };
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += i * F(i);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 82592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

const int mod = 7 + pow(10, 9);

int main(){
  string s;
  cin >> s;
  int N = s.size();
  long long dp[100010][4] = {};
  for (int i = N; i >= 0; --i){
    for (int j = 3; j >= 0; --j){
      if (i == N){
        dp[i][j] = (j == 3 ? 1: 0);
      }
      else{
        dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3LL : 1LL);
        if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
          dp[i][j] += dp[i + 1][j + 1];
        }
        dp[i][j] %= mod;
      }
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0, smn = INT_MAX, smx = INT_MIN;
        REP(i, n) {
            int s;
            cin >> s;
            sum += s;
            smn = min(smn, s);
            smx = max(smx, s);
        }
        cout << (sum - smn - smx) / (n - 2) << "\n";
    }

    return 0;
}



Measured memory_bytes: 3168
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

  //  Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n= cin.nextInt();
    int[] price = new int[n];
    for (int i=0;i<n;i++) {
      price[i] = cin.nextInt();
    }

    Arrays.sort(price);
    price[n-1] = price[n-1]/2;
    int sum = 0;
    for (int i=0;i<n;i++) {
      sum += price[i];
    }
    System.out.println(sum);

  }

}



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

public class Main {
    public static final long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        Integer a,b,c,i,j,k,n,m;

        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        List<Integer> l = Arrays.asList(
            a,
            b,
            c);
        Collections.sort(l);

        print((l.get(0)+l.get(1)));
        
        out.flush();
    }

    private static void print(Object o) {
        System.out.println(o.toString());
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if i+1 ==P[i]:
        P[i+1], P[i] = P[i], P[i+1]
        ans += 1
if P[-1]==N:
  ans+=1
print(ans)

Measured memory_bytes: 14008
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}

int a[200050];
void solve(){
    int n;
    cin>>n;
    int t = 1;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        t^=a[i];
    }
    t^=1;
    for (int i = 0; i < n; ++i) {
        t^=a[i];
        cout<<t<<' ';
        t^=a[i];
    }
}

Measured memory_bytes: 4308
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int K; cin >> K;
	int mod = 0;
	vector<bool> exists(K, false);
	int ans = 0;
	for (;;)
	{
		++ans;
		mod = (mod * 10 + 7) % K;
		if (mod == 0) break;
		if (exists[mod])
		{
			cout << -1 << endl;
			return 0;
		}
		exists[mod] = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#define PI 3.141592653589
using namespace std;

int main() {
	while (1) {
		int a, b;
		char op;
		cin >> a >> op >> b;

		if (op == '?')break;
		int c;
		switch (op) {
		case '+':
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
			break;
		case '%':
			c = a % b;
			break;
		}
		printf("%d\n", c);
	}

	return 0;
}

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

using namespace std;

int main() {
	vector<int> a(200);
	int N, counter = 0;
	bool f = true;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] % 2 != 0) {
			f = false;
		}
	}
	while (f==true) {
		for (int i = 0; i < N; i++) {
			a[i] = a[i] / 2;
			if (a[i] % 2 == 1) {
				f = false;
			}
		}
		counter++;
	}
	cout << counter << endl;
}

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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i] >> B[i];

  vector<int> dp(H + 10000, 1000000001);
  dp[0] = 0;
  for (int i = 0; i < H; ++i) {
    if (i != 0 && dp[i] == 1000000001)
      continue;
    for (int j = 0; j < N; ++j)
      dp[i + A[j]] = min(dp[i] + B[j], dp[i + A[j]]);
  }

  int ans = 1000000001;
  for (int i = H; i < H + 10000; ++i)
    ans = min(dp[i], ans);

  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	int total = 0;

	rep(i, n) {
		cin >> a[i];
		total += a[i];
	}

	int b = (4 * m);
	int th = ru(total, b);

	int cnt = 0;
	rep(i, n) {
		if (a[i] >= th) cnt++;
	}

	if (cnt >= m) cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
int main()
{
  int n;
  scanf("%d", &n);
  int a[n];
  int i, cnt = 0;
  for (i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    if ((i + 1) % 2 == 1)
    {
      if (a[i] % 2 == 1)
        cnt++;
    }
  }
  printf("%d", cnt);
}

Measured memory_bytes: 1728
//　小文字を大文字に直すプログラム
//　isalphaはアルファベットならtrueを返す関数
// toupperは小文字を大文字にして返す関数
// tolowerは大文字を小文字にして返す関数

#include <iostream>
#include <string>

using namespace std;

int main(void){

  string s;
  getline( cin , s );

  for( int i = 0 ; i < s.size() ; i++ ){
    if( isalpha( s[i]) ){
      s[i] = toupper( s[i] );  
    }
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 1176
N,X,M=[int(s) for s in input().split()]
modls=[0 for _ in range(M+1)]
modls[0]=X
modset=set()
for i in range(1,M+1):
  k=(modls[i-1]**2)%M
  if k in modset:
    break
  modls[i]=k
  modset.add(k)
loop_end=i
loop_start=modls.index(k)
loop_length=loop_end-loop_start

ans=0
ans+=sum(modls[:loop_start])
if k!=0:
  ans+=sum(modls[loop_start:])*((N-loop_start)//loop_length)
  ans+=sum(modls[loop_start:loop_start  +  (N-loop_start)%loop_length])
print(ans)

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

int a, b, d;
bool c=false;

int main (){
	cin >> d;
	for (int a=1;a<=9;a++){ 
		for (int b=1;b<=9;b++){
		if (d==a*b){
			c=true;
		}
		}
		}
		if (c==false){
			cout << "No" << endl;
		}else if (c==true){
			cout << "Yes" << endl;
		}
}
		

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    s[3] = '8';
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,ll arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to;
	ll dist;
};

ll ans;
int V;
vector<Edge> G[SIZE];


ll recursive(int node_id,int parent){

	ll max_path1 = 0;
	ll max_path2 = 0;

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i].to;
		if(child == parent)continue;

		ll tmp_dist = G[node_id][i].dist+recursive(child,node_id);

		if(tmp_dist > max_path1){

			max_path2 = max_path1;
			max_path1 = tmp_dist;

		}else if(tmp_dist > max_path2){

			max_path2 = tmp_dist;
		}
	}
	ans = max(ans,max_path1+max_path2);

	return max_path1;
}


int main(){

	scanf("%d",&V);

	int from,to;
	ll dist;

	for(int loop = 0; loop < V-1; loop++){

		scanf("%d %d %lld",&from,&to,&dist);
		G[from].push_back(Edge(to,dist));
		G[to].push_back(Edge(from,dist));
	}

	ans = 0;
	recursive(0,-1);

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 18008
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    double prob[n+1],dp[n+1][n+1]={0}, res = 0;
    for(int i = 1; i <= n; ++i)
        cin>>prob[i];
    dp[0][0]=1;
    for (int i = 1; i <=n; ++i)
    {
        for (int j = 0; j<=i; ++j)
        {
            if(j)
                dp[i][j]+=(dp[i-1][j-1]*prob[i]);
            dp[i][j]+=((1.0-prob[i])*dp[i-1][j]);
        }
    }
   // double res=0.0;
    for (int i = (n/2+1); i <= n; ++i)
    {
        res+=dp[n][i];
    }
    printf("%.10lf",res);
    
    return 0;
}


Measured memory_bytes: 70528