akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    priority_queue<int> p,m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a>=0){
            p.push(-a);
        }else{
            m.push(a);
        }
    }
    int ans[2*n];
    for(int i=0;i<n-1;i++){
        if(p.size()&&m.size()){
            int s=-p.top();
            p.pop();
            int t=m.top();
            m.pop();
            if(p.size()<=m.size()){
                ans[2*i]=s;
                ans[2*i+1]=t;
                p.push(t-s);
            }else{
                ans[2*i]=t;
                ans[2*i+1]=s;
                m.push(t-s);
            }
        }
        else if(p.size()==0){
            int s=m.top();
            m.pop();
            int t=m.top();
            m.pop();
            ans[2*i]=t;
            ans[2*i+1]=s;
            p.push(s-t);
        }
        else{
            int s=-p.top();
            p.pop();
            int t=-p.top();
            p.pop();
            if(p.size()==0){
                ans[2*i]=t;
                ans[2*i+1]=s;
                p.push(s-t);
            }else{
                ans[2*i]=s;
                ans[2*i+1]=t;
                m.push(s-t);
            }
        }
    }
    cout<<-p.top()<<endl;
    for(int i=0;i<n-1;i++){
        cout<<ans[2*i]<<" "<<ans[2*i+1]<<endl;
    }
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main() {
    int x;
    cin >> x;
    cout << !x << endl;

    return 0;
}

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

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        double sum = a[0];
        for (int i = 1; i < n; i++) {
            sum = (sum + a[i]) / 2;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  ll d;
  cin >> s >> d;
  ll n=s.size();
  mat dp0(n+1,vec(d)),dp1(n+1,vec(d));
  dp0[0][0]=1;
  for(ll i=0;i<n;i++) {
    ll id=s[i]-'0';
    for(ll j=0;j<d;j++) {
      (dp0[i+1][(j+id)%d]+=dp0[i][j])%=mod;
      for(ll k=0;k<10;k++) {
        (dp1[i+1][(j+k)%d]+=dp1[i][j])%=mod;
        if(id>k) {
          (dp1[i+1][(j+k)%d]+=dp0[i][j])%=mod;
        }
      }
    }
  }
  cout << (dp0[n][0]+dp1[n][0]-1+mod)%mod << endl;
}

Measured memory_bytes: 16640
def myAnswer(s:list,t:list) -> str:
   s.sort()
   t.sort(reverse=True)
   # print(s,t)
   return "Yes" if(s < t) else "No"

def modelAnswer():
   return
def main():
   s = list(input())
   t = list(input())
   print(myAnswer(s,t))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
let n = Scanf.scanf " %d" (+) 0
let xs = Array.init n @@ fun i -> Scanf.scanf " %d" @@ fun x -> x, i
let rs = Array.make n 0
let _ = Array.(sort compare xs; iteri (fun j (_, i) -> rs.(i) <- j) xs; iter (fun j -> Printf.printf "%d\n" @@ fst @@ if n / 2 - 1 < j then xs.(n / 2 - 1) else xs.(n / 2)) rs)

Measured memory_bytes: 14336
using System;
using System.Collections.Generic;

class Program
{
	static private List<int> PrimeList;

	static private int Max()
	{
		return PrimeList[PrimeList.Count-1];
	}

	static private bool Prime(int n)
	{
		if(n == 1) return false;

		int SqrtN = (int)Math.Sqrt(n);
		foreach(int p in PrimeList)
		{
			if(p > SqrtN) break;
			if(n%p == 0) return false;
		}

		bool a = true;
		int max = Max();
		if(max < SqrtN)
		{
			for(int i=max+2; i<=SqrtN; i+=2)
			{
				bool isprime = true;
				foreach(int p in PrimeList)
				{
					if(i%p == 0)
					{
						isprime = false;
						break;
					}
				}
				if(isprime)
				{
					PrimeList.Add(i);
					if(n%i == 0)
					{
						a = false;
						break;
					}
				}
			}
		}
		return a;
	}

	static void Main() 
	{
		PrimeList = new List<int>();
		PrimeList.Add(2);
		PrimeList.Add(3);
		int num = int.Parse(Console.ReadLine());

		int n = 0;
		for(int i=0; i<num; i++)
		{
			if(Prime(int.Parse(Console.ReadLine()))) n++;
		}
		Console.WriteLine(n.ToString());
	}
}

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

char s[10];

int main()
{
	scanf("%s",s+1);
	int cnt=0,ans=0;
	for(int i=1;i<=3;i++)
	{
		if(s[i]=='R') 
		{
			cnt++;
			ans=max(ans,cnt);
		}
		else cnt=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3716
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

void swap(int*, int*);

int main(void) {
	vector<int> a, b;
	int j = 0;
	int tmp1, tmp2;
	
	while(1) {		
		cin >> tmp1 >> tmp2;
		a.push_back(tmp1);
		b.push_back(tmp2);
		if(a[j] == 0 && b[j] == 0) {
			break;
		}
		j++; 
	}
	
	for(int i = 0; i < a.size() - 1; i++) {
		if(a[i] > b[i]) {
			swap(a[i], b[i]);
		}
		cout << a[i] << " " << b[i] << endl;
	}
	
	return 0;
}
void swap(int *a, int *b) {
	*a = *a + *b;
	*b = *a - *b;
	*a = *a - *b;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = getString(sc);

		System.out.println(s.lastIndexOf("Z") - s.indexOf("A") + 1);

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 27752
#include <stdio.h>
int main(){
    int x1, x2, x3, x4, x5;
    
    scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
    if(x1==0){
      printf("1");
    }else if(x2==0){
      printf("2");
    }else if(x3==0){
      printf("3");
    }else if(x4==0){
      printf("4");
    }else{
      printf("5");
    }
return 0;
}

Measured memory_bytes: 1612
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    static const ll MOD=1e9+7;
    char S[MAXN];
    ll preA[MAXN],sufC[MAXN];
    ll preQ[MAXN],sufQ[MAXN];
    ll pow3[MAXN];
    ll pow(ll b,ll t){
        if(t==0)return 1;
        ll tmp=pow(b,t/2);
        tmp=(tmp*tmp)%MOD;
        if(t%2)tmp=tmp*b%MOD;
        return tmp%MOD;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>S+1;
        int n=strlen(S+1);
        pow3[0]=1;
        for(int u=1;u<=n;u++){
            pow3[u]=pow3[u-1]*3%MOD;
        }
        for(int u=1;u<=n;u++){
            if(S[u]=='A')preA[u]=preA[u-1]+1;
            else preA[u]=preA[u-1];
            if(S[u]=='?')preQ[u]=preQ[u-1]+1;
            else preQ[u]=preQ[u-1];
        }
        for(int u=n;u>=1;u--){
            if(S[u]=='C')sufC[u]=sufC[u+1]+1;
            else sufC[u]=sufC[u+1];
            if(S[u]=='?')sufQ[u]=sufQ[u+1]+1;
            else sufQ[u]=sufQ[u+1];
        }
        ll ans=0;
        for(int u=2;u<n;u++){
            if(S[u]=='?'||S[u]=='B'){
                ll t[4]={0};
                t[0]=preA[u-1]*sufC[u+1]%MOD*pow3[preQ[u-1]+sufQ[u+1]]%MOD;
                t[1]=preA[u-1]*sufQ[u+1]%MOD*pow3[preQ[u-1]+sufQ[u+1]-1]%MOD;
                t[2]=preQ[u-1]*sufC[u+1]%MOD*pow3[preQ[u-1]+sufQ[u+1]-1]%MOD;
                t[3]=preQ[u-1]*sufQ[u+1]%MOD*pow3[preQ[u-1]+sufQ[u+1]-2]%MOD;
                for(int v=0;v<4;v++)ans=(ans+t[v])%MOD;
            }
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define S second 
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

// --------------------------template ends here------------------------------

void solve() {
    string str;
    cin >> str;
    if(is_palindrome(str)) {
        int len = str.length();
        string s1 = str.substr(0, (len-1)/2);
        string s2 = str.substr((len+1)/2 , len);
        if(is_palindrome(s1) && is_palindrome(s2))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }   
    else
        cout << "No" << endl; 
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
def heapfy(A, i, n):
    x = A[i]
    l,r = None, None
    if (i+1)*2-1<n:
        l = A[(i+1)*2-1]    
    if (i+1)*2<n:
        r = A[(i+1)*2]
    
    largest = i
    if l is not None and r is not None:
        if l>r:
            if l>x:
                largest = (i+1)*2-1
        else:
            if r>x:
                largest = (i+1)*2
    elif l is None and r is None:
        pass
    elif l is None:
        if r>x:
            largest = (i+1)*2
    elif r is None:
        if l>x:
            largest = (i+1)*2-1
    #print(x,l,r)
    
    if largest!=i:
        A[i], A[largest] = A[largest], A[i]
        heapfy(A, largest, n)
        
def buildMaxHeap(A, n):
    for i in range(n//2-1, -1, -1):
        heapfy(A, i, n)
        

buildMaxHeap(a, n)

print(' ', end='')
print(*a)


Measured memory_bytes: 63776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

ll		solve(ll n, ll ans) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			ll a = max(n / i, i);
			chmin(ans, a);
		}
	}
	return to_string(ans).size();
}

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

	ll n;
	cin >> n;
	cout << solve(n, n) << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n, l; cin >> n >> l;
  vector<int> vec(n);
  ll mi = INT_MAX;
  int p = -1;
  rep(i, n) {
    vec[i] = l+i;
    if (abs(vec[i]) < mi) {
      mi = abs(vec[i]);
      p = i;
    }
  }

  int ans = 0;
  rep(i, n) {
    if (i != p) {
      ans += vec[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int x, k;
    cin>>k>>x;
    int left = x - k + 1;
    int right = x + k - 1;
    int i;
    FOR(i, left, right+1)
        cout<<i<<" ";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	ll n,m,ans=0;
 	cin >> n>>m;
 	vector<ll> x;
 	for (int i = 0; i < n; i++){
 		ll a;
 		cin >> a;
 		ans+=a;
 		while(a!=1){
 			x.push_back(a-a/2);
 			a=a/2;
 		}
 		x.push_back(1);
 	}
 	sort(x.begin(),x.end());
 	ll y=x.size();
 	if(x.size()<=m){
 		cout << 0 << endl;
 		return 0;
 	}
 	for (int i = 0; i < m; i++){
 		ans-=x.at(y-i-1);
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 34916
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == S[i + 1]) {
			ans++;
			if (S[i + 1] == '0') S[i + 1] = '1';
			else S[i + 1] = '0';
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int[] n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        System.out.println(n[k-1]);
    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  ll n, ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;

  return 0;
}

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

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};


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

    int H,W;
    cin >> H >> W;
    vector<string> G(H);
    rep(h,H) cin >> G[h];

    BipartiteMatching bm(H*W);
    rep(h,H) rep(w,W) {
        if(G[h][w] == '#') continue;
        if((h+w)%2 == 0) {
            if(h+1 < H && G[h+1][w] == '.') bm.add_edge(W*h+w, W*(h+1)+w);
            if(w+1 < W && G[h][w+1] == '.') bm.add_edge(W*h+w, W*h+w+1);
        } else {
            if(h+1 < H && G[h+1][w] == '.') bm.add_edge(W*(h+1)+w, W*h+w);
            if(w+1 < W && G[h][w+1] == '.') bm.add_edge(W*h+w+1, W*h+w);
        }
    }

    cout << bm.bipartite_matching() << endl;
    rep(i,H*W) {
        int j = bm.match[i];
        if(W == 1) {
            if(i+1 == j) {
                G[i/W][i%W] = 'v';
                G[j/W][j%W] = '^';
            }
        } else {
            if(i+1 == j) {
                G[i/W][i%W] = '>';
                G[j/W][j%W] = '<';
            }
            if(i+W == j) {
                G[i/W][i%W] = 'v';
                G[j/W][j%W] = '^';
            }
        }
    }

    rep(h,H) cout << G[h] << "\n";
    return 0;
}


Measured memory_bytes: 4080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Competition
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var xu = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().ToArray()).ToArray();

            var sum = 0.0;
            for(var i = 0; i < n; i++)
            {
                if (xu[i][1] == "JPY") sum += long.Parse(xu[i][0]);
                if (xu[i][1] == "BTC") sum += double.Parse(xu[i][0]) * 380000.0;
            }
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 13524
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        mat: [[usize; 2]; m],
    }

    let mut tizu = vec![vec![false; n]; n];
    let mut visited_array = vec![false; n];
    visited_array[0] = true;

    //tizu生成
    for i in 0..m {
        tizu[mat[i][0]-1][mat[i][1]-1] = true;
        tizu[mat[i][1]-1][mat[i][0]-1] = true;
    }

    let ans = search(0, &tizu, &mut visited_array);

    println!("{}", ans);
}

fn search(pos: usize, tizu: &Vec<Vec<bool>>, visited_array: &mut Vec<bool>) -> usize {

    if !visited_array.iter().any(|x| *x == false) {
        return 1;
    }

    let mut sum = 0;
    for (i, b) in tizu[pos].iter().enumerate() {
        if *b && !visited_array[i]{
            visited_array[i] = true;
            sum = sum + search(i, tizu, visited_array);
            visited_array[i] = false;
        }
    }

    sum
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 1000005
#define INF 10000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
ll a[N];
ll b[N];
vector<int>ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,L;
    while(cin>>n>>L)
    {
        ans.clear();
        a[0] = b[0] = 0;
        int p = -1;
        FOR(i,1,n)
        {
            cin>>a[i];
            if(a[i]+a[i-1]>=L)p = i;
            b[i] = b[i-1]+a[i];
        }
        if(p == -1)cout<<"Impossible"<<endl;
        else
        {
            cout<<"Possible"<<endl;
            FOR(i,1,p-2)cout<<i<<endl;
            ROF(i,n,p+1)cout<<i-1<<endl;
            cout<<p-1<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k,i,j;
	cin>>n>>m;
	for (i=0;i<=n;i++)
	 for (j=0;j<=n;j++)
	 {   k=n-i-j;if (k<0) break;
	 	 if (i+j+k==n&&i*10000+j*5000+k*1000==m)
		    {cout<<i<<" "<<j<<" "<<k<<endl;return 0;}
	 }	
	cout<<"-1 -1 -1";
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter wr = new PrintWriter(System.out);
        String str = br.readLine().trim();
        StringTokenizer stk = new StringTokenizer(str);
        int n = Integer.parseInt(stk.nextToken());
        int g = n/3;
        System.out.println(g);

	}

}


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

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

    int Count = 0;
    for(int i = 0; i < s.size()-1; i++)
    {
        if((s[i] == 'R')&&(s[i+1] == 'R'))
            Count++;


    }
    if(s.find('R') == s.npos)
        cout<< 0;

    else
     cout<< Count + 1;

    return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;


int bubbleSort(int A[],int N){
    int count = 0;
    bool flag = 1;
    for(int i = 0;flag;i++){
        flag = 0;
        for(int j = N-1;j>=i+1;j--){
            if(A[j] < A[j-1]){
                int tmp = 0;
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    return count;
}
int main(void){
    int A[100];
    int N,sw;
    cin >> N;
    for(int i = 0;i<N;i++) cin >> A[i];
    
    sw = bubbleSort(A,N);
    
    for(int i = 0;i<N;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
    
}



Measured memory_bytes: 3128
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
	// 解法
	bool ans = false;
	REP(i,3){
		if (N%10==7) ans = true;
		N /=10;
	}

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3636
from collections import deque

n, m = list(map(int, input().split()))

roads = [[] for _ in range(n + 1)]
for _ in range(m):
	a, b = list(map(int, input().split()))
	roads[a].append(b)
	roads[b].append(a)

ans = [-1 for _ in range(n + 1)]

q = deque()
q.append(1)

while q:
	cur = q.popleft()
	for dest in roads[cur]:
		if ans[dest] == -1:
			ans[dest] = cur
			q.append(dest)


print("Yes")
for i in range(2, n+1):
	print(ans[i])

Measured memory_bytes: 34148
#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;

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j)); // .emplace(i,j)
    };
    update(si,sj,0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir,4) {
        int ni = i+di[dir], nj = j+dj[dir];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int N;
vector<int> x;
int main() {
  cin >> N;
  x.resize(N);
  rep(i, N) cin >> x[i];

  Combination<ModInt> comb(N);

  vector<ModInt> S(N + 1, 0);
  rep(i, N) S[i + 1] = S[i] + comb.factorial(N - 1) / (i + 1);

  ModInt ans = 0;
  rep(i, N - 1) ans += S[i + 1] * (x[i + 1] - x[i]);

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


Measured memory_bytes: 2944
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        auto m = s.split().map!(to!real).array();
        auto v = [0,1,4,5].map!(i=>m[i]-m[i+2]).array();
        writeln(v[0]*v[2]+v[1]*v[3]?"NO":"YES");
    }
}

Measured memory_bytes: 1080
//============================================================================
// Name        : SyousuuTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<stdio.h>
using namespace std;

int main() {
	double r,f1,f2;
	cin>>r;
	f2=(double)r*2*3.141592653589;
	f1=(double)r*r*3.141592653589;
	printf("%.6lf %.6lf\n",f1 ,f2);

	return 0 ;

}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int c1,c5,c10,c50,c100,c500,sum;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	sum=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;
	if(sum>=1000){
	  printf("1\n");
	}
	else{
	    printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define BAI(_a, _b) ((_a - 1) / _b * _b + _b)//_b倍にする
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	int n;
	ll ans = 0;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n)cin >> a[i] >> b[i];
	for (int i = n - 1; i >= 0; i--) {
		ans += (b[i] - (a[i] + ans) % b[i]) % b[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    writeln!(o, "{}", solve(n)).unwrap();
}
fn solve(n: usize) -> usize {
    let mut ans = 0;
    divisors(n, |x| {
        let m_1 = n / x;
        let m = m_1 - 1;
        if x < m {
            ans += m;
        }
    });
    ans
}
fn divisors<F: FnMut(usize)>(n: usize, mut f: F) {
    fn divisors_by<F: FnMut(usize)>(fs: &[(usize, usize)], mut n: usize, f: &mut F) {
        if fs.is_empty() {
            f(n);
            return;
        }
        let (p, c) = fs[0];
        for _ in 0..c + 1 {
            divisors_by(&fs[1..], n, f);
            n *= p;
        }
    }
    divisors_by(&factorize(n), 1, &mut f)
}
fn factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut fs = Vec::new();
    assert!(n != 0);
    let mut end = (n as f64).sqrt() as usize + 1;
    let mut f = 2;
    while f < end {
        let mut c = 0;
        while n % f == 0 {
            n = n / f;
            c += 1;
        }
        if c != 0 {
            fs.push((f, c));
            end = (n as f64).sqrt() as usize + 1;
        }
        f += 1;
    }
    if n != 1 {
        fs.push((n, 1));
    }
    fs
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

int main(){
    int n;cin >> n;
    vector<int> v(n);
    vector<int> ans;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    while(v.size() >0){    
        int max = 0;
        int index = 0;
        for(int i=0;i<v.size();i++){
            if(v[i] >=max && i+1 == v[i]){
                max = v[i];
                index = i;
            }
        }
        if(max == 0){
            cout <<"-1" << endl;
            return 0;
        }
        else{
            ans.push_back(max);
            v.erase(v.begin()+index);
        }
    }
    for(int i=0;i<ans.size();i++){
        cout << ans[ans.size()-1-i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    else if (b == 'T') cout << 'A' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
    return 0;
}


Measured memory_bytes: 256
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod        1000000007 
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod;}
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
map<ll,vector<ll> >m1;
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll ans=0;
vector<ll>root;
void calldfs(ll v,int visit[])
{
 visit[v]=1;
 for(int i=0;i<m1[v].size();i++)
 {
  if(visit[m1[v][i]]==0)
  {
   calldfs(m1[v][i],visit);
  }
 }
}
void dfs(ll n)
{
 ll i;
 int visit[1000000]={0};
 fli(i,1,n+1)
 {
  visit[i]=0;
 }
 fli(i,1,n+1)
 {
  if(visit[i]==0)
  {
   calldfs(i,visit);
   ans++;
  } 
 }
}
void comp()
{
 ll n,m,i;
 cin>>n>>m;
 int arr[1000000]={0};
 ll u,v,z;
 fl(i,m)
 {
  cin>>u>>v>>z;
  m1[u].pb(v);
  m1[v].pb(u);
 }
 dfs(n);
 cout<<ans<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 24448
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define inf 1e18

typedef struct {
	int u;
	int v;
	double d;
}edge;

typedef struct {
	int N;
	int *u;
	int *u_rank;
}union_find;

union_find *make_union_find(int N){
	int i;
	union_find *uf = (union_find *)malloc(sizeof(union_find));
	uf->N = N;
	uf->u = (int *)malloc(sizeof(int) * N);
	uf->u_rank = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		(uf->u)[i] = i;
		(uf->u_rank)[i] = 1;
	}
	return uf;
}

void flush_uf(union_find *uf){
	int i;
	for(i = 0; i < uf->N; i++){
		uf->u[i] = i;
		uf->u_rank[i] = 1;
	}
}

int root_uf(int x, union_find *uf){
	int *u = uf->u;
	if(u[x] == x){
		return x;
	}
	else{
		u[x] = root_uf(u[x], uf);
		return u[x];
	}
}

void combine_uf(int x, int y, union_find *uf){
	int x_root = root_uf(x, uf);
	int y_root = root_uf(y, uf);
	int *u = uf->u;
	int *u_rank = uf->u_rank;
	if(x_root == y_root){
		return;
	}
	else if(u_rank[x_root] < u_rank[y_root]){
		u[x_root] = y_root;
		u_rank[y_root] += u_rank[x_root];
		u_rank[x_root] = 0;
	}
	else{
		u[y_root] = x_root;
		u_rank[x_root] += u_rank[y_root];
		u_rank[y_root] = 0;
	}
}

//xとyが同じ集合に属していれば1を,そうでなければ0を返す
int is_same_union_uf(int x, int y, union_find *uf){
	if(root_uf(x, uf) == root_uf(y, uf)){
		return 1;
	}
	else{
		return 0;
	}
}

//xが属する集合の要素数を返す
int rank_uf(int x, union_find *uf){
	return (uf->u_rank)[root_uf(x, uf)];
}

int compare(const void *a, const void *b){
	if(((edge *)a)->d - ((edge *)b)->d < 0){
		return -1;
	}
	else if(((edge *)a)->d - ((edge *)b)->d > 0){
		return 1;
	}
	else{
		return 0;
	}
}

double max(double a, double b){
	return a >= b ? a : b;
}

double min(double a, double b){
	return a <= b ? a : b;
}

int main(){
	int N, i, j, k, l;
	scanf("%d", &N);
	double *x = (double *)malloc(sizeof(double) * N);
	double *y = (double *)malloc(sizeof(double) * N);
	double *a = (double *)malloc(sizeof(double) * N);
	for(i = 0; i < N; i++){
		scanf("%lf%lf%lf", &x[i], &y[i], &a[i]);
	}
	edge *e = (edge *)malloc(sizeof(edge) * ((N * (N - 1)) / 2));
	double *amaxmin = (double *)malloc(sizeof(double) * (1 << N));
	union_find *uf = make_union_find(N);
	double mst, asum;
	int V;
	amaxmin[0] = inf;
	for(i = 1; i < (1 << N); i++){
//		printf("i = %d\n", i);
		mst = 0;
		asum = 0;
		V = 0;
		l = 0;
		for(j = 0; j < N; j++){
			if((i | (1 << j)) == i){
				for(k = j + 1; k < N; k++){
					if((i | (1 << k)) == i){
						e[l].u = j;
						e[l].v = k;
						e[l].d = hypot(x[j] - x[k], y[j] - y[k]);
						l++;
					}
				}
				asum += a[j];
				V++;
			}
		}
		qsort(e, l, sizeof(edge), compare);
//		printf("l = %d\n", l);
		flush_uf(uf);
		for(j = 0; j < l; j++){
			if(is_same_union_uf(e[j].u, e[j].v, uf) == 0){
				combine_uf(e[j].u, e[j].v, uf);
				mst += e[j].d;
			}
		}
		amaxmin[i] = (asum - mst) / V;
//		printf("(mst, asum, V, amaxmin) = (%lf, %lf, %d, %lf)\n", mst, asum, V, amaxmin[i]);
	}
	double *dp = (double *)malloc(sizeof(double) * (1 << N));
	dp[0] = inf;
	for(i = 1; i < (1 << N); i++){
		dp[i] = amaxmin[i];
		for(j = (i & (i - 1)); j > 0; j = (i & (j - 1))){
			dp[i] = max(dp[i], min(dp[j], dp[i ^ j]));
		}
	}
	printf("%.12lf\n", dp[(1 << N) - 1]);
	return 0;
}

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

int dp[100010];

int main() {
	int n;
	cin >> n;
	dp[0] = 0;
	for (int i = 0;i < n;i++)dp[i + 1] = 1000000;
	for (int i = 0;i < n;i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + 1);
		for (int j = 6;i + j <= n;j *= 6) {
			dp[i + j] = min(dp[i + j], dp[i] + 1);
		}
		for (int j = 9;i + j <= n;j *= 9) {
			dp[i + j] = min(dp[i + j], dp[i] + 1);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

const int inf = 1e9;
const int mod = 1e9+7;

typedef pair<int, int> P;

int main(void){
    int n, k;
    long long surface = 4e18;
    cin >> n >> k;
    vector<int> vecx, vecy;
    vector<P> vec;
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        vecx.push_back(x);
        vecy.push_back(y);
        vec.push_back(P(x, y));
    }
    sort(vecx.begin(), vecx.end());
    sort(vecy.begin(), vecy.end());
    for(int xi=0; xi<n; xi++){
        for(int xj=xi+1; xj<n; xj++){
            for(int yi=0; yi<n; yi++){
                for(int yj=yi+1; yj<n; yj++){
                    int cnt=0;
                    long long tmp = (long long)(vecx[xj]-vecx[xi])*(vecy[yj]-vecy[yi]);
                    for(int i=0; i<n; i++){
                        P p = vec[i];
                        if(vecx[xi] <= p.first && p.first <= vecx[xj] && vecy[yi] <= p.second && p.second <= vecy[yj] ){
                            cnt++;
                        }
                    }
                    if(cnt >= k && surface > tmp){
                        surface = tmp;
                    }
                }
            }
        }
    }
    cout << surface << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e17;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll la, lb, lc, na, nb, nc, ne, ma, mb, mc, tc;
ll k;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];



int main(){
    cin >> n;
    cin >> k;
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    ll ans = 0;
    sort(x,x + n);
    for(ll i=0;i<n-k;i++){
        ans += x[i];
    }
    p(ans);
    return 0;
}


















Measured memory_bytes: 4352