akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
int p[100010];
typedef pair<int,int> pii;
vector<pii> v;
set<pii> st;
int32_t main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++){
        v.push_back(pii(p[i],i));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    st.insert(make_pair(0,0));
    st.insert(make_pair(n+1,0));
    ll ans=0;
    for(int i=0;i<v.size();i++){
        st.insert(pii(v[i].second,v[i].first));
        auto it=st.find(pii(v[i].second,v[i].first));
        if(it!=st.begin()){
            auto it1=it;it1--;
            int len=it->first-it1->first;
            auto it2=it;
            it2++;
            if(it2!=st.end()){
                auto it3=it2;it3++;
                if(it3!=st.end()){
                    ans+=it->second*len*(it3->first-it2->first);
                }
            }
        }
        auto it1=it;it1++;
        if(it1!=st.end()){
            int len=it1->first-it->first;
            auto it2=it;
            if(it2!=st.begin()){
                it2--;
                if(it2!=st.begin()){
                    auto it3=it2;
                    it3--;
                    ans+=(it2->first-it3->first)*len*it->second;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8816
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S, T, U;
  int A, B;
  while (cin >> S >> T >> A >> B >> U) {
    if (U == S)
      --A;
    else
      --B;
    cout << A << " " << B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
class SegmentTreeLazy():
    def __init__(self, arr, ti, ei, func, op, merge):
        self.h = (len(arr) - 1).bit_length()
        self.n = 2**self.h
        self.func = func
        self.op = op
        self.merge = merge
        self.ti = ti
        self.ei = ei
        self.val = [ti for _ in range(2 * self.n)]
        for i in range(len(arr)):
            self.val[self.n + i] = arr[i]
        for i in range(1, self.n)[::-1]:
            self.val[i] = self.func(self.val[2 * i], self.val[2 * i + 1])
        self.laz = [ei for _ in range(2 * self.n)]

    def reflect(self, k):
        if self.laz[k] == self.ei:
            return self.val[k]
        return self.op(self.val[k], self.laz[k])

    def propagate(self, k):
        if self.laz[k] == self.ei: return
        self.laz[2 * k] = self.merge(self.laz[2 * k], self.laz[k])
        self.laz[2 * k + 1] = self.merge(self.laz[2 * k + 1], self.laz[k])
        self.val[k] = self.reflect(k)
        self.laz[k] = self.ei

    def thrust(self, k):
        for i in range(1, self.h + 1)[::-1]:
            self.propagate(k >> i)

    def recalc(self, k):
        while k:
            k >>= 1
            self.val[k] = self.func(self.reflect(2 * k), self.reflect(2 * k + 1))

    def update(self, lt, rt, x):
        lt += self.n
        rt += self.n
        vl = lt
        vr = rt
        self.thrust(lt)
        self.thrust(rt - 1)
        while rt - lt > 0:
            if lt & 1:
                self.laz[lt] = self.merge(self.laz[lt], x)
                lt += 1
            if rt & 1:
                rt -= 1
                self.laz[rt] = self.merge(self.laz[rt], x)
            lt >>= 1
            rt >>= 1
        self.recalc(vl)
        self.recalc(vr - 1)

    def query(self, lt, rt):
        lt += self.n
        rt += self.n
        self.thrust(lt)
        self.thrust(rt - 1)
        vl = vr = self.ti
        while rt - lt > 0:
            if lt & 1:
                vl = self.func(vl, self.reflect(lt))
                lt += 1
            if rt & 1:
                rt -= 1
                vr = self.func(self.reflect(rt), vr)
            lt >>= 1
            rt >>= 1
        return self.func(vl, vr)

import sys
input = sys.stdin.readline

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

def func(x, y):
    x0, x1, x2 = x
    y0, y1, y2 = y
    return x0 + y0, x1 + y1, x2 + y2 + x1 * y0

def op(x, p):
    x0, x1, x2 = x
    if p:
        return x1, x0, x0 * x1 - x2
    else:
        return x0, x1, x2

def merge(p, q):
    return p ^ q

arr = [(1 - a, a, 0) for a in A]
ti = (0, 0, 0)
ei = 0

st = SegmentTreeLazy(arr, ti, ei, func, op, merge)
res = list()

for _ in range(Q):
    t, l, r = map(int, input().split())
    if t == 1:
        st.update(l - 1, r, 1)
    else:
        res.append(st.query(l - 1, r)[2])

print('\n'.join(map(str, res)))

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

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        n: usize,
        hs: [usize; n],
    }
    let r = (0..n)
        .filter(|&i| hs[0..i].iter().all(|&h| h <= hs[i]))
        .count();
    println!("{}", r);
}


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

int main(){
    int N, X, T;
    cin >> N >> X >> T;

    cout << (N+(X-1))/X*T << endl;
    return 0;
}

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

int main() {
    vector<int> pow(200001, 1);
    for (int i = 0; i < 200001; i++) {
        pow[i+1] = (10*pow[i]%2019);
    }
    string S; cin >> S;
    int N = S.size();
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        vec[i] = S[i]-'0';
    }
    reverse(vec.begin(), vec.end());
    vector<int> a(N+1, 0);
    for (int i = 0; i < N; i++) {
        int val = (a[i] + pow[i]*vec[i]);
        val %= 2019;
        if (val < 0) val += 2019;
        a[i+1] = val;
    }
    map<int, int> m;
    for (int i = 1; i < N+1; i++) {
        m[a[i]] ++;
    }
    int ans = m[0];
    for (auto t : m) {
        ans += (t.second*(t.second-1)/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6024
n  = int(input())
li = list(map(int,input().split()))
ok = set()
ng = set()
mul = set()

ans = 0

for i in li:
    if i not in ok:
        ok.add(i)
    else:
        ng.add(i)

M = max(ok)

for i in ok:
    for j in range(2,M+1):
        if i*j > 10**6:
            break
        else:
            mul.add(i*j)

for i in ok:
    if i not in mul:
        if i not in ng:
            ans+=1

print(ans)

Measured memory_bytes: 219804
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
using namespace std;

int main() {

	char input;

	cin >> input;


	if ('A' <= input && input <= 'Z')
		cout << "A";
	else if ('a' <= input && input <= 'z')
		cout << "a";


	return 0;
}

Measured memory_bytes: 3616
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll N=1e3+3;


int main(){
    IOS;
    make2(ll,n,m);
    vector <string> vec(n);
    fr(i,n) cin>>vec[i];
    vector <vector <ll> >dp(n,vector <ll>(m));

    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            dp[i][j]=0;
            if(i==0 && j==0) dp[i][j]=1;
            if(vec[i][j]=='.'){
                if(i>0) dp[i][j]=(dp[i][j]+dp[i-1][j])%M;
                if(j>0) dp[i][j]=(dp[i][j]+dp[i][j-1])%M;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;


    return 0;
}


Measured memory_bytes: 12124
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine()) % 10;
        var answer = "";

        if(N == 3)
        {
            answer = "bon";
        }
        else if(N == 0 || N == 1 || N == 6 || N == 8)
        {
            answer = "pon";
        }
        else
        {
            answer = "hon";
        }

        Console.WriteLine(answer);
        
    }
}


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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int main() {
  int n;cin>>n;
  vi a(n);cin>>a;
  vi b(n,0);
  rrepi(i,n) {
    int k = i;
    int bit = a[i-1];
    while (k <= n) {
      bit ^= b[k-1]; 
      k += i;
    }
    b[i-1] = bit;
  }
  int m = 0;
  rep(i,n) if (b[i]==1) m++;
  cout << m << endl;
  rep(i,n) if (b[i]==1) cout << i+1 << " ";
  cout << endl;
}


Measured memory_bytes: 2560
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b, c] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const k = Number(stdin.split('\n')[1])

const ans = _ => {
  const nums = [a, b, c]

  nums.sort((a, b) => b - a)

  nums[0] *= 2 ** k

  return nums.reduce((p, c) => p + c)
}

console.log(ans())


Measured memory_bytes: 7372
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
V = rl()

import heapq

heap = []
for v in V:
	heapq.heappush(heap, v)

while len(heap) >= 2:
	v = heapq.heappop(heap)
	v2 = heapq.heappop(heap)
	nv =(v + v2)/2
	heapq.heappush(heap, nv)
print(heap[0])


Measured memory_bytes: 62412
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);

        double r = scanner.nextDouble();
        
        System.out.printf("%.5f %.5f\n", Math.PI * r * r, 2 * Math.PI * r);
        
    }
}


Measured memory_bytes: 28112
s = str(input())
ans = "WA"
if s[0] == "A":
    shor = s[2:-1]
    a = shor.count("C")
    if a == 1:
        d = sum(1 for c in s if c.isupper())
        if d==2:
            ans = "AC"
print (ans)


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

        StringTokenizer st = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());

        int[] a = new int[n];
        int sum = 0;
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(st.nextToken());
            sum += a[i];
        }

        int count = 0;
        for (int x : a) {
            if (x >= sum / (double)(4 * m)) {
                count++;
            }
        }

        if (count >= m) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        pw.close();
    }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
ll dp[MAXN + 5][2 * MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}
void reorder(auto& v, const auto& mapping) {
  auto v2 = v;
  rep(i, 0, sz(v))
    v[i] = v2[mapping[i]];
}

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

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind), [&](int i, int j) {return s[i] + w[i] < s[j] + w[j];});


  reorder(v, ind);
  reorder(w, ind);
  reorder(s, ind);

  
  rep(i, 0, MAXN + 1) rep(j, 0, 2 * MAXS + 1)
    dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for (int weight = MAXS; weight >= 0; weight--) {
      if (dp[i][weight] == -1) continue;
      maxx(dp[i + 1][weight], dp[i][weight]);
      if (weight <= s[i]) {
	maxx(dp[i + 1][weight + w[i]], dp[i][weight] + v[i]);
      }
    }
  }
  auto res = 0LL;
  rep(i, 0, n + 1)
    maxx(res, *max_element(all(dp[i])));
  cout << res << '\n';
}


Measured memory_bytes: 156672
#include <bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >>n;
  vector<int> a(n);
  bool yes=true;
  for(int i=0;i<n;i++){
    cin >>a[i];
    if(a[i]&1) yes=false;
  }
  if(yes) cout <<"second\n";
  else cout <<"first\n";
  return (0);
}

Measured memory_bytes: 3716
n=int(input())
#n,k=map(int,input().split())
l=[int(i) for i in input().split()]
e,o={0:0},{0:0}
for a,i in enumerate(l):
    if a%2:
        if i in o: o[i]+=1
        else: o[i]=1
    else:
        if i in e: e[i]+=1
        else: e[i]=1
chko,chke=[0,0,0,0],[0,0,0,0]
for i in e:
    if e[i]>=chke[1]:
        chke[3]=chke[1]
        chke[2]=chke[0]
        chke[1]=e[i]
        chke[0]=i
    elif e[i]>=chke[3]:
        chke[3]=e[i]
        chke[2]=i
for i in o:
    if o[i]>=chko[1]:
        chko[3]=chko[1]
        chko[2]=chko[0]
        chko[1]=o[i]
        chko[0]=i
    elif o[i]>=chko[3]:
        chko[3]=o[i]
        chko[2]=i
#print(e,o)
#print(chko,chke)
if chko[0]!=chke[0]:
    print((n//2-chko[1])+(n//2-chke[1]))
else:
    ans=min((n//2-chko[1])+(n//2-chke[3]),(n//2-chko[3])+(n//2-chke[1]))
    print(ans)


Measured memory_bytes: 16548
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		for (int T = sc.nextInt() - 1; 0 <= T; T--) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] a = sc.nextIntArray(n);
			int[] b = new int[n - 1];
			Arrays.sort(a);
			int sum = a[n - 1] - a[0];
			for (int i = 0; i < n - 1; i++) {
				b[i] = a[i] - a[i + 1];
			}
			Arrays.sort(b);
			m = Math.min(m, n);
			for (int i = 0; i < m - 1; i++) {
				sum += b[i];
			}
			System.out.println(sum);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 55996
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long H, long long W) {
    ll ans = 0;
    if (H==1 || W==1) {
        ans = 1;
    } else {
        ans = (H * W + 1) / 2;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long H;
  cin >> H;
  long long W;
  cin >> W;
  solve(H, W);
  return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1]<<'\n';
}

Measured memory_bytes: 640
h,w = gets.split.map(&:to_i)

c = []
10.times do
	c.push(gets.split.map(&:to_i))
end
a = []
h.times do
	a.push(gets.split.map(&:to_i))
end

mp = []

10.times do |i|
	cost = Array.new(10,10**5)
	k = i
	rest = [0,1,2,3,4,5,6,7,8,9]
	rest.delete(i)
	cost[i] = 0
	next_e = nil
	while rest.include?(1)
		min = 10**5
		rest.length.times do |j|
			cost[rest[j]] = c[k][rest[j]] + cost[k] if cost[rest[j]] > c[k][rest[j]] + cost[k]
			if min > cost[rest[j]]
				next_e = rest[j]
				min = cost[rest[j]]
			end
		end
		rest.delete(next_e)
		k = next_e
	end
	mp[i] = cost[1]
end

count = Array.new(10,0)
h.times do |i|
	w.times do |j|
	count[a[i][j]] += 1 if a[i][j] >= 0
	end
end

ans = 0
10.times do |i|
	ans += mp[i] * count[i]
end
puts ans


Measured memory_bytes: 3836
import java.util.*;
import java.io.*;
 
public class Main{ 
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] t = new long[n];
        for(int i = 0; i < n; i++){
            t[i] = scanner.nextLong();
        }
        long cur = t[0];
        for(int i = 1; i < n; i++){
            cur = lcm(cur, t[i]);
        }
        System.out.println(cur);
    }
    public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int N, K;
vector<int> a(100);
vector<vector<int>> dp(2, vector<int>(100001, -1));

int dfs(int turn, int stone)
{
    if (dp[turn][stone] != -1)
        return dp[turn][stone];
    if (stone == 0)
    {
        return dp[turn][stone] = turn;
    }
    dp[turn][stone] = turn;
    for (int i = 0; i < N; i++)
    {
        if (a[i] > stone)
            break;
        if (dfs(1 - turn, stone - a[i]) != turn)
            dp[turn][stone] = 1 - turn;
    }
    return dp[turn][stone];
}

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

    cin >> N >> K;
    for (int i = 0; i < N; i++)
        cin >> a[i];
    cout << (dfs(0, K) ? "First" : "Second") << endl;
}


Measured memory_bytes: 8824
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x = inp()
t = x//11
s = x - t*11
if s == 0:
    print(t*2)
elif s <= 6:
    print(t*2+1)
else:
    print(t*2+2)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0; i < (n); ++i)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int n_kakko = 0, n_kokka = 0;

    stack<char> stk;

    REP0 (i, N)
    {
        if (S[i] == ')')
        {
            if (stk.empty())
                n_kakko++;
            else
                stk.pop();
        }
        else
        {
            stk.push(S[i]);
        }
    }

    n_kokka = stk.size();

    REP0 (i, n_kakko)
    {
        cout << '(';
    }

    cout << S;

    REP0 (i, n_kokka)
    {
        cout << ')';
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int N=3e5+100;
int a[N],qz[N];
int mymax(int x,int y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n%2==0){
		int sum1=0,sum2=0;
		for(int i=1;i<=n;i+=2) sum1+=a[i];
		for(int i=2;i<=n;i+=2) sum2+=a[i];
		printf("%d %d\n",mymax(sum1,sum2),mymin(sum1,sum2));
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(i%2==1) qz[i]=qz[i-1]+a[i];
		else qz[i]=qz[i-1]-a[i];
	}
	int l=0,r=2e9,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		int min=0;bool pd=false;
		for(int i=1;i<=n;i+=2){
			if(qz[i]-min>=mid){
				if(i==n) pd=true;
				min=mymin(min,qz[i]-a[i+1]);
			}
		}
		if(pd) ans=mid,l=mid+1;
		else r=mid-1;
	}
	int sum1=0,sum2=0;
	for(int i=1;i<=n;i+=2) sum1+=a[i];
	for(int i=2;i<=n;i+=2) sum2+=a[i];
	printf("%d %d\n",sum2+ans,sum1-ans);
	return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "NO";
    int x = 0;
    rep(i, 100) {
        if (x%b==c) {
            ans = "YES";
        }
        x += a;
    }
    
    cout << ans << endl;
    return 0;
}


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

#define vi vector<int>
#define ll long long int

int main() {

    ll N, A, B;
    cin >> N >> A >> B;

    vi H;
    ll h;
    for (int i = 0; i < N; i++) {
        cin >> h;
        H.push_back(h);
    }

    sort(H.begin(), H.end());

    ll L = 0;
    ll R = (H[N-1]/B) + 1;
    ll med;
    ll tmp;

    while (R-L > 1) {
        tmp = 0;
        med = (L+R) / 2;
        for (int i = 0; i < N; i++) {
            if (H[i] > med*B) {
                tmp += ceil(1.0 * (H[i] - med*B) / (A-B));
            }
        }
        if (tmp > med) L = med;
        else R = med;
    }

    cout << R << endl;

    return 0;
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
typedef long long ll;
const int NAX = 3e5 + 5, MOD = 1e9 + 7;
ll a[NAX], ones[62];

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> a[i];
		for(ll j=0; j<60; ++j) {
			ll p = ((ll)1) << j;
			if(a[i] & p)   ++ones[j];
		}
	}
	ll res = 0;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<60; ++j) {
			ll p = ((ll)1) << j;
			ll tot_ones =(a[i] & p) ? --ones[j], n - ones[j] - i - 1 : ones[j] ; 
			p %= MOD;
			ll pp = 1ll * tot_ones * p % MOD;
			if(pp >= MOD)
				pp -= MOD;
			res += pp;
			res %= MOD;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2560
n,k=gets.split.map(&:to_i)
ps=gets.split.map{|m| m.to_f/2+0.5}
now=ps[0..k-1].inject(:+)
max=now
k.upto(n-1) do |i|
  now+=ps[i]-ps[i-k]
  max=[max,now].max
end
puts max


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define MAX 10000007

using cd = complex<double>;
const double PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    int n = a.size();

    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1)
            j ^= bit;
        j ^= bit;

        if (i < j)
            swap(a[i], a[j]);
    }

    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            cd w(1);
            for (int j = 0; j < len / 2; j++) {
                cd u = a[i+j], v = a[i+j+len/2] * w;
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert) {
        for (cd & x : a)
            x /= n;
    }
}

vector<ll> multiply(vector<int> const& a, vector<int> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < (int)(a.size() + b.size())) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<ll> result(n);
    for (int i = 0; i < n; i++)
        result[i] = 1LL * round(fa[i].real());
    return result;
}

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

	ll n, m; cin >> n >> m;
	vi v(100010, 0);
	int maxi = 0;
	FOR(i, n){
		int x; cin >> x;
		v[x]++;
		maxi = max(maxi, x);
	}

	vector<ll> r = multiply(v, v);

	ll ans = 0;
	for(ll i = maxi*2; i >= 0 && m > 0; i--){
		if(r[i]){
			ll d = min((ll)r[i], m);
			ans += d*i;
			m-=d;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 11080
#include<stdio.h>
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%d",a>=b?a>=c?a*10+b+c:c*10+a+b:b>=c?b*10+a+c:c*10+a+b);
  return 0;
}

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

using namespace std;

int main(){
    int a[3000],b[3000];
    int i=0;
    cin>>a[0]>>b[0];
    while(!(a[i]==0&&b[i]==0)){

        vector<int> data={a[i],b[i]};
        sort(data.begin(),data.end());

        a[i]=data[0];
        b[i]=data[1];

        i=i+1;

        cin>>a[i]>>b[i];
    }

    for(int j=0;j<i;j++){
        cout<<a[j]<<" "<<b[j]<<endl;
    }

    return 0;
}




Measured memory_bytes: 3020
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

const INF: usize = 10000000000000;

fn cycle(xyu: &mut Vec<(usize, usize, char)>) {
   for (x, y, u) in xyu.iter_mut() {
      let xn = x.clone();
      let yn = y.clone();
      *x = yn;
      *y = 200000 - xn;
      *u = match u {
         'U' => 'R',
         'R' => 'D',
         'D' => 'L',
         'L' => 'U',
         _ => unreachable!(),
      };
   }
}

#[fastout]
fn main() {
   input! {
      n: usize,
      mut xyu:[( usize, usize, char); n]
   }

   let mut ans: usize = INF;
   for i in 0..4 {
      if i < 2 {
         let mut up = BTreeMap::<usize, BTreeSet<usize>>::new();
         let mut down = BTreeMap::<usize, BTreeSet<usize>>::new();
         for &(x, y, u) in xyu.iter() {
            match u {
               'U' => {
                  up.entry(x)
                     .and_modify(|v| {
                        v.insert(y);
                     })
                     .or_insert([y].iter().cloned().collect());
               }
               'D' => {
                  down
                     .entry(x)
                     .and_modify(|v| {
                        v.insert(y);
                     })
                     .or_insert([y].iter().cloned().collect());
               }
               _ => (),
            }
         }
         for (&x, up) in up.iter_mut() {
            if let Some(down) = down.get_mut(&x) {
               for &y1 in up.iter() {
                  if let Some(y2) = down.range(y1..).next() {
                     ans = min(ans, y2 - y1)
                  } else {
                     break;
                  }
               }
            }
         }
      }
      let mut up = BTreeMap::<usize, BTreeSet<usize>>::new();
      let mut right = BTreeMap::<usize, BTreeSet<usize>>::new();
      for &(x, y, u) in xyu.iter() {
         match u {
            'U' => {
               up.entry(x + y)
                  .and_modify(|v| {
                     v.insert(y);
                  })
                  .or_insert([y].iter().cloned().collect());
            }
            'R' => {
               right
                  .entry(x + y)
                  .and_modify(|v| {
                     v.insert(y);
                  })
                  .or_insert([y].iter().cloned().collect());
            }
            _ => (),
         }
      }
      for (&x, up) in up.iter_mut() {
         if let Some(right) = right.get_mut(&x) {
            for &y1 in up.iter() {
               if let Some(y2) = right.range(y1..).next() {
                  ans = min(ans, 2 * (y2 - y1));
               } else {
                  break;
               }
            }
         }
      }
      cycle(&mut xyu);
   }
   if ans == INF {
      println!("SAFE");
   } else {
      println!("{}", (ans as f64) / 2.0 * 10.0);
   }
}


Measured memory_bytes: 51500
#include <bits/stdc++.h>
using namespace std;
int n, h[100010], dp[100010], k;
int main() {
	scanf("%d%d", &n, &k);
	for(int i=1; i<=n; i++) {
		scanf("%d", h+i);
		if(i == 1) dp[1] = 0;
		else {
			dp[i] = 2e9;
			for(int j=1; j<=k; j++) {
				if(i - j >= 1) {
					dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
				}
			}
		}
	}
	printf("%d", dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,n){
        if(i!=n-1)ans += p[i];
        else ans+=p[i]/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int num;
    int count5=0;
    int count7=0;
    for(int i=0;i<3;i++){
        cin>>num;
        if(num==5){
            count5++;
        }else if(num==7){
            count7++;
        }
    }
    if(count5==2&&count7==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static boolean[][] bomb = new boolean[50][50];

  public static void main(String[] args) {
    int H = sc.nextInt();
    int W = sc.nextInt();
    int N = sc.nextInt();
    int K = sc.nextInt();

    rec(0, H, 0, W, N);
    long ans = 0;
    long mul = 1;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (bomb[i][j]) ans += mul;
        mul *= 2;
        mul %= K;
      }
    }
    System.out.println("! " + (ans % K));
    System.out.flush();
  }

  static void rec(int t, int b, int l, int r, int c) {
    if (c == 0) return;
    if ((b - t) * (r - l) == c) {
      for (int i = t; i < b; i++) {
        for (int j = l; j < r; j++) {
          bomb[i][j] = true;
        }
      }
      return;
    }
    if (b - t > r - l) {
      int upper = query(t, (t + b) / 2, l, r);
      rec(t, (t + b) / 2, l, r, upper);
      rec((t + b) / 2, b, l, r, c - upper);
    } else {
      int left = query(t, b, l, (l + r) / 2);
      rec(t, b, l, (l + r) / 2, left);
      rec(t, b, (l + r) / 2, r, c - left);
    }
  }

  static int query(int t, int b, int l, int r) {
    System.out.printf("? %d %d %d %d\n", t, l, b - 1, r - 1);
    System.out.flush();
    return sc.nextInt();
  }

}




Measured memory_bytes: 19412
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var NX = IO.RSLong;
            var N = (int)NX[0];
            var X = NX[1];

            WriteLine(Func(N, X));
        }

        public static long Func(int N, long X)
        {
            // レベル0はそれより下の階層がないので
            if (N == 0 && X == 1) return 1;

            // 1レベル下の総枚数、パティの枚数
            long sub_Len = (1L << (N + 1)) - 3;
            long sub_Patty = (1L << N) - 1;

            if (X == 1) return 0;
            else if (X <= sub_Len + 1) return Func(N - 1, X - 1);
            else if (X == sub_Len + 2) return sub_Patty + 1;
            else if (X <= 2 * sub_Len + 2) return sub_Patty + 1 + Func(N - 1, X - (sub_Len + 2));
            else return 2 * sub_Patty + 1;
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19028
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner ir = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = ir.nextInt();
		long m = ir.nextLong();
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++) {
			a[i] = new int[] { ir.nextInt(), ir.nextInt() };
		}
		int[][] ca = compress(a);
		int[] imos = new int[1000000];
		for (int i = 0; i < n; i++) {
			imos[ca[i][0]]++;
			imos[ca[i][1] + 1]--;
		}
		int ma = 0;
		for (int i = 0; i < 1000000 - 1; i++) {
			imos[i + 1] += imos[i];
			ma = Math.max(ma, imos[i]);
		}
		long res = (long) ma * m;
		if (ma % 2 == 0) {
			for (int i = 0; i < 1000000; i++) {
				if (imos[i] == ma) {
					res -= conv[i];
					break;
				}
			}
		} else {
			for (int i = 1000000 - 1; i >= 0; i--) {
				if (imos[i] == ma) {
					res -= (m - conv[i]);
					break;
				}
			}
		}
		out.println(res);
		out.flush();
	}

	static int[] conv = new int[1000000];

	static int[][] compress(int[][] a) {
		TreeSet<Integer> st = new TreeSet<>();
		int[][] ret = new int[a.length][2];
		for (int i = 0; i < a.length; i++) {
			for (int x : a[i])
				st.add(x);
		}
		ArrayList<Integer> l = new ArrayList<>(st);
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < 2; j++) {
				int idx = Collections.binarySearch(l, a[i][j]);
				ret[i][j] = idx;
				conv[idx] = a[i][j];
			}
		}
		return ret;
	}
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
uint64_t dp[101010][13]; // mod13

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll A, B, C; cin >> A >> B >> C;

    int ans = -1;
    for (int i = 0; i < 100; ++i) {
        if ( (A & 1) || (B & 1) || (C & 1)){
            ans = i;
            break;
        }
        ll tA = (B + C) / 2;
        ll tB = (C + A) / 2;
        ll tC = (A + B) / 2;
        A = tA, B = tB, C = tC;
    }
    cout << ans << endl;
    return 0;
}


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

pair<long, long> x[111];
long s[111], t[111];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		x[i] = { a,b };
		if (!a && !b) i--, n--;
	}
	sort(x, x + n, [](auto a, auto b) {
		if (a.second >= 0 && b.second <= 0 && (a.second || a.first > 0) && (b.second || b.first < 0))
			return true;
		if (b.second >= 0 && a.second <= 0 && (b.second || b.first > 0) && (a.second || a.first < 0))
			return false;
		return a.first*b.second > a.second*b.first;
	});
	for (int i = 0; i < n; i++)
		s[i + 1] = s[i] + x[i].first, t[i + 1] = t[i] + x[i].second;
	long m = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			auto a = s[j] - s[i], b = t[j] - t[i];
			m = max(m, a*a + b * b);
			a = s[n] - a, b = t[n] - b;
			m = max(m, a*a + b * b);
		}
	}
	cout.precision(18);
	cout << sqrt(m) << endl;
	return 0;
}


Measured memory_bytes: 256
/*B - One Clue*/

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

int main(){

	int elem;
	int pos;

	cin >> elem >> pos;

	elem--;
	vector <int> rango;
	rango.push_back(pos);

	for (int i = 1; i <= elem; ++i)
	{
		if(pos + i > 1000000){
			break;
		}
		rango.push_back(pos + i);
	}

	for (int i = 1; i <= elem; ++i)
	{
		if(pos - i < -1000000){
			break;
		}
		rango.push_back(pos - i);
	}

	sort(rango.begin(), rango.end());
	
	for (int i = 0; i < rango.size(); ++i)
	{
		cout << rango[i] << ' ';
	}
	return 0;
}




Measured memory_bytes: 256