akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll A, B, Q;
    vector<ll> s, t;
    cin >> A >> B >> Q;

    s.pb(-50000000000);
    t.pb(-50000000000);
    rep(i, A){
        ll si;
        cin >> si;
        s.pb(si);
    }
    rep(i, B){
        ll ti;
        cin >> ti;
        t.pb(ti);
    }

    s.pb(2e10+1);
    t.pb(2e10+1);

    rep(i, Q){
        ll x; cin >> x;
        ll sl,sr;
        ll tl,tr;

        sr = lower_bound(all(s), x)-s.begin(); sl = sr - 1;
        tr = lower_bound(all(t), x)-t.begin(); tl = tr - 1;

        ll ans = 100000000000;

        ll dsl = abs(x-s[sl]); ll dsr = abs(s[sr]-x);
        ll dtl = abs(x-t[tl]); ll dtr = abs(t[tr]-x);

        ans = min(ans, max(dtl, dsl));
        ans = min(ans, max(dtr, dsr));
        ans = min(ans, dtl*2 + dsr);
        ans = min(ans, dtl + dsr*2);
        ans = min(ans, dsl + dtr*2);
        ans = min(ans, dsl*2 + dtr);
        cout << ans << endl;
    }



    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: usize = sc.get();
    let B: usize = sc.get();
    let K: usize = sc.get();
    if K < A {
        println!("{} {}", A-K, B);
    } else if A <= K && K < A + B {
        println!("{} {}", 0, B-(K-A));
    } else {
        println!("{} {}", 0, 0);
    }
}


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

int main() {
  int64_t a, b, c, d, ans;
  cin >> a >> b >> c >> d;
  ans = max(max(a*c, b*d), max(a*d, c*b));
  cout << ans << endl;  
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}



int X,Y,Z;
vector<int> vs; 
struct Masu{
	int E,A;
	Masu(int E,int A):E(E),A(A){}
	Masu():E(-1),A(-1){}
}; 
vector<Masu> ms; 

double EPS=1e-9;
int main(){
	while(true){
		cin >> X >> Y >> Z;
		if(X==0 && Y==0 && Z==0)break;
		vs=vector<int>(X);REP(i,X)cin >> vs[i];
		
		ms=vector<Masu>(Y+1);
		REP(i,Z){
			int N,E,A;cin >> N >> E >>A;
			ms[N]=Masu(E,A);
		}
		int MAXM=6020;
		vector<vector<double> > dp(Y+1,vector<double>(MAXM+1000));
		dp[0][0]=1.0;
		REP(p,Y){
			REP(m,MAXM){
				if(dp[p][m]<EPS)continue;
				REP(x,X){
					int nxt=min(Y,p+vs[x]);
					switch(ms[nxt].E){
						case 1://move
						nxt=min(Y,nxt+ms[nxt].A);
						dp[nxt][m]+=dp[p][m]/X;break;
						case 2://add money
						dp[nxt][m+ms[nxt].A]+=dp[p][m]/X;break;
						case 3://remove money
						dp[nxt][max(0,m-ms[nxt].A)]+=dp[p][m]/X;break;
						default://no event
						dp[nxt][m]+=dp[p][m]/X;break;
					}
				}
			}
		}

		double Exp=0;REP(m,MAXM)Exp+=m*dp[Y][m];
		cout <<int(Exp)<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  string s;cin>>s;

  set<string>se;

  bool q[10];CLR(q,false);
  int qcount=0;

  for(int i=0;i<n-2&&qcount!=10;i++){
    if(q[s[i]-'0'])continue;
    q[s[i]-'0']=true;
    qcount++;
    bool w[10];CLR(w,false);
    int wcount=0;

    for(int j=i+1;j<n-1&&wcount!=10;j++){
      if(w[s[j]-'0'])continue;

      w[s[j]-'0']=true;
      wcount++;

      bool e[10];CLR(e,false);
      int ecount=0;
      for(int k=j+1;k<n&&ecount!=10;k++){
        if(e[s[k]-'0'])continue;
        else{
          e[s[k]-'0']=true;
          ecount++;
          string t="";
          t+=s[i];
          t+=s[j];
          t+=s[k];
          // out(t);
          se.insert(t);
        }
      }
    }

  }

  out(se.size());

  // int k=0;
  // rep(i,0,4){
  //   string t="";
  //   rep(j,0,n){
  //     if(k<=j&&j<k+(n-3));
  //     else t+=s[j];

  //   }
  //   k++;
  //   out(t);
  //   se.insert(t);
  // }

  // out(se.size());

  return 0;
}


Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
b=[a[0]]
a.pop(0)
for i in a:
  b.append(i)
  b.append(i)
ans=0
for i in range(n-1):
  ans+=b[i]
print(ans)

Measured memory_bytes: 31444
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

class RMQ{
	private:
	vp rmq;
	void updatefunc(int x,int k,int num){
		rmq[x].first=rmq[k].first;
		rmq[x].second=num;
	}
	public:
	int n;
	void init(int n_){
		n=1;
		while(n<n_) n*=2;
		rmq=vp(2*n-1,P(inf,-1));
	}
	void update(int k,int x){
		k+=n-1;
		rmq[k].second=k-n+1;
		rmq[k].first=x;
		while(k>0){
			k=(k-1)/2;
			if(rmq[k*2+1].first<rmq[k*2+2].first){
				updatefunc(k,k*2+1,rmq[k*2+1].second);
			}
			else if(rmq[k*2+1].first>rmq[k*2+2].first){
				updatefunc(k,k*2+2,rmq[k*2+2].second);
			}
			else{
				updatefunc(k,k*2+1,rmq[k*2+1].second);
				updatefunc(k,k*2+2,rmq[k*2+2].second);
			}
		}
	}
	P query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return P(inf,-1);
		if(a<=l&&r<=b) return rmq[k];
		else{
			int mid=(l+r)/2;
			P vl=query(a,b,k*2+1,l,mid);
			P vr=query(a,b,k*2+2,mid,r);
			return (vl.first<vr.first)?vl:vr;
		}
	}
	void open(){
		for(int i=0;i<rmq.size();i++) cout<<rmq[i].first<<endl;
		for(int i=0;i<rmq.size();i++) cout<<rmq[i].second<<endl;
	}
};

class Graph{
	private:
	int GV;
	vvi List;
	void Euler(int x,int l,int& ind,vb& used){
		euler[ind]=x;
		level.update(ind,l);
		used[x]=1;
		if(disc[x]==-1) disc[x]=ind;
		ind++;
		for(int i=0;i<List[x].size();i++){
			int v=List[x][i];
			if(!used[v]){
				Euler(v,l+1,ind,used);
				euler[ind]=x;
				level.update(ind,l);
				ind++;
			}
		}
	}
	public:
	vi euler,disc;
	RMQ	level;
	Graph(int v){
		GV=v;
		List=vvi(v);
	}
	void add_edge(int x,int y){
		List[x].push_back(y);
		List[y].push_back(x);
	}
	void LCAprepare(){
		euler=vi(2*GV-1);
		disc=vi(GV,-1);
		level.init(2*GV-1);
		int ind=0;
		vb used(GV);
		Euler(0,0,ind,used);
	}
	int LCA(int s,int t){
		s=disc[s];
		t=disc[t];
		if(s>t) swap(s,t);
		P index=level.query(s,t+1,0,0,level.n);
		return euler[index.second];
	}
};

int V,Q;

int main(){
	cin>>V;
	Graph gra(V);
	int n,s;
	for(int i=0;i<V;i++){
		cin>>n;
		for(int j=0;j<n;j++){
			cin>>s;
			gra.add_edge(i,s);
		}
	}
	gra.LCAprepare();
	cin>>Q;
	int u,v;
	for(int i=0;i<Q;i++){
		cin>>u>>v;
		cout<<gra.LCA(u,v)<<endl;
	}
}

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);

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

    sort(v.begin(), v.end());
    
    cout << v.back() - v[0] << endl;
}

Measured memory_bytes: 256
sa=list(input())
sb=list(input())
sc=list(input())
sa.append("x")
sb.append("x")
sc.append("x")
l=[sa,sb,sc]
na=len(sa)-1
nb=len(sb)-1
nc=len(sc)-1
a=0
b=0
c=0
f=0
turn="a"
while f==0:
    if turn=="a":
        a+=1
        turn=l[0][a-1]
        
    elif turn=="b":
        b+=1
        turn=l[1][b-1]
    else:
        c+=1
        turn=l[2][c-1]
    if a==na+1:
        print("A")
        exit()
    elif b==nb+1:
        print("B")
        exit()
    elif c==nc+1:
        print("C")
        exit()
    
    


Measured memory_bytes: 9108
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
int main(){
    gibe_de_fast_io_b0ss;
    int n, k;
    cin>>n>>k;
    vector<int> arr(n, 0), cache(n, INT_MAX / 2);
    
    for(int i = 0; i < n; i++) {
    	cin>>arr[i];
    }
    cache[0] = 0;
    for(int i = 1; i < n; i++) {
    	for(int j = i - 1; j >= max(0, i - k); j--) {
    		cache[i] = min(cache[i], cache[j] + abs(arr[i] - arr[j]));	
    	}
    }
    cout<<cache[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  n=n%10;
  if(n==2||n==4||n==5||n==7||n==9)
    cout<<"hon"<<endl;
  else
    if(n==0||n==1||n==6||n==8)
      cout<<"pon"<<endl;
  else if(n==3)
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3492
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=r&&y>=r&&x+r<=W&&y+r<=H){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

struct CalcResult {
	int value;
	int next_line_index;
};

int get_depth(std::string& s) {
	return s.size() - 1;
}

CalcResult calc(std::vector<std::string>& lines, int index) {
	std::string& line = lines[index];
	int depth = get_depth(line);
	char op = line[line.size() - 1];

	int result;
	int next_line_index = index + 1;

	switch (op)
	{
	case '+':
		result = 0;
		while (next_line_index < lines.size()) {
			int ndepth = get_depth(lines[next_line_index]);
			if (ndepth <= depth) break;
			CalcResult cr = calc(lines, next_line_index);
			result += cr.value;
			next_line_index = cr.next_line_index;
		}
		break;
	case '*':
		result = 1;
		while (next_line_index < lines.size()) {
			int ndepth = get_depth(lines[next_line_index]);
			if (ndepth <= depth) break;
			CalcResult cr = calc(lines, next_line_index);
			result *= cr.value;
			next_line_index = cr.next_line_index;
		}
		break;
	default:
		result = op - '0';
		break;
	}

	return { result, next_line_index };
}

int main()
{
	std::string line;

	while (true) {
		int n;
		{
			std::getline(std::cin, line);
			std::istringstream ss(line);
			ss >> n;
		}

		if (n == 0) return 0;

		std::vector<std::string> lines;
		lines.reserve(n);
		for (int i = 0; i < n; i++) {
			std::getline(std::cin, line);
			lines.push_back(line); // copy
		}

		std::cout << calc(lines, 0).value << std::endl;
	}
}

Measured memory_bytes: 3116
n = int(input())
x = list(map(int,input().split()))
ans = int(sum(x)**2)
current = 0
for p in range(min(x)-1,max(x)+1):
    for i in range(len(x)):
        current += int((x[i] - p)**2)
    if(current < ans):
        ans = current
    current = 0
print(ans)

Measured memory_bytes: 3060
import sys
from pprint import pprint
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def solve(a, b):
    print(lcm(a, b))

if __name__ == '__main__':
    a, b = map(int, sys.stdin.readline().strip().split(" "))
    solve(a, b)

Measured memory_bytes: 65260
#include <bits/stdc++.h>
#define mmp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
const int MN = 200200;
vector<pl> res;
bitset<2*MN> bs;
ll tr(ll n) {
	return n*(n+1)/2;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,k;
	bs.set();
	cin >> n >> k;
	ll ma = tr(3*n)-2*tr(2*n);
	ll mv = (ma/n)+1;
	//cout << ma << '\n';
	//cout << ma/n << '\n';
	if(k-1 > ma/n) {
		cout << -1 << "\n";
		return 0;
	}
	int a = 0,b = 2*n-1;
	int pct = 0;
	while(a < b && (a+b+mv < 3*n)) {
		res.push_back(mmp(a,b));
		bs.reset(a);
		bs.reset(b);
		pct++;
		a += 2;b--;
	}
	int bct = 3*n-res.size();
	for(int i=0;i<res.size();i++) {
		int u = res[i].first,v = res[i].second;
		cout << u+k << " " << v+k << " " << bct+k << '\n';
		bct++;
	}
	res.clear();
	a = 0,b = 2*n-1;
		//cout << "oof " << a << " " << b << '\n';
	for(;pct<n;pct++) {
		while(!bs[a]) {a++;}
		while(!bs[b]) {b--;}
		//cout << "oof " << a << " " << b << '\n';
		bs.reset(a);
		bs.reset(b);
		res.push_back(mmp(a,b));
	}
	for(int i=0;i<res.size();i++) {
		int u = res[i].first,v = res[i].second;
		cout << u+k << " " << v+k << " " << 2*n+k+i << '\n';
	}
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1')
            ans+=1;
    }
    cout<<ans;
    return 0;
}


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

class LCA{
public:
	vector<vector<pair<int,int>>>E;
	vector<vector<int>>par;
	vector<int>d1;
	vector<long long>d2;
	int MAX_LOG=18;
	int n;
	LCA(){}
	LCA(int N){
		n=N;
		E=vector<vector<pair<int,int>>>(n);
		par=vector<vector<int>>(MAX_LOG,vector<int>(n));
		d1=vector<int>(n);
		d2=vector<long long>(n);
	}
	void add_edge(int a,int b,int c){
		E[a].push_back(make_pair(c,b));
		E[b].push_back(make_pair(c,a));
	}
	void add_edge(int a,int b){
		E[a].push_back(make_pair(1,b));
		E[b].push_back(make_pair(1,a));
	}
private:
	void dfs(int u,int p,int a,long long b){
		par[0][u]=p;d1[u]=a;d2[u]=b;
		for(auto&v:E[u]){
			if(v.second!=p)dfs(v.second,u,a+1,b+v.first);
		}
	}
	bool flag=false;
	void init(){
		dfs(0,-1,0,0);
		for(int i=1;i<MAX_LOG;i++)for(int j=0;j<n;j++){
			if(par[i-1][j]==-1)par[i][j]=-1;
			else par[i][j]=par[i-1][par[i-1][j]];
		}
		flag=true;
	}
public:
	int lca(int u,int v){
		if(!flag)init();
		if(d1[u]>d1[v])swap(u,v);
		for(int i=0;i<MAX_LOG;i++){
			if((d1[v]-d1[u])>>i&1)v=par[i][v];
		}
		if(u==v)return u;
		for(int i=MAX_LOG-1;i>=0;i--){
			if(par[i][u]!=par[i][v]){
				u=par[i][u];
				v=par[i][v];
			}
		}
		return par[0][u];
	}
	long long dist(int u,int v){
		int l=lca(u,v);
		return d2[u]+d2[v]-d2[l]*2;
	}
};

int N;
struct node{
	node*l,*r;
	int cnt;
	node*update(int,int,int,int);
}pool[5000000];

node*nx(){
	static int p=0;
	return &pool[p++];
}
node*null;

void init(int n){
	N=1;while(N<n)N<<=1;
	null=nx();
	null->l=null->r=null;
}
node* node::update(int k,int x,int l=0,int r=N){
	if(k<l||r<=k)return this;
	if(r-l==1){
		node*n=nx();
		n->cnt=this->cnt+x;
		return n;
	}
	node*n=nx();
	n->l=this->l->update(k,x,l,(l+r)/2);
	n->r=this->r->update(k,x,(l+r)/2,r);
	n->cnt=n->l->cnt+n->r->cnt;
	return n;
}

int n,q;
node*seg[200000];

vector<int>E[200000];
int x[200000];

void dfs(int v,int p){
	seg[v]=(p==-1?null:seg[p])->update(x[v],1);
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v);
	}
}

int lower_bound(node*a,node*b,node*p,int val,int x,int l=0,int r=N){
	if(r-l==1)return l;
	int lc=a->l->cnt+b->l->cnt-2*p->l->cnt+(l<=val&&val<(l+r)/2);
	if(lc>=x)return lower_bound(a->l,b->l,p->l,val,x,l,(l+r)/2);
	return lower_bound(a->r,b->r,p->r,val,x-lc,(l+r)/2,r);
}

int main(){
	scanf("%d%d",&n,&q);
	LCA lca(n);
	vector<int>xs;
	rep(i,n){
		scanf("%d",&x[i]);
		xs.push_back(x[i]);
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	init(xs.size());
	rep(i,n){
		x[i]=lower_bound(xs.begin(),xs.end(),x[i])-xs.begin();
	}
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		lca.add_edge(a,b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	dfs(0,-1);
	rep(i,q){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		int p=lca.lca(a,b);
		printf("%d\n",xs[lower_bound(seg[a],seg[b],seg[p],x[p],c)]);
	}
}


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

using namespace std;

struct expand_type {
    template <typename... T>
    expand_type (T&&...) {}
};
template <typename... ArgTypes>
void print (ArgTypes... args) {
    expand_type {0, (cerr << args << ", ", 0)...};
    cerr << "\b\b \n";
}
#define printv(x) cerr << "["; for(auto i : (x)) cerr << i << ", "; cerr << "\b\b]\n";
#define __lcm(a,b) a * b / __gcd(a, b)

typedef unsigned long long ull;
typedef long double ld;

int main () {
    std::ios::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);
    ull n;
    cin >> n;
    string res = "";
    int mod;

    while (n > 0) {
        mod = (n - 1) % 26;
        res = char('a' + mod) + res;
        n = (ull)((n - mod) / 26);
    }

    cout << res<< endl;

    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
int A,B,C,D,E,good1,good2,good3,F,G,H;
scanf("%d",&A);
scanf("%d",&B);
scanf("%d",&C);
scanf("%d",&D);
scanf("%d",&E);
if(A<0){
G=C*-A;
H=B*E;
good1=G+D+H;
printf("%d\n",good1);
}else{
if(A==0){
good2=D+H;
printf("%d\n",good2);
}else{
F=B-A;
good3=E*F;
printf("%d\n",good3);
}}
return(0);
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int dp[105][80];
int main(){
    int n; cin >> n;

    map<int, int> pd;
    for(int i=2; i<=n;i++){
        int k = i;
        for(int p=2; p<=n; p++){
            while(k % p  == 0){
                pd[p]++;
                k /= p;
            }
        }
    }

    vector<int> num;
    for(auto p : pd) num.push_back(p.second);
    int l = num.size();

    vector<int> div = {1, 3, 5, 15, 25, 75};

    dp[0][1] = 1;
    rep(i,l){
        for(auto j : div){
            for(auto k : div){
                if(j*k <= 75 && num[i] + 1 >= k){
                    dp[i+1][j*k] += dp[i][j];
                }
            }
        }
    }

    cout << dp[l][75] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n;cin >>n;
  map<ll,ll> mp;
  ll s = 0;
  for(int i=0;i<n;++i){
    ll t;cin >> t;
    if(mp.find(t) != mp.end()){
      ++mp[t];
    } else {
      mp[t] = 1;
    }
    s+=t;
  }
  int q;cin >> q;
  for(int j=0;j<q;++j){
    ll b,c;cin >> b >>c;
    if(mp.find(b) != mp.end()){
      s += (c-b)* mp[b];
      if(mp.find(c) != mp.end()){
        mp[c] += mp[b];
        mp[b] = 0;
      } else {
        mp[c] = mp[b];
        mp[b] = 0;
      }
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 8640
// abc105_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    
    if (N % K ==  0){
        print(0);
    } else {
        print(1);
    }

    return 0;
}


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

int main(void){
    int i = 0;
    int s[10];

    for(i=0;i<10;i++){
        cin >> s[i];
    }

    sort(s, s+10);

    cout << s[9] << endl;
    cout << s[8] << endl;
    cout << s[7] << endl;

    return(0);
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    if (N % 2 == 0) {
        cout << (double)1 / 2 << "\n";
    } else {
        cout << (double)(N + 1) / (2 * N) << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  ll p[MAX], q[MAX], r[MAX];
  
  for(i=0; i<A; i++) cin >> p[i];
  for(i=0; i<B; i++) cin >> q[i];
  for(i=0; i<C; i++) cin >> r[i];
  sort(p, p+A); reverse(p, p+A);
  sort(q, q+B); reverse(q, q+B);
  sort(r, r+C); reverse(r, r+C);
  
  priority_queue<ll> qu;
  
  ll t=0;
  for(i=0; i<X; i++) {
    t+=p[i];
    qu.push(-p[i]);
  }
  for(i=0; i<Y; i++) {
    t+=q[i];
    qu.push(-q[i]);
  }
  
  ll ans=t;
  for(i=0; i<min(X+Y, C); i++) {
    t+=r[i];
    t-=-qu.top(); qu.pop();
    chmax(ans, t);
  }
  
  pt(ans);
  
}




Measured memory_bytes: 4724
[N,M] = [int(s) for s in input().rstrip().split(' ')]
if M == 1:
    print("1 2")
else:
    for i in range(1,M//2+1):
        print("{} {}".format(i,M+1-i))
    for i in range(1,-(-M//2)+1):
        print("{} {}".format(M+i,2*M+2-i))

Measured memory_bytes: 9220
// Math = ♥️

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

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n;
    cin >> n;

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

    ll sum = 0, curr = 0;
    for (int i = 0; i < n + 2; i++) {
        sum += llabs(curr - arr[i]);
        curr = arr[i];
    }

    for (int i = 1; i <= n; i++) {
        cout << sum + llabs(arr[i - 1] - arr[i + 1]) -
                    llabs(arr[i - 1] - arr[i]) - llabs(arr[i] - arr[i + 1])
             << "\n";
    }
}


Measured memory_bytes: 2032
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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


int main(){
    string s;
    cin >> s;
    int n = s.size() + 1;
    char t;
    vector<pair<long int, char> > v;
    t = s[0];
    long int num = 1;
    for (int i = 1; i < n - 1; i++){
        if (s[i] == t){
            num++;
        }else{
            v.push_back(pair<long int, char>(num, t));
            t = s[i];
            num = 1;
        }
    }
    v.push_back(pair<long int, char>(num, t));
    long int a = 0;
    long int ans = 0;
    for (int i = 0; i < v.size(); i++){
        if (v[i].second == '<'){
            for (int j = 0; j < v[i].first; j++){
                a++;
                ans += a;
                // cout << a << " ";
                
            }
        }else{
            ans -= a;
            a = max(a, v[i].first);
            ans += a;
            a = v[i].first;
            for (int j = 0; j < v[i].first; j++){
                a--;
                ans += a;
                // cout << a << " ";
                
            }
        }
        
        
    }
    // cout << endl;
    cout << ans << endl;
    
}

Measured memory_bytes: 7032
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int tar = 0;
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a == 0 && b == 0){
				break;
			}
			int sum = a + b;
			for(int i = 1;i < 5;i++){
				int c = scan.nextInt() + scan.nextInt();
				if(sum < c){
					sum = c;
					tar = i;
				}
			}
			switch(tar){
			case 0:
				System.out.print("A ");
				break;
			case 1:
				System.out.print("B ");
				break;
			case 2:
				System.out.print("C ");
				break;
			case 3:
				System.out.print("D ");
				break;
			case 4:
				System.out.print("E ");
				break;
			default:
				break;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 21124
A,B,C = map(int,input().split())
K = int(input())
import math

x,y = 0,0

if A > B:
    if math.modf(math.log2(A/B))[0] != 0:
        x = math.ceil(math.log2(A/B))
    else:
        x = math.ceil(math.log2(A/B))+1
elif A == B:
    x = 1
else:
    pass

if B*(2**x) > C:
    if math.modf(math.log2((B*(2**x))/C))[0] != 0:
        y = math.ceil(math.log2((B*(2**x))/C))
    else:
        y = math.ceil(math.log2((B*(2**x))/C))+1    
elif B*(2**x) == C:
    y = 1
else:
    pass


if x + y <= K:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <random>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// goto ANSWER; で最後へ飛ぶ

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

    int n;
    vector<int> r;
    cin >> n;
    r.resize(n);
    for(int i=0; i<n; i++)
        cin >> r[i];
    
    int ans = r[1] - r[0];
    int holder = r[0];
    for(int i=0; i<n; i++){
        if(r[i] > holder) continue;
        for(int k=i+1; k<n; k++){
            if(r[k] - r[i] > ans){
                ans = r[k] - r[i];
                holder = r[i];
            }
        }
    }

ANSWER:
    COUT(ans);

    return 0;
}


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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll add(ll a,ll b) {
	return ((a%hell)+(b%hell))%hell;
}
ll sub(ll a,ll b) {
	return ((a%hell)-(b%hell)+hell)%hell;
}
ll mul(ll a,ll b) {
	return ((a%hell)*(b%hell))%hell;
}

const ll MAXN=100005;
ll n;
vi a[MAXN];
ll dp[MAXN][2];

ll dfs(ll node,ll color,ll par) {
	trace(node,color);
	if (dp[node][color]!=-1)return dp[node][color];
	dp[node][color]=1;
	if (color==1){
		for(auto i:a[node]){
			if(i!=par){
				dp[node][color]=mul(dp[node][color],dfs(i,0,node));
			}
		}
	}
	else{
		for(auto i:a[node]){
			if(i!=par){
				dp[node][color]=mul(dp[node][color],add(dfs(i,0,node),dfs(i,1,node)));
			}
		}
	}
	return dp[node][color];
}

void solve() {
    cin>>n;
    rep(i,0,n-1){
    	ll x,y;
    	cin>>x>>y;
    	a[x].pb(y);
    	a[y].pb(x);
    }
    memset(dp,-1,sizeof dp);
    cout<<add(dfs(1,0,-1),dfs(1,1,-1))<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 17024
package main

import "fmt"

func main(){
  var A int
  var B int
  var C int
  var D int
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&C)
  fmt.Scan(&D)
  var sum1 int = A * B
  var sum2 int = C * D
  
  if sum1 <= sum2 {
    fmt.Println(sum2)
  } else if sum1 > sum2 {
    fmt.Println(sum1)
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
 
bool solve(
    int* const a,
    const int n,
    const int i,
    const int m)
{
    if (m < 0) {
        return false;
    }
    if (m == 0) {
        return true;
    }
    if (i == n) {
        return false;
    }
 
    return solve(a, n, i + 1, m)
        || solve(a, n, i + 1, m - a[i]);
}
 
int main()
{
    int n;
    std::cin >> n;
    std::cin.ignore();
 
    int a[20];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::stringstream stream;
        stream << buf;
        for (int i = 0; std::getline(stream, buf, ' '); ++i) {
            a[i] = std::stoi(buf);
        }
    }
 
    int q;
    std::cin >> q;
    std::cin.ignore();
 
    int m[200];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::stringstream stream;
        stream << buf;
        for (int i = 0; std::getline(stream, buf, ' '); ++i) {
            m[i] = std::stoi(buf);
        }
    }
 
    for (int i = 0; i < q; ++i) {
        std::cout << (solve(a, n, 0, m[i]) ? "yes" : "no") << std::endl;
    }
 
    return 0;
}

Measured memory_bytes: 3212
/***************************************************************
     File Name: B.cpp
     Created Time: 六  5/ 5 20:23:42 2018
 **************************************************************/
#define MEM0(x) memset(x,0,sizeof(x))
#define MEM1(x) memset(x,-1,sizeof(x))
#define MEMX(x) memset(x,0x3f,sizeof(x))
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

vector<int> v;
int main() {
  int a, b, c, k;
  while (cin >> a >> b >> c >> k) {
    v.clear();
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    cout << v[0] + v[1] + (v[2] << k) << endl;
  }
}


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

using namespace std;

void inputData(vector<string>& data_set) {
	string buffer;
	while(getline(std::cin,buffer))
		data_set.push_back(buffer);
}

template <class T>
T convertStringToNumber(const string& str) {
	stringstream ss;
	T ret;

	ss << str;
	ss >> ret;

	return ret;
}


void doAllProcess() {
	vector<string> buffer;
	vector<int> data_set;

	inputData(buffer);

	data_set.resize(buffer.size());
	for(int i = 0; i < buffer.size(); ++i)
		data_set[i] = convertStringToNumber<int>(buffer[i]);

	sort(data_set.begin(), data_set.end(), [](int n1, int n2){ return n1>=n2; });

	std::cout << data_set[0] << std::endl;
	std::cout << data_set[1] << std::endl;
	std::cout << data_set[2] << std::endl;
}


int main() {
	doAllProcess();

	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  string s1;
  ll n, k, i, j, d, a, m, b;
  cin>>n>>m;
  ll good=n;
  vector<ll>v(n);
  vector<ll>isGood(n, 1);
  for(i=0; i<n; i++){
    cin>>v[i];
  }
  for(i=0; i<m; i++){
    cin>>a>>b;
    if(v[a-1]<=v[b-1]&&isGood[a-1]==1){
      isGood[a-1]=0;
      good--;
    }
    if(v[b-1]<=v[a-1]&&isGood[b-1]==1){
      isGood[b-1]=0;
      good--;
    }
  }
  cout<<good;
  return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
#define mod  1000000007
#define mp make_pair
#define pb push_back
#define sd second
#define mod  1000000007
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++) 
ll i,j,k;
void solve(){
 ll n,a; cin >>n >> a;
  vl v(n); ll sum =0;
  for(i = 0; i < n; i++) cin >> v[i];
    sort(all(v));
    for(i = n - a - 1; i>=0; i--) sum = sum + v[i];
      cout << sum << endl;

     return ; 
} 
    signed main(){
   
    //CASET
    solve();
    
   
    return 0;
  }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

const ll INF = (1LL<<60);

int N, R;
ll res;
ll d[205][205];
int r[10];
bool used[205];

void dfs(int c, int las, int dist){
    if(c == R){
        if(res > dist) res = dist;
        return;
    }
    for(int i=1; i<=R; i++) if(!used[r[i]]){
        used[r[i]] = true;
        if(las == -1) dfs(c+1, i, 0);
        else dfs(c+1, i, dist+d[r[las]][r[i]]);
        used[r[i]] = false;
    }
}

void floyd(){
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            if(d[i][k] == INF) continue;
            for(int j=1; j<=N; j++){
                if(d[k][j] == INF) continue;
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int M; cin >> N >> M >> R;
    for(int i=1; i<=R; i++) cin >> r[i];

    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++) d[i][j] = ((i == j)? 0 : INF);
    }

    for(int i=0; i<M; i++){
        int a,b,c; cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }

    floyd();

    res = INF;
    dfs(0, -1, 0);
    cout << res << endl;
}

Measured memory_bytes: 512
#include<iostream>
#define DIM (1 << 18 + 5)
#define mod 1000000007
using namespace std;
int n, k, i, sol;
int p[DIM], d[DIM];
void solve(int nod, int prod){
    prod = prod * 1LL * nod % mod;
    if(nod < k){
        solve(2 * nod, prod);
        solve(2 * nod + 1, prod);
        return;
    }
    int u, prod2, sum;
    prod2 = prod;
    for(u = p[nod]; u != 1; u /= 2){
        prod2 = prod2 * 1LL * u % mod;
        sum = d[u / 2] - d[u] * 1LL * (u / 2) % mod;
        if(sum < 0){
            sum += mod;
        }
        sol = (sol + sum * 1LL * prod2) % mod;
    }
}
void clean(int nod){
    if(nod < k){
        clean(2 * nod);
        clean(2 * nod + 1);
    }
    else{
        for(int u = p[nod]; u != 0; u /= 2){
            d[u] = 0;
        }
    }
}
void calc(int nod, int prod){
    prod = prod * 1LL * nod % mod;
    if(nod < k){
        calc(2 * nod, prod);
        calc(2 * nod + 1, prod);
        return;
    }
    for(int u = p[nod]; u != 0; u = u / 2){
        prod = prod * 1LL * u % mod;
        d[u] = (d[u] + prod) % mod;
    }
}
int main(){
    cin>> n;
    k = (1 << (n - 1) );
    for(i = k; i < 2 * k; i++){
        cin>> p[i];
        p[i] = p[i] + k - 1;
    }
    for(i = 1; i < k; i++){
        calc(2 * i, i);
        solve(2 * i + 1, 1);
        clean(2 * i);
    }
    cout<< sol;
}


Measured memory_bytes: 5148
#include<stdio.h>
#include<string.h>
int main()
{
    char s[900001];
    int sum=0,i;
    scanf("%s",s);
    int l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(s[i]=='-')
        {
            sum=sum-1;
        }
        else if(s[i]=='+')
        {
            sum=sum+1;
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 128
let judge (n:int64) (k:int64) = List.min [n % k |> abs; (k - (n % k) |> abs)]
//let input = [| 7L, 4L; 2L, 6L; 1000000000000000000L, 1L |]
//for n, k in input do (judge n k |> printfn "%d")
// expected 1; 2; 0

[<EntryPoint>]
let main argv =
    stdin.ReadLine().Split()
    |> Array.map int64
    |> fun x -> judge x.[0] x.[1]
    |> printfn "%d"
    0


Measured memory_bytes: 29912
n = int(input())
a = list(map(int, input().split()))

b = [0]*n
for i in range(n)[::-1]:
    tmp = 0
    for j in range(n//(i+1)):
        tmp += b[(i+1)*(j+1)-1]
    if tmp%2 != a[i]:
        b[i] += 1

print(sum(b))
ans = [i+1 for i in range(n) if b[i]]
print(*ans)

Measured memory_bytes: 70364
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
map<string,int> arr;
int main() {
	int n;
	string inp,prev;
	bool ans=1;
	cin >> n >> inp;
	prev=inp;
	arr[inp]=1;
	for(int i = 1; i < n; i++){
		cin >> inp;
		if((arr[inp]!=0)||(inp[0]!=prev[prev.length()-1])){
			ans=0;
		}
		arr[inp]=1;
		prev=inp;
	}
	if(ans){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
H, W = map(int, input().split())
grid = np.array([list(map(str, input())) for _ in range(H)])

X = np.where(grid == '#')
A = np.zeros([H,W])
A[X] = 1
orig_black = np.count_nonzero(grid=='#')

q = [[0,0,0]]
while q:
	cx,cy,cd = q.pop(0)
	if cx == H-1 and cy == W-1:
		shortest = cd
		break
	elif A[cx,cy] == -1:
		continue

	A[cx,cy] = -1

	for nx,ny in [[cx+1,cy],[cx-1,cy],[cx,cy+1],[cx,cy-1]]:
		if 0 <= nx < H and 0 <= ny < W:
			if A[nx][ny] == 0:
				q.append([nx,ny,cd+1])

	if q == []:
		print(-1)
		sys.exit()

print((H*W)-shortest-orig_black-1)

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

int main(void){
  int x;
  scanf("%d", &x);
  int i;
  int ans;
  for(i=0; i<8; i++){
    if(400+200*i<=x && i<400+200*(i+1)){
      ans=8-i;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1716
#include <stdio.h>
int x[1000000];
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(scanf("%d",&n) != EOF){
		for(i=2;i<=n;i++){
			x[i]=1;
		}
	for(i=2;i<=n;i++){
		if(x[i]==1){
			sum++;
		}
		for(j=2;i*j<=n;j++){
			x[i*j]=0;
		}
	}
	
	printf("%d\n",sum);
	sum=0;
	}
      return 0;
	}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,m;
    while(cin >> n >> m, n+m){
        auto Ld = vectors(301,301,INF);
        auto Sd = vectors(301,301,INF);
        rep(i,n)Ld[i][i] = Sd[i][i] = 0;
        rep(i,m){
            int a,b,c; char s;
            cin >> a >> b >> c >> s;
            --a,--b;
            if(s == 'L'){
                cmin(Ld[a][b],c);
                Ld[b][a] = Ld[a][b];
            }else{
                cmin(Sd[a][b], c);
                Sd[b][a] = Sd[a][b];
            }
        }
        rep(k,n)rep(i,n)rep(j,n){
            cmin(Sd[i][j],Sd[i][k] + Sd[k][j]);
            cmin(Ld[i][j],Ld[i][k] + Ld[k][j] );
        }
        int r; cin >> r;
        vector<int>v;
        rep(i,r){
            int t; cin >> t;
            v.push_back(--t);
        }
        auto dp = vectors(1000+1,300+1,(int)INF);
        dp[0][v[0]]=0;
        rep(i,r-1){
            /*if(i == 0){
                rep(k,n)dp[0][k] = Ld[v[i]][k] + Sd[v[i]][k] + Ld[k][v[i]];
            }*/
            rep(j,n){
                cmin(dp[i+1][j],dp[i][j]+Ld[v[i]][v[i+1]]);
                rep(k,n){
                    cmin(dp[i+1][k],dp[i][j] + Ld[v[i]][j] + Sd[j][k] + Ld[k][v[i+1]]);
                }
            }
        }
        int ans = INF;
        rep(i,n)cmin(ans,dp[r-1][i]);
        cout << ans << endl;
    }
}




Measured memory_bytes: 6668