akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	int degree;
	int depth;
	int height;
	char type[15];
	
	int * child_list;
};
typedef struct Node * NodePointer;


void serach_depth (NodePointer ,int  ,NodePointer[]);

int main (){
	int n;
	scanf("%d\n",&n);
	
	//setting part
	NodePointer array [n];
	for (int i = 0; i < n;i++)
	{
		array[i] = (NodePointer) malloc (sizeof(struct Node));
		array[i]->parent = NULL;
		array[i]->degree = 0;
		strcpy(array[i]->type,"internal node");
	}
	
	//input part
	for (int i = 0; i < n;i++)
	{
		int id;
		scanf("%d ",&id);
		array[id]->key = id;
		int child_num;
		scanf("%d" ,&child_num);
		array[id]->child_list = (int *) malloc (child_num * sizeof(int));
		
		if ( child_num == 0){
			strcpy(array[id]->type ,"leaf");
		}else {
			for (int j = 0; j < child_num; j++){
				int child_id;
				scanf(" %d" ,&child_id);
				array[id]->child_list[j] = child_id;
				array[child_id]->parent = array[id];
				array[id]->degree++;
			}
		}

	}
	
	//search part
		for (int i = 0; i < n;i++)
	{
		if(array[i]->parent == NULL) {
			strcpy(array[i]->type ,"root");
			serach_depth(array[i],0 ,array); break;
		}
	}
	
	//print part
	for (int i = 0; i < n ;i++){
		printf("node %d: ",i);
		if (array[i] -> parent != NULL){
		printf("parent = %d, ",array[i]->parent->key);
		}else {
			printf("parent = -1, ");
		}
		printf("depth = %d, %s, [",array[i]->depth,array[i]->type );
		for ( int j = 0; j < array[i]->degree; j++){
			printf("%d" ,array[i]->child_list[j]);
			if ( j + 1 != array[i]->degree){printf(", ");}
		}
		printf("]\n");
	}
	
	return 0;
}

void serach_depth (NodePointer tag,int dep , NodePointer array[]){
	tag->depth = dep;
	if ( tag->degree == 0 ){tag->height = 0; return;}
	for ( int j = 0; j < tag->degree ; j++){
		serach_depth(array [ (tag->child_list[j]) ] , dep + 1 ,array);
	}
}



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

using namespace std;

typedef long long int ll;

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

  ll n;
  cin >> n;
  ll ans = 0;
  for(int i = 2; i <= sqrt(n); i++){
    if(n % i == 0){
      int cnt = 0;
      while(n % i == 0){
        cnt++;
        n /= i;
      }

      int j = 1;
      while(cnt >= j){
        ans++;
        cnt -= j;
        j++;
      }
    }
  }
  if(n > 1){
    ans++;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	string a, b, c;
	int ans = 0, m = 5000;
	for (int i = 0; i < s.size()-2; i++) {
		a = s[i];
		b = s[i + 1];
		c = s[i + 2];
		string t = a + b + c;
		int num = atoi(t.c_str());
		ans = abs(753 - num);
	     m = min(ans, m);
	}
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

typedef long long ll;

int N;
ll pT, pA;

int main()
{
  scanf( "%d", &N );
  rep( i, N )
  {
    ll T, A;
    scanf( "%lld%lld", &T, &A );

    if( !pT && !pA )
      pT = T, pA = A;
    else
    {
      ll k = std::max( pT%T?pT/T+1:pT/T, pA%A?pA/A+1:pA/A );
      pT = k*T;
      pA = k*A;
    }
  }

  printf( "%lld\n", pT+pA );
  
  return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a - b == 0 && a - c == 0) cout << 1 << endl;
	else if (a - b != 0 && b - c != 0 && c - a != 0) cout << 3 << endl;
	else cout << 2 << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let s: i32 = stdin.read();

    let mut a = s;
    let mut n = 1;
    while a != 1 && a != 2 && a != 4 {
        if a % 2 == 0 {
            a /= 2;
        } else {
            a = 3 * a + 1;
        }
        n += 1;
    }
    let m = n + 3;
    println!("{}", m);
}

mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

vi get_num(string str){
	str.pb('.');
	string s = "";
	vector<int> vec;
	rep(i,str.size()){
		if(str[i] == '.'){
			vec.pb(atoll(s.c_str()));
			s = "";continue;
		}
		s.pb(str[i]);
	}
	return vec;
}

int length_of_year(int y){ // 1-indexed
  if(y%400 == 0 || ((y%100 != 0) && (y%4 == 0)))return 366;
  return 365;
}

int length_of_month(int y, int m){ // 1-indexed
  int monthes[12] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if(m != 2)return monthes[m-1];
    if(length_of_year(y) == 366)return 29;
    return 28;
}

int date_to_int(string date){ //ex) 2018.08.05
	vector<int> vec = get_num(date);
	int ans = 0;
	int y = vec[0], m = vec[1], d = vec[2];
	repi(i,1,y)ans += length_of_year(i);
	repi(i,1,m)ans += length_of_month(y, i);
	return ans + d;
}

int maya_to_int(string date){
	vector<int> vec = get_num(date);
	int ans = 0, tmp = 1;
	int mask[] = {13, 20, 20, 18, 20};
	drep(i,5-1,0){
		ans += vec[i]*tmp;
		tmp *= mask[i];
	}
	return ans;
}

string to_str(int num){
	//return to_string(num);
	if(num == 0)return "0";
	string s = "";
	while(num > 0){
		s += ((num%10)+'0');
		num /= 10;
	}
	reverse(all(s));
	return s;
}

string anno_to_str(int date){
	int y = 1, m = 1;
	for(int i = 1;length_of_year(i) < date;i++){date -= length_of_year(i);y++;}
	for(int i = 1;length_of_month(y, i) < date;i++){date -= length_of_month(y, i);m++;}
	string ans;
	ans += to_str(y) + ".";
	ans += to_str(m) + ".";
	ans += to_str(date);
	return ans;
}

string maya_to_str(int date){
	int mark2[] = {13, 20, 20, 18, 20};
	int mark[5] = {}, ans[5] = {};
	int tmp = 20;
	drep(i,3,0){mark[i] = tmp;tmp *= mark2[i];}
	rep(i,4){
		ans[i] = date/mark[i];
		date -= mark[i]*(date/mark[i]);
	}ans[4] = date;
	string str = "";
	rep(i,4){
		str += to_str(ans[i]%mark2[i]) + ".";
	}
	return str+to_str(ans[4]);
}

signed main(){
	int B = date_to_int("2012.12.21");
	while(1){
		string str;
		cin >> str;
		if(str == "#")break;
		if(get_num(str).size() == 3){
			int num = date_to_int(str)-B;
			cout << maya_to_str(num) << endl;
		}else{
			int num = maya_to_int(str)+B;
			cout << anno_to_str(num) << endl;
		}
	}
	return 0;
}





Measured memory_bytes: 3192
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n/10 == 9 || n%10 == 9){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    }
  }

Measured memory_bytes: 21844
// use proconio::{fastout, input};

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

//     l.sort();

//     let mut ans = 0;
//     for i in 0..(n - 2) {
//         for j in (i + 1)..(n - 1) {
//             for k in (j + 1)..n {
//                 // if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
//                 //     ans += 1;
//                 // }
//                 if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
//                     continue;
//                 }
//                 if l[k] < l[i] + l[j] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i] {
//                     ans += 1;
//                 }
//             }
//         }
//     }

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

use proconio::{fastout, input};

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

    let mut cnt = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
                    continue;
                }
                if l[k] < l[i] + l[j] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i] {
                    cnt += 1;
                }
            }
        }
    }
    println!("{}", cnt);
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x,y,z,w;
  cin>>x>>y>>z>>w;
  if( abs(x-z) <= w or ( abs(x-y) <= w and abs(y-z) <= w) ){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}


Measured memory_bytes: 896
s = input()
s1 = int(s[2:])
s2 = int(s[:2])
if s1 < 13 and s1 > 0 and s2 < 13 and s2 > 0:
    ans = 'AMBIGUOUS'
elif s1 < 13 and s1 > 0:
    ans = 'YYMM'
elif s2 < 13 and s2 > 0:
    ans = 'MMYY'
else:
    ans = 'NA'
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    int n, m;
    cin >> n >> m;
    int s = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    sort(a.rbegin(), a.rend());

    for (int i = 0; i < m; i++) {
        if (4*m*a[i] < s) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";





    return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
p = tuple(p)
q = tuple(q)

l = list(range(1, n+1))
m = itertools.permutations(l,len(l))
_list = []
for i in m:
    _list.append(i)
print(abs(_list.index(p)-_list.index(q)))

Measured memory_bytes: 7924
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
D=[input_array() for i in range(n)]

count=0
for d in D:
	if d[0]==d[1]:
		count+=1
	else:
		count=0

	if count==3:
		break
if count==3:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    string s,t;
    cin >> s >> t;

    int size = s.size();
    t.erase(size,1);
    // 出力
    if(s == t)     cout << "Yes"<< endl;
    else      cout << "No"<< endl;
    return 0;
}


Measured memory_bytes: 3624
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# 1個飛ばしで列をカウントする
# それぞれについてもっとも多く数列に現れる数字の出現回数の合計cに対してlen(A)-cが答え
# cは具体的には、2つのカウントに対して同じ数字だったら合計しない。で次に数の多い方を採用


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


n = read_a_int()
V = read_ints()

from collections import Counter
gu = Counter(V[0::2]).most_common()
ki = Counter(V[1::2]).most_common()

c = gu[0][1] + ki[0][1]
if gu[0][0] == ki[0][0]:
    c //= 2
    if len(gu) == 1 and len(ki) == 1:
        pass
    elif len(gu) == 1:
        c += ki[1][1]
    elif len(ki) == 1:
        c += ki[1][1]
    else:
        c += max(gu[1][1], ki[1][1])

print(n - c)


Measured memory_bytes: 64604
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct vec{
  double x, y;
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return x * x + y * y; };
};
struct line{
  vec a, b;
  vec getvec(){ return b - a; }
  vec proj(vec p){
    vec pa = p - a, ba = b - a;
    double t = pa.dot(ba) / ba.norm();
    return a + ba.sca(t);
  }
};

signed main(void){
  int i, j, k;
  line l;
  cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
  int(q);
  for(;q--;){
    vec p;
    cin >> p.x >> p.y;
    vec res = l.proj(p);
    printf("%.15lf %.15lf\n", res.x, res.y);
  }

  return 0;
}

Measured memory_bytes: 1276
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A[4],B[4];
int main() {
	int S=0,T=0;
	for(int i=0;i<4;i++){
		cin>>A[i];
		S+=A[i];
	}
	for(int j=0;j<4;j++){
		cin>>B[j];
		T+=B[j];
	}
	if(S<T)cout<<T<<endl;
	if(S>T || S==T)cout<<S<<endl;


	return 0;
}

Measured memory_bytes: 3056
import * as fs from 'fs';

export function Main(input: string) {
    const [a, b, c, k] = input.split(' ')
        .map(x => parseInt(x));    // ?

    let result: number;

    if (k >= a) {
        result = a;
        if (k >= a + b) {
            result -= k - a - b;
        }
    } else {
        result = k;
    }

    //output
    console.log(result);
}

// Don't edit this line!
Main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29740
#[N-1]*Nから、逆操作をして構築していく。
K = int(input())
N=50 #N=50で固定してやる

ans=[N-1]*N #初期値は全てN-1

d = K//N # 全てにd回の操作をする
r = K % N  #r個には追加で1回操作をする

for i in range(N):
    ans[i] += N*d #d回の操作での増加分
    ans[i] -= d*(N-1) #他の(N-1)この操作に対する減少分

for i in range(r): #r個には追加で一回操作
    ans[i] += N-(r-1)

for i in range(r,N):#残りの奴らは引かれるだけ
    ans[i] -=r
print(N)
print(" ".join(map(str,ans)))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

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

    ll X1, Y1;
    ll X2, Y2;
    ll X3, Y3;

    X1 = Y1 = 0;
    X2 = 1e9;
    Y2 = 1;

    ll A = S/X2;
    ll B = S%X2;

    if(S % X2 != 0){
        Y3 = A + 1;
        X3 = X2 - B;
    }
    else{
        Y3 = A;
        X3 = 0;
    }

    printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);

    //printf("S = %lld\n", X2*Y3 - X3*Y2);
    return 0;
}


Measured memory_bytes: 256
from string import ascii_lowercase
D = {k:i for i, k in enumerate(ascii_lowercase)}

S = input()
n = len(S)

if n != 26:
    ans = S
    for c in ascii_lowercase:
        if c not in S:
            ans += c
            break
else:
    nokori = [D[S[-1]]]
    for i in range(24, -1, -1):
        res = 30
        for n in nokori:
            if D[S[i]] < n:
                res = min(res, n)
        if res == 30:
            nokori.append(D[S[i]])
        else:
            ans = S[:i] + ascii_lowercase[res]
            break
    else:
        ans = -1

print(ans)


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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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


int n,m;
vector<vector<int> > ed;
int dp[100005];

int dfs(int i) {
	if (dp[i]) return dp[i];

	for (int a : ed[i]) {
		dp[i] = max(dp[i],dfs(a)+1);
	}
	return dp[i];
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(dp,0,sizeof(dp));
	cin >> n >> m;
	ed.resize(n+1);
	for (int i = 0; i < m; i++) {
		int a,b;
		cin >> a >> b;
		ed[a].pb(b);
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = max(dfs(i),ans);
	cout << ans << "\n";
}

Measured memory_bytes: 11024
#include <stdio.h>
main()
{
  int i,j,ans;

  for(i = 1 ; i <= 9 ; i++)
    {
      for(j = 1 ; j <= 9 ; j++)
	{
	  ans = i * j;
	  printf("%dx%d=%d\n",i,j,ans);
	}
    }
  return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

ll ceiling(ll a,ll b){
  if(a % b == 0){
    return a / b;
  }else{
    return (a / b) + 1;
  }
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  int N;
  string S;
  cin >> N >> S;
  int W = count(S.begin(),S.end(),'.'),B = count(S.begin(),S.end(),'#');
  int WC = 0,BC = 0,ans = min(N-W,N-B);
  for(int i = 0;i < N;i++){
    if(S[i] == '#')BC++;
    else WC++;
    ans = min(ans,BC+W-WC);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define pii pair<int, int>

using namespace std;

int n, a[200005], res = 0, mx = 0;
void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        res += max((int)0, mx - a[i]);
        if (a[i] > mx)
            mx = a[i];
    }
    cout << res;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

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

using namespace std;

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    int ans = P + Q + R;
    ans = ans - max(max(P, Q), R);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define re register
#define Node vector<int>
#define ull unsigned long long
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return s*t;
}
const int N=3e5+5;
const int M=205;
const int P=998244353;
int n,m,fac[N],inv[N];
int Mod(int x){return x>=P?x-P:x;}
int ksm(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%P;
		x=1ll*x*x%P,k>>=1;
	}return res;
}
namespace Number{
	const int G=3;
	int Lim,p[N],w[N];
	void Init(int n){//x^n 
		for(Lim=0;(1<<Lim)<=n;Lim++);
		for(int i=0;i<(1<<Lim);i++)p[i]=(p[i>>1]>>1)|((i&1)<<Lim-1);
		Lim=(1<<Lim);
	}
	void NTT(Node &A,int n,int type){
		w[0]=1;for(int i=0;i<n;i++)if(i<p[i])swap(A[i],A[p[i]]);
		for(int m=1;m<n;m<<=1){
			int t0=ksm(G,P-1+type*(P-1)/(m<<1));
			for(int i=1;i<m;i++)w[i]=1ll*w[i-1]*t0%P;
			for(int k=0;k<n;k+=(m<<1))
			for(int i=k;i<k+m;i++){
				int x=A[i],y=1ll*A[i+m]*w[i-k]%P;
				A[i]=Mod(x+y),A[i+m]=Mod(x+P-y);
			}
		}
		int t0=ksm(n,P-2);
		if(type==-1)for(int i=0;i<n;i++)A[i]=1ll*A[i]*t0%P;
	}
	Node operator*(Node A,Node B){
		int n=A.size()-1,m=B.size()-1;
		Init(n+m+1),A.resize(Lim),B.resize(Lim);
		NTT(A,Lim,1),NTT(B,Lim,1);
		for(int i=0;i<Lim;i++)A[i]=1ll*A[i]*B[i]%P;
		NTT(A,Lim,-1);for(int i=n+m+1;i<Lim;i++)A[i]=0;
		A.resize(n+m+1);return A;
	}
}using namespace Number;
Node f[M],g,h;
int C(int n,int m){return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
void Pre(int n){
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%P;
	inv[n]=ksm(fac[n],P-2);for(int i=n;i>=1;i--)inv[i-1]=1ll*inv[i]*i%P;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),Pre(1e5);
	f[m].resize(n+1);for(int i=0;i<=n;i++)f[m][i]=C(n,i);
	for(int i=m-1;i>=0;i--){
		g.resize(n+1);for(int j=0;j<n;j++)g[j]=inv[n-j+2];
		h.resize(n+1);for(int j=0;j<=n;j++)h[j]=1ll*f[i+1][j]*fac[j+2]%P;
		h=h*g,f[i].resize(n+1);
		for(int j=0;j<=n;j++)f[i][j]=Mod(1ll*h[n+j]*inv[j]%P+1ll*f[i+1][j]*(C(j+1,2)+1)%P);
	}printf("%d",f[0][0]);
	return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> vec(M, vector<int>(2, 0));
	for (int i = 0; i < M; i++) {
		cin >> vec.at(i).at(0) >> vec.at(i).at(1);
	}

	for (int i = 0; i < N; i++) {
		int C = 0;
		for (int j = 0; j < M; j++) {
			if (vec.at(j).at(0) == i+1 || vec.at(j).at(1) == i+1) {
				C++;
			}
		}
		cout << C << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var dy = ps.Select(v => v[1]).Concat(ps.Select(v => v[3])).Distinct().OrderBy(y => y).Select((y, i) => new { y, i }).ToDictionary(_ => _.y, _ => _.i);

		var xs = ps.Where(v => v[1] == v[3]).SelectMany(v => new[] { new[] { -1, Math.Min(v[0], v[2]), dy[v[1]] }, new[] { 1, Math.Max(v[0], v[2]), dy[v[1]] } }).ToArray();
		var ys = ps.Where(v => v[0] == v[2]).Select(v => new[] { 0, v[0], dy[Math.Min(v[1], v[3])], dy[Math.Max(v[1], v[3])] }).ToArray();
		var qs = xs.Concat(ys).OrderBy(q => q[1]).ThenBy(q => q[0]);

		var r = 0L;
		var st = new ST(dy.Count);
		foreach (var q in qs)
			if (q[0] == 0)
				r += st.Subsum(q[2], q[3] + 1);
			else
				st.Add(q[2], -q[0]);
		Console.WriteLine(r);
	}
}

class ST
{
	struct KI
	{
		public int k, i;
	}

	int kMax;
	List<long[]> vs = new List<long[]> { new long[1] };
	public ST(int n)
	{
		for (int c = 1; c < n; vs.Add(new long[c <<= 1])) ;
		kMax = vs.Count - 1;
	}

	KI[] GetLevels(int i)
	{
		var r = new List<KI>();
		for (int k = kMax; k >= 0; --k, i >>= 1) r.Add(new KI { k = k, i = i });
		return r.ToArray();
	}

	KI[] GetRange(int minIn, int maxEx)
	{
		var r = new List<KI>();
		for (int k = kMax, f = 1; k >= 0 && minIn < maxEx; --k, f <<= 1)
		{
			if ((minIn & f) != 0) r.Add(new KI { k = k, i = (minIn += f) / f - 1 });
			if ((maxEx & f) != 0) r.Add(new KI { k = k, i = (maxEx -= f) / f });
		}
		return r.ToArray();
	}

	public void Add(int i, long v)
	{
		foreach (var x in GetLevels(i)) vs[x.k][x.i] += v;
	}

	public long Subsum(int minIn, int maxEx) => GetRange(minIn, maxEx).Sum(x => vs[x.k][x.i]);
}



Measured memory_bytes: 52092
S = input()

n = 0
e = 0
w = 0
s = 0

for v in S:
    if v == 'N': n+=1
    if v == 'E': e+=1
    if v == 'W': w+=1
    if v == 'S': s+=1
if ((0<n and 0<s) or (n==0 and s==0)) and ((0<e and 0<w) or (e==0 and w==0)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8984
n, d = gets.split(" ").map(&:to_i)
ps = []
n.times do |i|
  ps << gets.split(" ").map(&:to_i)
end

count = 0
d2 = d * d
ps.each do |x, y|
    count += 1 if x * x + y * y <= d2
end
puts count

Measured memory_bytes: 28840
R,C,K=map(int,input().split())
m=[[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
  r,c,v=map(int,input().split())
  m[r][c]=v
d=[[0]*4 for _ in range(R+1)]
for j in range(1,C+1):
  for i in range(1,R+1):
    t=m[i][j]
    if t>0:
      d[i][3]=max(d[i][3],d[i][2]+t)
      d[i][2]=max(d[i][2],d[i][1]+t)
      d[i][1]=max(d[i][1],d[i][0]+t,max(d[i-1])+t)
      d[i][0]=max(d[i][0],max(d[i-1]))
    else:
      d[i][0]=max(d[i][0],max(d[i-1]))
print(max(d[R]))

Measured memory_bytes: 147252
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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

    vector<vector<int>> edge(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            edge[i].push_back(--v);
        }
    }

    queue<int> q;
    vector <int> dist(n, n);
    dist[0] = 0;
    q.push(0);

    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        for (int ch : edge[cur]) {
            if (dist[ch] > dist[cur] + 1) {
                dist[ch] = dist[cur] + 1;
                q.push(ch);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i + 1 << ' ' << (dist[i] == n ? -1 : dist[i]) << '\n';
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

int main(void) {
    int n;
    cin >> n;
    vector<ll> a;
    REP(i, n) {
        ll input;
        cin >> input;
        a.push_back(input);
    }
    sort(ALL(a));

    int ans = a[0];
    while(a.size() >= 2) {
        ans = a[0];
        vector<int> erase_index;
        FOR(i, 1, a.size()) {
            a[i] = a[i] % a[0];
            if (a[i] == 0) {
                erase_index.push_back(i);
            }
        }
        for(int i = erase_index.size()-1; i >= 0; i--) {
            a.erase(a.begin() + erase_index[i]);
        }
        sort(ALL(a));
        // EACH(x, a) {
        //     P(x)
        // }
        // P("===============")
    }
    P(ans);

    return 0;
}


Measured memory_bytes: 1908
#   ?????¢??¨?????¢?????°?????????????????´?????¢?????°???????????????????????°??????

#   ??????????????¢????????????????????????
class Dice:
    def __init__(self):
        self.top = 1
        self.front = 2
        self.right = 3
        self.left = 4
        self.back = 5
        self.bottom = 6
    #   2->1->5->6
    def turnSouth(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self
    #   4->1->3->6
    def turnEast(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self
    #   3->1->4->6
    def turnWest(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self

    #   5->1->2->6
    def turnNorth(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self
    #   2->3->5->4
    def turnRight(self):
        temp = self.front
        self.front = self.right
        self.right = self.back
        self.back = self.left
        self.left = temp
        return self
    #   2->4->5->3
    def turnLeft(self):
        temp = self.front
        self.front = self.left
        self.left = self.back
        self.back = self.right
        self.right = temp
        return self

#   Dice?????????
myDice = Dice()
#   ?????????????????¶????????\???
myDice.top, myDice.front, myDice.right, myDice.left, myDice.back, myDice.bottom = input().split()
#   ???????????°q????¨??????\???????????????
q = int(input())
#   ?????????????????????????????????????????¨??????
#   ??????????±? ?????´??¢ ???????????????????????????(3)
for i in range(0, q):
    #   ????????????????????? ?????¢(1) ?????¢(2)???
    question = list(input())
    question = "".join(question).split()
    #   ?????¢??????????????????????????????
    for j in range(0, 3):
        if question[0] == myDice.top:
            break
        myDice.turnNorth()
    #   ?????¢??????????????????????????????
    for j in range(0, 3):
        if question[0] == myDice.top:
            break
        myDice.turnEast()
    #   ??£??¢???????????????????????¢????????????????????¢
    for j in range(0, 3):
        if question[1] == myDice.front:
            break
        myDice.turnRight()
    print("{0}".format(myDice.right))

Measured memory_bytes: 7796
import java.util.Scanner;

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

		String[] arr = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
		
		String input = sc.next();
		
		int tmp = 0;
		for(String i: arr) {
			if(input.equals(i)) {
				System.out.println(7-tmp);
				return;
			}
			
			tmp++;
		}
	}
}

Measured memory_bytes: 21332
x = gets.to_i
options = [0]
1.upto(200) do |i|
  options << i ** 5
end
options.repeated_combination(2) do |combi|
  a, b = combi
  if a + b == x
    a = options.find_index(a)
    b = options.find_index(b)
    b *= -1
    puts "#{a} #{b}"
    exit
  elsif a - b == x
    a = options.find_index(a)
    b = options.find_index(b)
    puts "#{a} #{b}"
    exit
  elsif b - a == x
    a = options.find_index(a)
    b = options.find_index(b)
    a *= -1
    b *= -1
    puts "#{a} #{b}"
    exit
  elsif (b * - 1) - a == x
    a = options.find_index(a)
    b = options.find_index(b)
    a *= -1
    puts "#{a} #{b}"
    exit
  end
end


Measured memory_bytes: 14372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

double PI=acos(-1);

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    if(a*a*b>=2*x){
        double y=2*x/(a*b);
        double ans=atan(b/y);
        ans=ans*180/PI;
        cout<<fixed<<setprecision(10)<<ans<<endl;
        //cout<<0<<endl;
    }
    else{
        double y=(2*x-a*a*b)/(a*a);
        double ans=atan((b-y)/a);
        ans=ans*180/PI;
        cout<<fixed<<setprecision(10)<<ans<<endl;
        //cout<<1<<endl;
    }
}


Measured memory_bytes: 4032
W, H, x, y, r = map(int, input().split())


def is_hamidasi(W, H, x, y, r):
    if W < x + r:
        return True
    if 0 > x - r:
        return True
    if H < y + r:
        return True
    if 0 > y - r:
        return True
    return False


if is_hamidasi(W, H, x, y, r):
    print("No")
else:
    print('Yes')



Measured memory_bytes: 5600
N = int(input())
a = list(map(int,input().split()))

sum = sum(a)

list_temp = [0 for i in range(10**5)]

for i in range(N):
    list_temp[a[i]-1] += 1

Q = int(input())
ans = [0 for i in range(Q)]

for i in range(Q):
    b, c = list(map(int,input().split()))
    sum += (c-b)*list_temp[b-1]
    list_temp[c-1] += list_temp[b-1]
    list_temp[b-1] = 0
    ans[i] = sum
for i in range(Q):
    print(ans[i])


Measured memory_bytes: 85848
from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit as setreclim
from sys import maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits
 
prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x,y)%mod, l)
 
class Dijkstra:
    """Dijkstra's algorithm : find the shortest path from a vertex
       used in GRL1A(AOJ)
    """
 
    def __init__(self, V, E, start, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list
            start: start vertex
            INF: Infinity distance
        """
        self.V = V
        self.E = E
        self.dijkstra(start, INF)
 
    def dijkstra(self, start, INF):
        que = list()
        self.distance = [INF] * self.V # distance from start
        self.prev = [-1] * self.V # prev vertex of shortest path
        self.distance[start] = 0
        heappush(que, (0, start))
 
        while len(que) > 0:
            dist, v = heappop(que)
            if self.distance[v] < dist: continue
            for to, cost in self.E[v]:
                if self.distance[v] + cost < self.distance[to]:
                    self.distance[to] = self.distance[v] + cost
                    heappush(que, (self.distance[to], to))
                    self.prev[to] = v
 
    def getPath(self, end):
        path = [end]
        while self.prev[end] != -1:
            end = self.prev[end]
        return path[::-1]
 
V, E, r = map(int, input().split())
INF = 10**10
edge = [[] for _ in range(V)]
for i in range(E):
    s, t, cost = map(int, input().split())
    edge[s].append((t, cost))
sp = Dijkstra(V, edge, r, INF)
for d in sp.distance:
    print(d if d != INF else 'INF')

Measured memory_bytes: 95636
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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 P (1'000'000'007)

class UnionFind {
public:
    UnionFind(int n) {
        for (int i = 0; i < n; i++) parent.push_back(i);
    }

    int find(int index) {
        if (is_root(index)) return index;
        return parent[index] = find(parent[index]);
    }

    bool is_root(int index) {
        return parent[index] == index;
    }

    bool has_same_root(int lhs, int rhs) {
        return find(lhs) == find(rhs);
    }

    void unite(int lhs, int rhs) {
        int l = find(lhs);
        int r = find(rhs);
        if (has_same_root(l, r)) return;
        parent[r] = l;
    }

private:
    vector<int> parent;
};

signed main() {
    int n, m;
    cin >> n >> m;

    vi va(n, -1);

    rep(i, n) {
        capi(p); --p;
        va[p] = i;
    }

    UnionFind uf(n);

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        --x; --y;

        uf.unite(x, y);
    }

    int ans = 0;

    rep(i, n) {
        if (uf.has_same_root(i, va[i])) {
            ++ans;
        } 
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4564
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  printf("%d",min(A,B)+min(C,D));
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	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(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/


Measured memory_bytes: 26648
#include <cstdio>
#include <iostream>
using namespace std;
#define CENTINEL 2000000000
#define MAX 200000
typedef long long int llong;
int n,A[200000];
int L[MAX/2+2],R[MAX/2+2];
llong merge(int A[],int left,int mid,int right){
  int na=mid-left;
  int nb=right-mid;
  llong sum=0;
  for(int i=0;i<na;i++)L[i]=A[left+i];
  for(int i=0;i<nb;i++)R[i]=A[mid+i];
  L[na]=R[nb]=CENTINEL;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j])A[k]=L[i++];
    else {A[k]=R[j++];sum+=na-i;}
  }
  return sum;
}
llong mergesort(int A[],int left,int right){
  llong v1,v2,v3;
  if(left+1<right){
    int mid=(left+right)/2;
    v1=mergesort(A,left,mid);
    v2=mergesort(A,mid,right);
    v3=merge(A,left,mid,right);
    return v1+v2+v3;
  } else return 0;
}
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  llong cnt;
  cnt=mergesort(A,0,n);
  printf("%lld\n",cnt);
  return 0;
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int k, a, b;
	cin >> k >> a >> b;
	bool flag = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) flag = true;
	}
	puts(flag ? "OK" : "NG");
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,a,b,c,d; cin>>n>>a>>b>>c>>d; a--; b--; c--; d--;
	string s; cin>>s;
	int run=0;
	for(int i=b;i<=d;i++)
	{
		if(s[i]=='#') run++;
		else run=0;
		if(run>=2)
		{
			cout<<"No\n"; return 0;
		}
	}
	for(int i=a;i<=c;i++)
	{
		if(s[i]=='#') run++;
		else run=0;
		if(run>=2)
		{
			cout<<"No\n"; return 0;
		}
	}
	if(d<c)
	{
		bool pos=0;
		for(int i=b;i<=d;i++)
		{
			if(s[i]!='#')
			{
				if(s[i-1]=='#'||s[i+1]=='#')
				{
					continue;
				}
				else pos=1;
			}
		}
		if(!pos)
		{
			cout<<"No\n"; return 0;
		}
	}
	cout<<"Yes\n";
}


Measured memory_bytes: 592
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  long a=2,b=1;
  int n=sc.nextInt();
  for(int i=0;i<n;i++){
  	long c=a;
    a=b;
    b+=c;
  }
  System.out.println(a);
}

}


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

int main(){
    int n,k;
    cin>>n>>k;
    double ret=0;
    for(int i=1;i<=n;i++){
        double tmp=1.0/n;
        int now=i;
        while(now<k){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }
    cout<<fixed<<setprecision(12)<<ret<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =  long long;
const ll INTF = 1e18L + 7;

int main() {

   int n;
   cin >> n;

   vector<ll> v(n ,0);
   for(int i=0; i<n; i++)
    cin >> v[i];

   ll dp[405][405];

   auto sum = [&](int l ,int r){
        ll s =0 ;
        for(int i=l; i<=r; i++)
            s += v[i];
        return s;
   };

   for(int i=n-1; i>=0; i--)
   {
    for(int j=i; j<n; j++)
    {
        if(i == j)
            dp[i][j] = 0;
        else
        {
            dp[i][j] = INTF;
            ll sm = sum(i, j);
            for(int k=i; k<=j-1; k++)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sm);
        }
    }
   }
    
    cout<<dp[0][n-1];
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

ll n,q,k,d;
ll low[1252525], high[1252525];

int main(){
  scanf("%lld%lld%lld%lld",&n,&q,&k,&d);
  --k;--d;
  low[0] = high[0] = d;
  REP(i,q){
    low[i+1] = n; high[i+1] = -1;
    {
      ll x = low[i];
      if(x>=n/2)x-=n/2;
      CHMIN(low[i+1], 2*x);
      CHMAX(high[i+1], 2*x+1);
    }
    {
      ll x = high[i];
      if(x>=n/2)x-=n/2;
      CHMIN(low[i+1], 2*x);
      CHMAX(high[i+1], 2*x+1);
    }
    if(low[i]<=n/2-1 && n/2-1<=high[i]){
      ll x = n/2-1;
      if(x>=n/2)x-=n/2;
      CHMIN(low[i+1], 2*x);
      CHMAX(high[i+1], 2*x+1);
    }
    if(low[i]<=n/2 && n/2<=high[i]){
      ll x = n/2;
      if(x>=n/2)x-=n/2;
      CHMIN(low[i+1], 2*x);
      CHMAX(high[i+1], 2*x+1);
    }
  }
  if(k<low[q] || k>high[q]){
    puts("-1");return 0;
  }
  ll x = k;
  FORR(i,0,q){
    if(low[i]<=x/2 && x/2<=high[i]){
      puts(x%2==0 ? "0" : "1");
      x = x/2;
    }else{
      puts(x%2==0 ? "1" : "0");
      x = x/2 + n/2;
    }
  }
  assert(x == d);
  return 0;
}



Measured memory_bytes: 17352