akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N), cnts;
    rep(i, N) {
        char c;
        cin >> c;
        A[i] = c - '0';
    }

    int cnt = 1;
    repd(i, 1, N) {
        if (A[i] == A[i - 1]) cnt++;
        else {
            cnts.emplace_back(cnt);
            cnt = 1;
        }
    }
    cnts.emplace_back(cnt);

    int ans = 0;

    int r = 2 * K + A[0];
    int len = (int)cnts.size();
    rep(i, min(r, len)) {
        ans += cnts[i];
    }

    if (A[0] == 1 && len % 2 == 0) cnts.emplace_back(0);
    if (A[0] == 0 && len % 2) cnts.emplace_back(0);

    len = (int)cnts.size();
    int res = ans;
    for (int i = r; i < len; i += 2) {
        res += cnts[i] + cnts[i + 1] - cnts[i - r] - cnts[i - r + 1];
        if (A[0] == 0 && i - r == 0) {
            res += cnts[i - r + 1];
            r++;
        }
        chmax(ans, res);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4232
k = int(input())

lst = [1]
for i in range(1, 10**7):
    lst.append((lst[-1]*10) % k)

num = 0
for i in range(10**7):
    num += 7*lst[i]
    num %= k
    if num == 0:
        print(i+1)
        exit()
print(-1)

Measured memory_bytes: 218400
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
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;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));

	ll ans = 0;
	rep(i, n-k) ans += h[i];
	co(ans);

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define M 1000000007
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int32_t main()
{
    //fastio;
    int t=1,n,k,i,j;
    //cin>>t;
    while (t--)
    {
        cin>>n;

        int dp[n][3];
        cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
        for(i=1;i<n;i++)
        {
            cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
            dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]+=max(dp[i-1][1],dp[i-1][0]);
        }
        
        cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<"\n";

    }
    return 0;
}

/*
    ifstream cin("input.txt");
    ofstream cout("output.txt");

    string s;
    cin>>s;
*/

Measured memory_bytes: 2560
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string s;
    cin >> s;
    ll count = 0;
    rep(i, 3) if (s[i] == '1') count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,C=map(int, input().split())
B=list(map(int, input().split()))
A=[]
ans=0
a=0
for i in range(N):
    A.append([int(j) for j in input().split()])
for i in range(N):
    for j in range(M):
         a+=A[i][j]*B[j]
    if a+C>0:
        ans+=1
        a=0
    else:
        a=0
print(ans)

Measured memory_bytes: 3064
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    s = list(sys.stdin.readline())
    del s[len(s) - 1]
    cnt = 0

    for i in range(1, len(s)):
        if s[i] != s[i - 1]:
            cnt += 1

    print(max(0, cnt))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11032
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>
#include <iomanip>

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

    std::vector<long> A_seq;
    A_seq.reserve(N);
    std::vector<long> num_of_balls;
    num_of_balls.resize(N + 1, 0);

    for (int i = 0; i < N; ++i) {
        int A;
        std::cin >> A;
        A_seq.push_back(A);
        num_of_balls[A] += 1;
    }

    std::vector<long> num_of_pairs;
    num_of_pairs.reserve(N + 1);
    num_of_pairs.push_back(0);
    long sum = 0;
    for (long value : num_of_balls) {
        long res = value * (value -1) / 2;
        num_of_pairs.push_back(res);
        sum += res;
    }

    for (int i = 0; i < N; ++i) {
        long A = A_seq[i];
        long num_of_A = num_of_balls[A];
        std::cout << sum + 1 - num_of_A << std::endl;
    }
    return 0;
}

Measured memory_bytes: 8548
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

pii p[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		int x;
		cin >> x;
		p[i] = M(x,i);
	}
	sort(p + 1, p + n + 1);
	for(int i = 1; i <= n; i ++)
		cout << p[i].S << ' ';





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final String S = sc.next();
			
			final int YY = Integer.parseInt(S.substring(0, 2));
			final int MM = Integer.parseInt(S.substring(2, 4));
			
			if(1 <= MM && MM <= 12) {
				if(1 <= YY && YY <= 12) {
					System.out.println("AMBIGUOUS");
				}else {
					System.out.println("YYMM");
				}
			}else {
				if(1 <= YY && YY <= 12) {
					System.out.println("MMYY");
				}else {
					System.out.println("NA");
				}
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>

using namespace std;
int main(void){
    int a,b,c,d;
    
    cin>>a>>b;
    
    c=(a+b)/2;
    d=(a+b)%2;
    
    if(d>=1){
        cout<<c+1<<endl;
    }else{
        cout<<c<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 #include<iostream>
 #include<algorithm> 
using namespace std;
 
const int MAXN=int(2e5+4);


long long seqa[MAXN];
long long seqb[MAXN];
 
 int temp=0; 
 int swap(int a,int b)
 {
     temp=a;
     a=b;
     b=temp; 
 } 
 int main() {
    int n;
    cin>>n;
    for (int i=0; i<n; i++) 
        cin>>seqa[i];
    for (int i=0; i<n; i++)
        cin>>seqb[i];
 
    reverse(seqb, seqb+n);
 
    int com=-1;
    int len=n;
    int re=-1;
    for (int i=0; i<n; i++) {
        if (com==-1 && seqa[i]==seqb[i]) {
            com=seqa[i];
            len=i;
            re=i;
        }
         else if (com!=-1 && seqa[i]==seqb[i]) 
         {
            re=i;
        }
    }

    for (int i=0; i<n; i++) {
        if (com!=seqa[i] && com!=seqb[i] &&len<=re)
        {
             
            swap(seqb[i], seqb[len]);
            len++;
        }
    }
 
    if (len<=re) {
        printf("No\n");
    } else {
        printf("Yes\n");
        for (int i=0; i<n; i++) {
            printf("%d ",seqb[i]); 
        }
    }
    //system("pause"); 
    return 0;
}


Measured memory_bytes: 6844
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict

    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    c = N * K
    b = 0
    while 2 ** b < c:
        b += 1

    doubling = [[0] * N for _ in range(b + 1)]

    idx = defaultdict(list)
    for i, x in enumerate(A):
        idx[x].append(i)

    for i in range(1, 200001):
        d = idx[i]
        l = len(d)
        for j in range(l):
            cur = d[j]
            nx = d[(j + 1) % l]
            if nx <= cur:
                doubling[0][cur] = N - (cur - nx) + 1
            else:
                doubling[0][cur] = nx - cur + 1

    for i in range(1, b + 1):
        for j in range(N):
            p = doubling[i - 1][j]
            doubling[i][j] = p + doubling[i - 1][(j + p) % N]

    cnt = 0
    cur = 0
    while c - cnt > 200000:
        for i in range(b, -1, -1):
            if cnt + doubling[i][cur] < c:
                cnt += doubling[i][cur]
                cur = cnt % N
                break

    rem = c - cnt
    res = []
    res_set = set()

    while rem > 0:
        num = A[cur]
        if num in res_set:
            while True:
                back = res[-1]
                res.pop()
                res_set.discard(back)
                if back == num:
                    break
        else:
            res.append(num)
            res_set.add(num)
        rem -= 1
        cur += 1
        cur %= N

    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 470364
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m,s;
ll a[100005];
bool color[100005];
ll sum=0;
bool muri=false;
 
int main(){
	cin>>n;
	ll itido=n*(n+1)/2;
	ll syo=0;
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		syo += sum/itido;
		sum=sum%itido;
	}
	if(sum%itido!=0)muri=true;
	ll kaisu=syo;
	ll kuro=0;
	for(i=0;i<n-1;i++){
		ll sa=a[i+1]-a[i];
		if((kaisu-sa)%n!=0)muri=true;
		if(kaisu-sa<0)muri=true;
		kuro+=(kaisu-sa)/n;
	}
	ll sa=a[0]-a[n-1];
	if((kaisu-sa)%n!=0)muri=true;
	if(kaisu-sa<0)muri=true;
	kuro+=(kaisu-sa)/n;
	if(kuro==kaisu && !muri){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define fi first
#define se second
#define pa pair <ll,ll>
#define mp make_pair
#define pb push_back
#define ve vector<ll>
#define vep vector< pa >
#define c(t) cout<<t<<"\n"
using namespace std;
void solve()
{  ll n,k;
cin>>n>>k;
if(k==1)
    c(0);
else
{
ll x=n-k;
c(x);
}
}
int main()
{
    ios::sync_with_stdio(true);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;

char offset(char a, int N) {
    char b = a + N;
    if (b > 'Z') return b - 26;
    return b; 
}

int main() {
    int N; cin >> N; string S; cin >> S;
    for (int i = 0; i < S.length(); i++) {
        cout << offset(S[i],N);
    }
    cout << endl;
}



Measured memory_bytes: 256
n, q = map(int, input().split())

n_ = 1 # 実際に確保した配列のサイズ
while n_ < n:
  n_ *= 2

initv = pow(2, 31)-1
seg_tree = [initv for i in range(2*n_-1)]

def update(i, x):
  i += n_ - 1
  seg_tree[i] = x
  while i > 0 :
    i = int((i - 1)/2)
    seg_tree[i] = min(seg_tree[i*2+1], seg_tree[i*2+2])

def findMin(s, t):
  return query(s, t+1, 0, 0, n_)

def query(a, b, k, l, r):
  if r <= a or b <= l :
    return initv
  if a <= l and r <= b:
    return seg_tree[k]

  vl = query(a, b, k*2+1, l, int((l+r)/2))
  vr = query(a, b, k*2+2, int((l+r)/2), r)
  return min(vl, vr)


output = []

for i in range(q):
  line = list(map(int, input().split()))

  if line[0] == 0:
    update(line[1], line[2])

  else :
    output.append(findMin(line[1],line[2]))


for ans in output:
  print(ans)


Measured memory_bytes: 10504
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        ps: [(i64, i64); n],
    }

    let mut ps = ps;
    ps.sort();

    debug!(ps);

    let mut diffs = BTreeSet::new();

    for p in &ps {
        for q in &ps {
            diffs.insert((p.0 - q.0, p.1 - q.1));
            // if 0 <= p.0 - q.0 {
            //     diffs.insert((p.0 - q.0, p.1 - q.1));
            // }
        }
    }

    // diffs.remove(&(0, 0));

    debug!(diffs);

    let ans = diffs.iter().fold(<usize>::max_value(), |a, diff| min(a, solve(&ps, diff)));
    println!("{}", ans);
}

fn solve(ps: &Vec<(i64, i64)>, diff: &(i64, i64)) -> usize {
    println!("\n\n");
    debug!(diff);
    let ps = ps.clone();

    let mut n: usize = 0;
    let mut groups = BTreeSet::new();

    for p in ps {
        let q = (p.0 - diff.0, p.1 - diff.1);

        if !groups.contains(&q) {
            n += 1;
            debug!(n);
            // debug!(q);
            debug!(p);
            debug!(groups);
        }

        groups.insert(p);
    }

    n
}


Measured memory_bytes: 4352
import java.util.Scanner;


class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    
    int[] firstDice = new int[n];
    
    for(int i=1;i<=n;i++){
      firstDice[i-1] = getExp(2,i,k);
    }
    int maxExp = firstDice[0];
    long upsum = 0;
    long downsum = pow(2,firstDice[0])*n;
    
    for(int i=0;i<n;i++){
      upsum+=pow(2,maxExp-firstDice[i]);
    }
    double answer = (double)upsum/downsum;
    
    System.out.print(answer);
    
    System.out.flush();
  }
  
  public static int getExp(int base , int first , int target){
    int exp = 1;
    int cnt = 0;
    while(first*exp<target){
      cnt++;
      exp*=base;
    }
    return cnt;
  }
  //x^n
  public static long pow(int x, int n){
    long ans = 1;
    while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; 
		n >>= 1;
	}
	return ans;
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,X,t,ans;
    cin >> N >> X;
    int m[N];
    for (int i = 0 ;i <N;i++) {
        cin >> m[i];
        X -= m[i];
    }
    sort(m, m+N);
    ans = X / m[0] + N;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int n;
    while (cin >> n) {
        unordered_map<long long, int> mp;
        mp[0] = 1;
        vector<int> a(n);
        long long cr = 0;
        for (int& p : a) {
            cin >> p;
            cr += p;
            mp[cr]++;
        }
        long long sm = 0;
        for (auto& p : mp)
            sm += (long long)p.second * (p.second - 1) / 2;
        cout << sm << endl;
    }
    return 0;
}


Measured memory_bytes: 12028
/*
Sharif Hasan - CSE, PUST
Feb 22, 2020 12: 35 PM 
*/
#include<bits/stdc++.h>
#define br cout<<"\n"

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(i=0;i<n;i++)
#define FROM(a,i,n) for(i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

/*Main function*/
int main()
{
int n;
cin>>n;
int i,j,arr[n];
FOR(i,n) cin>>arr[i];
sort(arr,arr+n);
long long stm=pow(2,63);
FOR(i,arr[n-1]){
    long long temp=0,pos=i+1;
    FOR(j,n){
        temp += (pos-arr[j])*(pos-arr[j]);
    }
    stm = min(stm,temp);
}
cout<<stm;br;
return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    vector<vector<mint>> dp(n + 1, vector<mint>(s + 1, 0));
    dp[0][0] = 1;

    auto add = [&](int i, int j, mint v) {
        if (i > n) return;
        if (j > s) return;
        dp[i][j] += v;
    };

    rep(i, n) {
        rep(j, s + 1) {
            add(i + 1, j, dp[i][j] * 2);
            add(i + 1, j + v[i], dp[i][j]);
        }
    }

    cout << dp[n][s] << endl;

}


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

int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if (a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if (b > c){
        tmp = c;
        c = b;
        b = tmp;
    }
    if (a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e5+5;
vector<PI>ans;
int n,k;
signed main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    int ma=(n-1)*(n-2)/2;
    if(k>ma){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=2;i<=n;i++){
        ans.push_back({1,i});
    }
    ma-=k;
    for(int i=2;i<=n&&ma;i++){
        for(int j=i+1;j<=n&&ma;j++){
            ans.push_back({i,j});
            ma--;
        }
    }
    cout<<ans.size()<<endl;
    for(auto i:ans){
        cout<<i.first<<' '<<i.second<<endl;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') dump(b)
	else {
		if (b == 'H') dump("D") else dump("H");
	}
}

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

typedef struct{
  double x;
  double y;
}point;

void kock(int, point, point);
double pi = M_PI;


int main(){
  int n;
  point p1, p2;
  p1.x = p1.y = p2.y = 0;
  p2.x = 100;

  scanf("%d", &n);
  printf("%f %f\n", p1.x, p1.y);
  kock(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);

  return 0;
}

void kock(int n, point p1, point p2){
  if(n == 0) return;
  point s, t, u;

  s.x = (2*p1.x + 1*p2.x) / 3;
  s.y = (2*p1.y + 1*p2.y) / 3;
  t.x = (1*p1.x + 2*p2.x) / 3;
  t.y = (1*p1.y + 2*p2.y) / 3;

  u.x = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x;
  u.y = (t.x - s.x)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y;

  kock(n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  kock(n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  kock(n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  kock(n-1, t, p2);
}



Measured memory_bytes: 2112
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    println!("{}", if s.trim().len() == 3 {s.chars().filter_map(|t| str::parse::<i8>(&t.to_string()).ok()).fold(1, |p, x| p * x)} else { -1 });
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()
{
    fast;
    ll i,j,n,m,k,x,y;
    cin>>n>>x>>y;
    vector<ll> a(n,0);
    for(i=1;i<n;i++){
        for(j=i+1;j<=n;j++){
            k=min(j-i,abs(x-i)+abs(y-j)+1);
            a[k]++;
        }
    }
    for(i=1;i<n;i++) cout<<a[i]<<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val x = sc.nextInt
  val a = sc.nextInt
  val b = sc.nextInt

  val res =
    if(b <= a) "delicious"
    else if(a < b && b <= a + x) "safe"
    else "dangerous"

  println(res)
}


Measured memory_bytes: 25804
#include <iostream>

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  bool is_find = false;
  for (auto i = 1; i <= 9;++i) {
    if (N % i == 0) {
      int c = N/i;
      if (1 <= c && c <= 9) {
        is_find = true;
        break;
      }
    }
  }
  if (is_find == false) {
    std::cout << "No\n";
  } else {
    std::cout << "Yes\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int answer = 0;
		char c[] = new char[2];
		c[0] = str.charAt(0);
		for(int i = 1; i < str.length(); i++){
			 c[1] = str.charAt(i);
			if(c[0] == c[1]){
				answer += 1;
				if(c[1] == '0'){
					c[1] = '1';
				}else{
					c[1] = '0';
				}
			}
			c[0] = c[1];
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 26116
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}


signed main(){ 
    int h,w; cin>>h>>w;
    int n; cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];

    int grid[h][w];

    int col=0;

    for(int i=0;i<h;i++){
        if(i%2==0){
            rep(wi,0,w){
                if(a[col]!=0){
                    grid[i][wi]=col+1;
                    a[col]--;
                }else{
                    col++;
                    grid[i][wi]=col+1;
                    a[col]--;
                }
            }
        }else{
            for(int wi=w-1;wi>=0;wi--){
                if(a[col]!=0){
                    grid[i][wi]=col+1;
                    a[col]--;
                }else{
                    col++;
                    grid[i][wi]=col+1;
                    a[col]--;
                }
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j!=0) cout<<" ";
            cout<<grid[i][j];
        }
        cout<<endl;
    }
}  

Measured memory_bytes: 384
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod  =2019
    L,R = map(int,input().split())
    if R //mod - (L-1) //mod >1:
        print(0)
        exit()
    ans = 10**9
    for i in range(L,R):
        for j in range(i+1,R+1):
            a = (i * j ) %mod
            ans = min(a,ans)
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 64720
#include <cstdio>
using namespace std;

int main()
{
    int k,ans;
    ans = 0;
    scanf("%d",&k);
    for(int i = 1;i <= k;i++)
    {
        for(int j = i + 1;j <= k;j++)
        {
            if((i + j) % 2 == 1)
                ans++;
        }
    }
    printf("%d\n",ans);

    return 0;
}


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


int main() {
	int A, B;
	cin >> A >> B;

	if(A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}else {
		cout << ":(" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int A, B, C, D;

int main(void) {
    scanf("%d %d %d %d", &A, &B, &C, &D);
    
    int ans = min(A, B) + min(C, D);
   
    
    printf("%d\n", ans);
    

	return 0;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	LL a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	LL maks = a[0];
	LL w = 0;
	for(int i=1; i<n; i++) {
		w += max((LL) 0, maks-a[i]);
		maks = max(maks, a[i]);
	}
	cout<<w;
}


Measured memory_bytes: 5216
use std::io::*;
use std::str::FromStr;

fn main(){
    for i in 0..3{
        print!("{}",read::<String>().chars().nth(i).unwrap());
    }
    println!("")
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
N = int(input())
h = list(map(int, input().split()))

def rWater(L):
#  print (L)
  if len(L) == 1:
    return L[0]
  if L[0] == 0:
    return rWater(L[1:])
  if L[-1] == 0:
    return rWater(L[:-1])
  if 0 in L:
    return rWater(L[:L.index(0)]) + rWater(L[L.index(0)+1:])
  return rWater(list(map(lambda x: x-1,L)))+1
print (rWater(h))

Measured memory_bytes: 3188
#include<stdio.h>

void maxHeapify(int*,int,int);

#define MAX 500001

int main(){
  int H,i,A[MAX];

  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);

  for(i=H/2;i>=1;i--){
    maxHeapify(A,i,H);
  }
  
  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

void maxHeapify(int *A,int i,int H){
  int l,r,largest,a,j;
  l=2*i;
  r=2*i+1;
  if(l<=H&&A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest])largest=r;
    
  if(largest!=i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
    maxHeapify(A,largest,H);
  }
}


Measured memory_bytes: 4664
def main():
    n, m = map(int, input().split())
    left = 1
    right = n

    for _ in range(m):
        left_i, right_i = map(int, input().split())
        left = max(left, left_i)
        right = min(right, right_i)
    
    print(max(0, right - left + 1))

main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int K = 2;
	int nbPierres;
	cin >> nbPierres;
	int hauteur[nbPierres];
	int meilleurSolution[nbPierres];

	for (int i = 0 ; i < nbPierres ; i++)
	{
		cin >> hauteur[i];
		meilleurSolution[i] = 1e9;
	}
	meilleurSolution[0] = 0;
	for (int i = 1 ; i < nbPierres ; i++)
	{
		for (int j = 1 ; j <= K ; j++)
		{
			if (i - j < 0) break;
			//cout<<i - j<<endl;
			meilleurSolution[i] = min(meilleurSolution[i] ,
								      meilleurSolution[i - j] + abs(hauteur[i] - hauteur[i -j]));
		}
		//cout<<meilleurSolution[i]<<endl;
	}
	cout << meilleurSolution[nbPierres - 1] << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin>> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int sum = 0;
	for(int i = 0;  i < n - 1; i++){
	    for(int j = i + 1; j < n; j++){
	        sum += a[i] * a[j];
	    }
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  string s;
  cin >> a >> b >> s;

  bool judge = true;
  rep(i, 0, s.size()) {
    if (i == a && s[i] != '-') {
      judge = false;
      break;
    } else if (i != a && (s[i] < '0' || s[i] > '9')) {
      judge = false;
      break;
    }
  }
  if (judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = input()
ls = []
rs = []
for i in range(Q) :
    l, r = map(int,input().split())
    ls.append(l)
    rs.append(r)

ans = [0 for _ in range(N+1)]
temp = 0
for i in range(N) :
    if S[i:i+2] == "AC" :
        temp += 1
    ans[i+1] += temp

for i in range(Q) :
    print(ans[rs[i]-1] - ans[ls[i]-1])


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;
  if (s[0] == s[2]) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3584
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n), b;
	rep(i, n)scanf("%d", &a[i]);
	b = a;
	sort(all(b));
	rep(i, n) printf("%d\n", distance(b.begin(), lower_bound(all(b), a[i])) >= n / 2 ? b[n / 2 - 1] : b[n / 2]);

	Please AC;
}


Measured memory_bytes: 3712
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
    L,R=map(int,input().split())
    a[1][R]+=1
    a[L+1][R]-=1
a=np.cumsum(a, axis=1)
a=np.cumsum(a, axis=0)
for i in range(q):
    L,R=map(int,input().split())
    print(int(a[L][R]))

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

double mean(ll p)
{
            if(p%2==0)return p/2.0+0.5; 
            else return (p-1.0)/2.0+1.0; 
} 

int main()
{
    ll N,K;
    cin >> N >> K;
    vector<double> m(N,0);
    vector<double> S(N+1,0);
    for(ll i=0;i<N;i++)
    {
        ll p;cin>>p;
        m[i]=mean(p);
    }
    S[0]=0;
    for(ll i=0;i<N;i++)
    {
        S[i+1]+=S[i]+m[i];
    }

    double res = 0;
    for(ll i=0;i<=N-K;i++){
        res=max(res,S[i+K]-S[i]);
    }
    cout << std::fixed << std::setprecision(6) << res << endl;
}

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

using namespace std;

int main(){
	ll n;
	ll mod = 1e9 + 7;
	cin >> n;
	//cout << n<<endl;
	ll k;
	//cout <<"yes\n";
	cin >> k;
	vector <ll> a(n);
	//cout <<"yes\n";
	for(ll i = 0;i < n;i++){
		cin >> a[i];
	}
	//cout <<"yes\n";
	ll ways[n + 1][k + 1],sum[n + 1][k + 1];
	for(ll i = 0;i <= n;i++){
		for(ll j = 0;j <= k;j++){
			ways[i][j] = 0;
			sum[i][j] = 0;
		}
	}
	sum[1][0] = 1;
	ways[1][0] = 1;
	for(ll i = 1;i <= k;i++){
	    ways[1][i] = (i <= a[0]);
		sum[1][i] = sum[1][i - 1] + (i <= a[0]);
	}
	ll sum1 = 0;
	sum1 = a[0];
	//cout << "yes" << endl;
	for(ll i = 2;i <= n;i++){
	    sum1 += a[i - 1];
		for(ll j = 0;j <= k;j++){
		    if(j <= sum1){
			    ways[i][j] = sum[i - 1][j];
			    if(j - a[i - 1] > 0){
				    ways[i][j] -= sum[i - 1][j - a[i-1] - 1];
			    }
		    }
		    ways[i][j] %= mod;
			sum[i][j] = ways[i][j];
			if(j){
				sum[i][j] += sum[i][j - 1];
			}
			//cout << i << " " << j << " " << ways[i][j] << endl;
		}
	}
	cout << ways[n][k];
 	return 0;
}

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

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

	int remove = 0, count = 0;
	if( n <= k + 1 ) {
		cout << n << endl;
	} else {
		n -= k + 1;
		remove += k + 1;
		while( 1 ) {
			n -= ceil( static_cast<double>( remove ) / k );
			remove += ceil( static_cast<double>( remove ) / k );
			if( n < 0 ) {
				break;
			}
			count++;
		}

		cout << count + k + 1 << endl;

	}
}



Measured memory_bytes: 3112
#include <iostream>
#include <string> 
#include <cstring>
#include <map>

using namespace std;

int main() {
   string a, b, ans;
   cin >> a >> b;

   if (a == "H") {
      if (b == "H") {
         ans = "H";
      } else {
         ans = "D";
      }
   } else {
      if (b == "H") {
         ans = "D";
      } else {
         ans = "H";
      }
   }

   cout << ans << endl;

}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    Vi b(m);
    REP(i,m) cin>>b[i];
    V<Vi> a(n, Vi(m));
    REP(i,n){
        REP(j,m){
            cin>>a[i][j];
            a[i][j] *= b[j];
        }
    }

    int cnt = 0;
    REP(i,n){
        if(SUM(a[i])+c>0) cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int64_t ans=1;
    for(int i = 1; i<=n;i++){
        ans = ans * i % 1000000007;
    }
    cout << ans % (1000000007) << endl;
}

Measured memory_bytes: 256