akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[] str = new char[1100];
	static int N;
	static HashSet<String> outer = new HashSet<String>();
	static HashSet<String> inner = new HashSet<String>();

	public static void main(String[] args) {
		while (sc.hasNextLine()) {
			N = 0;
			outer.clear();
			inner.clear();
			for (char c : sc.nextLine().toUpperCase().toCharArray()) {
				if ('A' <= c && c <= 'Z') {
					str[N++] = c;
				}
			}
			for (int i = 0; i + 2 < N; i++) {
				if (str[i] == str[i + 2]) {
					solve(i, i + 2);
				}
			}
			for (int i = 0; i + 3 < N; i++) {
				if (str[i] == str[i + 3] && str[i + 1] == str[i + 2]) {
					solve(i, i + 3);
				}
			}
			outer.removeAll(inner);
			String[] ans = outer.toArray(new String[0]);
			if (ans.length > 0) {
				System.out.print(ans[0]);
			}
			for (int i = 1; i < ans.length; ++i) {
				System.out.print(" " + ans[i]);
			}
			System.out.println();
		}
	}

	static void solve(int l, int r) {
		while (l > 0 && r < N - 1 && str[l - 1] == str[r + 1]) {
			inner.add(String.valueOf(str, l, r - l + 1));
			--l;
			++r;
		}
		outer.add(String.valueOf(str, l, r - l + 1));
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<cmath>

using namespace std;

const long long MOD = 998244353;

long long powmod(long long n,long long k){
    k%=MOD-1;
    if(k<0)k+=MOD-1;
    long long ret=1;
    while(k){
        if(k&1)ret=ret*n%MOD;
        n=n*n%MOD;
        k>>=1;
    }
    return ret;
}

int main()
{
    int N,a[110000],key;
    cin >> N;
    for (int i=0; i<N; ++i)
    {
        cin >> key;
        ++a[key];
        if (i==0 && key != 0)
        {
            cout << 0 << endl;
            return 0;
        } 
    }

    if(a[0] != 1)
    {
        cout << 0 << endl;
        return 0;
    }

    // long long ans = 1;
    // int sum = 0;
    // for (int i=1; i<N; ++i)
    // {
    //     if(a[i-1]==0 && a[i]>0)
    //     {
    //         cout << 0 << endl;
    //         return 0;
    //     }
    //     if(a[i-1]>0 && a[i]==0)
    //     {
    //         for(int j=i; j<N; ++j)
    //         {
    //             sum += a[j];            
    //         }
    //         if(sum != 0)
    //         {
    //             cout << 0 << endl;
    //             return 0;
    //         }
    //         else
    //         {
    //             cout << ans << endl;
    //             return 0;
    //         }
    //     }
    //     long long tmp = (long long)pow(a[i-1],a[i]) % MOD;
    //     ans *= tmp;
    //     ans %= MOD; //取り忘れ 
    // }

    long long ans = 1;
    int sum = 0;
    for (int i=0; i<N; ++i)
    {
        // long long tmp = (long long)pow(a[i],a[i+1]) % MOD;
        long long tmp = powmod(a[i],a[i+1]);
        ans *= tmp;
        ans %= MOD; //取り忘れ
        sum += a[i]; 
        if(a[i+1]==0) break;
    }
    if(sum != N) cout << 0 << endl;
    else cout << ans << endl;
    // cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
vector<int> x_dire = {0,0,-1,1};
vector<int> y_dire = {-1,1,0,0};
int main(){

    ll h,w,m;
    cin >> h >> w >> m;
    map<ll,ll> datax;
    map<ll,ll> datay;
    if(m==0){
        cout<<0<<endl;
        return 0;
    }
    vector<set<int>> cntx(h);
    //vector<set<int>> cnty(h);
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        datax[a]++;
        datay[b]++;
        cntx[a].insert(b);

    }
    ll max_x = -1;
    ll max_y = -1;
    for(auto p = datax.begin();p!=datax.end();p++){
        max_x = max(max_x,p->second);
    }
    for(auto p = datay.begin();p!=datay.end();p++){
        max_y = max(max_y,p->second);
    }
    //cout<<max_x<<max_y<<endl;
    queue<ll> kouho_x;
    queue<ll> kouho_y;
    for(auto p = datax.begin();p!=datax.end();p++){
        if(p->second==max_x){
            kouho_x.push(p->first);
            
        }
    }
    for(auto p = datay.begin();p!=datay.end();p++){
        if(p->second==max_y){
            kouho_y.push(p->first);
        }
    }
    ll ans = -1;
    while(!kouho_x.empty()){
        ll x = kouho_x.front();
        ll y;
        queue<ll> next = kouho_y;
        while(!kouho_y.empty()){
            y = kouho_y.front();
            if(!cntx[x].count(y)){
                ans = max_x+max_y;
                cout<<ans<<endl;
                return 0;
            }
            kouho_y.pop();
        }
        kouho_y = next;
        kouho_x.pop();
    }
    cout << max_x+max_y-1<<endl;
    return 0;


    
    

}

Measured memory_bytes: 76372
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q4
int main()
{
	int nN;
	cin >> nN;
	int arr[200000];
	memset(arr, 0, sizeof(arr));

	for (int i = 0; i < nN; i++)
		cin >> arr[i];

	int nK = 0;
	int nCur = 0;
	for (int i = 0; i < nN; i++)
	{
		if (nCur + 1 != arr[i])
			nK++;
		else
			nCur = arr[i];
	}
	if(nN == nK)
		cout << -1;
	else
		cout << nK;
	return 0;
}

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

int main() {
    int n,m,s;
    cin >> n >> m; // switch ligjt
    vector<int> swnum (m);
    vector<vector<int>> ls (m);
    vector<int> p (m);
    for(int i=0; i<m; i++){
        cin >> swnum.at(i);
        for(int j=0; j<swnum.at(i); j++){
            cin >> s;
            s--;
            ls.at(i).push_back(s);
        }
    }
    for(int i=0; i<m; i++){
        cin >> p.at(i);
    }
    int ans = 0;
    int count;
    for(int b=0; b<(1<<n); b++){
        bool judge = true;
        for(int i=0; i<m; i++){
            count = 0;
            for(int j=0; j<swnum.at(i); j++){
                if((b >> ls.at(i).at(j))&1){
                    count++;
                }
            }
            if(count%2 != p.at(i)){
                judge = false;
            }
        }
        if(judge){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define pb push_back 
#define sc second 
#define f first 
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 305;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;
using namespace std;
int divide(int a, int b)
{
          return (a+b-1)/b;
}
vector<vector<int>> adj;
vector<bool> used;
void dfs(int s)
{
          if(used[s]) return;
          used[s]=true;
          for(auto x: adj[s]) 
          {
                    dfs(x);
          }
}
int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 fast;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
        int n,m;
        cin>>n>>m;
        adj.resize(n+2);
        used.resize(n+2);
        fill(all(used),0);
        while(m--) 
        {
                  int a,b;
                  cin>>a>>b;
                  adj[a].pb(b);
                  adj[b].pb(a);
        }
        int ans=0;
        for(int i=1;i<=n;i++) 
        {
                  if(used[i]) continue;
                   ans++;
                  dfs(i);
        }
        cout<<ans-1;
    
 }
    
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}

Measured memory_bytes: 9268
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005


int main() {
    int k;
    int a, b;
    cin >> k >> a >> b;
    for (int i = 0; i <= b; i += k) {
        if (a <= i) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
h,w=gets.chomp.split.map(&:to_i)
a = []
h.times do
    a << gets.chomp.split.map(&:to_i)
end

prev_i = -1
prev_j = -1

ans = []
0.upto(h-1) do |i|
    if i%2==0
        0.upto(w-1) do |j|
#            printf("%d %d\n",i,j)            
            if a[i][j] % 2 != 0
                if prev_i == - 1
                    prev_i = i
                    prev_j = j
                else
                    ans << [prev_i+1, prev_j+1, i+1, j+1]
                    prev_i = -1
                    prev_j = -1
                end
            end
        end
    else
        (w-1).downto(0) do |j|
#            printf("%d %d\n",i,j)
            if a[i][j] % 2 != 0
                if prev_i == - 1
                    prev_i = i
                    prev_j = j
                else
                    ans << [prev_i+1, prev_j+1, i+1, j+1]
                    prev_i = -1
                    prev_j = -1
                end
            end
        end
    end
end
#p ans

s = []
t = [] 

ans.each do |v|
    pi, pj, ti, tj = v

    while(pi != ti || pj != tj)
        s << [pi, pj]
#        p [pi, pj]
        if pi == ti
            if pi % 2 != 0
                pj += 1
            else
                pj -= 1
            end
        else
            if pi %2 != 0
                if pj == w
                    pi += 1
                else
                    pj += 1
                end
            else
                if pj == 1
                    pi += 1
                else
                    pj -= 1
                end
            end
        end                        

        t << [pi, pj]
 #       p [pi, pj]
    end
end

puts s.size
0.upto(s.size-1) do |i|
    printf("%d %d %d %d\n", s[i][0],s[i][1],t[i][0],t[i][1])
end


Measured memory_bytes: 36988
def main():
    n, k = map(int, input().split())
    h = [0] + list(map(int, input().split()))

    INF = 10 ** 12
    dp = [INF] * (n + 1)
    dp[1] = 0

    for i in range(1, n):
        for j in range(1, k + 1):
            if i + j <= n:
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84888
s = input()
ans = [0] * len(s)
bef_step = "R"
step_count = 0
prev_pos = 0
for i in range(len(s)):
    if(s[i] == "L" and bef_step == "R"):
        prev_pos = i - 1
        ans[i-1] += (step_count + 1) // 2
        ans[i] += step_count // 2
        step_count = 1
    elif(s[i] == "R" and bef_step == "L"):
        ans[prev_pos] += step_count // 2
        ans[prev_pos + 1] += (step_count + 1) // 2
        step_count = 1
    else:
        step_count += 1
    bef_step = s[i]
ans[prev_pos] += step_count // 2
ans[prev_pos + 1] += (step_count + 1) // 2
print(" ".join(str(e) for e in ans))


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

#define ll long long

int n, w;
vector<pair<int, int>> arr; // weight, value
vector<vector<ll>> dp;

ll getMaxVal(int index, int weight) {
	if (index >= n || weight == 0) {
		return 0;
	}
	ll result = 0;
	if (dp[index][weight] != -1) {
		return dp[index][weight];
	}
	if (weight >= arr[index].first) {
		result = arr[index].second + getMaxVal(index + 1, weight - arr[index].first);
	}
	result = max(result, getMaxVal(index + 1, weight));
	return dp[index][weight] = result;
}

int main() {
	cin >> n >> w;
	arr = vector<pair<int, int>> (n);
	dp = vector<vector<ll>> (n, vector<ll> (w + 1, -1));
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		arr[i] = make_pair(a, b);
	}
	cout << getMaxVal(0, w) << endl;
}

Measured memory_bytes: 82396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説を思い出しながら自分で書く
const int INF=1001001001;
vector<int>to[100005];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    --a;--b;//1を引く
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue <int>q;
  vector<int>dist(n,INF);//距離
  vector<int>pre(n,-1);//直前の頂点
  q.push(0);
  dist[0]=0;
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0)continue;
    int ans=pre[i];
    ++ans;
    cout<<ans<<endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 10564
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i * i <= n; i++){
        int m = n - i;
        if(m % i){
            continue;
        }
        if(m/i <= i){
            continue;
        }
        ans += m / i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	char c[20];
	int n=0;
	
	while(cin>>c[n])n+=1;
	
	for(int i=n-1;i>=0;i--)cout<<c[i];
	cout<<endl;
	
	return 0;
}

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

int main(){

  while(1){

    int N, M, l[30], tre[21][21] = {0}, x[30], y[30], xx = 10, yy = 10, cnt = 0;
    char d[30];

    cin >> N;
    if(N == 0)break;

    for(int i = 0; i < N; i++){
      cin >> x[i] >> y[i];
      tre[x[i]][y[i]] = 1;
    }
    
    cin >> M;
    
    for(int i = 0; i < M ; i++){
      cin >> d[i] >> l[i];
      if(d[i] == 'N'){
	for(int n = 0; n < l[i]; n++){
	  yy+=1;
	  if(tre[xx][yy] == 1) tre[xx][yy] = 3;
	  //  cout << xx << yy << endl;
	}
      }else if(d[i] == 'S'){
	for(int n = 0; n < l[i]; n++){
	  yy-=1;
	  if(tre[xx][yy] == 1) tre[xx][yy] = 3;
	}
      }
      else if(d[i] == 'E'){
	for(int n = 0; n < l[i]; n++){
	  xx+=1;
	  if(tre[xx][yy] == 1) tre[xx][yy] = 3;
	  // cout << xx << yy << endl;
	}
      }
      else if(d[i] == 'W'){
	for(int n = 0; n < l[i]; n++){
	  xx-=1;
	  if(tre[xx][yy] == 1) tre[xx][yy] = 3;
	  
	}
      }
    }
    for(int i = 0; i < 21; i++){
      for(int j = 0; j < 21; j++){
	//	if(tre[i][j] == 3) cnt++;
	if(tre[i][j] == 3) cnt++;
      }
    }
       if(cnt == N) cout << "Yes" << endl;
    else cout << "No" << endl;
    //    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
using System;

namespace CA {
	class Prg {
		static void Main() {
			string[] s = Console.ReadLine().Split(' ');
            byte a = byte.Parse(s[0]);
            byte b = byte.Parse(s[1]);
            byte c = byte.Parse(s[2]);
            if ((a < b) & (a < c) & (b < c))
            {
                Console.WriteLine("Yes");
				return;
            }
                Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 9712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  int A, B; cin >> A >> B;
  if (B % A == 0) {
    cout << (A + B) << endl;
  } else {
    cout << (B - A) << endl;
  }
}


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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
	int b,f,r,v,n,i,j,k;
	int X[5][5][20]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		X[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<10;k++)
			{
		 		printf(" %d",X[i][j][k]);
			}
			printf("\n");
		}
		if(i<3) printf("####################\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int n,a[1000005];
multiset<int>fre,cur,tmp;

int main()
{
    SPEED;

    cin>>n;
    for(int i=1;i<=(1<<n);i++)
    {
        cin>>a[i];
        fre.insert(a[i]);
    }

    cur.insert(*fre.rbegin());
    fre.erase(fre.find(*fre.rbegin()));
    for(int h=0;h<n;h++)
    {
        tmp.clear();
        for(auto j:cur)
        {
            auto h=fre.lower_bound(j);
            if(h==fre.begin())
                return cout<<"No"<<endl,0;
            h--;
            tmp.insert(*h);
            fre.erase(h);
        }
        for(auto j:tmp)
            cur.insert(j);
    }

    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 19712
// Math = ♥️

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
// #define ordered_set                            \
//     tree<ll, null_type, less<ll>, rb_tree_tag, \
//          tree_order_statistics_node_update>

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    vb seive(n + 1, true);
    seive[0] = false;
    vi smol(n + 1);
    iota(all(smol), 0);

    for (int i = 2; i * i <= n; i++) {
        if (seive[i]) {
            for (int j = i * i; j <= n; j += i) {
                seive[j] = false;
                smol[j] = min(smol[j], (ll)i);
            }
        }
    }

    vi dp(n + 1, 2);
    dp[1] = 1;
    ll ans = 1;
    for (int i = 2; i <= n; i++) {
        if (seive[i]) {
            ans += i * 2;
        } else {
            ll curr = smol[i];
            ll x = i;
            ll how = 1;
            ll count = 0;
            while (smol[x] == curr) {
                x /= curr;
                how *= curr;
                count++;
            }

            if (x != 1) {
                dp[i] = dp[how] * dp[x];
                ans += (i * dp[i]);
            } else {
                dp[i] = count + 1;
                ans += (i * dp[i]);
            }
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 160800
N = int(input())
K = int(input())
x = list(map(int,input().split()))
lists = []
result = 0
for i in range(N):
    min = x[i] * 2
    num = x[i] - K
    B = abs(num) * 2
    if min > B:
        lists.append(B)
    else:
        lists.append(min)
    result += lists[i]
print(str(result))

Measured memory_bytes: 3064
N, K = map(int, input().split())

cnt = 0
while 2 ** cnt < K:
    cnt += 1

res = 0
for i in range(1, N + 1):
    while i * (2 ** cnt) >= K and cnt >= 0:
        cnt -= 1
    cnt += 1
    res += 1 / ((2 ** cnt) * N)

print("{:.12g}".format(res))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200010];
long long ans=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		 
	}
	for(int i=2;i<=n;i++){
		 if(a[i]<a[i-1]){
		 	ans+=a[i-1]-a[i];
		 	a[i]=a[i-1];
		 }
	}
	cout<<ans<<endl; 
	return 0;
} 

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

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

    long long n,d;
    cin >>n>>d;

    int pts = 0;
    ll a,b;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if( a*a + b*b <= d*d)
            pts++;
    }

    cout<<pts<<endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    
    int n;
    cin>>n;

    vector <pair<int,int> > vec;

    for(int i=0;i<n;i++) {
        int x;
        cin>>x;
        vec.pb({x,i});
    }

    sort(vec.begin(),vec.end());

    for(auto it:vec) {
        cout<<it.second+1<<" ";
    }
    
    return 0;
}

Measured memory_bytes: 1780
#include "bits/stdc++.h"
using namespace std;

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

string s;
int n,ind=0;
string w = "keyence";

int main(){
  cin>>s;
  n=s.size();
  bool bl=true;
  FOR(i,n-7,n){
    if(s[i]!=w[i-(n-7)]){
      bl=false;
      break;
    }
  }
  if(bl){
    cout<<"YES"<<endl;
    return 0;
  }

  bl=true;
  FOR(i,0,7){
    if(s[i]!=w[i]){
      bl=false;
      break;
    }
  }
  if(bl){
    cout<<"YES"<<endl;
    return 0;
  }

  bl=true;
  REP(i,7){
    if(s[i]!=w[i]){
      ind=i;
      break;
    }
  }
  REP(i,7-ind){
    if(s[n-1-i]!=w[7-1-i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
from itertools import accumulate

Q = int(input())
LR = []

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    # print(int(math.sqrt(n)))
    for i in range(2,int(math.sqrt(n))+1):
        for j in range(i*2, n+1 ,i):
            is_prime[j] = False

    return is_prime

def like2017(is_prime,n):
    solve = [0] * (n+1)
    for i in range(3,n+1,2):
        if is_prime[i] and is_prime[int((i+1)/2)]:
            solve[i] = 1
        
    return solve

for _ in range(Q):
    t = [int(i) for i in input().split(' ')]
    LR.append(t)

L = 10 ** 5
is_prime = primes(L)
solve = like2017(is_prime,L)
# print(solve)
ans = list(accumulate(solve))
# print(ans)

for l, r in LR:
    print(ans[r] - ans[l-1])

Measured memory_bytes: 26544
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=2e5+5;
struct edge{int u,v,next;}e[N*2];
int head[N],cnt;
int dep[N],x,y;
int n,m;
void add_edge(int u,int v){
	e[++cnt]=(edge){u,v,head[u]};
	head[u]=cnt;
}
void dfs(int u,int fa){
	dep[u]=dep[fa]+1;
	if(dep[u]>dep[x]) x=u;
	for(int i=head[u];i;i=e[i].next)
		if(e[i].v!=fa) dfs(e[i].v,u);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	memset(dep,0,sizeof dep);
	dfs(x,0);
	if(dep[x]<3) puts(dep[x]==1 ? "First" : "Second");
	else puts(dep[x]%3==2 ? "Second" : "First");
}

Measured memory_bytes: 12800
def solve(s):
    odd = 0
    even = 0
    for c in s:
        if c == "0":
            even += 1
        else:
            odd += 1
    return 2*min(even, odd)

assert solve("0011") == 4
assert solve("11011010001011") == 12
assert solve("0") == 0

s = input()
print(solve(s))



Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;

const int INF = 1e9;
typedef long long ll;

int main(void){
  int L, A, B, C, D;
  cin >> L >> A >> B >> C >> D;
  int DA = (A % C == 0) ? A / C : A / C + 1;
  int DB = (B % D == 0) ? B / D : B / D + 1;
  cout << L - max(DA, DB) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <string>
#include <iostream>

std::string s[200];

int main()
{
	int h,w;
	std::cin >> h >> w;
	for(int i=1;i<=h;i++)
		std::cin >> s[i];
	for(int i=1;i<=2*h;i++)
	{
		int on=(i+1)/2;
		for(int j=0;j<w;j++)
			std::cout << s[on][j];
		std::cout << '\n';
	}
}

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

using namespace std;

#define ll long long
ll a[200010];

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d)
    {
        cout << "Yes" << endl;
    }
    else if(abs(a-b)<=d && abs(b-c)<=d)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3636
whn = input().split()
w = int(whn[0])
h = int(whn[1])
n = int(whn[2])

x = []
y = []
a = []

for i in range(n):
	xya = input().split()
	x.append(int(xya[0]))
	y.append(int(xya[1]))
	a.append(int(xya[2]))

wo = 0
ho = 0
for i in range(n):
	if a[i] == 1:
		if wo < x[i]:
			wo = x[i]
			
	if a[i] == 2:
		if x[i] < w:
			w = x[i]
			
	if a[i] == 3:
		if ho < y[i]:
			ho = y[i]
		
	if a[i] == 4:
		if y[i] < h:
			h = y[i]
		
		
if w <= wo or h <= ho:
	ans = 0
else:
	ans = (w - wo)*(h - ho)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
#define vi vector<int>
#define rep(i, xtz, n) for(int i=xtz; i<n; i++)
#define repx(i, xtz, n) for(int i=xtz; i>n; i--)
#define lli long long int

using namespace std;

int main(){
    //freopen("i.in", "r", stdin);
    int n;
    cin>>n;
    vector<double> vec(n+1);
    rep(i, 0, n) cin>>vec[i+1];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    rep(i, 0, n+1){
        rep(j, 0, i+1){
            if(i==0 && j==0) dp[i][j]=1;
            else if(j==0) dp[i][j] = dp[i-1][j] * (1 - vec[i]);
            else if(j==i) dp[i][j] = dp[i-1][j-1] * vec[i];
            else{
                dp[i][j] = (dp[i-1][j-1] * vec[i]) + (dp[i-1][j] * (1 - vec[i]));
            }
        }
    }
    double count=0.0;
    rep(i, n/2+1, n+1) count+=dp[n][i];
    //cout.setf(ios::fixed);
    cout<<setprecision(10)<<count; 
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,ans;
string s[100010];

int main()
{

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

    cin >> n;
    for(ll i=0; i<n; i++) cin >> s[i] , sort( s[i].begin() , s[i].end() );
    sort( s , s+n );

    for(ll i=0; i<n; i++){
        ll j;
        for(j=i+1; j<n; j++){
            if( s[j]!=s[i] ) break;
        }

        ans+=((j-i)*(j-i-1))/2;
        i = j-1;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#define INF 10000000
 
int matrixChainOrder(int *p, int n){
  int i, j, k, l,  m[100][100], q;
  for(i = 1; i <= n; i++)
    m[i][i] = 0;
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k = i; k < j; k++){
    q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
    if(m[i][j] > q) m[i][j] = q;
      }
    }
  }
  return m[i-1][j];
}
 
int main(){
  int i, n, p[100];
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d %d",&p[i], &p[i+1]);
  printf("%d\n",matrixChainOrder(p,n));
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    rrrep(i,100,1){
        ll now=i;
        rep(j,n){
            if(now<=a[j])cnt++;
        }
        if(cnt>=now){
            Cout(now);
            return 0;
        }
        cnt=0;
    }
    return 0;
}


Measured memory_bytes: 3192
candidates = []
seps = ["KIH", "B", "R", ""]
for i in range(1 << 4):
    has_A = []
    for j in range(4):
        if i >> j & 1:
            has_A.append("A")
        else:
            has_A.append("")
    candidate = []
    for a, sep in zip(has_A, seps):
        candidate.append(a + sep)
    candidates.append("".join(candidate))

print("YES") if input() in candidates else print("NO")


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    int n; cin>>n;
    vector<int> b(n-1);
    rep(i,n-1) cin>>b[i];

    vector<int> a(n,0);
    for(int i=0; i<=n-2; i++){
        if(i==0){
            a[i]=b[i];
        }
        a[i+1]=min(b[i],b[i+1]);
    }
    a[n-1]=b[n-2];
    ll ans=0;
    rep(i,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> P(N);
    REP(i, N) cin >> P[i];
    vector<ll> Q(N);
    REP(i, N) Q[P[i]-1] = i;

    multiset<ll> st;
    st.insert(-1);
    st.insert(-1);
    st.insert(N);
    st.insert(N);

    ll res = 0;
    for(int q=N-1;q>=0;q--){
    	ll idx = Q[q];
    	ll tmp = 0;
    	auto migi = st.lower_bound(idx);
        auto migi2 = next(migi);
    	auto hidari = prev(migi);
        auto hidari2 = prev(hidari);
    	tmp += (*migi - idx)*(*hidari - *hidari2);
    	tmp += (*migi2 - *migi)*(idx-*hidari);
    	res += (q+1)*tmp;
    	st.insert(idx);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll INF = 1000000000000000000ll;

int main()
{
  int n;
  cin>>n;
  vector<int64_t> a(n);
  for(auto&& e:a) cin>>e;
  ll mn = INF;
  vector<int64_t> psum(n+1);
  partial_sum(ALL(a), begin(psum)+1);
  FOR(i,2,n-1) {
    ll x = psum[i];
    ll y = psum.back() - x;
    auto idx1 = lower_bound(begin(psum),begin(psum)+i+1,(x+1)/2) - begin(psum);
    ll p = psum[idx1], q = x-p;
    ll lg1 = INF;
    ll sm1 = 0;
    if (idx1 < i) {
      lg1 = min(lg1, max(p, q));
      sm1 = max(sm1, min(p, q));
    }
    if (idx1>1) {
      --idx1;
      p = psum[idx1];
      q = x-p;
      lg1 = min(lg1, max(p, q));
      sm1 = max(sm1, min(p, q));
    }
    auto idx2 = lower_bound(begin(psum)+i,end(psum),x+(y+1)/2) - begin(psum);
    ll r = psum[idx2]-x, s = y-r;
    ll lg2 = INF;
    ll sm2 = 0;
    if (idx2 < n) {
      lg2 = min(lg2, max(r, s));
      sm2 = max(sm2, min(r, s));
    }
    if (idx2>i+1) {
      --idx2;
      r = psum[idx2]-x;
      s = y-r;
      lg2 = min(lg2, max(r, s));
      sm2 = max(sm2, min(r, s));
    }
    ll lg = max(lg1, lg2);
    ll sm = min(sm1, sm2);
    mn = min(mn, lg - sm);
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
double N,K,a,p,s;
int main(){
  cin>>N>>K;
  for(int i=1;i<=N;i++){
    p=1/N;
    s=i;
    while(s<K){
      s*=2;
      p*=0.5;
    }
    a+=p;
  }
  printf("%.10f\n",a);
  return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=305;
double n;
double f[N][N][N];
int sum[3],a[N];
double dfs(int x,int y,int z){
	if(x==0&&y==0&&z==0) return 0;
	if(f[x][y][z]) return f[x][y][z];
	double ans=1.0*n/(x+y+z);
	if(x) ans+=(1.0*x/(x+y+z))*dfs(x-1,y+1,z);
	if(y) ans+=(1.0*y/(x+y+z))*dfs(x,y-1,z+1);
	if(z) ans+=(1.0*z/(x+y+z))*dfs(x,y,z-1);
	return f[x][y][z]=ans;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),sum[a[i]]++;
	printf("%.10lf",dfs(sum[3],sum[2],sum[1]));
}
/*
f[i][j][k]表示有i个3，j个2，k个1
*/

Measured memory_bytes: 219392
lst=[]
for i in range(6):
    n=int(input())
    lst.append(n)

lst1=lst[0:4]
lst2=lst[4:6]
lst1.sort(reverse=True)
lst3=lst1[0:3]
a=sum(lst3)
b=max(lst2)

print(a+b)



Measured memory_bytes: 5600
a, b, c = map(int, input().split())

if a > b:
    if b < c and c < a:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    if a < c and c < b:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

Measured memory_bytes: 2940
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, a, b) = get!(i32, i32, i32);
    println!("{}", if (x - a).abs() < (x - b).abs() { "A" } else { "B" });
}

Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    string S; cin >> S;
    vec w(N + 1, 0);
    REP(i, N){
        if(S[i] == '.') w[i + 1] = w[i] + 1;
        else w[i + 1] = w[i];
    }
    int ans = INF;
    REP(i, N + 1){
        Min(ans, i - w[i] + w[N] - w[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2196
//
//AtCoder Beginner Contest 177
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

using Graph = vector<vector<int>>;

int main()
{
    int N, M;
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    REP(m, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans =0;
    vector<int> seen(N, -1);
    REP(i, N){
        if (seen[i]!=-1) continue;

        queue<int> que;
        seen[i] = 0;
        que.push(i);
        int cnt=0;
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int nv : G[v]) {
                if (seen[nv] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                seen[nv] = seen[v] + 1;
                cnt++;
                que.push(nv);
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans+1 << endl;
    return 0;
}


Measured memory_bytes: 15612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,a[100100],memo[100100][2];
bool done[100100][2];

int solve(int p, int k){
	if(done[p][k]){
		return memo[p][k];
	}
	done[p][k] = true;
	if(p == n){
		return memo[p][k] = 1;
	}
	if(a[p] == a[p+1] || ((a[p]<a[p+1])^k)){
		return memo[p][k] = min(solve(p+1,k),solve(p+1,1-k)+1);
	}else{
		return memo[p][k] = min(solve(p+1,k),solve(p+1,1-k))+1;
	}
}

int main(void){
	int i;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	--n;
	cout << min(solve(0,0),solve(0,1)) << endl;
	return 0;
}


Measured memory_bytes: 7808
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int n,q;
    cin>>n>>q;
    atcoder::dsu uf(n);
    for (size_t i = 0; i < q; i++)
    {
        int t,u,v;
        cin>>t>>u>>v;
        if(t)
        {
            cout<<uf.same(u,v)<<endl;
        }
        else
        {
            uf.merge(u,v);
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3868
object Main extends App {
  import scala.io.StdIn._
  
  val Array(n,k) = readLine.split(" ").map{_.toInt}.toArray
  val check = Array.fill(n+1)(false)
  check(0) = true
                              
  for (i <- 1 to k) {
    val d = readInt
    val a = readLine.split(" ").map{_.toInt}.toList
    a.foreach{x => check(x) = true}
  }
  
  println(check.count{x => !x})
                                         
}

Measured memory_bytes: 54876
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    int N, A[200005], B[200005] = {0};

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

    for (int i = 1; i <= N; i++) {
        cout << B[i] << endl;
    }

    return 0;
}


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

int main() {
  int n = 0;
  int a = 0;
  int square = 0;
  int black = 0;
  cin >> n;
  cin >> a;
  square = n * n;
  black = square - a;
  
  cout << black << endl;
}
  

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        Console.WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
    }
}



Measured memory_bytes: 11220