akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int64 A, B;

int main() {
    cin >> A >> B;
    int64 r = [&]() {
        for (int b = 60; b >= 0; --b) {
            if ((A & (1LL << b)) < (B & (1LL << b))) {
                return b;
            }
        }
        return -1;
    }();

    if (r == -1) { // A == B
        cout << 1 << endl;
        return 0;
    }

    int64 k = [&]() {
        for (int b = r-1; b >= 0; b--) {
            if ((B & (1LL << b)) != 0) {
                return b;
            }
        }
        return -1;
    }();
    int64 m = 1LL << r, A_ = A % m, ks = 1LL << (k+1);
    int64 ans = (m - A_) + (m + ks - m) + (2*m - max(m + ks, m + A_));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long K, N;
  cin>>K>>N;
  long long A[N];
  for(long long i=0;i<N;i++){
    cin>>A[i];
  }
  long long B[N];
  for(long long i=0;i<N-1;i++){
    B[i]=A[i+1]-A[i];
  }
  B[N-1]=A[0]+K-A[N-1];
  long long max=B[0];
  for(long long i=0;i<N;i++){
    if(max<B[i]){
      max=B[i];
    }
  }
  cout<<(K-max);
  return 0;
}

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


int main(){
  int N,K;
  cin >> N >> K;
  multiset<int> p;
  for(int i=0; i <N;i++){
    int indata;
    cin >> indata;
    p.insert(indata);
  }
  auto itr = p.begin();
  int sumprice = *itr;
  for(int i = 1; i < K; i++){
    itr++;
    sumprice += *itr;
  }
  cout << sumprice;
}


Measured memory_bytes: 3680
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            char a = char.Parse (str[0]);

            if (Char.IsUpper (a)) Console.WriteLine ("A");
            else Console.WriteLine ("a");
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

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

bool kai(string s, int l, int r)
{
	string t = s;
	reverse(s.begin() + l, s.begin() + r);
	for (int i = l; i < r; i++) {
		if (s[i] != t[i])  return false;
	}
	return true;
}

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

	int n = s.size();
	int n1 = (n - 1) / 2;
	int n2 = (n + 3) / 2;

	if (kai(s, 0, n1) && kai(s, n2 - 1, n) && kai(s, 0, n))  cout << "Yes" << endl;
	else  cout << "No" << endl;
}

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

typedef long long int ll;

int main(){
    string s;
    cin >> s;
    int n  = s.size();
    ll sum = 0;

    map<string, int> m;
    for (int x = 0; x <= (1 << n); x++){
        vector<ll> arr;
        string num = "";
        string str = "";
        for (int i = 0; i < n; i++){
            num += s[i];
            str += s[i];
            if (x & (1 << i) && i != n - 1){
                str += '+';
                arr.push_back(stoi(num));
                num = "";
            }
        }
        if (m[str] == 0){
            if (num != "") arr.push_back(stoll(num));
            for (int i = 0; i < arr.size(); i++) sum += arr[i];
            m[str]++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';
var NS = {};
function addProps(ns) {
    var isBrowser = function() {
        return typeof window !== 'undefined';
    }
    ns.isBrowser = isBrowser;
    
    var isNodejs = function() {
        return ! isBrowser();
    }
    ns.isNodejs = isNodejs;
    
    if (isBrowser()) {
        var getHtmlEncoded = function(string0) {
            return String(string0)
                    .replace(/&/g, '&amp;')
                    .replace(/"/g, '&quot;')
                    .replace(/'/g, '&#39;')
                    .replace(/</g, '&lt;')
                    .replace(/>/g, '&gt;');
        }
        ns.getHtmlEncoded = getHtmlEncoded;
        
        var outputCode = function() {
            document.getElementById('code').innerHTML = '<pre><code>' + getHtmlEncoded(addProps) + '</code></pre>';
        }
        ns.outputCode = outputCode;
    }
    
    var getInput = function() {
        var inputLines = [];
        if (isBrowser()) {
            var html = document.getElementById('input').innerHTML;
            inputLines = html.split('<br>');
        }
        if (isNodejs()) {
            inputLines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n');
        }
        return inputLines;
    }
    
    var doOutput = function(outputLines) {
        if (isBrowser()) {
            document.getElementById('output').innerHTML = outputLines.map(getHtmlEncoded).join('<br>\n');
        }
        if (isNodejs()) {
            for (var i = 0; i < outputLines.length; i++) {
                console.log(outputLines[i]);
            }
        }
    }
    ns.doOutput = doOutput;
    
    var getProduct = function(a, b) {
        return a * b;
    }
    
    var main = function() {
        var strings = [];
        for (var a = 1; a <= 9; a++) {
            for (var b = 1; b <= 9; b++) {
                var s = a + 'x' + b + '=' + getProduct(a, b);
                strings.push(s);
            }
        }
        doOutput(strings);
    }
    ns.main = main;
}
addProps(NS);
if (NS.isBrowser()) {
    window.onload = function() {
        NS.outputCode();
    }
}
NS.main();

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

int main(){
	int q,t,a;
	char c;
	string s;
	cin >> s;
	deque<char> dq;
	for(auto x:s)
		dq.push_back(x);
	cin >> q;
	bool fl = false;
	while(q--){
		cin >> t;
		if(t==2){
			cin >> a >> c;
			if(a==1){
				if(!fl) dq.push_front(c);
				else dq.push_back(c);
			}else{
				if(!fl) dq.push_back(c);
				else dq.push_front(c);
			}
		}else{
			fl = !fl;
		}
	}
	string ans="";
	for(auto x:dq)
		ans.push_back(x);
	if(fl)
		reverse(ans.begin(),ans.end());
	cout << ans << '\n';
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int i = 0, j = int( s.size() ) - 1, cont = 0;

	while ( i <= j )
	{
		if ( s[i] != s[j] ) cont++;
		i++; 
		j--;
	} 
	cout << cont;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>
using namespace std;

int main() {
char s[4];
int i,cnt=0,max=0;
cin>>s;
for(i=0;i<strlen(s);i++){
    if(s[i]=='R'){
        cnt++;
    }
    else{
        if(cnt>=max) max=cnt;
        cnt=0;
    }
}
if(cnt>max)
cout<<cnt;
else
cout<<max;


    return 0;
}

Measured memory_bytes: 3604
n, a, b = map(int, input().split())
pre_h = [int(input()) for _ in range(n)]

def check(cnt):
	h = [0] * n
	for i in range(n):
		if pre_h[i] - b * cnt > 0:
			h[i] = pre_h[i] - b * cnt
		else:
			h[i] = 0

	if sum([(i - 1) // (a - b) + 1 for i in h]) <= cnt:
		return True
	else:
		return False

minimum = 1
maximum = (max(pre_h) - 1) // b + 1

while maximum - minimum > 1:
	if check(minimum + (maximum - minimum) // 2):
		maximum = minimum + (maximum - minimum) // 2
	else:
		minimum = minimum + (maximum - minimum) // 2

print(maximum)

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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX
#define Mod 1000000007
#define N 1000001
int exp(int x,int y,int mod){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x,int mod){return exp(x,mod-2,mod);}

int fac[N];


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

	int n;
	cin>>n;
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=(fac[i-1]*i)%Mod;
	int ans=(exp(10,n,Mod)-exp(8,n,Mod)+Mod)%Mod;
	int val=0;
	for(int r=1;r<=n;r++)
	{
		int temp=(((fac[n]*modinv(fac[r],Mod))%Mod)*modinv(fac[n-r],Mod))%Mod;
		int t2=exp(8,n-r,Mod);
		temp=(temp*t2)%Mod;
		val=(val+temp)%Mod;
	}
	val=(val*2)%Mod;
	ans=(ans-val+Mod)%Mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11372
def check(x, y)
  return 'Yes' if x == y
  2.times do |z|
    4.times do
      a, b, c, d, e, f  = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      return 'Yes' if x == y
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return 'Yes' if c == y
      end
    end
  end
  'No'
end
 
puts check(*$<.map(&:chomp).map(&:split))

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

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a[3][3];
  
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      int tmp;
      cin >> tmp;
      a[i][j] = tmp;
    }
  }
  
  int n;
  cin >>n;
  
  for (int i=0; i<n; i++){
    int tmp;
    cin >>tmp;
    for (int i=0; i<3; i++){
      for (int j=0; j<3; j++){
        if(tmp == a[i][j])a[i][j] = 0;
      }
    }
  }
  
  string ans ="No";
  bool flag=false;
  
  for (int i=0; i<3; i++){
    if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0){
      ans = "Yes";
      flag=true;
    }
    if(a[0][i]==0 && a[1][i]==0 && a[2][i]==0){
      ans = "Yes";
      flag=true;
    }
    
    if(flag) break;
  }
  
  if(a[1][1]==0 && a[2][2]==0 && a[0][0]==0){
      ans = "Yes";
      flag=true;
    }
  if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0){
      ans = "Yes";
      flag=true;
    }
  
  cout <<ans <<endl;
  
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int now = 0;
  rep(i, n) if (a[i] == now + 1) ++now;
  if (now == 0) cout << -1 << endl;
  else cout << n - now << endl;
  return 0;
}

Measured memory_bytes: 3992
#include <iostream>
// #include <vector>

using namespace std;

int selectionSort(int A[], const int N) {
    int c = 0;
    for (int i = 0; i < N; ++i) {
        int min = i;
        for (int j = i; j < N; ++j) {
            if (A[j] < A[min]) {
                min = j;
            }
        }
        if (i != min) {
            swap(A[i], A[min]);
            c++;
        }
    }
    return c;
}

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

    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int c = selectionSort(a, n);
    for (int i = 0; i < n-1; ++i) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3100
// 解説AC
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

// Union Find Tree
class UnionFindTree {
   private:
    vector<int> parent;
    vector<int> rank;
    vector<int> size;  // グループのメンバー数
   public:
    int root(int x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }
    // コンストラクタ n: メンバー数
    UnionFindTree(int n) {
        parent.resize(n);
        iota(parent.begin(), parent.end(), 0);
        rank.assign(n, 0);
        size.assign(n, 1);
    }
    // メンバーxとメンバーyが同じグループに所属しているかどうかを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // メンバーxとメンバーyが所属するグループを合併する
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;

        if (rank[x] < rank[y]) {
            parent[x] = y;
            size[y] += size[x];
        } else {
            parent[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }
    // メンバーxが所属するグループのサイズを返す
    int getGroupSize(int x) { return size[root(x)]; }
};

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

    int n, k, l;
    cin >> n >> k >> l;

    UnionFindTree road(n), rail(n);

    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        road.unite(p - 1, q - 1);
    }
    for (int i = 0; i < l; i++) {
        int p, q;
        cin >> p >> q;
        rail.unite(p - 1, q - 1);
    }

    map<pair<int, int>, int> m;
    for (int i = 0; i < n; i++) {
        m[make_pair(road.root(i), rail.root(i))]++;
    }

    for (int i = 0; i < n; i++) {
        const int ans = m[make_pair(road.root(i), rail.root(i))];
        cout << ans << " ";
    }

    cout << endl;
}


Measured memory_bytes: 21120
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                print("Yes")
                exit()
print('No')


'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 8912
#include <stdio.h>

#define input_add	scanf("%hd", &s), sum += s

int main(void)
{
	short sum = 0;
	short s;

	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	input_add;
	
	printf("%hd\n", sum);

	return (0);
}

Measured memory_bytes: 600
from functools import reduce
def gcd(a,b):
  if a<b:a,b=b,a
  if a%b==0:return b
  return gcd(b,a%b)

read=lambda :map(int,input().split())
n,k=read()
*a,=read()

m=max(a)
o=reduce(gcd,a)
print("POSSIBLE" if k<=m and k%o==0 else "IMPOSSIBLE")
  

Measured memory_bytes: 14748
#include<bits/stdc++.h>
using namespace std;
int dp[31][1<<16];
int P[1<<16];
int main()
{
	for(int i=0;i<(1<<16);i++){
		for(int j=0;j<16;j++){
			if((i>>j)&1)P[i]++;
		}
	}
	while(true){
		int n;int c;
		int a[31];
		int b[32];
		for(int i=0;i<=30;i++){
			for(int j=0;j<(1<<16);j++){
				dp[i][j]=-1;
			}
			a[i]=0;b[i]=0;b[i+1]=0;
		}
		dp[0][0]=0;
		scanf("%d%d",&n,&c);
		if(n==0&&c==0)break;
		for(int i=1;i<=n;i++){
			for(int j=0;j<16;j++){
				int x;
				scanf("%d",&x);
				if(x==1)a[i]+=(1<<j);
			}
		}
		for(int i=1;i<=c;i++){
			for(int j=0;j<16;j++){
				int x;
				scanf("%d",&x);
				if(x==1)b[i]+=(1<<j);
			}
		}
		b[c+1]=0;
		c++;
		
		for(int i=1;i<=n;i++){
			for(int j=0;j<(1<<16);j++){
				if(dp[i-1][j]==-1)continue;
				int board=j|a[i];
				//printf("%d %d %d\n",j,a[i],board);
				for(int k=1;k<=c;k++){
					int point=P[b[k]&board]+dp[i-1][j];
					int cou=board-(b[k]&board);
					dp[i][cou]=max(dp[i][cou],point);
				}
				
			}
		}
		int ans=0;
		for(int i=0;i<(1<<16);i++){
			ans=max(ans,dp[n][i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 9380
import java.util.*;
import java.lang.Math;

public class Main{

public static void main(String[] args){
Scanner scanner1 = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
long a=scanner1.nextLong();
long b=scanner1.nextLong();
long c=scanner1.nextLong();
long d=scanner1.nextLong();
long t=a*c;

long e=Math.max(a*c,Math.max(a*d,Math.max(b*c,b*d)));
System.out.println(e);



}
}

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

using namespace std;

const int MOD = 1e9 + 7;

int add(int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

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() , greater<int>());

//    int test = 0;
//    for (int m = 0 ; m < (1 << n) ; m++) {
//        for (int i = 0 ;i < n ;i++) {
//            if (!(m & (1 << i))) continue;
//            int cnt = 0;
//            for (int j = 0 ;j < i ;j++) {
//                if (m & (1 << j)) cnt++;
//            }
//            test += (cnt + 1) * a[i];
//        }
//    }

    int sum = 0 , ans = 0;
    for (int i = 0 ;i < n ;i++) {
        ans = add(ans , mul(a[i] , add(sum , power(2 , n - 1))));
        sum = add(sum , power(2 , n - 2));
    }

    cout << mul(ans , power(2 , n));
}

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

int main() {
	int N;
	long long K;
	cin >> N >> K;
	long long ans;

	ans = K;
	for (int i = 0; i < N - 1; i++) {
		ans *= K - 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int N, A, B;
   

   cin >> N >> A >> B;

   int sum = 0;
   int ans = 0;

   for(int i=1;i<=N;i++){
       int tmp = i;
       int sum = 0;
       for(int j=0;j<5;j++){
           sum = sum + tmp % 10;
           tmp = tmp / 10;
       }
       if(A <=sum && sum <=B){
           ans = ans + i;
       }
   }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H,W,N = map(int,input().split())
ab_list = [tuple(map(int,input().split())) for _ in range(N)]
table_dict = {}

diffs = [-1,0,1]
diff_tuples = [(a,b) for a in diffs for b in diffs]

for a, b in ab_list:
    for da,db in diff_tuples:
        if a+da in table_dict:
            row = table_dict[a+da]
            if b+db in row:
                row[b+db] += 1
            else:
                row[b+db] = 1
        else:
            table_dict[a+da] = {}
            table_dict[a+da][b+db] = 1

cnts = [0 for _ in range(10)]

for h,row in table_dict.items():
    for w,v in row.items():
        if 2 <= h <= H-1 and 2 <= w <= W-1:
            cnts[v] += 1

square_3x3 = (H-2) *(W-2)
cnts[0] = square_3x3 - sum(cnts[1:])

for cnt in cnts:
    print(cnt)

Measured memory_bytes: 163416
N, M = map(int,input().split())

T = list(map(int, input().split())) # heights
G = [[] for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)

ans = 0
for i in range(N):
    h = T[i]
    good = True
    for next in G[i]:
        if h <= T[next]:
            good = False
            break
    if good:
        ans += 1

print(ans)

Measured memory_bytes: 29440
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int max_n = 2e5+100;

signed main() {
    int T;cin>>T;
    while(T--){
        int n;cin>>n;
        int ans=0;
        set<pair<int,int> , greater<pair<int,int> > > S;
        set<int> indices;

        int k[n],l[n],r[n];

        for(int i=0;i<n;i++){
            indices.insert(i);

            cin>>k[i]>>l[i]>>r[i];
            k[i]--;

            S.insert({l[i]-r[i],i});
        }

        int indices_used=0;

        while(S.size()>0){
            pair<int,int> c = *S.begin();
            if(c.first<0) break;
            S.erase(S.begin());
            int i = c.second;

            set<int>::iterator itr = indices.upper_bound(k[i]);
            if(itr==indices.begin()){
                ans+=r[i];
                continue;
            }else itr--;

            indices.erase(itr);
            ans+=l[i];
        }

        indices.clear();
        for(int i=0;i<n;i++){
            indices.insert(i);
        }

        while(S.size()>0){
            set<pair<int,int> >::iterator last = S.end();
            last--;
            pair<int,int> c = *last;
            S.erase(last);

            int i = c.second;
            set<int>::iterator itr = indices.upper_bound(k[i]);
            if(itr==indices.end()){
                ans+=l[i];
                continue;
            }else{
                ans+=r[i];
                indices.erase(itr);
            }
        }

        cout<<ans<<endl;

    }


    return 0;
}


Measured memory_bytes: 30204
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

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

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


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = (0 until n).map { sc.next() }
    println(problem155c(n, s))
}

fun problem155c(n: Int, s: List<String>): String {
    val map = mutableMapOf<String, Int>()
    for (i in s) {
        if (map.containsKey(i)) {
            map[i] = map[i]!! + 1
        } else {
            map[i] = 1
        }
    }
    val max = map.values.max()!!
    val maxList = map.filter { it.value == max }.keys
    return maxList.sorted().joinToString("\n")
}

Measured memory_bytes: 120712
#include <iostream>
#include <cmath>
#include <functional>
#include <vector>
using namespace std;

template <typename T>
struct SegmentTree{
private:
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
public:
  SegmentTree(){};
  SegmentTree(F f,T ti) : f(f),ti(ti) {}
  void build(int n_){
    n = n_;
    dat.assign(2*n,ti);
  }
  void build(const vector<T> &v){
    int n_ = v.size();
    build(n_);
    for(int i = 0; i < n; ++i) dat[n+i]=v[i];
    for(int i = n-1; i >= 0; --i)
      dat[i]=f(dat[2*i+0],dat[2*i+1]);
  }
  void set_val(int k,T x){
    dat[k+=n] = x;
    while(k > 0){
      k = k/2;
      dat[k]=f(dat[2*k+0],dat[2*k+1]);
    }
  }
  T query(int a,int b){
    T vl = ti, vr = ti;
    for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1){
      if(l&1) vl = f(vl,dat[l++]);
      if(r&1) vr = f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};


int main(){
  using T = double;
  function<T(T,T)> f = [](T a, T b){
                         return min(a,b);
                       };
  T ti = 1e9;
  SegmentTree<T> st(f,ti);
  int n;
  double k;
  cin >> n >> k;
  vector<double> S(n);
  for(int i = 0; i < n; ++i) cin >> S[i];
  for(int i = 0; i < n; ++i){
    if(S[i] < 1e-3){
      cout << n << endl;
      return 0;
    }
  }
  double lk = log(k);
  vector<double> L(n+1);
  for(int i = 0; i < n; ++i)
    L[i+1] = log(S[i]);
  for(int i = 0; i < n; ++i)
    L[i+1] += L[i];
  st.build(L);
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int ok = i, ng = n+2;
    while(ng-ok > 1){
      int m = (ok+ng)/2;
      double mi = st.query(m,n+1);
      if(mi-L[i] > lk) ng = m;
      else ok = m;
    }
    ans = max(ans,ok-i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define pb push_back
#define mp make_pair
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void solve(long long N) {
  // main coding
  int cnt=0;
  rep1(i,N+1) if(to_string(i).length()%2) cnt++;
  cout<<cnt<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
void rev(vel &v) { reverse(v.begin(), v.end()); }
int zero(void) { return 0; }
vel he(string s) {
	string mo = "abcdefghijklmnopqrstuvwxyz";
	int n = s.size();
	vel qs(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			if (mo[j] == s[i]) {
				qs[i] = j;
			}
		}
	}
	veb seen(26,false);
	veb cha(26);
	int th = 0;
	for (int i = 0; i < n; i++) {
		if (seen[qs[i]]) {
			qs[i] = cha[qs[i]];
		}
		else {
			cha[qs[i]] = th;
			seen[qs[i]] = true;
			qs[i] = th;
			th++;
		}
	}
	return qs;
}
signed main() {
	string s;
	cin >> s;
	vel qs = he(s);
	string t;
	cin >> t;
	vel qt = he(t);
	if (qs == qt) { cout << "Yes"; }
	else { cout << "No"; }
	return 0;
}

Measured memory_bytes: 4032
using System;

namespace Contest148
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] nums = { 1, 2, 3 };
			int a = int.Parse(Console.ReadLine());
			int b = int.Parse(Console.ReadLine());
			int ans = 0;

			for (int i = 0; i < nums.Length; i++)
			{
				if (nums[i] != a & nums[i] != b)
				{
					ans = nums[i];
				}
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll a,b,i;
  vector<pair <ll,ll> > v(n);
  for(i=0;i<n;i++){
    cin >> a >> b;
    v[i].first=a+b;
    v[i].second=a;
  }
  sort(v.begin(),v.end());
  ll ans = 0;
  for(i=0;i<n;i++){
    if(i%2==0)ans+=v[n-1-i].second;
    if(i%2==1)ans-=v[n-1-i].first-v[n-1-i].second;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b;cin>>a>>b;
    out(a+b-gcd(a,b)+1);
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	int N;
	cin >> N;
	int ok = 0;
	for (int i = 1; i <= 9; i++) {
		if (N%i == 0 && N / i <= 9)ok = 1;
	}
	if (ok)puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int N,A,B;
cin>>N>>A>>B;
if(N*A<=B){
    cout<<N*A;
}
else if(N*A==B){
    cout<<B;
}
else if(N*B>=B){
    cout<<B;
}
return 0 ;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
#include <bitset>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int N;

    //入力
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    //まず1があるか調べる
    auto it = find(a.begin(), a.end(), 1);
    //cout << *it << endl;
    if(it == a.end() && *it != 1) { cout << "-1" << endl; return 0; }

    //それ以外を調べる
    int i;
    for(i=2; i<=N ; i++) {
        it = find(it+1, a.end(), i);
        //cout << i << endl;
        if(it == a.end()) break;
    }
    if(*it == i) i++;
    cout << N-i+1 << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }



    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();


        int N = sc.intarr[0];
        int ans = N;

        int[] H = sc.intarr;
        for(int i = 0; i < N; ++i)
        {
            for(int j = 0; j < i; ++j)
            {
                if (H[i] < H[j])
                {
                    ans--;
                    break;
                }
            }
        }
        wr.wri(ans);






    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------
ll dist(ll x, ll y){
  return x*x + y*y;
}

int main(void) {
  ll n, d;
  cin >> n >> d;
  vecll x(n), y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  d*=d;
  ll ans=0;
  rep(i,n){
    if(dist(x[i], y[i])<=d){
      ans++;
    }
  }

  prt(ans);
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 5000005
#define endl "\n"
lli arr[MAX];
int st[MAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    lli t;
    t = 1;
    while(t--){
        lli k;
        cin>>k;
        st[1] = 7%k;
        for(lli i = 2; i<1000005; i++){
            st[i] = st[i-1]*10%k;
        }
        lli dp = 0;
       /* for(lli i = 1; i<5; i++){
            cout<<st[i]<<" ";
        }*/
        lli ans = -1;
        for(lli i = 0; i<1000000; i++){
            dp += st[i+1];
            dp %=k;
            if(dp == 0){
                ans = i+1;
                break;
            }
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

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

    int now = 0;
    vector<int> here{0, 0};
    bool ret = true;
    for (int i = 0; i < n; i++) {
        int t, x, y;
        cin >> t >> x >> y;

        int diff = t - now;
        int dis = abs(here[0] - x) + abs(here[1] - y);

        if (!(dis <= diff && (diff - dis) % 2 == 0)) ret = false;

        now = t, here = {x, y};
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    string S;
    cin>>S;
    for(int i=0;i<S.size()-8;i++){
        cout<<S[i];
    }
    cout<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, x, y;
long long int a[100100];
long long int b[100100];
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = -a[i];
    }
    
    sort(a, a+n);
    sort(b, b+n);
    
    int k = a[n-1];
    x = *lower_bound(a, a+n, k/2);
    y = *lower_bound(b, b+n, -k/2);
    
    if(abs(2*x - k) < abs(-2*y - k) && x != k)
    {
        cout << k << " " << x << endl;
    }
    else if(-y != k)
    {
        cout << k << " " << -y << endl;
    }
    else
    {
        cout << k << " " << 0 << endl;
    }
    
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <numeric>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

ll A, B;
bool OK(const vector<ll> &nums, ll t) {
  ll k = 0;
  ll c = A - B;
  for (auto x : nums) {
    if (t * B >= x) {
      continue;
    }
    ll diff = x - (t * B);
    k += (diff+(c-1)) / c;
    if (k > t) {
      return false;
    }
  }
  return true;
}

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N >> A >> B;
  vector<ll> nums(N);
  rep(i,N){
    cin >> nums[i];
  }
  ll lp = 0;
  ll up = 1LL<<34;
  while (lp != up) {
    ll mid = (up + lp) / 2;
    if (OK(nums, mid)) {
      up = mid;
    } else {
      lp = mid + 1;
    }
  }
  cout << lp << endl;
  return 0;
}



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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d.at(i);
  }
  vector<int> e(N);
  for(int i=0; i<N; i++){
    e.at(i)=d.at(i);
  }
  sort(e.begin(),e.end());
  reverse(e.begin(),e.end());
  int max = e.at(0);
  int sec = e.at(1);
  for(int i=0; i<N; i++){
    if(d.at(i)<max){
      cout<<max<<endl;
    }
    else{
      cout<<sec<<endl;
    }
  }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

ll minll( ll a, ll b )
{
  if( a < b ) return a;
  else return b;
}

int main()
{
  ll I, O, T, J, L, S, Z;
  ll ans = 0;
  cin >> I >> O >> T >> J >> L >> S >> Z;
  if( I && J && L ) {
    ans = (I-1) / 2 * 2 + (J-1) / 2 * 2 + (L-1) / 2 * 2 + 3;
  }
  ans = max(ans, I / 2 * 2 + J / 2 * 2 + L / 2 * 2);
  ans += O;
  cout << ans << endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[][] A = new int[2][N];
		for(int i = 0;i < 2;i++){
			for(int j = 0;j < N;j++){
				A[i][j] = s.nextInt();
			}
				
		}
		
		int max = 0;
		for(int i = 0;i < N;i++){
			int count = 0;
			for(int j = 0;j <= i;j++){
				count += A[0][j];
			}
			for(int j = i;j < N;j++){
				count += A[1][j];
			}
			max = Math.max(max, count);
		}
		
		System.out.println(max);
	}
	
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
using namespace std;

int main(){
	int q,x;cin>>q;
  	string com;
  	list<int> v;
  	scanf("%d",&q);
  
  for(int i=0;i<q;i++){
  	cin>>com;
    if(com=="insert"){
  		scanf("%d",&x);
    	v.push_front(x);
  	}else if(com=="deleteFirst"){
  		v.pop_front();    
  	}else if(com=="deleteLast"){
  		v.pop_back();
  	}else if(com=="delete"){
  		scanf("%d",&x);
      	for(list<int>::iterator it=v.begin();it!=v.end();it++){
        	if(*it==x){
            	v.erase(it);
              	break;
            }
        }
  	}
}
  
  int i=0;
  	for(list<int>::iterator it=v.begin(); it!=v.end();it++){
  		if(i++) printf(" ");
    	printf("%d",*it);
  	}
  printf("\n");
  }


Measured memory_bytes: 34500
<?php
$code = <<<'CODE'
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return(x+=y)<mod?x:x-mod;}
int sub(int x,int y){return(x-=y)>= 0?x:x+mod;}
int dp[1<<21];
int n,a[21][21];
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      scanf("%d",&a[i][j]);
    }
  }
  dp[0]=1;
  for(int b=1;b<(1<<n);++b){
    int bc=__builtin_popcount(b)-1;
    for(int i=0;i<n;++i){
      if((b>>i&1)&&a[bc][i]){
        dp[b]=add(dp[b],dp[b^(1<<i)]);
      }
    }
  }
  printf("%d\n",dp[(1<<n)-1]);
}
CODE;
file_put_contents("A.cpp", $code);
while($line = fgets(STDIN)){
  $lines[] = $line;
}
file_put_contents("in", implode("\n", $lines));
exec("g++  A.cpp -o a.out");
exec("./a.out < in", $a, $b);
echo implode("\n", $a);


Measured memory_bytes: 59336
#include<bits/stdc++.h>
#include<utility>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

#define pb push_back
#define PI acos(-1.0)
#define MAX 10000007 //1e7+7
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define __FastIO  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
/*------------------------------------------------------*/
int main(){
  __FastIO;
  ll N,i;
  ll V[100009];
  while(cin>>N){
    for(i=0;i<N;i++){
      cin>>V[i];
    }
    ll cnt=0,min_Val=V[0],mx=0;
    for(i=1;i<N;i++){
      if(V[i]>min_Val){
        min_Val=V[i];
        mx=max(mx,cnt);
        //cout<<mx<<" "<<cnt<<" ";
        cnt=0;
      }
      else{
        cnt++;
        min_Val=V[i];

        mx=max(cnt,mx);
      }
    }
    cout<<mx<<endl;
    //V.clear();
  }

  return 0;
}


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

#define fi first
#define se second

const int N = 200200;
const long long mod = 998244353;

using namespace std;

int n;
bool shit[N];

void put(int x, int y)
{
        cout << x << " " << y << "\n";
        if(x == n + 1) shit[y] = true;
        if(y == n + 1) shit[x] = true;
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        int gg = n;
        while(gg % 2 == 0) gg /= 2;
        if(gg == 1){
                cout << "No" << "\n";
                return 0;
        }
        cout << "Yes" << "\n";
        put(1, 2);
        put(2, 3);
        put(3, n + 1);
        put(n + 1, n + 2);
        put(n + 2, n + 3);
        for(int i = 4; i < n; i += 2){
                put(n + 1, i);
                put(i, i + 1);
                put(n + 1, n + i + 1);
                put(n + i + 1, n + i);
        }
        if(n % 2 == 0){
                int m = n ^ (n - 1) ^ 1;
                if(shit[n - 1])put(n - 1, n);
                else put(n + n - 1, n);
                if(shit[m]) put(m, n + n);
                else put(m + n, n + n);
        }
}


Measured memory_bytes: 3072
*n,t=open(0).read().split()
n,k,r,s,p=map(int,n)
*t,=t
for i in range(n-k):
  if t[i+k]==t[i]:t[i+k]=5
a,b,c=map(t.count,'rsp')
print(a*p+b*r+c*s)

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

int main() {
  string s, t;
  cin >> s >> t;
  sort( s.begin(), s.end() );
  sort( t.begin(), t.end() );
  reverse( t.begin(), t.end() );
  
  int nagasa = min( s.size(), t.size() );
  for( int i = 0; i < nagasa; i++ ){
    if( s.at(i) < t.at(i) ){
      cout << "Yes" << endl;
      return 0;
    }else if( s.at(i) > t.at(i) ){
      cout << "No" << endl;
      return 0;
    }
  }
  if( s.size() < t.size() ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
X,N=map(int,input().split())
*P,=sorted(map(int,input().split()))

from bisect import bisect_left

if N==0:
    t=X
else:
    l = bisect_left(P, X)
    for i in range(100):
        t=X-i
        if l-i<0 or t!=P[l-i]: break
        t=X+i
        if N<=l+i or t!=P[l+i]: break
print(t)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<(n+1)/2;
}

Measured memory_bytes: 256