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

public class Main {
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        final MyList[] myLists = new MyList[n + 1];
        for (int i = 1; i <= n; i++) {
            myLists[i] = new MyList();
        }
        for (int i = 0; i < m; i++) {
            final int left = scanner.nextInt();
            final int right = scanner.nextInt();
            final int distance = scanner.nextInt();
            myLists[left].add(new Pair(right, distance));
            myLists[right].add(new Pair(left, -distance));
        }

        final boolean[] isVisited = new boolean[n + 1];
        final long[] position = new long[n + 1];

        for (int i = 1; i <= n; i++) {
            if (isVisited[i]) {
                continue;
            }

            isVisited[i] = true;
            position[i] = 0;

            if (!dfs(isVisited, position, i, myLists)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

    private static boolean dfs(final boolean[] isVisited, final long[] distances, final int start, final MyList[] myLists) {
        isVisited[start] = true;
        boolean result = true;
        for (final Pair pair : myLists[start]) {
            if (isVisited[pair.destination] && distances[pair.destination] != distances[start] + pair.distance) {
                return false;
            }

            if (!isVisited[pair.destination]) {
                distances[pair.destination] = distances[start] + pair.distance;
                result &= dfs(isVisited, distances, pair.destination, myLists);
            }
        }

        return result;
    }

    static class MyList extends ArrayList<Pair> {
    }

    static class Pair {
        int destination;
        long distance;

        public Pair(int destination, int distance) {
            this.destination = destination;
            this.distance = distance;
        }
    }
}


Measured memory_bytes: 182712
#include <stdio.h>
#include <math.h>

int main(void){
	int i,str,hand,a[13],b[5];

	while(scanf("%d,%d,%d,%d,%d",&b[0],&b[1],&b[2],&b[3],&b[4])!=EOF){
		for(i=0;i<13;i++)a[i]=0;
		for(i=0;i<5;i++)a[b[i]-1]++;
		hand=0;str=0;
		for(i=0;i<13;i++){
			if(a[i]==1){str++;if(str==5)hand=6;}
			else {
				str=0;
				if(a[i]==2)hand++;
				else if(a[i]==3)hand+=3;
				else if(a[i]==4)hand=5;
			}
		}
		if(str==4 && a[0]==1)hand=6;
		switch(hand){
		case 1:printf("one pair\n");break;
		case 2:printf("two pair\n");break;
		case 3:printf("three card\n");break;
		case 4:printf("full house\n");break;
		case 5:printf("four card\n");break;
		case 6:printf("straight\n");break;
		default:printf("null\n");
		}
	}

	return 0;
}

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

using namespace std;

int main() {
    long long N,K;
    cin>>N>>K;
    long long modulo = 1e9+7;
    long long res = 0;
    for(long long int K2 = K;K2<=N+1;K2++) {
        long long maxi = ((N)*(N+1))/2 - ((N-K2)*(N-K2+1))/2;


        long long mini = ((K2-1)*(K2))/2;

        res += (maxi-mini+1);
        res%=modulo;
    }


    cout<<res;
}


Measured memory_bytes: 3636
L,R = list(map(int, input().split()))

MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(i+1,2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

#for i in range(2019):
#    idx = myidx(i,i)
#    MOD[idx] = 2019

MMM = []
MIN = 2019
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(max(Lmod,i+1), 2019)):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

#MMM=list(set(MMM))
#MMM.sort()
#print(MMM.pop(0))
print(MIN)


Measured memory_bytes: 92548
n,k=map(int,input().split())
A=list(map(int,input().split()))
bit_max=40
ans=0

#1ビットずつ見ていく
for c in range(bit_max,-1,-1):
  #2ビット表現を大きい方から順に小さくしていく
  Xi = 1<<c
  #Aの中でk番目にビットが立っているものの数
  ck=len([1 for a in A if a&Xi!=0])
  tmp=ck
  #もしckの値がn-ckより小さいならn-ck個を採用　
  if Xi<= k and ck<=n-ck:
    tmp=n-ck
    k-=Xi
  contribution=Xi*tmp
  ans+=contribution
print(ans)

Measured memory_bytes: 14620
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

tmp = 1
for i in a:
  tmp = (i * tmp)//fractions.gcd(i, tmp)

ans = 0
for i in a:
  ans += tmp//i
#print(tmp)
print(ans %mod)


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

using namespace std;

int main() {
	int k, t;
	int a[101];
	cin >> k >> t;
	for (int i = 0; i < t; i++) {
		cin >> a[i];
	}

	sort(a, a+t);

	int x, y, tmp;
	x = a[t-1];

	for (int i = t-2; i >= 0; i--) {
		y = a[i];
		if (y > x) {
			tmp = x;
			x = y;
			y = tmp;
		}

		x -= y;
	}

	if (x > 0) {
		x--;
	}
	cout << x << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
main()
{
	int N,K,X,Y;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N <= K)
	{
		printf("%d",N*X);
	}
	else
    {
        printf("%d",(N-K)*Y+K*X);
    }
}


Measured memory_bytes: 128
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])


Measured memory_bytes: 2940
def main():
  n,m=map(int,input().split())
  inf=10**9
  dp=[inf]*(1<<n)
  dp[0]=0
  
  #cost=[inf for i in range(m)]
  for i in range(m):
    a,b=map(int,input().split())
    c=[int(x)-1 for x in input().split()]
    t=0
    for j in c:
      t|=1<<j
    #cost[i]=[s,a]
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
    
  #print(cost)
  """
  dp=[inf]*(1<<n)
  dp[0]=0
  for s in range(1<<n):
    for bit,c in cost:
      dp[s|bit]=min(dp[s|bit], dp[s]+c)
  #print(dp)
  """
  #print(dp)
  print(-1 if dp[-1]==inf else dp[-1])

if __name__=='__main__':
  main()

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int kaijou(int x) {
	if (x == 1) return 1;
	return x * kaijou(x - 1);
};

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(2));
	rep(i, n)rep(j, 2) cin >> a[i][j];
	
	vector<int> b(n);
	rep(i, n) {
		b[i] = i;
	}

	double sum = 0;
	do {
		rep(i, n - 1) {
			double x = (a[b[i]][0] - a[b[i + 1]][0]) * (a[b[i]][0] - a[b[i + 1]][0]);
			double y = (a[b[i]][1] - a[b[i + 1]][1]) * (a[b[i]][1] - a[b[i + 1]][1]);
			sum += pow(x + y, 0.5);
		}
	} while (next_permutation(b.begin(), b.end()));

	sum /= kaijou(n);
	printf("%lf", sum);
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX=1000000007;
int main(){
	char ca[2][60];
	int i,j,k;
	int n;
	long long int s=1;
	cin>>n;
	for(i=0;i<2;i++){
		for(j=0;j<n;j++){
			cin>>ca[i][j];
		}
	}
	k=0;
	for(i=0;i<n;){
		if(ca[0][i]==ca[1][i])s*=(3-k),k=1,i++;
		else{
			if(k==0)s*=3*2;
			if(k==1)s*=2*1;
			if(k==2)s*=3;
			k=2,i+=2;
		}
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a,b,c=0,d=0,e=0;
for(a=1;a<=10;a++){
scanf("%d",&b);
if(b>c){e=d;d=c;c=b;}
else if(b>d){e=d;d=b;}
else if(b>e){e=b;}
}
printf("%d\n%d\n%d\n",c,d,e);
return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    init();
   int n;
   cin>>n;
   ll cnt=0;
   mint ans=1;
   for(int i=0;i<n;i++){
       ll x;cin>>x;
       if(x<cnt*2+1){
           ans*=mint(cnt+1);
           cnt--;
       }
       cnt++;
   }
   ans*=fac[cnt];
   cout<<ans<<"\n";
}


Measured memory_bytes: 47104
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

  if(s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
using namespace tr1;
#endif

typedef unsigned int uint;
typedef pair<int, uint> iu;

uint encode(const vector<int>& v)
{
	uint res = 0;
	for (int i = (int)v.size() - 1; i >= 0; --i)
		res = (res << 4) + v[i];
	return res;
}
vector<int> decode(uint e)
{
	vector<int> res;
	for ( ; e; e >>= 4)
		res.push_back(e & 0xf);
	return res;
}
int main()
{
	int n, c[16][16];
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			cin >> c[i][j];

	vector<int> ori;
	for (int i = 1; i <= n; ++i)
		ori.push_back(i);
	int ori_e = encode(ori);

	int res = 0;
	unordered_map<int, int> dis;
	priority_queue<iu, vector<iu>, greater<iu> > q;
	dis[ori_e] = 0;
	q.push(iu(0, ori_e));
	while (!q.empty())
	{
		iu t = q.top(); q.pop();
		int cost = t.first;
		uint e = t.second;
		if (cost > dis[e])
			continue;

		max_swap(res, cost);

		vector<int> v = decode(e);
		for (int i = 0; i < n; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				swap(v[i], v[j]);
				int nc = cost + c[v[i]][v[j]];
				uint ne = encode(v);
				swap(v[i], v[j]);

				if (!dis.count(ne) || nc < dis[ne])
				{
					dis[ne] = nc;
					q.push(iu(nc, ne));
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 0
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    if N == 0:
        print('0')
        return
    ans = []
    while N != 0:
        m = N % 2
        if m < 0:
            m = m + 2
        N = (N-m) // -2
        ans.append(m)
    print(''.join(str(_) for _ in ans[::-1]))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt(), p = 1, q = 1, r = 1;
        for(long i = 1; i <= 3500; i++)
            for(long j = 1; j <= 3500; j++)
                if(4 * i * j - n * i - n * j > 0)
                if(n * i * j % (4 * i * j - n * i - n * j) == 0){
                    p = i;
                    q = j;
                    r = n * i * j / (4 * i * j - n * i - n * j);
                    break;
                }
        System.out.println(p + " " + q + " " + r);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

/* ?????°?????´??°x??\????????¨???????´???°???????????¢??° */
/* ?????????????´???°????????°????????°???????????????????´???°???????´???????. */
int era (int x, int *array)
{
	int search[x];
	int len = 0;
	search[0] = search[1] = 0;
	for (int i = 2; i < x; i++)
		search[i] = 1;
	double root_x = sqrt(x);
	for (int i = 0; ; i++) {
		int num = search[i];
		if (num == 1) {
			if (root_x <= i)
				break;
			else {
				array[len++] = i;
				for (int j = i; j < x; j+=i)
					search[j] = 0;
			}
		}
	}
	for (int i = 0; i < x; i++) {
		if (search[i] == 1) {
			array[len++] = i;
			search[i] = 0;
		}
	}
	return len;
}

/* ?????°????´??????°????±?????????¢??°  */
int p_list(int a, int *list, int *primes, int len)
{
	int a_len = 0;
	int i = 0;
	while (primes[i] <= a) 
	{
		if (a % primes[i] == 0)
			list[a_len++] = primes[i];
		i++;
		if (len <= i)
			break;
	}
	return a_len++;
}

int key(int *list, int len)
{
	int sum = 0;
	if (len == 1)
		return list[0];
	for (int i = 0; i < len - 1; i++) 
		sum += list[i];
	return list[len-1] - sum;


}

int main (void)
{
	int *primes;
	int len;
	primes = (int *)malloc(sizeof(int) * 1000000);
	len = era(1000000, primes);	
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0)
			break;
		int a_pri[a/2], b_pri[b/2];
		int a_len, b_len;
		a_len = p_list(a, a_pri, primes, len);
		b_len = p_list(b, b_pri, primes, len);
#ifdef DEBUG
		cout << a_len << " " << b_len << endl;
		for (int i = 0; i < a_len; i++)
			cout << a_pri[i] << endl;
		for (int i = 0; i < b_len; i++)
			cout << b_pri[i] << endl;
#endif
		int a_key, b_key;
		a_key = key(a_pri, a_len);
		b_key = key(b_pri, b_len);
#ifdef DEBUG
		cout << "a " << a_key << endl;
		cout << "b " << b_key << endl;
#endif
		if (a_key > b_key)
			cout << "a" << endl;
		else
			cout << "b" << endl;
	}
	free(primes);
	return 0;
}

Measured memory_bytes: 6880
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

ll ans;
ll M;
vector<ll> A;
//[l,r) default: l=0,r=N,isL = true
vector<ll> count(int l, int r, bool isL){
	if(r-l == 1){
		vector<ll> ret;
		ret.push_back(A[l]%M);
		if(A[l]%M==0){
			//cout<<l<<" "<<r<<" "<<isL<<endl;
			ans++;
		}
		return ret;
	}
	vector<ll> left = count(l,(l+r)/2,true);
	vector<ll> right = count((l+r)/2,r,false);
	sort(left.begin(),left.end());
	rep(i,right.size()){
		if(right[i] == 0){
			right[i] = M;
		}
	}
	sort(right.begin(),right.end());
	reverse(right.begin(),right.end());
	int li=0,ri=0;
	while(li < left.size() && ri < right.size()){
		if((left[li] + right[ri]) == M){
			//cout<<l<<" "<<left[li]<<" "<<r<<" "<<right[ri]<<" "<<isL<<endl;
			int lc = 0, rc = 0;
			while(li+1 < left.size() && left[li] == left[li+1]){
				li++;
				lc++;
			}
			while(ri+1 < right.size() && right[ri] == right[ri+1]){
				ri++;
				rc++;
			}
			li++;lc++;ri++;rc++;
			ans += lc * rc;

		}else if((left[li] + right[ri]) < M){
			li++;
		}else{
			ri++;
		}
	}
	vector<ll> ret;
	ll memo = 0;
	if(isL){
		for(int i=r-1;i>=l;i--){
			memo += A[i];
			memo %= M;
			ret.push_back(memo);
		}
	}else{
		for(int i=l;i<r;i++){
			memo += A[i];
			memo %= M;
			ret.push_back(memo);
		}
	}
	return ret;


}

int main(void){
	ll n,a;
	cin>>n>>M;
	ans = 0;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	count(0,n,true);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define int int64_t
#define r(i, N) for(int i=0; i<N; i++);
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	int T, A; cin >> T >> A;
	vec H(N+1); for(int i=0; i<N; i++) cin >> H.at(i);

	double best_tmp=INF; int best_T;
	for(int i=0; i<N; i++) {
		double tmp = T-H.at(i)*0.006;
		if(best_tmp>abs(double(A)-tmp)) {
			best_tmp = abs(double(A)-tmp);
			best_T = i;
		}
	}

	cout << best_T+1 << endl;

}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

bool check(int a, int b, int c) {
    return a < b + c and b < c + a and c < a + b;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

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

    sort(v.begin(), v.end());
    int pans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int a = v[i], b = v[j];
            int mid, lo = j + 1, h = n - 1, ans = -1;
            while (lo <= h) {
                mid = lo + h >> 1;
                if (check(a, b, v[mid])) {
                    ans = mid;
                    lo = mid + 1;
                } else
                    h = mid - 1;
            }
            if (ans != -1)
                pans += ans - j;
        }
    }
    cout << pans << endl;
    return 0;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int n;
int a[205];

int main() {
    scanf("%d", &n);
    FO(i,0,2*n) scanf("%d", a+i);
    sort(a,a+2*n);
    int r = 0;
    FO(i,0,n) r += a[2*i];
    printf("%d\n", r);
}


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

bool isGood(long long i, long long A, long long B){
    long long sumdig=0;
    while(i > 0){
        sumdig += i%10;
        i /= 10;
    }
    if (A <= sumdig && sumdig <= B) return true;
    else return false;
}

void solve(long long N, long long A, long long B){
    long long res=0;
    for(int i=1; i < N+1; i++){
        if(isGood(i, A, B)) res += i;
    }
    cout << res << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



int main()
{
    ll N;
    cin >> N;
    vector<char> S(N);
    rep(i, 0, N) cin >> S[i];

    ll sm = 0;
    rep(i, 0, 1000) {
        char digits[4];
        sprintf(digits, "%03d", i);
        ll pos1 = 0;
        ll pos2 = 0;
        ll pos3 = 0;
        ll idx = 0;
        while(true) {
            if (idx >= N) break;
            if (S[idx] == digits[0]) {
                pos1 = idx;
                break;
            }
            ++idx;
        }
        ++idx;
        while(true) {
            if (idx >= N) break;
            if (S[idx] == digits[1]) {
                pos2 = idx;
                break;
            }
            ++idx;
        }
        ++idx;
        while(true) {
            if (idx >= N) break;
            if (S[idx] == digits[2]) {
                pos3 = idx;
                break;
            }
            ++idx;
        }
        //cout << pos1 << ' ' << pos2 << ' ' << pos3 << endl;

        if (pos1 < pos2 and pos2 < pos3 and pos1 < pos3 and pos1 < N and pos2 < N and pos3 < N) {
            //cout << digits[0] << digits[1] << digits[2] << endl;
            sm++;
        }
    }

    cout << sm << endl;
}


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

int main() {
	long long N; cin >> N;
	long long humanMove = 0;
	long long minMove = 0;

	for(int i = 0; i < 5; i++)
	{
		cin >> humanMove;
		if (minMove == 0) {
			minMove = humanMove;
		} else {
			minMove = min(minMove, humanMove);
		}
		
	}
	
	long long ans = 0;
	if (N < minMove) {
		ans = 5;
	} else {
		long long group = (N + (minMove - 1 )) / minMove;
		ans = 5 + group - 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#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()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int n, a, b;

int sum_digits(int k){
  int res = 0;
  for(int i = 0; i < 5; i++){
    res += k % 10;
    k = k / 10;
  }
  return res;
}
int main(){
  cin >> n >> a >>b;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ans += a <= sum_digits(i) && sum_digits(i) <= b ? i : 0;
  }
  cout << ans <<endl;
}
    

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer[] a = new Integer[N];
        for(int i = 0; i < N; i++){
          a[i] = sc.nextInt();
        }
        int sum = 0;
        Arrays.sort(a, Collections.reverseOrder());
        for(int i = 0; i < N; i++){
          if(i % 2 == 0){
            sum += a[i];
          } else {
            sum -= a[i];
          }
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


map< pii, ll> cnt;

int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n; cin >> n;

	ll ct =0;
	for(int i = 1;i <= n; ++i){
		int last = i%10;
		int t = i;
		int mod = t;
		while(t){
			mod = t%10;
			t /= 10;
		}
		// trace(i , mod , last);
		cnt[mp(mod , last)]++;
		// if(last == mod)
		// 	--ct;
	}
	// ll ct = 0;
	for(int i = 0;i < 10 ; ++i){
		for(int j = 0;j < 10; ++j){
			ct += cnt[mp(i , j)]*cnt[mp(j,i)];
		}
	}
	cout << ct << endl;
	// trace(cnt);
	// for(auto it : cnt){

	// 	// if(it.F.F == it.F.S)
	// 	// ct += it.S*(it.S);
	// 	// else{
	// 		ct += cnt[mp(it.F.S , it.F.F)];
	// 	// }
	// }
	// cout << ct << endl;










	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N;
ll a[200010],b[200010];
ll tmpA[200010];
ll tmpB[200010];
string s;
int main(){
    cin>> N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    for(ll i=0;i<N;i++){
        cin>>b[i];
    }
    ll ans=0;
    for(ll bit=0;bit<29;bit++){
        for(ll i=0;i<N;i++){
            tmpA[i]=a[i]%(1<<(bit+1));
            tmpB[i]=b[i]%(1<<(bit+1));
        }
        sort(tmpB,tmpB+N);
        ll T=(1<<bit);
        ll cnt=0;
        for(ll i=0;i<N;i++){
            cnt+=lower_bound(tmpB,tmpB+N,T*2-tmpA[i])-lower_bound(tmpB,tmpB+N,T-tmpA[i]);
            cnt+=lower_bound(tmpB,tmpB+N,T*4-tmpA[i])-lower_bound(tmpB,tmpB+N,T*3-tmpA[i]);
        }
        if(cnt%2){
            ans+=(1<<bit);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
//  val list = List.fill(3)(sc.nextInt)

  val ans = (1 to n).sum

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25552
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

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

int main(){
    ll n, x; cin >> n >> x;
    vector<ll> lis(n), lis2(n);
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, n){
        lis2[i] = abs(lis[i] - x);
    }
    sort(ALL(lis2));
    ll ans = lis2[0];
    REP(i, 1, n){
        ans = gcd(ans, lis2[i]);
    }
    cout << ans << endl;
}

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

int main() {
  
  int n,c;
  cin >> n;
  c = 0;
  int a,b;
  
  for (int i = 0 ; i < n ; i++){
    cin >> a >> b;
    c = c-a+b+1;
  }
  cout << c << endl;
}


Measured memory_bytes: 3588
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		var V = G;
		int N = I[0], K = I[1];
		var max = 0L;
		for (var l = 0; l < N; l++)
			for (var r = l; r <= N; r++)
			{
				// [l,r) を残す
				var t = N - (r - l);
				if (t > K) continue;
				var x = new List<long>();
				for (var i = 0; i < l; i++) x.Add(V[i]);
				for (var i = r; i < N; i++) x.Add(V[i]);
				x.Sort();
				var s = x.Sum();
				var j = 0;
				while (t < K && x.Count > 0 && j < x.Count && x[j] < 0) { t++; s -= x[j]; j++; }
				max = Max(max, s);
			}
		WriteLine(max);
	}
}
static class Func { }


Measured memory_bytes: 13396
import math
n = int(input())
a = 0

def is_prime(m: int)->bool:
    m2 = int(math.sqrt(m))+1
    for j in range(2, m2):
        if m % j == 0:
            return True
    else:
        return False

for i in range (n):
    m = int(input())
    if is_prime(m): a += 0
    else:
        a+=1
print (a)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll a, b, mi, ma, o = 0;
    cin >> a >> b;
    mi = a / 4 * 4;
    ma = b / 4 * 4;
    for (; ma <= b; ma++)
        o ^= ma;
    for (; mi < a; mi++)
        o ^= mi;
    cout << o << endl;
}


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

// 頂点fromから頂点toへのコストcostの辺
struct edge { long long from, to, cost; };

edge es[2005]; // 辺

long long d[2005]; // 最短距離

#define INF LONG_MAX/3

long long V, E; // Vは頂点数、Eは辺数


int main(){
	cin >> V >> E;
	for(long long i = 0; i < E; i++){
		cin >> es[i].from >> es[i].to >> es[i].cost;
		es[i].from--;es[i].to--;
		es[i].cost *= -1;
	}

	long long upnum = 0;
	for (int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[0] = 0;
	while (true) {
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if(upnum > V-1 && e.to == V-1){
					cout << "inf" << endl;
					return 0;
				}
			}
		}
		if (!update) break;
		upnum++;
		if(upnum > 5 * V)
			break;
	}

	cout << -1*d[V-1] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    


  int main(){
      lint a,q;
      string s;
      cin>>a;
      cout<<a+a*a+a*a*a;
     }
     

  
 
  
      
      
    
 
  
          
  

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;



int N, K,S[100050];
int dp[100000];//dp[i]:i回目の最大幸福度


int main() {
	cin >> N >> K;
	string s;
	cin >> s;
	ll res = 0;
	rep(i, N) {
		if (s[i] == 'L') {
			S[i] = -1;
			res++;
		}
		else {
			S[i] = 1;
		}
	}
	ll happiness = 0;
	rep(i, N) {
		if (i + S[i] < N && i + S[i] >= 0 && S[i + S[i]] == S[i]) {
			happiness++;
		}
	}
	if (res > N - res) {
		dp[0] = res;
	}
	else {
		dp[0] = N-res;
	}
	res = happiness;
	
	for (int i = 1; i < N; i++) {
		
		for (int j = i; j < N-1; j++) {
			if (S[i - 1] == S[i])break;
			if (S[i-1] != S[i] && S[j + 1] != S[j] && S[i] == S[j]) {
				res += 2;
				//reverse(S + i, S + j);
				for (int k = i; k <= j; k++) {
					S[k] *= -1;
				}
				K--;
				
				
			}
			if (K <= 0) {
				
				cout << res << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < N-1; i++) {

		if (S[0] == S[i] && S[i +1] != S[i]) {

			res++;
			//reverse(S, S + i);
			for (int k = 0; k <= i; k++) {
				S[k] *= -1;
			}
			K--;
		}
		if (K <= 0) {
			cout << res << endl;
			return 0;
		}
	}
	/*for (int i = N-1; i >= 1; i--) {

		if (S[N-1] == S[i] && S[i - 1] != S[i]) {

			res++;
			//reverse(S+N, S + i);
			for (int k = N-1; k >= i; k--) {
				S[k] *= -1;
			}
			K--;
		}
		if (K <= 0) {
			cout << res << endl;
			return 0;
		}
	}*/
	cout << res << endl;


}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll A[200009], S[600009];
ll L[200009], R[200009];

void calc(ll *F){
    for(*S=0;*S<N;) S[++*S]=0;
    ll sum=0;
    FOR(i,2,N+1){
        ll x=A[i-1],y=A[i];
        while(x<y) sum+=i-1-S[(*S)--],x*=4;
        while(x>=y*4) S[++(*S)]=i-1,y*=4;
        F[i]=sum*2;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep1(i,N) cin>>A[i];
    calc(L);
    reverse(A+1,A+1+N);
    calc(R);
    ll ans=LLINF*5;
    rep1(i,N) chmin(ans,L[i-1]+i-1+R[N-i+1]);
    cout1(ans)
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
 
#define rep(i, n) \
for(int i = 0; i <n; i++)
#define REP(i, a, b) \
for(int i = int(a); i <= int(b); i++)
#define TRvi(c, it) \
for(vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for(vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for(msi::iterator it = (c).begin(); it != (c).end(); it++)
 
#define INF 2000000000
 
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
 
void solve(){
    int n;
    cin>>n;
    if(n>=30){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3628
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int x[100010], y[100010], w[100010];
map<PII, int> mp;
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    cin >> x[i] >> y[i] >> w[i];
    mp[{x[i], y[i]}] = w[i];
  }

  int res = 0;
  REP(i, n) {
    chmax(res, mp[{x[i], y[i]}] + mp[{x[i]-1, y[i]}] + mp[{x[i]-1, y[i]-1}] + mp[{x[i], y[i]-1}]);
    chmax(res, mp[{x[i], y[i]}] + mp[{x[i]-1, y[i]}] + mp[{x[i]-1, y[i]+1}] + mp[{x[i], y[i]+1}]);
    chmax(res, mp[{x[i], y[i]}] + mp[{x[i]+1, y[i]}] + mp[{x[i]+1, y[i]-1}] + mp[{x[i], y[i]-1}]);
    chmax(res, mp[{x[i], y[i]}] + mp[{x[i]+1, y[i]}] + mp[{x[i]+1, y[i]+1}] + mp[{x[i], y[i]+1}]);
  }
  cout << res << " / 1" << endl;

  return 0;
}

Measured memory_bytes: 61660
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int aka = 0;
    int ao = 0;
    
    for(int i = 0 ; i < n ; ++i){
      if(s.charAt(i)=='0'){
        aka++;
      }else{
        ao++;
      }
    }
    
    int ju = Math.min(aka,ao);
    System.out.println(ju*2);
    
  }
}


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

void swap (int &nx, int &ny){
    int temp = nx;
    nx = ny;
    ny = temp;
   
} 

int main(void){
   int a,b,c;
   cin>>a>>b>>c;
   
   if(a > b) swap(a,b);
   if(b > c) swap(b,c);
    if(a > b) swap(a,b);
   
   cout<<a << " " <<b <<" " <<c <<endl;
  
}


Measured memory_bytes: 3116
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts [n] * n * ' '
  exit
end

ans = []
[k, 41].min.times do |i|
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = i - t
    if 0 <= j
      ans[j] += 1
    else
      ans[0] += 1
    end
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  ans.cumsum!
  a = ans.dup
end

puts ans * ' '

Measured memory_bytes: 80748
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll calc(ll x) {
  ll res = 0;

  if (x == -1) return 0;

  res = (x / 2 + (x % 2 == 0)) % 2 == 0;

  for(int i=1;i<60;i++){
    if(x & (1LL << i)) {
      if (i != 0 && x % 2 == 0)
        res |= 1LL << i;
    }
  }

  debug(res);

  return res;
}

int main(){
  ll A, B;

  cin >> A >> B;

  cout << (calc(A-1) ^ calc(B)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005,M=1<<19|2,inf=1e9+7;
int sum[M][2],lzy[M];
PI tr[M][2];
char ch[N];
PI operator +(PI a,int b){
	a.fi+=b;
	return a;
}
void push_up(int nod){
	For(i,0,1){
		sum[nod][i]=sum[nod<<1][i]+sum[nod<<1|1][i];
		tr[nod][i]=max(tr[nod<<1|1][i],tr[nod<<1][i]+sum[nod<<1|1][i]);
	}
	if(lzy[nod]){
		swap(sum[nod][0],sum[nod][1]);
		swap(tr[nod][0],tr[nod][1]); 
	}
}
void cao(int nod){
	lzy[nod]^=1;
	swap(sum[nod][0],sum[nod][1]);
	swap(tr[nod][0],tr[nod][1]); 
}
void ins(int l,int r,int i,int nod){
	if(i<=l){
		cao(nod); return;
	}
	int mid=(l+r)>>1;
	if(i<=mid)ins(l,mid,i,nod<<1);
	ins(mid+1,r,i,nod<<1|1);
	push_up(nod);
}
void Ins(int l,int r,int i,int nod){
	if(l==r){
		tr[nod][0].fi=tr[nod][1].fi=-inf; return;
	}
	int mid=(l+r)>>1;
	if(i<=mid)Ins(l,mid,i,nod<<1);
	else Ins(mid+1,r,i,nod<<1|1);
	push_up(nod);
}
void build(int l,int r,int nod){
	if(l==r){
		For(i,0,1)if(ch[l]){
			tr[nod][i].fi=-inf; sum[nod][i]=(l%2^i)?-1:1;
		}else tr[nod][i].se=l;
		return;
	}
	int mid=(l+r)>>1;
	build(l,mid,nod<<1); build(mid+1,r,nod<<1|1);
	push_up(nod);
}
ll mx,mn;
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	scanf("%s",ch+1);
	int n=strlen(ch+1),cnt=0,c1=0,c2=0;
	Rep(i,n,1){
		ch[i]-='0';
		swap(c1,c2);
		if(ch[i]==1){
			swap(mn,mx);
			mx+=cnt+1; c1++; 
		}else{
			ll mmx=max(c1+mx,mn+(c1+c2+1)/2);
			ll mmn=max(c2+mn,mx+(c1+c2)/2);
			mx=mmx; mn=mmn;
			cnt++;
		}
		//cout<<mn<<" "<<mx<<" "<<c1<<" "<<c2<<endl;
	}
	Rep(i,n-cnt-1,1)mx+=(i+1)/2;
	cout<<mx<<endl;
}
/*
010101

*/

Measured memory_bytes: 3912