akhauriyash/Code-Regression huggingface dataset:
#
import sys
import math
import numpy as np
import itertools


# ひとつ入力
n = int(input())

# リストに入れる
h = list(input()) 

lb = [0]*len(h)
rw = [0]*len(h)
b=0
w=0
for i in range(len(h)):
    if h[i]=="#":
        b += 1
    lb[i] = b

for i in range(len(h)-1,-1,-1):
    if h[i]==".":
        w += 1
    rw[i] = w
answer = rw[0]
for i in range(len(h)-1):
    answer = min(answer,lb[i]+rw[i+1])
answer = min(answer,lb[len(h)-1])
#print(lb,rw)
print(answer)



Measured memory_bytes: 23172
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int> > ruiseki(N+1, vector<int>(N+1, 0));
    REP(i, M){
        int L, R;
        cin >> L >> R;
        ruiseki[L][R]++;
    }
    //二次元累積和table作成
    for(int i=1; i<N+1; i++){
        for(int j=1; j<N+1; j++){
            ruiseki[i][j] += ruiseki[i][j-1];
            ruiseki[i][j] += ruiseki[i-1][j];
            ruiseki[i][j] -= ruiseki[i-1][j-1];
        }
    }

    REP(i, Q){
        int p, q;
        cin >> p >> q;
        cout << ruiseki[q][q] - ruiseki[q][p-1] - ruiseki[p-1][q] + ruiseki[p-1][p-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int c[100];
int ams(long a){
    int i=0;
    int tmp;
    while(a){
      tmp=a%10;
      c[i]=tmp;
      a=a/10;
      i++;
    }
    return i;
  }
int main(){
  long int b;
  cin >> b;
  int size=ams(b)+1;
  int tmp;
  int sa=10000;
  for(int i=size-2;i!=1;i--){
    tmp=c[i]*100+c[i-1]*10+c[i-2];
    int a=abs(tmp-753);
    if(sa>a){
      sa=a;
    }
  }
  cout << sa << endl;
  return 0;
}


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

int main() {
	long long a, b;
	cin >> a >> b;
	vector<long long>A(a);
	for (long long i = 0; i < a; i++) {
		cin >> A.at(i);
	}
	a--; b--;
	long long ans;
	ans = a / b;
	if (a % b != 0) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    int n;
    cin >> n;
    int h[n+1]={};
    for (int i=1; i<=n; i++) {
        cin >> h[i];
    }
    int dp[n+1]={};
    dp[2] = dp[1] + abs(h[1]-h[2]);
    for (int i=3; i<=n; i++) {
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }
    cout << dp[n] << '\n';
    return 0;
}


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

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

    std::vector<int> vec(n + 1);
    vec.at(0) = 1;
    vec.at(1) = 1;
    for(int i = 2; i <= n; ++i){
        vec.at(i) = vec.at(i - 1) + vec.at(i - 2);
    }

    std::cout << vec.at(n) << std::endl;

    return 0; 
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin >> a >> b;
  int n = a.length();
  int m = b.length();
  int dp[n+1][m+1];
  memset(dp, 0, sizeof dp);
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if (i == 0 || j == 0){
	dp[i][j] = 0;  
      }else if (a[i-1] == b[j-1]){
	dp[i][j] = dp[i - 1][j - 1] + 1;
      }else{
	dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }  
  }
  int x = n,y = m;
  string ans = "";
  while(x>0 && y>0){
    if(a[x-1]==b[y-1]){
      ans.push_back(a[x-1]);
      x--;
      y--;
    }else{
      if(dp[x-1][y]>dp[x][y-1]){
	x--;
      }else{
	y--;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans<<'\n' ;

    
  return 0;
}


Measured memory_bytes: 38776
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: h,a,counter
      
      read*,h,a
      counter = 0
      
      do while( .true. )
        h = h - a
        counter = counter + 1
        if( h<= 0 ) exit
      end do
      
      print*,counter
      
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k;
    double ans = 0;
    Rep(i, 1, n + 1)
    {
        double tmp = 1.0 / n;
        int cur = i;
        while(cur < k)
        {
            cur *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    vector<vector<vector<lint>>> dp(N, vector<vector<lint>>(4, vector<lint>(4, -1e15)));
    dp[0][0][0] = A[0];
    dp[0][1][1] = 0;
    FOR(i, 1, N) {
        REP(j, 4) {
            dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][1]+A[i]);
            dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][2]+A[i]);
            dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][3]+A[i]);
        }
        REP(j, 4) {
            if(i == N-1) {
                if(j != 3) dp[i][j+1][1] = dp[i-1][j][0];
            } else {
                dp[i][j][1] = dp[i-1][j][0];
            }
            
        }
        REP(j, 3) {
            if(i == N-1) {
                if(j != 2) {
                    dp[i][j+2][2] = dp[i-1][j][1];
                    dp[i][j+2][3] = dp[i-1][j][2];  
                }
            } else {
                dp[i][j+1][2] = dp[i-1][j][1];
                dp[i][j+1][3] = dp[i-1][j][2];  
            }
             
        }
    }
    lint ans = -1e15;
    if(N%2 == 0) {
        REP(k, 4) {
            ans = max(ans, dp[N-1][1][k]);
        }
        
    } else {
        REP(k, 4) {
            ans = max(ans, dp[N-1][2][k]);
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 68904
if __name__ == '__main__':
	N, K = map(int, input().split())

	n=[]
	num=0
	for j in range(100000):
		n.append(0)

	for i in range(N):
		a, b = map(int, input().split())
		n[a-1] += b

	for j in range(100000):
		num+=n[j]
		if(num>=K):
			break

	print(j+1)

Measured memory_bytes: 5920
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[a[i][j]], y[-a[i][j]-1]}:
                break
            if x[j] == y[a[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
    return False

a = [[0, 1, 2], [2, 0, 1], [1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]
n = int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

Measured memory_bytes: 7804
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[0]+ " " +a[1]+" "+a[2]);
    }
}
    


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

using namespace std;

void test()
{
   int a,b,c;

   map<int,int>mp;
   int res=0;
   cin>>a>>b>>c;

   mp[a]++;
   mp[b]++;
   mp[c]++;

   for(int i=1;i<=100;i++)
   {
       if(mp[i])
        res++;
   }

   cout<<res<<"\n";

}

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

    test();

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
    int N = 0;
    int H[20] = {0};
    cin>>N;
    
    for(int i = 0;i < N;i++){
        cin>>H[i];
    }
    
    int res = 0;
    for(int i = 0;i < N;i++){
        bool hi = true;
        for(int j = 0;j < i;j++){
            
        if(H[j] > H[i]){
             hi = false;
            break;
            
        }
    }
    
    if(hi)res++;
    }
    
    cout<<res;
    
    return 0;
}


Measured memory_bytes: 256
S = str(input())

mae = str(S[:2])
ato = str(S[2:])

if (1 <= int(mae) <= 12) and (1 <= int(ato) <= 12):
  print('AMBIGUOUS')
elif (1 <= int(mae) <= 12):
  print('MMYY')
elif (1 <= int(ato) <= 12):
  print('YYMM')
else:
  print('NA')


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, sum = 0;
    cin >> n;
    vector<ll> v;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for(ll i = 1; i < n; i++) sum+=v[i];
    if(v[0] < sum) cout << "Yes";
    else cout << "No";
}


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

using namespace std;

int main(){
  string N;
  cin >> N;
  
  int sum = 0;
  for(int i = 0; i < N.size(); i++){
    sum += N[i] - '0';
  }
  
  if(sum % 9) puts("No");
  else puts("Yes");
  
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  ll ans = 0;
  for (int bit = 0; bit < (1 << n-1); bit++) {
    ll tmp = 0;
    rep(i,n) {
      tmp = tmp * 10 + s.at(i) - '0';
      if (bit & (1 << i)) {
        ans += tmp;
        tmp = 0;
      }
    }
    ans += tmp;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
fun main() {
    val k = readLine()!!.toInt()
    fun gcd(a: Int, b: Int): Int {
        return if (b == 0) a else gcd(b, a % b)
    }
    var ans = 0L
    for (a in 1..k) {
        for (b in 1..k) {
            for (c in 1..k) {
                ans += gcd(gcd(a, b), c)
            }
        }
    }
    println(ans)
}


Measured memory_bytes: 34692
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll x, a, b;
  cin >> x >> a >> b;

  if(b <= a) cout << "delicious";
  else if(b <= a + x) cout << "safe";
  else cout << "dangerous";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long L, R;
    cin >> L >> R;

    // LとRの差が2019あれば0
    int minimum_value;
    if (2019 <= (R - L)) {
        minimum_value = 0;
    } else {
        int i_min = (L % 2019);
        int i_max = i_min + (R - L);
        int x;

        minimum_value = 2018;
        for (int i = i_min; i <= (i_max-1); i++) {
            for (int j = i_min+1; j <= i_max; j++) {
                x = (i * j) % 2019;
                
                if (x < minimum_value) {
                    minimum_value = x;
                }
            }
        }
    }

    cout << minimum_value;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

struct HashNode{
    char key[12];
    HashNode *next;
};
HashNode *list[1046527];
void init(){
    for(int i=0;i<1046527;i++)
    {
        list[i]=(HashNode*)malloc(sizeof(HashNode));
        list[i]->next=NULL;

    }
}
int getChar(char ch)
{
    if(ch == 'A')return 1;
    else if(ch == 'C')return 2;
    else if(ch == 'G')return 3;
    else if(ch == 'T')return 4;
    else return 0;
}
long long getKey(char str[])
{
    long long sum=0;
    int p=1;
    for(int i=0;i<strlen(str);i++)
    {
        sum+=p*getChar(str[i]);
        p*=5;
    }
    return sum;
}
int Hash(long long key){
    return int(key%1046527);
}
void insert(int index,char str[]){
    HashNode *p=(HashNode *)malloc(sizeof(HashNode));
    strcpy(p->key,str);
    p->next=NULL;
    HashNode *temp=list[index];
    while(temp->next!=NULL){
        temp=temp->next;
        if(strcmp(temp->key,str)==0)
        {
            free(p);
            return;
        }
    }
    temp->next=p;
}
int search(int index,char str[]){
    HashNode *temp=list[index]->next;
    while(temp!=NULL){
        if(strcmp(temp->key,str)==0)
            return 1;
        temp=temp->next;
    }
    return 0;
}
int main()
{
    int n;
    char com[10],str[12];
    init();
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>com>>str;
        if(com[0]=='i')
        {
            insert(Hash(getKey(str)),str);
        }
        else
        {
            if(search(Hash(getKey(str)),str))
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 52568
#include <vector>
#include <algorithm>
#include <iostream>

int main()
{
	std::vector<int> a;
	int b;
	while (std::cin >> b)
		a.push_back(b);
	std::sort(a.begin(), a.end());
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

int i,n,count1=0,count3=0,num[100];
for(i=1;i<=3;i++){
    scanf("%d",&num[i]);
    if(num[i]==5){
        count1++;
    }

    else if(num[i]==7){
        count3++;
    }

}
if(count1==2 && count3==1){

    printf("YES\n");
}
else{
    printf("NO\n");
}
return 0;
}


Measured memory_bytes: 1636
function martch(a::String)
		if a[1] == 'M'
			1
		elseif a[1] == 'A'
			2
		elseif a[1] == 'R'
			3
		elseif a[1] == 'C'
			4
		elseif a[1] == 'H'
			5
		else
			0
		end
end

function main()
	n = parse(readline())
	march = [0 for i in 1:5]
	for i in 1:n
		ch = martch(readline())
		if ch != 0
			march[ch] += 1
		end
	end
	sum = march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[2]*march[5]+march[1]*march[3]*march[4]+march[1]*march[3]*march[5]+march[1]*march[4]*march[5]+march[2]*march[3]*march[4]+march[2]*march[3]*march[5]+march[2]*march[4]*march[5]+march[3]*march[4]*march[5]
	print(sum)
end

main()

Measured memory_bytes: 126512
#include<stdio.h>
#include<string.h>
int main ()
{
	char s[30];
	while(scanf("%s",s)!=EOF)
	{
		int len ,i,t=0;
		len =strlen(s);
		for(i=0;i<len;i++)
		{
			for(int k=i+1;k<len;k++)
				if(s[k]==s[i])
				{
					t=1;
					break;
				}
			if(t==1)
			break;
		}
		if(t==1)
			printf("no\n");
		else
			printf("yes\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;


#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back

int main(){
    ll n, tmp; cin >> n;
    set<ll> v;
    rep(i,n) {
        cin >> tmp;
        v.insert(tmp);
    }
    if (v.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(int n){return n==0?1:10*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

struct UF {
    vi data;
    void init(int n)
    {
        data.resize(n);
        fill(all(data), -1);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        x = root(x);
        return -data[x];
    }
    bool is_root(int x)
    {
        return x == root(x);
    }
};

UF uf;
bool used[200010];

signed main()
{
    int N, M; cin >> N >> M;
    uf.init(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    } 

    vi arr;

    int ans = 0;

    rep(i, N) {
        chmax(ans, uf.size(i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t N, ans = 0;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    map<int64_t, int64_t> p;
    for (int i = N; i > 0; i--){
        ans += p[A.at(i - 1) + i];
        p[i - A.at(i - 1)]++;
    }
    cout << ans << endl;


}

Measured memory_bytes: 27420
#include <stdio.h>

int main(){
  int n,i;
  char s[10001];
  scanf("%d%s",&n,s);
  
  for(i=0;s[i]!='\0';i++){
    if(s[i]+n > 'Z'){
      s[i]=s[i]+n-26;
    }else{
      s[i]=s[i]+n;
    }
  }
  printf("%s\n",s);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

ll h[101010];

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    vector <ll> pk;

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL), pk(sz_) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
        for (ll i=0; i<sz_; i++) pk[i] = h[i];
    }
    void init(ll sz_) {
        par.resize(sz_);
        pk.resize(sz_);
        for (ll i=0; i<sz_; i++) pk[i] = h[i];
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        // // 親に保持した最大値を更新する
        // pk[x] = max(h[x], h[y]);
        // pk[y] = max(h[x], h[y]);
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll get_peak(ll x){
        return pk[root(x)];
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int al[101010];

vector<int> mp[101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    rep(i,m){
        int a,b;cin>>a>>b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        int isok = true;
        map<P, int> t;
        for(auto a : mp[i]){
            if(t[make_pair(i, a)]==1) continue;
            t[make_pair(i, a)]=1;
            if(h[i] <= h[a]) isok = false;
        }
        if(isok) ans++;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 12400
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String[] s = sc.next().split("");
		int[] t = new int[n];
		t[0]=0;
		for(int i=1;i<t.length;i++){
			t[i]=t[i-1];
			if(isAC(s[i-1],s[i]))t[i]++;
		}
		int[] pnt=new int[q];
		for(int i=0;i<q;i++){
			int l= sc.nextInt()-1;
			int r= sc.nextInt()-1;
			pnt[i]=t[r]-t[l];
		}
		for(int i=0;i<pnt.length;i++)System.out.println(pnt[i]);
	}
	
	
	static boolean isAC(String x,String y){
		if(x.equals("A")&&y.equals("C"))return true;
		else return false;
	}
}

Measured memory_bytes: 62420
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll A[3][3];
	REP(i,0,3)
	{
		REP(j,0,3)
		{
			cin>>A[i][j];
		}
	}
	ll n;
	cin>>n;
	ll b[n];
	bool done[3][3];
	REP(i,0,3)
	{
		REP(j,0,3)
		{
			done[i][j]=false;
		}
	}
	REP(y,0,n)
	{
		cin>>b[y];
		REP(i,0,3)
		{
			REP(j,0,3)
			{
				if(A[i][j]==b[y])
				{
					done[i][j]=true;
				}
			}
		}
	}
	if(done[0][0] && done[1][1] && done[2][2])
	{
		cout<<"Yes\n";
		exit(0);
	}
	if(done[0][2]&&done[1][1]&&done[2][0])
	{
		cout<<"Yes\n";
		exit(0);
	}
	REP(i,0,3)
	{
		if(done[i][0] && done[i][1] && done[i][2])
		{
			cout<<"Yes\n";
			exit(0);
		}
		if(done[0][i]&&done[1][i]&&done[2][i])
		{
			cout<<"Yes\n";
			exit(0);
		}
	}
	cout<<"No\n";
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector <int> dp (3,0);
    for(int i=0;i<n;i++){
        vector <int> newdp (3,0);
        int inp[3];
        for(int j=0;j<3;j++) cin>>inp[j];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                newdp[j]=max(newdp[j],dp[k]+inp[k]);
            }
        }
        dp=newdp;
    }
    int ans = -1;
    for(int i=0;i<3;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $in = <>;
	chomp $in;
	my @data = split(/ /, $in);

	printf("%d %d %d\n", $data[2], $data[0], $data[1]);

	return 0;
}

#----- 実行 -----#
exit( main() );




Measured memory_bytes: 640
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n,k;
    while(cin>>n>>k,n){

        bool a[100020]={};
        for(int i = 0;i < k;i++){
            int x;
            cin>>x;
            a[x] = true;
        }
        int d[100020][2] = {};
        for(int i = 1;i <= n;i++){
            if(a[i]){
                d[i][0] = d[i-1][0] + 1;
                d[i][1] = d[i-1][1] + 1;
            }
            else{
                d[i][1] = d[i-1][0] + 1;
            }
        }
        int best = 0;
        for(int i = 1;i <= n;i++){
            if(a[0]){
                best = max(best, d[i][1]);
            }
            best = max(best, d[i][0]);
        }
        cout<<best<<endl;
    }
    return 0;
}

Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.indexOf("C") == -1){
			System.out.println("No");
		}else{
			if(s.indexOf("F") >= 0 && s.substring(s.indexOf("C")+1).indexOf("F") >= 0 ){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 10192
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        long[] x=new long[n];
        st=new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++){ x[i]=Integer.parseInt(st.nextToken()); }
        long sum=0;
        for(int i=0;i<n-1;i++){
            if((x[i+1]-x[i])*a<b) sum=sum+(long)((x[i+1]-x[i])*a);
            else sum+=b;
        }System.out.println(sum);
    }
}

Measured memory_bytes: 24164
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[26];
int ans[4];
int main()
{	
	
	int n,m;
	scanf("%d %d\n",&n,&m);
	for(int i=0;i<n;i++)
	{
		char t;
		for(int i=0;i<m;i++)
		{
			scanf("%c",&t);
			a[t-'a']++;
			if(a[t-'a']>=4)
			{
				a[t-'a']-=4;
				ans[4]++;
			}
						
		}
		getchar();
	}
	for(int i=0;i<26;i++)
    {
    	if(a[i]%2==1)
    		{
    			a[i]--;
    			ans[1]++;
    		}
    	if(a[i]==2)
    			ans[2]++;
    }
    int  ok=0;
    if(n%2==1)
    	ok++;
    if(m%2==1)
    	ok++;
	if(ok==0)
    {
    	if(ans[4]>=n/2*m/2)
    			puts("Yes");
    	else
    		puts("No");
    }
    if(ok==1)
    {
    	if(ans[4]>=(n/2)*(m/2)&&ans[1]==0)
    		puts("Yes"); 
    	else
    		puts("No");
    }
    if(ok==2)
    {
    	if(ans[1]==1 && ans[4]>=(n/2)*(m/2))
    		puts("Yes");
    	else
    		puts("No");
    }
   
    	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
#define double long double
int h, w, a, b;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> h >> w >> a >> b;
    if(h % a == 0 && w % b == 0){
        cout << "No";
        return 0;
    }
    int x, y;
    x = h, y = a;
    if(h % a == 0){
        x= w, y = b;
    }
    int cnt = x/(y);
    int neg = -1e9;
    int pos = (-neg)/(y - 1) - 1;
//    int gap = x/cnt;
    //int rem = x % cnt;
//    debug(gap);
    int cnt2=  0;
    vi temp(x, pos);
    for(int i = 0; i + y - 1< x; i+=y){
       temp[i + y - 1] = neg;
       cnt2++;
//       for(;i < x && range; i++){temp[i]       }
//       if(i % (gap + (rem >= 1)) == ((gap+1+ (rem >= 1))/2 - 1))temp[i] = neg, cnt2++, rem--;else temp[i] = pos; 
    }
//    debug(cnt);
 //   debug(cnt2);
    assert(cnt2 == cnt);
    cout << "Yes" <<endl;
    if(h % a){
        FOR(i, h){
            FOR(j, w){
                cout << temp[i] << " "; 
            }
            cout << endl;
        }
    }else{
        FOR(i, h){
            FOR(j, w){
                cout << temp[j] << " ";
            }
            cout <<endl;
        }
    }

}




Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,_;
    cin>>n>>_;
    vector<stack<int>> s(n);
    int t,x;
    while(_--){
        int Q;
        cin>>Q;
        switch(Q){
        case 0:
            cin>>t>>x;
            s[t].push(x);
            break;
        case 1:
            cin>>t;
            if(!s[t].empty())cout<<s[t].top()<<endl;
            break;
        case 2:
            cin>>t;
            if(!s[t].empty())s[t].pop();
            break;
        }
    }
}




Measured memory_bytes: 4424
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#include<cfenv>
#include<cmath>
#define MAX_N pow(10,6)
#define MAX_M pow(10,6)
#define INF pow(10,6)
#define REP(i,n) for(long long i=0;i<n;i++)
typedef long long ll;
using namespace std;
//vector<vector<int>>dp(MAX_N,vector<int>(MAX_N));
//vector<pair<int,int>>item_retail(MAX_N);
int main(){
    ll x;
    cin>>x;
    ll a=100;
    for(int i=1;;i++){
        a=a*1.01;
        if(x<=a){
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 3624
function Main(s) {
  var n = s.split("\n")[0]*1;
  var ans = n; 
  for (var i = 0; i <= n; i++) {
    var cnt = 0, t = i;
    while(t > 0) cnt += t % 6, t = ~~(t / 6);
    t = n - i;
    while(t > 0) cnt += t % 9, t = ~~(t / 9);
    if(ans > cnt) ans = cnt;
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d %d",&a ,&b);
	
	if (a > b){
		printf("a > b\n");
	}
	else if (b > a){
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}
	
	return(0);
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int cnt = 0;
		for (int i = 0; i < s.length; i++) {
			if (Integer.parseInt(s[i]) == 1)
				cnt++;
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 21716
N, D = map(int, input().split())
x =[]
cnt = 0


for i in range (N):
  x.append(list(map(int, input().split())))

for j in range (N-1):
  for k in range (j+1, N):
    t = 0
    for d in range (D):
      t += (x[j][d]-x[k][d])**2
    if t **(1/2) %1 == 0:
      cnt += 1
        
        
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
using namespace std;
const int maxn=6666;
std::string a,b,c; 
bool ab[maxn<<1],ac[maxn<<1],bc[maxn<<1];
int ans=maxn<<2;
inline bool cmp(char c1,char c2) {return c1==c2||c1=='?'||c2=='?';}
signed main()
{
	std::cin>>a>>b>>c; int lena=a.length(),lenb=b.length(),lenc=c.length();
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenb;++j) if(!cmp(a[i],b[j])) ab[i-j+maxn]=1;
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenc;++j) if(!cmp(a[i],c[j])) ac[i-j+maxn]=1;
	for(rgi i=0;i<lenb;++i) for(rgi j=0;j<lenc;++j) if(!cmp(b[i],c[j])) bc[i-j+maxn]=1;
	for(rgi i=-4001;i<=4001;++i) for(rgi j=-4001;j<=4001;++j)
		if(!ab[i+maxn]&&!ac[j+maxn]&&!bc[j-i+maxn])
			ans=std::min(ans,std::max(lena,std::max(i+lenb,j+lenc))-std::min(0,std::min(i,j)));
	std::cout<<ans;
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 2e5+100;
using namespace std;
typedef long long ll;
vector <int> q[maxn];
int h[maxn];
int cnt[maxn];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=n;i++)
    cin>>h[i];
    while(m--){
    	cin>>u>>v;
    	q[u].push_back(v);
    	q[v].push_back(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(q[i].size()==0){
			ans++;
		}
		else if(cnt[i]){
			continue;
		}
		else{
			int cnt1=h[i],flag=0;
			for(int j=0;j<q[i].size();j++){
				if(cnt1>h[q[i][j]])
				cnt[q[i][j]]=1;
				else if(cnt1==h[q[i][j]]){
					cnt[q[i][j]]=1;
					flag=1;
				}
				else flag=1;
			}
			if(!flag)
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11932
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,f;
  int num=0;
  map<string,int>mp;
  int con[1001][1001]={};
  cin >> n >> f;
  string str[1001];
  for(int i=0;i<n;i++){
    int m;
    cin >> m;
    vector<string>it(m);
    
    for(int j=0;j<m;j++){
	cin >> it[j];	
    	if(!mp[it[j]]){
	  num++;
	  mp[it[j]]=num;
	  str[num]=it[j];
	}
    }
    for(int j=0;j<m;j++){
      for(int k=m-1;k>=0;k--){
	if(j==k)continue;
	if(it[j]>it[k])continue;
	con[mp[it[j]]][mp[it[k]]]++;
      }
    }
  }
  vector< pair<string,string> > ans;
  pair<string,string>abuf;
  int anum=0;
  for(int i=1;i<=num;i++){
    for(int j=0;j<=num;j++){
      if(con[i][j]>=f){
	abuf.first=str[i];
	abuf.second=str[j];
	ans.push_back(abuf);
	anum++;
      }
    }
  }
  sort(ans.begin(),ans.end());
  cout << anum << endl;
  for(int i=0;i<anum;i++){
    cout << ans[i].first << " "<< ans[i].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 7348
let rec take n xs =
    match xs with
    | x :: xs' when n > 0 -> x :: take (n - 1) xs'
    | _ -> []

let rec cost k cs xs y =
    let cs' = take k cs in
    let xs' = take k xs in
    List.fold_left2 (fun m c x -> min m (c + abs (y - x))) max_int cs' xs'

let rec solve k cs xs ys =
    match ys with
    | y :: ys' ->
            let c = cost k cs xs y in
            solve k (c :: cs) (y :: xs) ys'
    | [] -> List.hd cs

let () =
    let k =
        let line = read_line () in
        Scanf.sscanf line "%d %d" (fun _ k -> k)
    in
    let h =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    match h with
    | x :: xs ->
            print_int (solve k [0] [x] xs);
            print_newline ()
    | _ -> ()


Measured memory_bytes: 15232
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i=0; i<n; i++) {
       cin >> a[i];
   }
   sort(a.begin(), a.end());
   float ans = a[0] / (pow(2, n-1));
   for (int i=1; i<n; i++) {
       ans += a[i] / (pow(2, n-i));
   }
   cout << ans << '\n';
   
   return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int main(){
	int x[10];
	rep(i,10) cin >> x[i];
	sort(x,x+10,greater<int>());
	rep(i,3) cout << x[i] << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int64_t L=1,R=1;
	for(int i=0;i<n;++i){
		int64_t t,a; cin>>t>>a;
		int64_t mul=max((L+t-1)/t,(R+a-1)/a);
		L=t*mul,R=a*mul;
	}
	cout<<L+R<<"\n"s;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	int a=in(),b=in();
	printf("%.6lf\n",a*b/3.305785);
	
	return 0;
}


Measured memory_bytes: 3204
// Problem : F - Three Variables Game
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

string ss[100005];

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a[3];
	int N;
	cin >> N >> a[0] >> a[1] >> a[2];
	vector<char> ans;
	for(int i = 1; i<=N; i++){
		cin >> ss[i];
	}
	ss[N+1] = "AB";
	for(int i = 1; i<=N; i++){
		string s = ss[i];
		if(a[s[0]-'A'] == 0 && a[s[1]-'A'] == 0){
			cout << "No\n";
			return 0;
		}
		else if(a[s[0]-'A'] == a[s[1]-'A']){
			if(ss[i+1][0] == s[1] || ss[i+1][1] == s[1]){
				a[s[1]-'A']++, a[s[0]-'A']--;
				ans.push_back(s[1]);
			}
			else{
				a[s[1]-'A']--, a[s[0]-'A']++;
				ans.push_back(s[0]);
			}
		}
		else if(a[s[0]-'A'] > a[s[1]-'A']){
			ans.push_back(s[1]);
			a[s[0]-'A']--, a[s[1]-'A']++;
		}
		else{
			ans.push_back(s[0]);
			a[s[0]-'A']++, a[s[1]-'A']--;
		}
	}
	cout << "Yes\n";
	for(auto c : ans){
		cout << c << "\n";
	}
}

Measured memory_bytes: 6924
// Created by kashi on 21-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}


int32_t main() {
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
import math

N = int(input())
xy_list = []
for i in range(N):
    xy_list.append([int(i) for i in input().split()])
result = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        city1 = math.pow(xy_list[i][0] - xy_list[j][0], 2)
        city2 = math.pow(xy_list[i][1] - xy_list[j][1], 2)
        result += math.sqrt(city1 + city2)
print("{:.10f}".format(result / N))


Measured memory_bytes: 3064
/* Name        : d
 * Creat       : Fri Jul 12 18:11:56 CST 2019
 * Accept      : Fri Jul 12 18:20:50 CST 2019
 * Author      : landcold7
 * Motivation  : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].x >> a[i].y;
  }
  typedef pair<int, int> pii;
  sort(a.begin(), a.end(), [](const pii& c, const pii& d){
    if (c.y == d.y) {
      return c.x < d.x;
    }
    else {
      return c.y < d.y;
    }
  });
  trace(a);
  int t = 0;
  for (int i = 0; i < n; ++i) {
    t += a[i].x;
    if (t > a[i].y) {
      cout << "No" << "\n";
      return;
    }
  }
  cout << "Yes" << "\n";
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b,b+n,greater<int>());
  for(int i=0;i<n;++i) {
    if(a[i]==b[0]) cout << b[1] << endl;
    else cout << b[0] << endl;
  }
}

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

int n;
vector<int> A(50);

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M;
    cin >> n;
    rep(i, n) cin >> A[i];
    cin >> q;
    rep(i, q) {
        cin >> M;
        if (solve(0, M)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize,
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    for i in a..min(a + k, b + 1) { writeln!(out, "{}", i).unwrap(); }
    if a + k > b { return; }
    else {
        for i in max(a + k, b - k + 1)..(b + 1) {
            writeln!(out, "{}", i).unwrap();
        }
    }
}


Measured memory_bytes: 4352