akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = (1LL << 31) - 1;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera, mod);
}
struct SegmentTree {
    vector<ll> ar;
    ll size = 1;
    SegmentTree(int n) {
        ar.resize(4 * n - 1, INF);
        while (size < n) {
            size *= 2;
        }
    }
    void update(ll idx, ll x) {
        ll k = size + idx;
        ar[k] = x;
        while (k != 1) {
            k /= 2;
            ar[k] = min(ar[k * 2], ar[k * 2 + 1]);
        }
    }
    ll findinner(ll s, ll t, ll idx, ll be, ll en) {
        ll mid = (be + en) / 2;
        if (be == s && t == en) {
            return ar[idx];
        }
        ll two = INF;
        ll one = INF;
        if (s < mid) {
            two = findinner(s, min(t, mid), 2 * idx, be, mid);
        }
        if (t > mid) {
            one = findinner(max(s, mid), t, 2 * idx + 1, mid, en);
        }
        return min(one, two);
    }
    ll find(ll s, ll t) { return findinner(s, t, 1, 0, size); }
};
signed main() {
    ll n, q;
    cin >> n >> q;
    SegmentTree st(n);
    REP(i, q) {
        ll com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            st.update(x, y);
        } else {
            cout << st.find(x, y + 1) << endl;
        }
    }
}


Measured memory_bytes: 6004
//aoj0516 in binary indexed tree

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

int n, k;
int a[100010];
int ans = 0;

struct bittree
{
  int tree[100010];

  void reset()
  {
    memset(tree, 0, sizeof tree);
  }
  
  void add(int where, int val)
  {
    for(int i = where; i <= n; i += i & -i){
      tree[i] += val;
    }
  }

  int sum(int where)
  {
    int ret = 0;
    
    for(int i = where; i >= 1; i -= i & -i){
      ret += tree[i];
    }

    return ret;
  }
} tr;

int main()
{
  while(cin >> n >> k, n && k){
    for(int i = 1; i <= n; i++){
      cin >> a[i];
    }

    tr.reset();
    
    for(int i = 1; i <= n; i++){
      tr.add(i, a[i]);
    }

    for(int i = 1; i <= n - k + 1; i++){
      ans = max(ans, tr.sum(i + k - 1) - tr.sum(i - 1));
    }

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

Measured memory_bytes: 3792
def main():
    n, q = [int(x) for x in input().split(' ')]
    stacks = []
    for i in range(n):
        stacks.append([])
    for i in range(q):
        query = input()
        cmd = int(query[0])
        if cmd == 0:
            _, t, x = [int(x) for x in query.split(' ')]
            stacks[t].append(x)
        elif cmd == 1:
            _, t = [int(x) for x in query.split(' ')]
            if stacks[t]:
                print(str(stacks[t][-1]))
        elif cmd == 2:
            _, t = [int(x) for x in query.split(' ')]
            if stacks[t]:
                stacks[t].pop()


if __name__ == '__main__':
    main()



Measured memory_bytes: 13668
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	S := sc.nextStr()
	b, _ := strconv.Atoi(S[0:2])
	a, _ := strconv.Atoi(S[2:])
	yymm, mmyy := false, false
	if 1 <= b && b <= 12 {
		mmyy = true
	}
	if 1 <= a && a <= 12 {
		yymm = true
	}
	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
	} else if yymm {
		fmt.Println("YYMM")
	} else if mmyy {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 640
#!/usr/bin/env ruby
T = ['dream', 'dreamer', 'erase', 'eraser']
t = T.map{|term| term.reverse.chars }
    # ["maerd", "remaerd", "esare", "resare"]
S = STDIN.readline().strip
s = S.reverse!
def match_term(s, offset, rt)
  rt.each_with_index { |c, i| return false if s[i+offset] != c }
  true
end
def check(s, ts)
  offset = 0
  while s.length != offset do
    m = ts.find{|t| match_term(s, offset, t)}
    return false if not m
    offset += m.length
  end
  return true
end
puts "#{check(s, t) ? 'YES' : 'NO'}"

Measured memory_bytes: 1916
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

map<string, int> m;
vector<string> v;

signed main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		string s;
		cin >> s;
		m[s]++;
	}

	int ma = 0;
	for (auto p : m)
	{
		ma = max(ma, p.second);
	}

	for (auto p : m)
	{
		if (p.second == ma)
		{
			v.push_back(p.first);
		}
	}

	SORT(v);

	for (auto s : v)
	{
		cout << s << endl;
	}
}




Measured memory_bytes: 26868
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i,n;
    
    char str[256];
    fgets(str,256,stdin);
    
    n = strlen(str);
    i = n-1;
    
    while(i != 0){
        i -= 2;
        if(strncmp(str, str+i/2, i/2)==0){
            printf("%d\n" ,i);
            return 0;
        }
    }
    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long N, std::vector<long long> L){
    int ans=0;
    sort(ALL(L));
//    vout(L);
    REP(i,0,N-2){
        REP(j,i+1,N-1){
            int low=j+1,high=N-1;
            if(L[i]+L[j]>L[high]){
                ans += high-j;
                continue;
            }
            if(L[i]+L[j]<=L[low]) continue;
            while(high-low>1){
                int mid=(low+high)/2;
                if(L[i]+L[j]>L[mid]) low=mid;
                else high=mid;
            }
//            cout<<i<<" "<<j<<" "<<low<<endl;
            ans += low-j;
        }
    }
    cout<<ans<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int arr[6];
	int j;
	for(j=1;j<=5;j++)
	  cin>>arr[j];
	for(j=1;j<=5;j++)
	{
		if(arr[j]==0)
		{
			cout<<j<<endl;
			exit(0);
		}
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	re 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

int change(const string & s, char c) {
  int n = s.size();
  vector<int> pos;
  for (int i = 0; i < n; i++)
    if (s[i] == c) pos.push_back(i);
  if (pos.size() == 0) return 1000;
  int last = -1, gap = 0;
  for (int x: pos) {
    gap = max(gap, x-last-1);
    last = x;
  }
  gap = max(gap, n-last-1);
  return gap;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  string s;
  cin >> s;
  int n = s.size();
  int best = 1000;
  for (char c = 'a'; c <= 'z'; c++) {
    best = min(best, change(s, c));
  }
  cout << best << endl;
  return 0;
}



Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val n: Int = io.StdIn.readInt()
    val children: Array[Seq[Int]] = Array.fill(n)(Seq(-1,-1))
    val parent: Array[Option[Int]] = Array.fill(n)(None)

    (0 until n) foreach { _ =>
      val (a,b,c) = io.StdIn.readf3("{0,number} {1,number} {2,number}")
      val i = a.asInstanceOf[Long].toInt
      val c1 = b.asInstanceOf[Long].toInt
      val c2 = c.asInstanceOf[Long].toInt
      children(i) = Seq(c1, c2)
      if (c1 != -1) parent(c1) = Some(i)
      if (c2 != -1) parent(c2) = Some(i)
    }

    def depth: Memoized = Memoized {i =>
      parent(i) match {
        case None => 0
        case Some(x) => 1 + depth(x)
      }
    }
    def height: Memoized = Memoized {i =>
      children(i) match {
        case Seq(-1, -1) => 0
        case Seq( x, -1) => 1 + height(x)
        case Seq(-1,  y) => 1 + height(y)
        case Seq( x,  y) => 1 + (height(x) max height(y))
      }
    }

    for (i <- 0 until n) {
      val p: Int = parent(i).getOrElse(-1)
      val s: Int = if (p == -1) -1 else children(p).filterNot(_ == i).head
      val deg: Int = children(i).filterNot(_ == -1).length
      val t = if (p == -1) "root" else if (deg == 0) "leaf" else "internal node"

      println(s"node $i: parent = $p, sibling = $s, degree = $deg, depth = ${depth(i)}, height = ${height(i)}, $t")
    }
  }

  case class Memoized(f: Int => Int) extends (Int => Int) {
    val cache: Array[Option[Int]] = Array.fill(32)(None)
    def apply(i: Int): Int = cache(i) match {
      case None => cache(i) = Some(f(i)); cache(i).get
      case Some(x) => x
    }
  }
}

Measured memory_bytes: 45536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define MOD ll(1e9L+7)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 
#define t2() ll tt2; cin>>tt2; for(ll tti=1;tti<=tt2;tti++)
#define printcj "Case #"<<tti<<": "
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define debug3(x, y,z) cout << #x << " = " << x << "   " << #y << " = " << y << " "<<#z<<" = "<<z<<"\n";
#define debugarray(arr,n,x) { cout << "[" ; for(ll i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"] , "<<#x<<" = "<<x<<'\n';}

vector<vector<ll>>g;
//pll represent dp{white,black}
pll solve(ll source,ll parent)
{
    pll current = {1,1}; //base case if leaf
    for(auto to:g[source]){
        if(to!=parent){
            pll temp = solve(to,source);
            current.first = (current.first* (temp.first + temp.second))%MOD;
            current.second = (current.second*temp.first)%MOD;
        }
    }
    // debug3(source,current.first,current.second);
    return current;
}

int main()
{
    fastio;
    ll n,i,u,v;
    cin>>n;
    g.resize(n+1);
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    pll temp = solve(1,1);
    cout<<(temp.first+temp.second)%MOD<<'\n';    
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
   int n,x,y;
   cin>>n>>x>>y;
   vin a(n,0);
   x--; y--;
   vin cnt(n);
   rep(i,n){
       for(int j=i+1;j<n;j++){
           int ans=min((j-i),1+abs(i-x)+abs(y-j));
           
           cnt[ans]++;
       }
   }
   rep(i,n-1) cout<<cnt[i+1]<<endl;
   
   
   
}


Measured memory_bytes: 3648
z = list(map(int,input().split()))
#print(K)

x1, y1, x2, y2 =z[0],z[1],z[2],z[3] 
dx = x2-x1
dy = y2-y1
z1 = [0]*4
z1[0] = x2-dy
z1[1] = y2+dx
z1[2] = z1[0] - dx
z1[3] = z1[1] - dy

print(z1[0],z1[1],z1[2],z1[3])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2371&lang=jp
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
struct edge {
	int u;
	int v;
	int route;
	int time;
	edge() {}
	edge(int u, int v, int r, int t) :u(u), v(v), route(r), time(t) {}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, T; cin >> N >> T;
	map<string, int> mp;
	int cnt = 0;
	string A, B; cin >> A >> B;
	mp[A] = cnt; cnt++;
	mp[B] = cnt; cnt++;
	vector<vector<ll>> S(N), Time(N);
	for (int i = 0; i < N;i++) {
		ll a; cin >> a;
		for (int j = 0; j < a;j++) {
			string s; cin >> s;
			if (mp.count(s) != 0) { S[i].push_back(mp[s]); }
			else { mp[s] = cnt; S[i].push_back(cnt); cnt++; }
		}
		for (int j = 0; j < a - 1;j++) {
			ll t; cin >> t; Time[i].push_back(t);
		}
	}

	vector<vector<pii>> Change(cnt);
	for (int i = 0; i < N;i++) {
		for (int j = 0; j < (int)S[i].size();j++) {
			Change[S[i][j]].push_back({ i,j });
		}
	}

	vector<vector<pll>> dist(N);
	for (int i = 0; i < N;i++) {
		dist[i].resize(S[i].size(), { LINF,LINF });
	}
	vector<int> checked(cnt);
	using Key = pair<pll, pll>;
	priority_queue<Key, vector<Key>, greater<Key>> q;
	for (auto e : Change[0]) {
		dist[e.first][e.second] = { 0,0 };
		q.emplace(make_pair(pll(0, 0), e));
	}
	while (!q.empty()) {
		auto pp = q.top(); q.pop();
		auto d = pp.first;
		int route = pp.second.first;
		int pos = pp.second.second;
		int station = S[route][pos];
		if (dist[route][pos] < d) continue;

		/* same route / rev */
		if (pos != 0) {
			int time = Time[route][pos - 1];
			if (dist[route][pos - 1] > make_pair(d.first + time, d.second)) {
				dist[route][pos - 1] = { d.first + time,d.second };
				q.emplace(make_pair(dist[route][pos - 1], pll(route, pos - 1)));
			}
		}
		/* same route / ad */
		if (pos != S[route].size() - 1) {
			int time = Time[route][pos];
			if (dist[route][pos + 1] > make_pair(d.first + time, d.second)) {
				dist[route][pos + 1] = { d.first + time,d.second };
				q.emplace(make_pair(dist[route][pos + 1], pll(route, pos + 1)));
			}
		}
		/* change route */
		if (checked[station] == 0) {
			checked[station] = 1;
			for (auto e : Change[station]) {
				if (dist[e.first][e.second] > make_pair(d.first + T, d.second + 1)) {
					dist[e.first][e.second] = { d.first + T,d.second + 1 };
					q.emplace(make_pair(dist[e.first][e.second], pll(e.first, e.second)));
				}
			}
		}
	}
	pll ans = { LINF,LINF };
	for (auto e : Change[1]) ans = min(ans, dist[e.first][e.second]);
	if (ans.first >= LINF) cout << -1 << endl;
	else cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 21896
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    ll N_{};
    ll K_{};
    ll Q_{};
    vector<ll> v_{};
    vector<ll> score_;
    explicit C1(ll N, ll K, vector<ll> v) : N_(N), K_(K), Q_(v.size()), v_(move(v)), score_(N_, K_-Q_){}
    vector<bool> resolve() {
        for(auto a : v_) {
            score_[a-1]++;
        }
        vector<bool> ret(N_);
        for(ll i=0; i < N_; i++) {
            ret[i] = score_[i] > 0;
        }
        return ret;
    }
};

int main() {
    ll N, K , Q;
    cin >> N >> K >> Q;
    vector<ll> v{};
    for (int i=0; i < Q; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{N, K, move(v)};
    auto res = c.resolve();
    for(auto r : res) {
        cout << (r ? "Yes" : "No") << endl;
    }
    return 0;
}


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

const int all = (1 << 17) - 1;

int append(int mask,  int val)
{
	return ((mask << val) | (1 << (val-1))) & all; 
}

const int mod = (int) 1e9 + 7;


typedef long long ll;

int dp[45][(1 << 17)  + 2];

bool is_subset(int mask1, int mask)
{
	return ((mask1 & mask) == mask);
}

void add(int &a, int b)
{
	a += b;
	if(a >= mod)
		a -= mod;
}

int main()
{

	int n,x,y,z;
	scanf("%d %d %d %d",&n,&x,&y,&z);
	int s = 0;
	s = append(s,x);
	s = append(s,y);
	s = append(s,z);

	dp[0][0] = 1;

	for(int i = 1; i <= n ; i++)
	{
		for(int mask = 0; mask <= all; mask++)
		{
			for(int k = 1; k <= 10; k++)
			{
				int x = append(mask,k);
				if(is_subset(x,s))
					continue;
				add(dp[i][x],dp[i-1][mask]);
			}
		}
	}
	ll ans = 1;
	for(int i = 1; i <= n; i++)
	{
		ans = (ans * 10) % mod;
	}
	
	int sum = 0;

	for(int mask = 0; mask <= all; mask++)
	{
		add(sum,dp[n][mask]);
	}
//	cout << sum << endl;
	printf("%lld\n",(ans - sum + mod)%mod);
	

	return 0;
}


Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
void sortk(vector<int>a,int n){
  for(int i=0;i<n-1;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;
  
  for(int i=1;i<n;i++){
    int v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int j=0;j<n-1;j++){
      cout<<a[j]<<" ";
    }
    cout<<a[n-1]<<endl;
  }
}
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sortk(a,n);
}



Measured memory_bytes: 3156
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <vector>
using namespace std;

struct node_t {
	string name;
	int x1, y1, x2, y2;
	vector<unique_ptr<node_t>> children;

	node_t(const string &name_, int x1_, int y1_, int x2_, int y2_):
		name(name_), x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}

	bool in(int x, int y) const {
		return x1 <= x && x <= x2 && y1 <= y && y <= y2;
	}

	string click(int x, int y) const {
		for(const auto &child : children) {
			if(child->in(x, y)) return child->click(x, y);
		}
		return name + " " + to_string(children.size());
	}

	void add_child(unique_ptr<node_t> &&child) {
		children.emplace_back(move(child));
	}
};

int get_int(string::const_iterator &it) {
	int res = 0;
	while(isdigit(*(++it))) res = res * 10 + *it - '0';
	return res;
}

unique_ptr<node_t> parse(string::const_iterator &it) {
	string name = "";
	while(isalpha(*(++it))) name += *it;
	const int x1 = get_int(it);
	const int y1 = get_int(it);
	const int x2 = get_int(it);
	const int y2 = get_int(it);

	unique_ptr<node_t> res(new node_t(name, x1, y1, x2, y2));
	while(*(it + 1) != '/') res->add_child(parse(it));

	it += name.size() + 3; // "</name>"
	return res;
}


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

	for(int n; cin >> n && n;) {
		string tags;
		cin >> tags;

		auto it = tags.cbegin();
		const auto root = parse(it);

		for(int i = 0; i < n; ++i) {
			int x, y;
			cin >> x >> y;

			cout << (root->in(x, y) ? root->click(x, y) : "OUT OF MAIN PANEL 1") << "\n";
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1248
#include  <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c||a==c&&a!=b||b==c&&a!=b){
    cout<<"Yes"<<endl;
  }else
    cout<<"No"<<endl;
  
    
    
}

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

int main() {
  int n,d;
  cin >> n >> d;
  cout << (2*d+n)/(2*d+1) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define N 100005
using namespace std;
int a[N],b[N],n,m,d[N],c[N],n1,f[N];
map <int,int> h;
bool bz[N];
int getf(int k)
{
    if(f[k]==0||f[k]==k) return k;
    return (f[k]=getf(f[k])); 
}
int main()
{
    cin>>n;
    int v=0;
    fo(i,1,n) scanf("%d",&a[i]),v^=a[i],c[i]=a[i];
    a[n+1]=c[n+1]=v;
    bool pd=0;
    v=0;
    fo(i,1,n) scanf("%d",&b[i]),d[i]=b[i],v^=b[i];
    b[++n]=d[n]=v;
    sort(c+1,c+n+1),sort(d+1,d+n+1);
    n1=0;
    fo(i,1,n) 
    {
        if(c[i]!=d[i]) 
        {
            printf("-1\n");
            return 0;
        }
        if(h.count(c[i])==0) h[c[i]]=++n1;
        if(h.count(d[i])==0) h[d[i]]=++n1; 
    }
    int ans=0;
    fo(i,1,n) 
    {
        a[i]=h[a[i]],b[i]=h[b[i]];
        if(a[i]!=b[i]) 
        {
            if(i<n) ans++;
            int fx=getf(a[i]),fy=getf(b[i]);
            f[fx]=fy;
            bz[fx]=1,bz[fy]=1;
        }
    }
    if(ans==0) printf("0\n");
    else
    {
        bz[a[n]]=bz[b[n]]=1;
        fo(i,1,n1) if(bz[i]&&getf(i)==i) ans++;
        printf("%d\n",ans-1);
    }
}

Measured memory_bytes: 8960
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  vector<int> ans;
  int y=0,x[200010],n,a[200010],i,j;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    x[i]=0;
    scanf("%d\n",&a[i]);
  }
  for(i=n;i>0;i--){
    for(j=2;i*j<=n;j++){
      if(x[i*j]==1){
        y++;
      }
    }
    if(y%2!=a[i]){
      x[i]=1;
    }
    y=0;
  }
  for(i=1;i<=n;i++){
    if(x[i]==1){
      ans.push_back(i);
    }
  }
  printf("%d\n",ans.size());
  if(ans.size()==0){
    return 0;
  }
  for(i=0;i<ans.size();i++){
    if(i==0){
      printf("%d",ans[i]);
    }
    else{
      printf(" %d",ans[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int N,wn=0,rn=0;
	cin >> N;
	v.resize(N);
	vector<int> w(N);
	rep(i, 0, N - 1) {
		char C;
		cin >> C;
		if (C == 'W') { 
			v[i] = 1; 
			++wn;
		}
		else v[i] = 0;
	}
	rn = N - wn;
	if (wn == 0 || rn == 0) {
		cout << 0 << '\n';
		return 0;
	}
	int ct = 0;
	rep(i, 0, N - 1) {
		if (i < rn) {
			if (v[i] == 1)++ct;
		}
		else {
			if (v[i] == 0)++ct;
		}
	}
	cout << ct / 2 + ct % 2 << '\n';
	return 0;
}

Measured memory_bytes: 4832
N, X = list(map(int, input().split()))
bounds = list(map(int, input().split()))

zahyos = [0]
for i, bound in enumerate(bounds):
    zahyo = zahyos[i] + bound
    zahyos.append(zahyo)
    
cnt = 0
for num in zahyos:
    if num <= X:
        cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

int main(void) {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int mid = n / 2;
    vi ans;
    if (n % 2 == 0) {
        for (int i = mid; i > 0; --i) {
            ans.push_back(a[2 * i - 1]);
        }
        ans.push_back(a[0]);
        for (int i = 1; i <= mid - 1; ++i) {
            ans.push_back(a[2 * i]);
        }
    } else {
        for (int i = mid; i > 0; --i) {
            ans.push_back(a[2 * i]);
        }
        ans.push_back(a[0]);
        for (int i = 1; i <= mid; ++i) {
            ans.push_back(a[2 * i - 1]);
        }
    }
    for (const auto e : ans) {
        cout << e << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  int n, a[10010];
  cin >> n;
  REP(i, n) cin >> a[i];

  ll sum = 0;
  REP(i, n) sum += a[i];

  bool flag = true;
  while (flag) {
    for (int i = 0; i < n; i++) {
      flag = false;
      for (int j = n - 1; j >= i + 1; j--) {
        if (a[j] < a[j-1]) {
          swap(a[j], a[j-1]);
          flag = true;
        }
      }
    }
  }

  cout << a[0] << " " << a[n - 1] << " " << sum << "\n";
}


Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
typedef pair<int, int> P;
vector<P> G[100005];
int C[100005];

void dfs(int idx, int color) {
  if (C[idx]>=0) return;
  C[idx]=color;
  for (auto p: G[idx]) {
    dfs(p.first, (color+p.second)%2);
  }
}

int main() {
  INCANT;
  cin >> N;
  int u,v,w;
  rep(i, N-1) {
    cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(P(v, w%2));
    G[v].push_back(P(u, w%2));
  }
  fill(C, C+N, -1);
  dfs(0, 0);
  rep(i, N) cout << C[i] << "\n";
  return 0;
}

Measured memory_bytes: 7552
import scala.io.StdIn

object Main extends App {

  final val infity = Int.MaxValue
  var compareCount = 0
  
  @inline def copyToArray(start: Int, end: Int): Array[Int] = {
    val alsize = end - start + 1
    val ar = new Array[Int](alsize)
    Array.copy(a, start, ar, 0, alsize - 1)
    ar(alsize-1) = infity
    ar
  }
  
  def merge(left: Int, mid: Int, right: Int): Unit ={
    //var al = a.slice(left, mid) ++ Array(infity)
    val al = copyToArray(left, mid)
    
    //var ar = a.slice(mid, right) ++ Array(infity)
    val ar = copyToArray(mid, right)
    var i = 0
    var j = 0
    //println("left:" + al.toList)
    //println("right:" + ar.toList)
    (left until right).foreach{ k =>
      compareCount += 1
      if(al(i) <= ar(j)){
        a(k) = al(i)
        i += 1
      } else {
        a(k) = ar(j)
        j += 1
      } 
    }
    //println("all:" + a.toList.mkString(" "))
  }
  
  val n = StdIn.readLine().trim.toInt
  val a = StdIn.readLine().trim.split(' ').map(_.toInt)

  def mergeSort(left: Int, right: Int): Unit ={
    if(left+1 < right){
      val mid = (left + right) / 2
      mergeSort(left, mid)
      mergeSort(mid, right)
      merge(left, mid, right)
    }
  }
  
  mergeSort(0, a.size)
  println(a.toList.mkString(" "))
  println(compareCount)

}




Measured memory_bytes: 313932
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    if(d==25){
        cout << "Christmas" << endl;
    }elif(d==24){
        cout << "Christmas Eve" << endl;
    }elif(d==23){
        cout << "Christmas Eve Eve" << endl;
    }elif(d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int n;

class node {
public:
	int id;
	int parent, child1, child2, sibling;
	int degree, depth, height;
	node() :id(-1), parent(-1), child1(-1), child2(-1), sibling(-1), degree(0), depth(0), height(0) {};

	friend ostream& operator<<(ostream& os, const node& N) {
		cout << "node " << N.id;
		cout << ": parent = " << N.parent;
		cout << ", sibling = " << N.sibling;
		cout << ", degree = " << N.degree;
		cout << ", depth = " << N.depth;
		cout << ", height = " << N.height;
		cout << ", ";
		if (N.parent == -1) cout << "root";
		else if (N.child1 == -1 && N.child2 == -1) cout << "leaf";
		else cout << "internal node";
		cout << endl;
	}
};

void Pos(int n, vector<node> N) {
	int c1 = N[n].child1, c2 = N[n].child2;
	if (c1 != -1) Pos(c1-1, N);
	if (c2 != -1) Pos(c2-1, N);
	cout <<  n+1 << " ";
}
void solve(vector<int> P, vector<int> S, vector<node> &N) {
	N[P[0]-1].id = P[0];
	int i = 0;
	while (P[0] != S[i])i++;
	if (i>0) {
		N[P[0]-1].child1 = P[1];
		vector<int> P1, S1;
		P1.assign(P.begin() + 1, P.begin() + i + 1);
		S1.assign(S.begin(), S.begin() + i);
		solve(P1, S1, N);
	}
	if (i<P.size() - 1) {
		N[P[0]-1].child2 = P[i + 1];
		vector<int> P1, S1;
		P1.assign(P.begin() + i + 1, P.end());
		S1.assign(S.begin() + i + 1, S.end());
		solve(P1, S1, N);
	}
}

int main() {
	cin >> n;
	vector<node> N(n);
	vector<int> P(n), S(n);
	REP(i, n) cin >> P[i];
	REP(i, n) cin >> S[i];
	solve(P, S, N);
	n = P[0]-1;
	int c1 = N[n].child1, c2 = N[n].child2;
	if (c1 != -1) Pos(c1-1, N);
	if (c2 != -1) Pos(c2-1, N);
	cout << n+1 <<endl;
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LLONG_MIN
#define     INF         LLONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


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

    ll a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a)<<endl;
    return 0;
}



















Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String input = scan.nextLine();
                int len = input.length();
                int sum1 = 0;
                int sum0 = 0;
                int result = 0;

                for (int i=0; i<len; i++) {
                        if ( input.charAt(i) == '1' ) {
                                sum1++;
                        }
                        else {
                                sum0++;
                        }
                }
                if ( sum0 <= sum1 ) {
                        result = sum0 * 2;
                }
                else {
                        result = sum1 * 2;
                }
                System.out.println( result );
                scan.close();
        }
}


Measured memory_bytes: 27068
# input
N = int(input())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]

# const
counter = 0
overed = 0
affs = []
i = 0
# process
for a,b in zip(a_list,b_list):
    if b>a:
        overed += b-a
        counter += 1
    elif b<a:
        affs.append(a-b)
affs = sorted(affs, reverse = True)

while overed>0:
    if i == len(affs):
        print(-1)
        exit()
    overed -= affs[i]
    counter += 1
    i += 1
print(counter)

Measured memory_bytes: 18492
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

long int dp[11][2][10][2];

long int generate(long int idx, string &s, bool tight, long int lastNumber, bool allZero){
  if(idx == s.size())
    return 1;

  if(dp[idx][tight][lastNumber][allZero] != -1)
    return dp[idx][tight][lastNumber][allZero];

  long int upper = (tight)? (s[idx] - '0') : 9;
  long int ans = 0;

  if(idx == 0 || allZero){
    for(long int i = 0; i <= upper; i++)
      ans += generate(idx + 1, s, tight && (i == upper),i, (allZero && !i));
  }
  else{
    for(long int i = 0; i <= upper; i++){
      if(llabs(i - lastNumber) <= 1)
        ans += generate(idx + 1, s, tight && (i == upper), i, (allZero && !i));
    }
  }

  return dp[idx][tight][lastNumber][allZero] = ans;

}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   long int be = 0, en = 1e11;
   long int ans = 0;

   while(be <= en){
    long int mid = (be + en) / 2;
    memset(dp,-1,sizeof(dp));
    string s = to_string(mid);
    long int val = generate(0,s,true,0,true) - 1;

    if(val >= n){
      ans = mid;
      en = mid - 1;
    }
    else
      be = mid + 1;
   }

   cout<<ans;
   return 0;
}

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

bool cmp(int a,int b)		//让怪兽血量从大到小排序 
{
	return a>b;
}

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	sort(a,a+n,cmp);		//排序 
	
	long long sum=0ll;		//2e5*1e9 超int了，用long long 
	for(int i=k;i<n;i++)		//只要从k开始算就行了，k以前的被秒掉了 
		sum+=a[i];		//累计刀数 
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main( void ) {

	int n, a, b, c, d, count;

	while (	scanf( "%d", &n ) != EOF ) {

		count = 0;

		for ( a = 0; a <= 9; a++ ) {

			for ( b = 0; b <= 9; b++ ) {

				for ( c = 0; c <= 9; c++ ) {

					for ( d = 0; d <= 9; d++ ) {

						if ( a + b + c + d == n ) { count++; }

					}

				}

			}

		}

		printf( "%d\n", count );

	}

	return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

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

    ll i = 0;
    ll n = s.size();

    ll ans = 0;

    ll an = 0;

    while (i + 2 < n)
    {
        if (s[i] == 'A') { ++an; } else { an = 0; }

        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            ans += an;

            s[i + 0] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';

            i = i + 2;
            --an;
        }
        else
        {
            ++i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
const long long mod=1000000007;
typedef long long ll;

int main(){
  ll n,ans=0,k,m=0,x=0,y=0;
  cin>>n>>k;
  k=k*2+1;
  cout<<(n+k-1)/k<<endl;
  
}


Measured memory_bytes: 256
N, K = map(int, input().split())
R,S,P = map(int,input().split())
T = input()
A = [0 for i in range(N)]
for i in range(K):
  if T[i] == "r":
    A[i] = P
  if T[i] == "s":
    A[i] = R
  if T[i] == "p":
    A[i] = S
for i in range(K, N):
  if (T[i] == "r") and (T[i-K] != "r"):
    A[i] = P
  if (T[i] == "r") and (T[i-K] == "r") and (A[i-K] == 0):
    A[i] = P
  if (T[i] == "s") and (T[i-K] != "s"):
    A[i] = R
  if (T[i] == "s") and (T[i-K] == "s") and (A[i-K] == 0):
    A[i] = R
  if (T[i] == "p") and (T[i-K] != "p"):
    A[i] = S
  if (T[i] == "p") and (T[i-K] == "p") and (A[i-K] == 0):
    A[i] = S
print(sum(A))

Measured memory_bytes: 4212
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
ll n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	ll A, B, C;
	cin >> A >> B >> C >> k;

	if (k <= A + B) {
		cout << min(A, k);
		exit(0);
	}

	cout << A - (k-A-B);
	
	return Accepted;
}

// B...a

Measured memory_bytes: 17724
#include<bits/stdc++.h> 
#define N 100005
using namespace std;
struct edge{
	int t,next;
}e[N*2];int ecnt,head[N];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;
}
long long ans;
int ini[N],ax[N],delta[N],del;
void DFS(int u,int fr){
	delta[u]=ini[u];
	for(int i=head[u];i;i=e[i].next){
		if(e[i].t!=fr&&i!=del&&i!=(del^1)){
			DFS(e[i].t,u);
			delta[u]-=delta[e[i].t];
			ax[u]-=ax[e[i].t];
		}
	}
	ax[u]==0? ans+=abs(delta[u]):0;
}
int vis[N],num[2],A,B,type[N];
void DFS2(int u,int fr,int side){//find the circle
	num[side]++;vis[u]=1;type[u]=side;
	for(int i=head[u];i;i=e[i].next){
		if(e[i].t==fr) continue;
		if(vis[e[i].t]==0){
			DFS2(e[i].t,u,side^1);
		}else{
			A=u;B=e[i].t;del=i;
		}
	}
}
int n,m;
void solve1(){
	del=0;
	DFS(1,0);
	if(delta[1]!=0) puts("-1"),exit(0);
}
void solve2(){
	DFS2(1,0,0);
	if(type[A]==type[B]){//odd
		int t=(num[type[A]^1]-num[type[A]])/2;
		ini[A]+=t;ini[B]+=t;
		DFS(A,0);
		ans+=abs(t);
	}else{//even
		if(num[0]!=num[1]) puts("-1"),exit(0);
		ax[B]=-1;
		DFS(A,0);
		assert(ax[A]==1);
		assert(delta[A]==0);
		vector<int> v;
		for(int i=1;i<=n;i++) 
			if(ax[i]!=0)
				v.push_back(-ax[i]*delta[i]);
		sort(v.begin(),v.end());
		for(int i=0,mid=v[v.size()/2];i<v.size();i++) ans+=abs(mid-v[i]);
	}
}
int main(){
	scanf("%d%d",&n,&m);ecnt=1;
	if(n%2!=0) return puts("-1"),0; 
	for(int i=1,u,v;i<=m;i++) scanf("%d%d",&u,&v),addedge(u,v);
	for(int i=1;i<=n;i++) ini[i]+=1;
	if(m==n-1) solve1();
	else solve2();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9468
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int n;
cin >> n;
int arr[n];

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

int max=0;
int sum=0;

for(int i=0;i<n;i++)
{
	if(arr[i]>max)
	{
		max=arr[i];
	}
	sum=sum+arr[i];
}

cout << (sum)-(max/2) << endl;


 	return 0;
}












Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
// int a[100010],n,j;
bool ok=false;
int gcd(int a,int b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
void factor(int x,long long fact[])
{
   if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
  
}
int main()
{
    int n;
    cin>>n;
    int a[n];
    //cin >> a[i];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int totalgcd=a[0];
    long long fact[1000001]={0};
   //factor(a[0],fact);
    for(int i=1;i<n;i++)
    {
        totalgcd=__gcd(totalgcd,a[i]);
      // factor(a[i],fact);
    }
  //fact[1]=1;
    for(int i=0;i<n;i++)
        factor(a[i],fact);
  
   //int ispairwise=1;
   // for(int i=0;i<n;i++)
   // {
   //   if(fact[a[i]]>1){ispairwise=0;break;}
   // }
   if(!ok)
   {
    cout <<"pairwise coprime" << endl;
   }
else if(totalgcd==1)
     cout <<"setwise coprime" << endl;
   else
     cout <<"not coprime" << endl;
}


Measured memory_bytes: 15352