akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
    int A,B;cin>>A>>B;
	int H,M;cin>>H>>M;

	ld lo = 30 * H;
	ld mi = (ld)M*6;
	lo += (ld) M/2;
	ld ans = (ld)sqrt((A*A + B*B-2*A*B*cos((ld)(lo-mi)*PI/180)));
	out(ans);
	
}

Measured memory_bytes: 4184
def invr():
    return(map(int, input().split()))


n, k = invr()
arr = []
d = dict()
for i in range(n):
    a, b = invr()
    if a in d:
        d[a] += b
    else:
        d[a] = b
        arr.append(a)
arr = sorted(arr)
pos = 0
for i in arr:
    pos += d[i]
    if pos >= k:
        print(i)
        break


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

int main(){
    int A,B;
    cin >> A >> B;
    for (int i = 1; i <= 10000; i++){
        int C = i * 0.08;
        int D = i * 0.1;
        if (C == A && D == B){
            cout << i << endl;
            break;
        }
        else if (i == 9000){
            cout << -1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	string t;
	int a,b;
	cin>>s;
	int ans=0;
	for(int i=0;i<6;i++){
		if(s[i]=='1')ans++;
	}
	cout<<ans<<endl;
}

	


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int fie[40][40];
int w,h;
bool wall[40][40][40][40];

void bfs(int a,int b){
    bool used[40][40];
    rep(i,40)rep(j,40)used [i][j] = false;
    int dx[] = {-1,0,1,0};
    int dy[] = {0,1,0,-1};
    queue<pii> que;
    que.push(pii(a,b));
    while(que.size()){
        int y=que.front().first,x=que.front().second;
        used[y][x] = true;
        que.pop();
        rep(i,4){
            int ddy = y+dy[i],ddx = x+dx[i];
            if(ddy<0 || ddx<0 || ddy>h || ddx>w || used[ddy][ddx])continue;
            if(wall[y][x][ddy][ddx])continue;
            fie[ddy][ddx] = min(fie[ddy][ddx],fie[y][x]+1);
            used[ddy][ddx] = true;
            que.push(pii(ddy,ddx));
        }
    }
}


int main(){
    while(cin>>w>>h&&w&&h){
        rep(i,40)rep(j,40)rep(k,40)rep(l,40)wall[i][j][k][l] = true;
        wall[0][1][1][1] = false;
        wall[h][w][h+1][w]=false;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w-1;j++){
                cin>>wall[i][j][i][j+1];
                wall[i][j+1][i][j] = wall[i][j][i][j+1];
            }
            if(i==h)continue;
            for(int j=1;j<=w;j++){
                cin>>wall[i][j][i+1][j];
                wall[i+1][j][i][j] = wall[i][j][i+1][j];
            }
        }
        rep(i,40)rep(j,40)fie[i][j] = INF;
        fie[0][1] = 0;
        bfs(0,1);
        if(fie[h][w] == INF)cout<<0<<endl;
        else cout<<fie[h][w]<<endl;
        
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
   int k,t,c=0;
   cin >> k >> t;
   for(int i=0;i<t;i++){
       int a;
       cin >> a;
       c = max(a,c);
   }
   cout << max(c-1-(k-c),0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int arr[10];
    arr[0] = a*c - b;
    for(int i=1;i<=10;++i)
    {
        cout << (c*(int)pow(a,i)) - (int)((b)*(int)((int)pow(a,i)-1)/(a-1));
        cout << endl;
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

void build_tree(ll node, vector<set<ll>>& graph, vector<vll>& tree, bool* visited){
  vll del;
  for(auto e: graph[node]){
    if(visited[e]) continue;
    visited[e] = true;
    del.push_back(e);
    graph[e].erase(node);
    tree[node].push_back(e);
    build_tree(e, graph, tree, visited);
  }
  for(ll n: del) graph[node].erase(n);
}

 void solve(ll node, ll prev, vector<vll>& tree, bool* odd){
   for(ll e: tree[node]) solve(e, node, tree, odd);
   if(prev == 0) return;
   if(odd[node]){
     odd[node] = false;
     printf("%lld %lld\n", node, prev);
   }
   else {
     odd[prev] = !odd[prev];
     printf("%lld %lld\n", prev, node);
   }
   // for(ll i=1;i<=4;i++) cerr<< odd[i] << " "; cerr<<endl;
 }

int main(){
  ll N, M; cin >> N >> M;
  vector<set<ll>> graph(N+1);
  vector<vll> tree(N+1);
  bool odd[N+1] = {}, visited[N+1] = {};
  rep(_, M){
    ll a, b;
    cin >> a >> b;
    graph[a].insert(b);
    graph[b].insert(a);
  }

  if(M % 2){
    cout << -1 << endl;
    exit(0);
  }
  visited[1] = true;
  build_tree(1, graph, tree, visited);
  repi(s, 1, N+1){
    for(ll t: graph[s]){
      odd[s] = !odd[s];
      graph[t].erase(s);
      printf("%lld %lld\n", s, t);
    }
  }
  solve(1, 0, tree, odd);
  return 0;
}


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

int f(int n) {
  int res = 0;
  for(int i = 1; i <= n; i++) {
    if(n % i == 0) res++;
  }
  return res;
}

int main() {
  int n; cin >> n;
  if(n < 105) cout << 0 << endl;
  else {
    int ans = 0;
    for(int i = 105; i <= n; i+=2) {
      if(f(i) == 8) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


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

struct Node{int parent,left,right;};

Node T[10000];
int n,D[10000],H[10000];

void depth(int u,int d){
    if(u==-1)return;
    D[u]=d;
    depth(T[u].left,d+1);
    depth(T[u].right,d+1);
}
int height(int u){
    int h1=0,h2=0;
    if(T[u].left!=-1)
    h1=height(T[u].left)+1;
    if(T[u].right!=-1)
    h2=height(T[u].right)+1;
    
    return H[u]=(h1>h2?h1:h2);
}

int sibling(int u){
    if(T[u].parent==-1)return -1;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=-1)
    return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=-1)
    return T[T[u].parent].right;
    return -1;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",sibling(u));
    int a=0;
    if(T[u].left!=-1)a++;
    if(T[u].right!=-1)a++;
    printf("degree = %d, ",a);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    
    if(T[u].parent==-1){
        printf("root\n");
    }else if(T[u].left==-1&&T[u].right==-1){
        printf("leaf\n");
    }else printf("internal node\n");
    }
    
int main(){
    int v,l,r,root=0;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)T[i].parent=-1;
    
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left=l;
        T[v].right=r;
        if(l!=-1)T[l].parent=v;
        if(r!=-1)T[r].parent=v;
    }
    for(int i=0;i<n;i++)if(T[i].parent==-1)root=i;
    
    depth(root,0);
    height(root);
    
    for(int i=0;i<n;i++)print(i);
    
    return 0;
}


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n, d;
    cin >> n >> d;
    int a[n][d];
    for(int i=0; i<n; ++i)
        for(int j=0; j<d; ++j)
            cin >> a[i][j];
        
    int ans=0;
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            if(i!=j){
                ll az=0;
                for(int k=0; k<d; ++k){
                    az += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
                }
                double dist = sqrt(az);

                if(floor(dist) == dist)
                    ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(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> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}



int main() {
    ll N;
    cin >> N;
    ll s[MAX*2]={};
    ll i;
    
    for(i=1; i<=N; i++) {
        ll t;
        cin >> t;
        s[i]=s[i-1]+t;
    }
    
    ll ans=INF;
    ll l=1, r=3;
    for(i=2; i<=N-2; i++) {
        while(abs(s[l]-(s[i]-s[l]))>abs(s[l+1]-(s[i]-s[l+1]))) l++;
        while (abs(s[N]-s[r]-s[r]+s[i])>abs(s[N]-s[r+1]-s[r+1]+s[i])) r++;
        
        ll ma=max({s[l], s[i]-s[l], s[r]-s[i], s[N]-s[r]});
        ll mi=min({s[l], s[i]-s[l], s[r]-s[i], s[N]-s[r]});
        chmin(ans, abs(ma-mi));
    }
    pt(ans);
    
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
	cin>>N;
	map<ll,ll> m;
	vector<ll> v(N);
	rep(i,0,N){
		cin>>v[i];
		m[v[i]]++;
	}
	vector<ll> pow2;
	ll num=1;
	while(num<=(1e9)*2){
		pow2.push_back(num);
		num*=2;
	}

	sort(all(v));
	urep(i,N-1,0){
		if(m[v[i]]!=0){
			if(m[*upper_bound(all(pow2),v[i])-v[i]]!=0){
				if(v[i]==*upper_bound(all(pow2),v[i])-v[i]){
					if(m[v[i]]==1)
						continue;
				}
				ans++;
				m[v[i]]--;
				m[*upper_bound(all(pow2),v[i])-v[i]]--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 26752
#B - Frog 2
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    for j in range(K,0,-1):
        dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))

#print(dp)
print(dp[N-1])

Measured memory_bytes: 52592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
ll gcd(ll gcmax,ll gcmin){
  if(gcmax<gcmin)swap(gcmax,gcmin);
  return gcmax%gcmin?gcd(gcmin,gcmax%gcmin):gcmin;
}
ll lcm(ll lcmax,ll lcmin){
  return lcmax/gcd(lcmax,lcmin)*lcmin;
}
int main(){
  ll n,k;cin>>n>>k;
  cout<<lcm(n,k);
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
ans=0
ma=max(a,b,c)
mi=min(a,b,c)
mj=a+b+c-ma-mi
ans+=(ma-mi)//2
mi+=((ma-mi)//2)*2
ans+=(ma-mj)//2
mj+=((ma-mj)//2)*2
if ma==mi==mj:
    print(ans)
elif ma==mi+1 and ma==mj+1:
    print(ans+1)
else:
    print(ans+2)

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

int x_sum(int c){
	int Sum = 0;
	while(c != 0){
		Sum += (c%10);
		c /= 10;
	}
	return Sum;
}
	
int main(){
	int n,a,b;
	cin >> n >> a >> b;

	int sum = 0;
	for(int i = 1;i<=n;i++){
		if(a<=x_sum(i) && x_sum(i) <= b){
			sum += i;
		}
	}
	
	cout << sum << endl;
}

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


int main() {
    ll N;
    cin >> N;
    string s = to_string(N);
    int n = s.size();
    int ans = 9 * (n - 1) + (s[0] - '0');
    for (int i = 1; i < n; i++) {
        if (s[i] != '9') {
            ans--;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 10000

int isPrime(int x){
	int i;
	if(x < 2)  
	return 0;
	if(x == 2) 
	return 1;
	if(x % 2 == 0)
	return 0;
	
	for(i = 3; i * i <= x; i = i + 2)
	if(x % i == 0)
	return 0;
	
	return 1;
	
}

int main(void) {
	int count, i , n;
	count = 0;
	scanf("%d" ,&n);
	int a[N];
	
	for(i = 0;i < n;i++){
		scanf("%d" , &a[i]);
		count = count + isPrime(a[i]);
	}
	
	printf("%d\n" , count);
	
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define clr(x)  memset(x,0,sizeof(x))
using namespace std;

long long ar[500005],visit[500005],len;
map<long long,long long>ma;
pair<long long,long long>pa;

string s,ss;

struct st
{
    long long a,b,c;
    string s;
};

long long vv[500005];


int main()
{
    long long i,j,k,n,ans=0,a,b,c,tc,x=0,m;
    cin>>n>>k;
    m=0;
    while(n>m)
    {
        m+=(k*2+1);
        x++;
    }
    a=1;

    cout<<max(a,x)<<endl;



    return 0;

}


Measured memory_bytes: 2304
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n, ia = 0, ib = 0, ic = 0;
	string a, b, c;
	char aa, bb, cc, s;

	cin >> a >> b >> c;

	n = 0;

	while (1) {
		if (n == 0) {
			aa = a[ia];
			ia++;
			if (aa == 'a') {
				n = 0;
			}
			else if (aa == 'b') {
				n = 1;
			}
			else if (aa == 'c') {
				n = 2;
			}
			else if (aa == '\0') {
				n = 3;
				s = 'A';
			}
		}else if (n == 1) {
			bb = b[ib];
			ib++;
			if (bb == 'a') {
				n = 0;
			}
			else if (bb == 'b') {
				n = 1;
			}
			else if (bb == 'c') {
				n = 2;
			}
			else if (bb == '\0') {
				n = 3;
				s = 'B';
			}
		}else if (n == 2) {
			cc = c[ic];
			ic++;
			if (cc == 'a') {
				n = 0;
			}
			else if (cc == 'b') {
				n = 1;
			}
			else if (cc == 'c') {
				n = 2;
			}
			else if (cc == '\0') {
				n = 3;
				s = 'C';
			}
		}
		else if (n == 3) {
			break;
		}
	}

	cout << s << endl;

	return 0;

}


Measured memory_bytes: 256
#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 MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_by_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

struct t3
{
	int i1, i2;
	ll ct;
};

void solve(int T)
{
	int a,b,m;
	cin>>a>>b>>m;
	VL ax(a), bx(b);
	for(auto &&u : ax)
	cin>>u;
	for(auto &&u : bx)
	cin>>u;
	vector<t3> cx(m);
	for(auto &&u : cx)
	cin>>u.i1>>u.i2>>u.ct;
	ll m1 = MOD, m2 = MOD;
	for(auto u : ax)
	m1 = min(m1, u);
	for(auto u : bx)
	m2 = min(m2, u);
	ll tot = m1 + m2;
	for(auto u : cx)
	tot = min(tot, ax[u.i1-1] + bx[u.i2-1] - u.ct);	
	cout<<tot<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll A,B;
	double H,M,HH,MM,deg,ANS;
	cin>>A>>B>>H>>M;
	if(H>=12)H=H-12;
	HH=H*30+(M*0.5);
	MM=M*6;
	deg=deg2rad(min(max(HH,MM)-min(HH,MM),360-(max(HH,MM)-min(HH,MM))));
	cout << fixed << setprecision(20);
	//cout<<deg<<endl;
	ANS=(A*A+B*B)-(2*A*B*cos(deg));
	cout << fixed << setprecision(20);
	cout<<sqrt(ANS)<<endl;
}

Measured memory_bytes: 3608
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

int main()
{

  //cout << fixed << setprecision(10);

  int n=5;
  vector<int> q(n); rep(i,n){cin>>q[i];}
  vector<int> q1(n); rep(i,n){q1[i]=q[i]%10;}
  vector<int> ot(n); rep(i,n){ot[i]=(int)ceil(q[i]/10.0)*10;}
  int m1i=0,m1=INT_MAX;
  rep(i,n){
    if (m1 > q1[i] && q1[i]!=0){m1=q1[i];m1i=i;}
  }
  int ans=0;
  rep(i,n){
    if (i==m1i){ans+=q[i];}
    else {ans+=ot[i];}
  }

  cout << ans << endl;

  

  return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1){}
    void init(int n) {par.assign(n, -1);}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m), z(m);
    for(int i=0; i<m; i++) {
        cin >> x[i] >> y[i] >> z[i];
        x[i]--; y[i]--;
    }

    UnionFind uf(n);
    for(int i=0; i<m; i++) uf.merge(x[i], y[i]);

    set<int> st;
    for(int i=0; i<n; i++) st.insert(uf.root(i));
    cout << st.size() << endl;

    return 0;
}

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

using namespace std;

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

    vector<int> vec;
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        vec.push_back(num);
    }

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

    int centerRight = vec[n/2];
    int centerLeft = vec[(n/2)-1];
    if (centerRight == centerLeft)
    {
        cout << 0 << endl;
        return 0;
    }
    
    cout << centerRight-centerLeft << endl;
    return 0;
}

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

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

  double x, y;

  int ans = 0;
  rep(i, n)
  {
    cin >> x >> y;
    x = abs(x);
    y = abs(y);
    double dis = sqrt(x * x + y * y);
    if (dis <= d)
      ans++;
  }

  cout << ans;
}


Measured memory_bytes: 3836
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = -1
    maw = -1
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah < h:
            mah = h
            hmaps = {i}
        elif mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw < w:
            maw = w
            wmaps = {i}
        elif maw == w:
            wmaps.add(i)
    ans = mah+maw
    aru = True
    if len(hmaps) * len(wmaps) <= 5*10**6:
        for h in list(hmaps):
            for w in list(wmaps):
                if (h, w) not in maps:
                    aru = False
                    break
    else:
        aru = False
    if aru:
        print(ans - 1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 216200
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 100010;
int n, m;
char s[N], t[N];
int main(){
	read(n), read(m);
	scanf("\n%s", s + 1);
	scanf("\n%s", t + 1);
	int tmp = __gcd(n, m);
	for (int i = 1; i <= tmp; i++)
		if (s[n / tmp * (i - 1) + 1] != t[m / tmp * (i - 1) + 1]){
			printf("-1\n");
			return 0;
		}
	printf("%lld\n", 1ll * n * m  / tmp);
	return 0;
}



Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	a := make([]int, n + 1)
	for i := 0; i < m; i++ {
		var b int
		fmt.Scan(&b)
		a[b] = 1
	}
	var ansI int
	for i := x; i <= n; i++ {
		ansI += a[i]
	}
	var ansD int
	for i := x; i >= 0; i-- {
		ansD += a[i]
	} 
	fmt.Println(min(ansD, ansI))
}

func min(a,b int) int {
	if a > b {
		return b
	} else {
		return a
	}
} 


Measured memory_bytes: 512
#include<stdio.h>
 
int main(void)
{
  int a,b,c;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  if((a==b && b==c) && c==a)
    printf("No\n");
  else if((a!=b && b!=c) && c!=a)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 128
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final double N, D;

    AtCoder(FastScanner sc) {
        N = sc.nextDouble();
        D = sc.nextDouble();
    }

    void solve(PrintWriter out) {
        out.println((int) Math.ceil(N / (2.0 * D + 1.0)));
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 21460
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using System.Collections;

class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();
        for (int i = 1; i < a.Count; i++)
        {
            if(a[i - 1] + a[i] >= nk[1])
            {
                Console.WriteLine("Possible");
                for (int j = a.Count - 1; j > i; j--) Console.WriteLine(j);
                for (int j = 1; j < i; j++) Console.WriteLine(j);
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine("Impossible");
    }
}


Measured memory_bytes: 28636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll solve(ll n)
{
	ll d=sqrt(n);
	for(ll i=d;i>=1;--i)
	if(n%i==0)return i+n/i;
}
int main()
{
	scanf("%lld",&n);
	printf("%lld\n",solve(n)-2);
	return 0;
}


Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

a,b = input().split()
b = int(b.replace(".",""))
a = int(a)
print((a*b)//100)


Measured memory_bytes: 68872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String b = sc.next();
		int c = sc.nextInt();
		
		while (!b.equals("?")) {
			System.out.println(calc(a, b, c));
			a = sc.nextInt();
			b = sc.next();
			c = sc.nextInt();			
		}
	}
	
	public static int calc(int a, String b, int c) {
		int result = 0;
		
		if(b.equals("+")) result = a + c;
		else if (b.equals("-")) result = a - c;
		else if (b.equals("*")) result = a * c;
		else if (b.equals("/")) result = a / c;
		else if (b.equals("?")) result = 0;
		
		return result;
	}

}

Measured memory_bytes: 18184
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


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


int main() {
	ll a, ans,b2,ans2;
	long double b, c;
	cin >> a >> b;
	b2 = 100*b + 0.5;
	//小数を表すときは誤差が生じるので100倍だけだと少し小さくなって切り捨てられるかもしれないので0.5を足しておく
	
	ans = a * b2;
	ans /= 100;

	

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3168
s=input()
# ss=int(s)
n=len(s)
ans=int(s)
for bit in range(1<<(n-1)):
    if bit==0 : continue
    now=[] #+の位置
    for i in range(n):
        if bit>>i &1 :
            now.append(i)

    for i in range(len(now)-1):
        ans+=int(s[now[i]+1:now[i+1]+1])
    ans+=int(s[:now[0]+1])
    ans+=int(s[now[-1]+1:])

print(ans)

Measured memory_bytes: 9112
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	long long int n,W,w1,ans = -1;
	cin >> n >> W;
	long long int w[110],v[110]; 
	vector<long long int> vec[4];
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		if(i == 0)
			w1 = w[i];
		vec[w[i] - w1].push_back(v[i]);
	}
	
	for(int i = 0; i < 4; i++){
		sort(vec[i].begin(), vec[i].end(), greater<long long int>());
	}
	//cerr << vec[0].size() << endl;
	
	for(int i = 0; i <= vec[0].size(); i++){
		for(int j = 0; j <= vec[1].size(); j++){
			for(int k = 0; k <= vec[2].size(); k++){
				for(int l = 0; l <= vec[3].size(); l++){
					if(w1 * i + (w1+1)*j + (w1+2)*k + (w1+3) *l > W){
						continue;
					}
					long long int c=0;
					for(int x = 0; x < i; x++){
						c += vec[0][x];
					}
					for(int x = 0; x < j; x++){
						c += vec[1][x];
					}
					for(int x = 0; x < k; x++){
						c += vec[2][x];
					}
					for(int x = 0; x < l; x++){
						c += vec[3][x];
					}
					if(ans < c){
						ans = c;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<cstring>
#include<algorithm>
using namespace std;
char str[8009];
int heng[8009],shu[8009];
set<int>yy[2];
int main(){
	int x,y;
	scanf("%s",str);
	scanf("%d%d",&x,&y);
	int now=0,qx=0;
	while(str[now]&&str[now]!='T') ++now;
	qx=now;
	bool t=0;
	++now;
	int H=0,S=0;
	for(;str[now];++now) {
		if(str[now]=='T') {if(!t) t=1;
	    else t=0;continue;}
		int j;for(j=now+1;str[j]&&str[j]!='T';++j);
	    if(!t) shu[S++]=j-now;
	    else  heng[H++]=j-now;
	    now=j;
	    if(!t) t=1;
	    else t=0;
	}
	yy[0].insert(0);
	int at=1;now=0;
	set<int>::iterator it;
	if(shu) for(int i=0;i<S;++i){
	for(it=yy[now].begin();it!=yy[now].end();++it) 
	yy[at].insert(*it+shu[i]),yy[at].insert(*it-shu[i]);
	yy[now].clear();
	swap(now,at);
	}
	bool ok=0;
	for(it=yy[now].begin();it!=yy[now].end();++it) {
		if(*it==y) {
			ok=1;break;
		}
	}
	if(!ok) {
		puts("No");
		return 0;
	}
	yy[now].clear();
	now=0,at=1;
	yy[0].insert(qx); 
	if(heng) for(int i=0;i<H;++i){
	for(it=yy[now].begin();it!=yy[now].end();++it) 
	yy[at].insert(*it+heng[i]),yy[at].insert(*it-heng[i]);
	yy[now].clear();
	swap(now,at);}
	ok=0;
	for(it=yy[now].begin();it!=yy[now].end();++it) {
		if(*it==x) {
			ok=1;break;
		}
	}
	if(!ok) {
		puts("No");
		return 0;
	}
	puts("Yes");
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;



int main(int argc, const char * argv[]) {

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

	string S;
	string ans;

	cin >> S;

	if(S=="A"){
		ans="T";
	}

	if(S=="T"){
		ans="A";
	}

	if(S=="G"){
		ans="C";
	}

	if(S=="C"){
		ans="G";
	}


    cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    int N,K;
    cin >> N >> K;
    vl H(N);
    in(N,H);
    
    sort(all(H));
    reverse(all(H));
    
    ll ans = 0;
    reps(i,K,N) ans += H[i];
    out(ans);
    



    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int sz = 1e5+5;
int n, a[sz], s[sz];

void solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        s[i] = a[i];
    }
    sort(s, s+n);

    map<int, int> pos;
    for(int i = 0; i < n; ++i) pos[s[i]] = i;

    int numoff = 0;
    for(int i = 0; i < n; ++i){
        numoff += i%2 != pos[a[i]]%2;
    }

    assert(numoff%2 == 0);
    cout << numoff/2 << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 8996
n = int(input())
nums = list(map(int, input().split()))

print(' '.join(map(str, nums)))
for i in range(1, n):
    v = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    print(' '.join(map(str, nums)))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <boost/format.hpp>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


struct P {
  int year;
  int city;
  int num;
};

int main(){
  int n, m;
  scanf("%d %d", &n, &m);

  vector<P> v(m);
  int c, y;
  REP (i, m) {
    cin >> c >> y;
    v[i] = {y, c, i};
  }

  sort(v.begin(), v.end(), [](const P &a, P &b){ return a.year < b.year; });

  int d[n + 1] = {0};
  vector<string> ans(m);
  REP (i, m) {
    string str = (boost::format("%06d%06d") % v[i].city % (d[v[i].city] + 1)).str();
    ans[v[i].num] = str;
    d[v[i].city]++;
  }

  REP (i, m) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8576
N = int(input())
A = list(map(int, input().split()))
ans = r = x = 0

for l in range(N):
  while r < l or r < N and x ^ A[r] == x + A[r]:
    x^=A[r]
    r+=1
  ans+=r-l
  x^=A[l]

print(ans)

Measured memory_bytes: 32056
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// llの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n; cin >> n;

  vector<ll> a(n,0);
  vector<ll> v(n+1,0);
  vector<ll> adjust(n+1,0);

  REP(i,n){
    cin >> a[i];
    v[a[i]]++;
  }
  //for(ll i:a) cout << "a" << i << endl;
  ll sum=0;
  REPZ(i,1,n+1){
    ll temp=v[i]*(v[i]-1)/2;
    sum+=temp;
    adjust[i]=(-temp);
    if(v[i]>2) adjust[i]+=(v[i]-1)*(v[i]-2)/2;
    //cout << i << " " << temp << " " << adjust[i] << endl;
  }
  REP(i,n){
    cout << sum+adjust[a[i]] << endl;
  }

  
  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };



int main() {
	ll a;
	cin >> a;
	string ans = "";
	REP(i, 0, a) ans += "ACL";
	PRI(ans);
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb emplace_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define rreps(i,j,k) for(int i = (j); i >= (k); --i)
#define rrep(i,j) rreps(i,j,0)
#define all(a) (a).begin(),(a).end()
#define MOD 10007 
typedef pair<int,int> Pii;
typedef pair<int, ll> Pil;
typedef pair<int,string> Pis;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int idx = 0;
	string str;
	cin >> str;
	int a[32]={};
	memset(a,-1,sizeof(a));
	rep(i,str.size()){
		if(str[i] == '0'){
			a[idx] = 0;
			idx++;
		}
		else if(str[i] == '1'){
			a[idx] = 1;
			idx++;
		}
		else if(str[i] == 'B'){
			if(idx > 0){
				idx--;
			}
			a[idx] = -1;
		}
	}

	for(int i = 0; a[i] != -1; ++i){
		printf("%d",a[i]);
	}
	puts("");

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
dp = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'T' or s[i] == 'G':
        dp[i+1] = dp[i] + 1
print(max(dp))

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

int main(void) {
    int x, y, t;
    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        else if (x > y) {t = x; x = y; y = t;}
        cout << x << " " << y << endl;

    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int h,a;
  cin>>h>>a;
  int ans = (h+a-1)/a;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >>  n;
    std::vector<ll> x(n); REP(i,n) cin >> x[i];
    std::vector<ll> x_(n);
    x_ = x;
    sort(x.begin(), x.end());
    ll l = x[x.size()/2-1];
    ll u = x[x.size()/2];

    REP(i,n) x_[i] >= u ? cout << l << endl : cout << u << endl;



    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
# define PI           3.14159265358979323846  /* pi */

using namespace std;

int main()
{	

	long a, b, c, k;
	cin >> a >> b >> c >> k;
	long fans = 0;
	long u = min(a, k);
	fans += u;
	a -= u;
	k -= u;
	if (k > 0)
	{
		u = min (k, b);
		k -= u;
	}
	if (k > 0)
	{
		u = min(k, c);
		k -= u;
		fans -= u;
	}
	cout << fans;
	
	return 0;
}


Measured memory_bytes: 3636