akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxh 15
#define maxn 1010
#define INF 1e9
#define int ll
int H,W,K;
int grid[maxh][maxn],ss[maxh][maxn];
char tempgrid[maxh][maxn];
int qry(int x1,int y1,int x2,int y2){
	return ss[x2][y2] - ss[x1-1][y2] - ss[x2][y1-1] + ss[x1-1][y1-1];
}


int32_t main(){
	fast;
	
	cin>>H>>W>>K;
	
	
	FOR(i,1,H){
		FOR(j,1,W){
			cin>>tempgrid[i][j];
		}
	}
	
	FOR(i,1,H){
		FOR(j,1,W){
			if (tempgrid[i][j] == '0') grid[i][j] = 0;
			else grid[i][j] = 1;
		}
	}
	
	ss[1][1] = grid[1][1];
	
	FOR(i,1,H){
		FOR(j,1,W){
			if (i == 1 && j == 1) continue;
			ss[i][j] = ss[i][j-1] + ss[i-1][j] + grid[i][j] - ss[i-1][j-1];
		}
	}
	

	int ans = INF;
	FOR(bm,0,(1<<(H)) - 1){
		int res = 0;
		int prevcol = 1;
		bool np = 0;
		
		FOR(i,0,H-1) if (bm & (1<<i)) res++;
		FOR(i,1,W){
			
			bool yes = 1;
			int prevrow = 1;
			
			FOR(j,0,H - 2){
				if (bm & (1<<j)){
					//cut btwn j+1 and j+2
					if (qry(prevrow,prevcol,j+1,i) > K) yes = 0;
					prevrow = j + 2;
				}
			}
			if (qry(prevrow,prevcol,H,i) > K) yes = 0;
			
			

			if (!yes){
				prevcol = i;
				
				
				bool yes2 = 1;
				int prevrow2 = 1;
				
				FOR(j,0,H - 2){
					if (bm & (1<<j)){
						//cut btwn j+1 and j+2
						if (qry(prevrow2,prevcol,j+1,i) > K) yes2 = 0;
						prevrow2 = j + 2;
					}
				}
				
				if (qry(prevrow2,prevcol,H,i) > K) yes2 = 0;
				
				if (!yes2) np = 1;
				//cout<<i<<' ';
				res++;
			}
		}
		
		//cout<<res<<'\n';
		if (np) continue;
		ans = min(ans,res);
	}
					
			
	cout<<ans;
	
	
	
}




Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 1;
        int n = sc.nextInt();
        int k = sc.nextInt();
        for (int i=0;i<n;i++){
            ans = Math.min(ans*2,ans+k);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;

ll N;


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

	cin >> N;
	if (N >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}

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

int main() {
    int n;
    cin >> n;
    n %= 1000;
    if (n > 0)
        n = 1000 - n;
    cout << n << endl;
}


Measured memory_bytes: 3664
#create date: 2020-06-27 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def g(n):
    return n * (n+1) // 2

def main():
    n = ni()
    ans = 0
    for i in range(1, n+1):
        ans += i * g(n//i)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 63580
N, M = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(N)]
q = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
  m = 1000000000
  cnt = -1
  pnt = p[i][:]
  for j in range(M):
    d = abs(pnt[0] - q[j][0]) + abs(pnt[1] - q[j][1])
    if m > d:
      cnt = j
      m = d
  print(cnt+1)

Measured memory_bytes: 3064
while query = gets
  hand = query.chomp.split(",").map(&:to_i)
  cnt_max = hand.max_by{|x| hand.count(x)}
  same = hand.count(cnt_max)

  case same
  when 4
    puts "four card"

  when 3
    cnt_min = hand.min_by{|x| hand.count(x)}
    if hand.count(cnt_min) == 2
      puts "full house"
    else puts "three card"
    end

  when 2
    if hand.uniq.length == 3
      puts "two pair"
    else puts "one pair"
    end

  else
    hand.sort!
    str_flag = true
    4.times do |i|
      unless hand[i+1] - hand[i] == 1
        str_flag = false
        break
      end
    end

    if str_flag
      puts "straight"
    elsif hand == [1, 10, 11, 12, 13]
      puts "straight"
    else puts "null"
    end
  end
end

Measured memory_bytes: 8636
#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>;
const int INF=1001001;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int>w(n,0);
  vector<int>e(n,0);
  vector<int>v(n,0);
  int cnt=0;
  rep(i,n){
    char now=s[i];
    if (now=='E')cnt++;
    e[i]=cnt;
  }
  cnt=0;
  for(int i=n-1;i>=0;i--){
    char now=s[i];
    if (now=='W')cnt++;
    w[i]=cnt;
  }
  int ans=0;
  if (n>2){
  for(int i=1;i<n-1;i++){
    v[i]=e[i-1]+w[i+1];
    ans=max(ans,v[i]);
  }
  ans=max(ans,e[n-2]);
  ans=max(ans,w[1]);
  cout<<n-ans-1;}
  else{
    cout<<0;
  }






}


Measured memory_bytes: 4228
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int[] f = new int[n + 1];
        f[0] = Integer.MAX_VALUE;
        int len = 0;
        for (int i = 0; i < n; ++i) {
            int x = scanner.nextInt();
            if (f[len] >= x) {
                f[++len] = x;
            } else {
                int l = 0;
                int r = len;
                while (l < r) {
                    int mid = (l + r) >> 1;
                    if (f[mid] < x)
                        r = mid;
                    else
                        l = mid + 1;
                }
                f[l] = x;
            }
        }
        writer.println(len);


        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

//~ const int MOD=1000000007;
const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int main(){
	ll n;cin>>n;
	auto mp=prime_factor(n);
	ll ans=0;
	for(auto p:mp){
		int cnt=0;
		while(p.second>=cnt+1){
			p.second-=cnt+1;
			cnt++;
		}
		ans+=cnt;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<long long> notches(n + 1);
	int curr;
	for (int i = 1; i <= n; ++i) {
		cin >> curr;
		notches[i] += notches[i - 1] + curr;
	}

	double half = (double) notches[n] / 2;
	double closest_dist = INT_MAX;
	for (int i = 1; i <= n; ++i) {
		closest_dist = min(closest_dist, abs(half - notches[i]));
	}

	cout << (long long) (closest_dist * 2) << "\n";

	return 0;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    
    int i;
    int x;
    int n;

    scanf("%d", &n);
    i = 1;
    do {
        if(i % 3 == 0) {
            printf(" %d", i);
            continue;
        }
        x = i;
        do {
            if(x % 10 == 3) {
                printf(" %d", i);
                break;
            }
            x /= 10;
        }
        while(x);

    }
    while(++i <= n);

    printf("\n");

    return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n;
    cin>>n;
    Graph G(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n,-1),dist1(n,-1),pr(n);
    queue<int> que;
    dist[0]=0;
    que.push(0);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(int nv:G[v]){
            if(dist[nv]!=-1) continue;
            dist[nv]=dist[v]+1;
            pr[nv]=v;
            que.push(nv);
        }
    }
    int d=dist[n-1]-1;
    int cnt;
    if(d%2==0) cnt=d/2+1;
    else cnt=(d+1)/2+1;
    vector<int> path;
    path.push_back(n-1);
    while(true){
        int m=path.size();
        int mm=pr[path[m-1]];
        path.push_back(mm);
        if(mm==0) break;
    }
    reverse(all(path));
    int m=path.size();
    if(d==0) dist1[n-1]=0;
    else{
        int u=1;
        int uu;
        while(true){
            if(u==cnt){
                uu=path[u];
                break;
            }
            u++;
        }
        dist1[uu]=0;
    }
    queue<int> q;
    dist1[0]=0;
    q.push(0);
    int cc=0;
    while(!q.empty()){
        int v=q.front();q.pop();
        for(int nv:G[v]){
            if(dist1[nv]!=-1) continue;
            dist1[nv]=dist1[v]+1;
            q.push(nv);
            cc++;
        }
    }
    int c=n-2-cc;
    if(cc<=c) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    int n; cin >> n;
    reg int res = n / 2;
    if (n % 2) cout << (double)(res + 1) / (double)n << endl;
    else cout << (double)res / (double)n << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
a_list = sorted(list(map(int,input().split())),reverse=True)
alice = []
bob = []
for _ in range(math.ceil(len(a_list)/2)):
    alice.append(a_list.pop(0))
    if len(a_list) == 0:
        break
    bob.append(a_list.pop(0))
print(sum(alice)-sum(bob))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,i,t,min;
    cin >> N >> K;
    int x[N];
    min=2147483647;
    for(i=0;i<N;i++){
        cin >> x[i];
    }
    for(i=0;i<N-K+1;i++){
        if(x[i+K-1]<0){
            t=-x[i];
        }else if(x[i]>0){
            t=x[i+K-1];
        }else{
            if(-x[i]>x[i+K-1]){
                t=2*x[i+K-1]-x[i];
            }else{
                t=x[i+K-1]-2*x[i];
            }
        }
        if(t<min){
            min=t;
        }
    }
    cout << min << endl;
}


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

typedef long long ll;
ll n,m,Out;

int main(){
	cin>>n>>m;
	if(n >= 2) Out += (n * (n - 1) / 2);
	if(m >= 2) Out += (m * (m - 1) / 2);
	cout<<Out<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    let n = s.len() + 1;

    let mut x = vec![];
    for i in 1..(n - 1) {
        let left = s[i - 1];
        let right = s[i];
        if left == '<' && right == '>' {
            x.push(i);
        }
    }

    if s[0] == '>' {
        x.push(0);
    }
    if s[n - 2] == '<' {
        x.push(n - 1);
    }

    let mut ans = vec![0; n];
    for x in x.into_iter() {
        if x == 0 {
            let mut right = x;
            while right + 1 < n - 1 && s[right + 1] == '>' {
                right += 1;
            }
            for i in x..(right + 2) {
                ans[i] = cmp::max(ans[i], right + 1 - i);
            }
        } else if x == n - 1 {
            let mut left = x - 1;
            while left > 0 && s[left - 1] == '<' {
                left -= 1;
            }
            for i in left..(x + 1) {
                ans[i] = cmp::max(i - left, ans[i]);
            }
        } else {
            let mut left = x - 1;
            while left > 0 && s[left - 1] == '<' {
                left -= 1;
            }
            let mut right = x;
            while right + 1 < n - 1 && s[right + 1] == '>' {
                right += 1;
            }
            for i in left..(x + 1) {
                ans[i] = cmp::max(i - left, ans[i]);
            }
            for i in x..(right + 2) {
                ans[i] = cmp::max(ans[i], right + 1 - i);
            }
        }
    }

    println!("{}", ans.iter().sum::<usize>());
}

/// < >>> << >0<<<<<5>>> <

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		String AStr[] = br.readLine().split(" ");
		int A[] = new int[n];

		for(int i = 0 ; i < n ; i++) A[i] = Integer.parseInt(AStr[i]);

		selectSort(n,A);

	}

	public static void selectSort(int n,int[] A){
		int count = 0;
		for(int i = 0 ; i < n ; i++){
			int minIndex = i;
			for(int y = i + 1 ; y < n ; y++){
				if(A[minIndex] > A[y]){
					minIndex = y;
				}
			}
			if(minIndex != i){
				int tmp = A[minIndex];
				A[minIndex] = A[i];
				A[i] = tmp;
				count++;
			}
		}

		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < n; i++){
			sb.append(A[i]);
			sb.append(" ");
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
		System.out.println(count);
	}

}

Measured memory_bytes: 24140
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

s=input()
if s==s.lower():
    print("a")
else:
    print("A")







Measured memory_bytes: 10604
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        String op = scan.next();
        int b = scan.nextInt();
        while(!op.equals("?")) {
            if (op.equals("+")) {
                System.out.println(a + b);
            }
            else if (op.equals("-")) {
                System.out.println(a - b);
            }
            else if (op.equals("*")) {
                System.out.println(a * b);

            }
            else{
                System.out.println(a / b);

            }
             a = scan.nextInt();
             op = scan.next();
             b = scan.nextInt();
        }
    }
}


Measured memory_bytes: 26272
open System
let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int

let [| N; Y |] = readIntArray ()

let showResult (a, b, c) = printfn "%d %d %d" a b c

seq { for i in [0..N] do
          for j in [0..(N - i)] do
              yield (i , j, N - i - j)}
|> Seq.tryFind (fun (a, b, c) -> a * 10000 + b * 5000 + c * 1000 = Y)
|> (fun opt -> if Option.isSome opt then Option.get opt else (-1, -1, -1))
|> showResult 






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


int main()
{
    int x,a;
    cin >> x >> a;
    if(x<a) cout << 0;
    else cout << 10;
    return 0;
}

    

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   int k;cin >>k;
   ll ans=0;
   ll a=0;
   ll b=0;
   bool flg=true;
   char key=s[0];
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]==key)a++;
        else break;
    }
    reverse(all(s));
    key=s[0];
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]==key)b++;
        else break;
    }
    reverse(all(s));
//    cout <<s<<endl;
    for (int i = 1; i < (int) s.size(); ++i) {
        if(s[i]==s[i-1]){
            ans+=k;
            i++;
        }
    }
//    cout <<ans<<endl;
    ll sub=0;
    if(s[0]==s.back()) {
        sub += a / 2 + b / 2 - (a + b) / 2;
    }
   ans-=sub*(k-1);
   if(a==s.size()){
       cout <<(a*k)/2<<endl;
   }
   else {
       cout << ans << endl;
   }
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;

  char c = S[K - 1];
  for (char s : S) {
    if (s == c) {
      cout << s;
    } else {
      cout << '*';
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, M = map(int,input().split())
A = list(map(int,input().split()))

hq = []
for a in A:
    heappush(hq, -a)

for _ in range(M):
    heappush(hq, -(-heappop(hq)//2))

ans = -sum(hq)
print(ans)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
    optimizar_io
    int a,b,c,ans=0; cin>> a >> b >> c;
    int aux=c;
    while(aux<=a){
        aux+=b; aux+=c;
        if(aux<=a)ans++;
    }
    cout<<ans<<endl;

}



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

int main() {
  int n, q;
  cin>>n>>q;
  queue<pair<string,int> > Q;
  string name;
  int t;
  for (int i=0; i<n; i++) {
    cin>>name>>t;
    Q.push(make_pair(name,t));
  }
  pair<string,int> u;
  int elaps=0;
  while (!Q.empty()) {
    u=Q.front();
    Q.pop();
    int a=min(u.second,q);
    u.second-=a;
    elaps+=a;
    if (u.second>0) {
      Q.push(u);
    } else {
      cout<<u.first<<" "<<elaps<<endl;
    }
  }
  return 0;
}



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

int main() {
	int a;
  	int count=0;
  	cin >> a;
  	for(int i=1;i < a+1;i++){
      if(i/10 ==0)
        count++;
  	  else if(i/100 >= 1 && i/100 < 10)
        		count++;
      		else if(i/10000 >= 1&&i/10000 <10)
        			count++;
    }
  cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
  	cin>>n ;
  	b = 0 ;
  	for(i=0 ; i<n ; i=i+1)
  	{
  		cin>>a ;
		b = __gcd(b,a) ;	
	}
	cout<<b; 
}

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

int main()
{
	int a[3];
	int k;

	cin >> a[0] >> a[1] >> a[2] >> k;

	sort(a, a + 3);

	for (int i = 0; i < k; i++)
		a[2] *= 2;

	cout << a[0] + a[1] + a[2] << endl;

	return 0;
}

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

using namespace std;

string o, m;

void solve() {
	int len = (int)o.size();
	int sz = (int)m.size();
	
	for (int i = len - 1; i >= 0; i--) {
		switch (o[i]) {
		case 'J':
			m = m[sz - 1] + m.substr(0, sz - 1);
			break;
		case 'C':
			m = m.substr(1, sz - 1) + m[0];
			break;
		case 'E':
			if (sz % 2) {
				m = m.substr(sz / 2 + 1, sz / 2) + m[sz / 2] + m.substr(0, sz / 2);
			} else {
				m = m.substr(sz / 2, sz / 2) + m.substr(0, sz / 2);
			}
			break;
		case 'A':
			reverse(m.begin(), m.end());
			break;
		case 'P':
			for (int i = 0; i < sz; i++) {
				if ('1' <= m[i] && m[i] <= '9') {
					char c = m[i] - 1;
					m[i] = c;
				} else if (m[i] == '0') m[i] = '9';
			}
			break;
		case 'M':
			for (int i = 0; i < sz; i++) {
				if ('0' <= m[i] && m[i] <= '8') {
					char c = m[i] + 1;
					m[i] = c;
				} else if (m[i] == '9') m[i] = '0';
			}
			break;
		default:
			break;
		}
	}
	
	cout << m << endl;
}

int main() {
	int n; cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> o;
		cin >> m;
		solve();
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll nCr(ll n,ll r){
	ll x=1;
	ll y=1;
	rep(i,r){
		x=x*(n-i)%mod;
		y=y*(i+1)%mod;
	}
	return x*powmod(y,mod-2)%mod;
}

int main()
{
	ll n,k;
	cin >> n >> k;
	for(ll i=1;i<=k;i++){
		cout << nCr(n-k+1,i)*nCr(k-1,i-1)%mod << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

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--)
int N,K,X,Y;

int main()
{

	cin >> N >> K >> X >> Y;

	if(N > K){
		cout << K * X + (N-K) * Y;
	}
	else{
		cout << N*X;
	}





}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 200005;

int H,W,X,Y,n;

char s[MAXN];
char t[MAXN];

int main()
{
	scanf("%d%d%d%d%d%s%s",&H,&W,&n,&X,&Y,s + 1,t + 1);
	int Lx = 1,Rx = H,Ly = 1,Ry = W;
	for (int i = n;i >= 1;i--)
	{
		if (t[i] == 'L')
			Ry = min(Ry + 1,W);
		if (t[i] == 'R')
			Ly = max(Ly - 1,1);
		if (t[i] == 'U')
			Rx = min(Rx + 1,H);
		if (t[i] == 'D')
			Lx = max(Lx - 1,1);
		if (s[i] == 'L')
			Ly++;
		if (s[i] == 'R')
			Ry--;
		if (s[i] == 'U')
			Lx++;
		if (s[i] == 'D')
			Rx--;
		if (Lx > Rx || Ly > Ry)
		{
			puts("NO");
			return 0;
		}
	}
	if (Lx <= X && X <= Rx && Ly <= Y && Y <= Ry)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 640
list=[]
count=int(input())
for i in range(count):
    list.append(input())
print("AC"+" "+"x"+" "+str(list.count("AC")))
print("WA"+" "+"x"+" "+str(list.count("WA")))
print("TLE"+" "+"x"+" "+str(list.count("TLE")))
print("RE"+" "+"x"+" "+str(list.count("RE")))

Measured memory_bytes: 16248
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	map<ll, ll> mp;
	rep(i, n) {
		ll a;
		cin >> a;
		mp[a]++;
	}
	priority_queue<ll> p;
	for (auto item : mp) {
		p.push(item.second);
	}
	while (true) {
		if (p.size() == 1) break;
		ll a1 = p.top();
		if (a1 == 1) {
			break;
		}
		p.pop();
		ll a2 = p.top();
		p.pop();
		if (a2 == 1) {
			a1--;
			p.push(a1);
			break;
		}
		a1--;
		a2--;
		p.push(a1);
		p.push(a2);
	}
	cout << p.size() << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 10408
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int r;
    scan(r);
    auto ans = 2 * r * PI;
    writefln("%.12f", ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

const int MAX_N = 100005;

int n, A[MAX_N], B[MAX_N], C[MAX_N], pos[3 * MAX_N], rev[3 * MAX_N];


void wypisz() {
    cout << "----------------------\n";
    for(int i = 1; i <= n; i++) cout << A[i] << " ";
    cout << endl;
    for(int i = 1; i <= n; i++) cout << B[i] << " ";
    cout << endl;
    for(int i = 1; i <= n; i++) cout << C[i] << " ";
    cout << endl;
}

void swapColumn(int i) {
    swap(A[i], C[i]);
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];
    for(int i = 1; i <= n; i++) cin >> B[i];
    for(int i = 1; i <= n; i++) cin >> C[i];
    
    for(int i = 1; i <= n; i++) {
        if((B[i] % 3 != 2) || (((B[i] - 2) / 3) % 2 == i % 2)) {
            cout << "No";
            return 0;
        }
        int a = (A[i] - 1) / 3;
        int b = (B[i] - 1) / 3;
        int c = (C[i] - 1) / 3;
        if(a != b || a != c || b != c) {
            cout << "No";
            return 0;
        }
    }
    for(int i = 1; i <= n; i++) {
        pos[B[i]] = i;
    }
    for(int i = 1; i <= n; i++) {
        if(B[i] == 3 * i - 1) {
            continue;
        }
        int j = pos[3 * i - 1];
        int x = B[i];
        int y = B[j];
        B[i] = y;
        B[j] = x;
        swap(A[i], A[j]);
        swap(C[i], C[j]);
        pos[x] = j;
        pos[y] = i;
        
        if((i - j) % 4 != 0) {
            swapColumn(i);
            swapColumn(j);
        }
        swap(A[i + 1], C[i + 1]);
//         wypisz();
    }
    
    int odd = 0, even = 0;
    for(int i = 1; i <= n; i++) {
//         if(rev[B[i]]) swap(A[i], C[i]);
        if(A[i] > C[i]) {
            if(i % 2 == 1) odd++;
            else even++;
//             cout << "No3";
//             return 0;
        }
    }
    
    if(odd % 2 == 1 || even % 2 == 1) {
        cout << "No";
        return 0;
    }
    
    cout << "Yes";
    return 0;
}

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

int main() {
	int n,t,ans=10000;
	cin>>n>>t;
	int cost[n],tim[n];
	for(int i=0;i<n;i++){
	    cin>>cost[i]>>tim[i];
	}
	for(int j=0;j<n;j++){
	    if(tim[j]<=t&&cost[j]<ans){
	        ans=cost[j];
	    }
	}
	if(ans==10000)cout<<"TLE";
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int x, y;
   scanf("%d %d", &x, &y);
   while(x + y){
      if( x < y ){
         printf("%d %d\n", x, y);
      }else{
         printf("%d %d\n", y, x);
      }
      scanf("%d %d", &x, &y);
   }

   return 0;
}



Measured memory_bytes: 2036
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

    if k <= cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()


Measured memory_bytes: 38384
let n, a, b, c, d, s = Scanf.scanf " %d %d %d %d %d %s" @@ fun a b c d e f -> a, b - 1, c - 1, d - 1, e - 1, f
let s2, s3 = String.sub s a @@ c - a + 1, String.sub s b @@ d - b + 1
let f s = try Str.search_forward (Str.regexp "##") s 0 |> ignore; false with _ -> true
let s4 = String.sub s (b - 1) @@ min (n - b + 1) @@ d - b + 3
let _ = print_endline @@ 
  if f s2 && f s3 then
    if d < c then
      try Str.search_forward (Str.regexp "\\.\\.\\.") s4 0 |> ignore; "Yes" with _ -> "No"
    else "Yes"
  else "No"

Measured memory_bytes: 3200
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <numeric>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define rng mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count())

#define ri(...) i64 __VA_ARGS__; rx(__VA_ARGS__)
#define rc(...) char __VA_ARGS__; rx(__VA_ARGS__)
#define rs(...) string __VA_ARGS__; rx(__VA_ARGS__)
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << '[' << #__VA_ARGS__ << "]: "; dbg_log(__VA_ARGS__)
#else
#define dbg(...) ;;
#endif

#define fa(i, v) for (auto &i : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(i) ri(_i); fi(i, _i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#ifdef __SIZEOF_INT128__
typedef __uint128_t u128;
typedef __int128_t i128;
#endif
typedef vector<i64> vi;
typedef vector<vi> vvi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) out << x << ' ';
    return out;
}

template<typename T>
inline void rx(T &x) {
    cin >> x;
}

template<typename T, typename... R>
inline void rx(T &x, R &... l) {
    cin >> x;
    rx(l...);
}

template<typename T>
inline void dbg_log(const T &x) {
    cerr << x << '\n';
}

template<typename T, typename... R>
inline void dbg_log(const T &x, const R &... l) {
    cerr << x << ", ";
    dbg_log(l...);
}

template<typename T>
inline void wl(const T &x) {
    cout << x << '\n';
}

template<typename T, typename... R>
inline void wl(const T &x, const R &... l) {
    cout << x << ' ';
    wl<R...>(l...);
}

int main() {
    fio;

    ri(n, k);
    rvi(a, n);
    double i = 0;
    double j = 1e9 + 1;
    fi(t, 100) {
        double m = (i + j) / 2;
        i32 r = 0;
        fa(x, a) {
            r += floor(x / m);
        }
        if (r > k) {
            i = m;
        } else {
            j = m;
        }
    }
    wl((u64) ceil(i - 1e-10));

    return 0;
}


Measured memory_bytes: 4728
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    int l[50];
    int k;
    cin >> n >> k;
    imfor(i, n) {
        cin >> l[i];
    }
    sort(l, l + n, greater<int>());
    int ans = 0;
    imfor(i, k) {
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.valueOf(br.readLine());
		System.out.println(num*num*num);
	}

}

Measured memory_bytes: 24308
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <map>
#define DEBUG
#undef DEBUG
using namespace std;
typedef long long ll;

ll N;
ll midn;
ll a[100005];

ll func(ll x){
    ll b[100005]; //x以下なら1、そうでなければ0という数列の累積和
    ll BIT[(1<<18)+1]; //累積和のBinary Index Tree
    for(ll i=0;i<=(1<<18);i++){
        BIT[i]=0;
    }
    b[0]=1e5+1;
    for(ll i=1;i<=N;i++){
        b[i]=b[i-1];
        if(a[i-1]<=x){b[i]++;}
        else{b[i]--;}
    }
#ifdef DEBUG
#endif
    
    //
    ll ans=0;
    ll j = b[0];
    while(j<=(1<<18)){
        BIT[j]++;
        j=j+((-j)&j);
    }
    for(ll i=1;i<=N;i++){
        ll j = b[i]-1;
        while(j>0){
            ans += BIT[j];
            j=j-((-j)&j);
        }
        j = b[i];
        while(j<=(1<<18)){
            BIT[j]++;
            j=j+((-j)&j);
        }
    }
    return ans;
}

int main(){
    cin>>N;
    midn = N*(N+1)/4+1;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    ll left=0,right=1e9,mid;
    while(right-left>1){
        mid=(left+right)/2;
#ifdef DEBUG
        cout<<mid<<endl;
#endif
        if(func(mid)<midn){
            left=mid;
        }else{
            right=mid;
        }
    }
    cout<<right<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll s; cin >> s;
  switch (s)
  {
    case 25:fin("Christmas") exit(0);
    case 24:fin("Christmas Eve") exit(0);
    case 23:fin("Christmas Eve Eve") exit(0);
    case 22:
      fin("Christmas Eve Eve Eve") exit(0);
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

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

int main(void){
	int h,w,a,b;
	std::cin >> h >> w; a = h*60+w;
	std::cin >> h >> w; b = h*60+w;
	b -= a; std::cin >> a;
	std::cout << (b-a) << std::endl;
	return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double m = H * 60 + M;
	double PI = acos(-1);
	double rad1 = m / 720 * 2 * PI; // 時針
	double rad2 = m / 60 * 2 * PI; // 分針
	
	double x1 = B * cos(rad1), y1 = B * sin(rad1);
	double x2 = A * cos(rad2), y2 = A * sin(rad2);
	double d = hypot(x1 - x2, y1 - y2);
	printf("%.18f\n", d);
	return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    string S;
    cin >> S;
    int ans1, ans2;
    if (S.size() == 2 && S[0] == S[1])
    {
        ans1 = 1;
        ans2 = 2;
        cout << ans1 << " " << ans2 << endl;
        return 0;
    }
    else
    {
        rep(i, S.size())
        {
            if (S[i] == S[i + 1])
            {
                if (i + 2 < S.size())
                {
                    cout << i + 1 << " " << i + 2 << endl;
                    return 0;
                }
                else
                {
                    cout << i << " " << i + 2 << endl;
                    return 0;
                }
            }
            else if (S[i] == S[i + 2])
            {
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
        cout << -1 << " " << -1 << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a,b;cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }else if(a>=6){
    cout<<b/2<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
flag = 1
h[0] -= 1
for i in range(1,n-1):
    if h[i]-h[i+1] >= 2:
        flag = 0
        break
    elif h[i]-h[i+1] == 1:
        if h[i] == h[i-1]:
            flag = 0
            break
        else:
            h[i] -= 1
    else:
        if h[i] != h[i-1]:
            h[i] -= 1

if flag == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 63984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++mp[a];
    }
    int res = 0;
    for(auto it : mp){
        int num = it.first, cnt = it.second;
        if(num < cnt)   res += cnt - num;
        else if(num > cnt)  res += cnt;
    }
    cout << res << endl;
}

Measured memory_bytes: 4736