akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}


int point,N;
int A, B, C, D,E;
string S,s;
long long a, b, c;

int main() {
	cin >> N;
	A = B = C = D = 10;

	if (N < 1000) {
		A = 0;
	}

	for (int i = 0; i < 11; i++) {
		if (N - (1000 * i)<0 && A > 9) {
			A = i-1;
		}
	}

	for (int i = 0; i < 11; i++) {
		if (N - (1000 * A) - (100 * i) < 0 && B > 9) {
			B = i-1;
		}
	}
	for (int i = 0; i < 11; i++) {
		if (N - (1000 * A) - (100 * B)-(10*i) < 0 && C > 9) {
			C = i-1;
		}
	}
	D = N - (1000 * A) - (100 * B) - (10 * C);

	if (A + B + C + D == 7) {
		cout << A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7" << endl;
		return 0;
	}
	if (A - B + C + D == 7) {
		cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
		return 0;
	}
	if (A + B - C + D == 7) {
		cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
		return 0;
	}
	if (A + B + C - D == 7) {
		cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
		return 0;
	}
	if (A - B - C + D == 7) {
		cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
		return 0;
	}
	if (A - B + C - D == 7) {
		cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
		return 0;
	}
	if (A - B - C - D == 7) {
		cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
		return 0;
	}
	if (A + B - C - D == 7) {
		cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
		return 0;
	}

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
 
using namespace std;
typedef long long ll;
int e[15][15];
int main() {
    while (1) {
        int d, w; cin >> d >> w;
        if (d == 0 && w == 0)break;
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < w; j++) {
                cin >> e[i][j];
            }
        }
        int Max = 0;
        for (int i = 1; i < d - 1; i++) {
            for (int j = 1; j < w - 1; j++) {
                for (int k = i; k < d - 1; k++) {
                    for (int l = j; l < w - 1; l++) {
                        int Min = 100;
                        for (int a = i - 1; a <= k + 1; a++) {
                            Min = min(Min, e[a][j - 1]);
                            Min = min(Min, e[a][l + 1]);
                        }
                        for (int b = j - 1; b <= l + 1; b++) {
                            Min = min(Min, e[i - 1][b]);
                            Min = min(Min, e[k + 1][b]);
                        }
                        int cnt = 0;
                        bool flag = true;
                        for (int c = i; c <= k; c++) {
                            for (int d = j; d <= l; d++) {
                                cnt += (Min - e[c][d]);
                                if (e[c][d] >= Min) {
                                    flag = false;
                                    break;
                                }
                            }
                        }
                        if (flag == true)Max = max(Max, cnt);
                    }
                }
            }
        }
        cout << Max << endl;
    }
}


Measured memory_bytes: 3080
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll N;
	cin >> N;
	ll V[N], C[N];
	rep(i, N)cin >> V[i];
	rep(i, N)cin >> C[i];
	ll ans = 0;
	rep(i, N)if(V[i]>C[i])ans += V[i]-C[i];
	cout << ans << endl;

}








Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    a_list = [int(x) for x in input().rstrip().split(" ")]

    print(sum(a_list) - len(a_list))

if __name__ == "__main__":
    resolve()


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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6)
	{
		cout << (b / 2) << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
using namespace std;
int main()
{
	string str;
	cin>>str;
	if(str[2] == str[3] && str[4] == str[5])
		puts("Yes");
	else
		puts("No");
		
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(k):
    new_A = [0]*(n+1)
    cnt = 0
    for i in range(n):
        a = A[i]
        if a == n:
            cnt += 1
        L = max(0, i-a)
        R = min(n, i+a+1)
        new_A[L] += 1
        new_A[R] -= 1
    A = list(accumulate(new_A))
    if cnt == n:
        break

print(*A[:-1])


Measured memory_bytes: 198660
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int comp(const void * a, const void * b){
  return (*(int *)b) - (*(int *)a);
}
int main(){
	char *a = malloc(200001 * sizeof(char));
	int *sla = malloc(200000 * sizeof(int));
    int streak = 0, var = 0, counter = 0;
	scanf("%s", a);
	for (int i = 0; i < strlen(a); ++i){
		if ((a[i] == 'A') && (streak == 0)) streak = 1;
		if(streak == 1) ++counter;
		if ((a[i] == 'Z') && (streak == 1)){;
            sla[var] = counter;
            ++var;
		}
	}
	qsort(sla,var + 1,sizeof(sla[0]),comp);
    printf("%d\n", sla[0]);
    free(a);
    free(sla);
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
ll a[maxn+10];
ll zheng[maxn+10];
ll fu[maxn+10];
int n,k;
int main()
{
    while(~scanf("%d%d",&n,&k))
    {
        int da=0;
        int xi=0;
        for(int i=0;i<=n;i++)
        {
            zheng[i]=0;
            fu[i]=0;
        }
        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
            if(a[i]>=0)
            {
                zheng[++da]=a[i];
            }
        }
        for(int i=n;i>=1;i--)
        {
            if(a[i]<0)
            {
                fu[++xi]=-a[i];
            }
        }
        ll ans=1e18;

        for(int i=max(0,k-max(da,xi));i<=k&&i<=min(da,xi);i++)
        {
            if(da<=xi)
            {
                ll tmp=zheng[i]*2+fu[k-i];
                ans=min(ans,tmp);
                tmp=fu[k-i]*2+zheng[i];
                ans=min(ans,tmp);
            }
            else
            {
                ll tmp=fu[i]*2+zheng[k-i];
                ans=min(ans,tmp);
                tmp=zheng[k-i]*2+fu[i];
                ans=min(ans,tmp);
            }

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

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

int n , k ;
int s[101] , b[101] ;

int f(){
	for( int i=0 ; i<k ; i++ ) if( s[i]-b[i] < 0 ) return 1 ;
	return 0 ;
}

int main(){
	
	int a ;
	
	while(1){
		cin >> n >> k ;
		if( n==0 && k==0 ) break ;
		
		for( int i=0 ; i<101 ; i++ ) b[i] = 0 ;
		
		for( int i=0 ; i<k ; i++ ) cin >> s[i] ;
		for( int i=0 ; i<n ; i++ ){
			for( int j=0 ; j<k ; j++ ){
				cin >> a ;
				b[j] += a ;
			}
		}
		
		if( f() == 0 ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}
	
return 0 ;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define int ll

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

  int N,M;
  cin>>N>>M;
  vector<int>x(M),y(M);
  for(int i=0;i<M;i++)cin>>x[i]>>y[i];
  for(int i=0;i<M;i++)x[i]--,y[i]--;
  vector<bool>red(N,false);
  red[0]=true;
  vector<int>box(N,1);
  for(int i=0;i<M;i++){
    box[y[i]]++,box[x[i]]--;
    if(red[x[i]])red[y[i]]=true;
    if(box[x[i]]==0)red[x[i]]=false;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(red[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(), n = sc.nextLong();

		long x = Math.min(n, b-1);
		System.out.println(a*x/b-a*(x/b));
	}

	static class FastScanner {
			private BufferedReader reader = null;
		    private StringTokenizer tokenizer = null;
		    public FastScanner(InputStream in) {
		        reader = new BufferedReader(new InputStreamReader(in));
		        tokenizer = null;
		    }

		    public String next() {
		        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
		            try {
		                tokenizer = new StringTokenizer(reader.readLine());
		            } catch (IOException e) {
		                throw new RuntimeException(e);
		            }
		        }
		        return tokenizer.nextToken();
		    }

		    public String nextLine() {
		        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
		            try {
		                return reader.readLine();
		            } catch (IOException e) {
		                throw new RuntimeException(e);
		            }
		        }

		        return tokenizer.nextToken("\n");
		    }

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

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

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

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

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


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int n,a;
	cin>>n;
	unordered_set<int> s;
	for(int i=0;i<n;i++){
		cin>>a; 
		s.insert(a);
	}
	if(s.size()==n)
		cout<<"YES\n";
	else
		cout<<"NO\n";

	return 0;
}

Measured memory_bytes: 8520
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}



int main() {
    for (int m, n; cin >> m >> n, (m | n) != 0;) {
        int bs[100];
        rep(i, n) cin >> bs[i];

        int lb = 0, ub = 1500001;
        while (ub - lb > 1) {
            int mid = (ub + lb) / 2;
            int c = 1;
            int l = 0;
            bool suc = true;
            rep(i, n) {
                if (l + bs[i] > mid) {
                    if (c == m || bs[i] > mid) {
                        suc = false;
                        break;
                    }
                    c++;
                    l = bs[i];
                }
                else {
                    l += bs[i];
                }
            }
            if (suc) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vll V;

ll ltmp;
string stmp;
double dtmp;
ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
int main(){

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

    cin >> N;
    cin >> K;

    rep(ni,N){
        cin >> ltmp;
        V.push_back(ltmp);
    }

    ll li_max = llmin(K,N);
    ll ans = 0;
    for( ll li = 0 ; li <=K ; li ++ ){
        ll left_k = li_max - li;
        for( ll ri = 0 ; ri <= left_k ; ri++ ){
            
            vll Vp;
            vll Vm;

            rep(l,li){
                ll index = l;
                ll val = V[index];
                if(val>=0) Vp.push_back(val);
                else Vm.push_back(val);
            }
            rep(r,ri){
                ll index = (N-1) - r;
                ll val = V[index];
                if(val>=0) Vp.push_back(val);
                else Vm.push_back(val);
            }

            sort(Vm.begin(),Vm.end());
            ll tmpans=0;
            ll count_m = K - li - ri;
            rep(pi,Vp.size()) tmpans += Vp[pi];
            rep(mi,Vm.size()){
                if(count_m>0){
                    count_m--;
                }else{
                    tmpans+=Vm[mi];
                }
            }
            //cout << li << " : " << ri << " = " << tmpans << endl;
            ans = llmax(ans,tmpans);
        }
    }
    cout << ans << endl;



    

}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pii>>A(N);//A[k-1]の中に、県kに属する市の誕生年と番号をを格納していく
	for (int i = 0; i < M; ++i) {
		int P, Y;
		cin >> P >> Y;//県の番号を1下げる
		A[P - 1].push_back(pii(Y, i));//市の誕生年と番号を格納
	}
	vector<pii>B(M);//B[k].firstは市kの属する県、secondは市kの属する県の中での誕生年の順番
	for (int i = 0; i < N; ++i) {//
		sort(A[i].begin(), A[i].end());
		for (int j = 0; j < A[i].size(); ++j) {
			B[A[i][j].second] = pii(i, j);
		}
	}
	for (int i = 0; i < M; ++i) {
		B[i].first++; B[i].second++;
		string newpr = to_string(B[i].first);
		string newpl = to_string(B[i].second);
		for (int j = 0; j < 6 - newpr.length(); ++j) {
			cout << 0;
		}
		cout << newpr;
		for (int j = 0; j < 6 - newpl.length(); ++j) {
			cout << 0;
		}
		cout << newpl;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    char past=' ';
    rep(i,n){
        if(past!=s[i]){
            ans++;
            past=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n; cin >> n;
	cin.ignore();
	while (n--) {
		string s;
		getline(cin, s);
		for (int i = 0; i + 6 < s.size(); i++) {
			if (s.substr(i, 7) == "Hoshino")s[i + 6] = 'a';
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = MAP()

print(X if X%Y else -1)


Measured memory_bytes: 27124
import java.util.Scanner;

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

		int a2b = sc.nextInt();
		int b2c = sc.nextInt();
		int c2a = sc.nextInt();

		int[] all = new int[6];
		all[0] = a2b + b2c;
		all[1] = c2a + b2c;
		all[2] = a2b + c2a;
		all[3] = b2c + c2a;
		all[4] = c2a + a2b;
		all[5] = b2c + a2b;

		int min = all[0];
		for (int i = 1; i < all.length; i++) {
			if (all[i] < min) {
				min = all[i];
			}

		}

		System.out.println(min);
		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
vector<pipii> g[100005];
LL ans[100005];

int par[17][100005], depth[100005];
LL dp[100005];
void dfs(int u, int p, int d, LL val){
    depth[u] = d;
    par[0][u] = p;
    dp[u] = val;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, c = g[u][i].second.first, l = g[u][i].second.second;
        if(v == p) continue;
        dfs(v, u, d+1, val+l);
    }
}
int LCA(int a, int b){
    if(depth[b] > depth[a]) swap(a, b);
    int diff = depth[a] - depth[b];
    for(int i=17-1;i>=0;i--){
        if((diff>>i)&1) a = par[i][a];
    }
    if(a == b) return a;
    for(int i=17-1;i>=0;i--){
        if(par[i][a] != par[i][b]) a = par[i][a], b = par[i][b];
    }
    return par[0][a];
}

LL dist(int a, int b){
    return dp[a] + dp[b] - 2*dp[LCA(a, b)];
}

vector<pipii> cur[100005];
LL dis[100005], cnt[100005];
void dfs2(int u, int p){

    for(int i=0;i<cur[u].size();i++){
        int j = cur[u][i].first, x = cur[u][i].second.first, y = cur[u][i].second.second;

        if(j < 0){
            j = -j;
            ans[j] -= 2*(y*1ll*cnt[x] - dis[x]);
        }
        else{
            ans[j] += y*1ll*cnt[x] - dis[x];
        }
    }

    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, c = g[u][i].second.first, d = g[u][i].second.second;
        if(v == p) continue;

        dis[c] += d;
        cnt[c]++;
        dfs2(v, u);
        dis[c] -= d;
        cnt[c]--;
    }
}


int main(){
    int n, q, a, b, c, d;
    scanf("%d%d", &n, &q);
    for(int i=1;i<=n-1;i++){
        scanf("%d%d%d%d", &a, &b, &c, &d);
        g[a].push_back(pipii(b, pii(c, d)));
        g[b].push_back(pipii(a, pii(c, d)));
    }   
    dfs(1, 0, 0, 0);
    for(int j=1;j<17;j++){
        for(int i=1;i<=n;i++){
            if(par[j-1][i] != 0) par[j][i] = par[j-1][par[j-1][i]];
        }
    }
    for(int i=1;i<=q;i++){
        int x, y, u, v, lca;
        scanf("%d%d%d%d", &x, &y, &u, &v);
        lca = LCA(u, v);
        ans[i] = dist(u, v);

        cur[lca].push_back(pipii(-i, pii(x, y)));
        cur[u].push_back(pipii(i, pii(x, y)));
        cur[v].push_back(pipii(i, pii(x, y)));
    }
    dfs2(1, 0);
    for(int i=1;i<=q;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 30136
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-01 23:05:44
*/

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    long h, w;
    cin >> h >> w;

    long p = w * ( ceil((float)h/3) - h/3 );
    long q = h * ( ceil((float)w/3) - w/3 );

    long ans = min(p, q);

    for (long x = 1; x <= h-1; x++) {
        long y = w/2;
        long a, b, c;
        a = x * w;
        b = (h-x) * y;
        c = (h-x) * (w-y);

        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > b) swap(a, b);

        if (ans > c-a) ans = c-a;
    }

    for (long y = 1; y <= w-1; y++) {
        long x = h/2;
        long a, b, c;
        a = h * y;
        b = x * (w-y);
        c = (h-x) * (w-y);

        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > b) swap(a, b);

        if (ans > c-a) ans = c-a;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	A := make([]int, 2)
	B := make([]int, 2)
	A[0], A[1], B[0], B[1] = sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()
	mx := A[0] * B[0]
	for _, v1 := range A {
		for _, v2 := range B {
			v := v1 * v2
			if v > mx {
				mx = v
			}
		}
	}
	fmt.Println(mx)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

bool ready[201][201];
int value[201][201];

long long GCD(long long a, long long b){
    if (ready[a][b]) return value[a][b];
    if (b == 0)
    {   
        ready[a][b] = true;
        value[a][b] = a;
        return a;
    }else{
        return GCD(b, a % b);
    }
}

long long GCDm(long long a, long long b){
    long long ans;
    if (ready[a][b]){
        return value[a][b];
    }else{
        ans = GCD(a, b);
        ready[a][b] = true;
        value[a][b] = ans;
        return ans;
    }
}

long long GCD3(long long a, long long b, long long c){
    long long d = GCD(b, c);
    return GCD(a, d);
}

int main(){
    int K;
    cin >> K;
    int ans = 0;

    for (int i = 1; i < K + 1; i++)
    {
        for (int j = 1; j < K + 1; j++)
        {
            for (int k = 1; k < K + 1; k++)
            {
                ans += GCD3(i, j, k);
            }
            
        }
        
    }
    
    cout << ans << "\n";
    
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    int sum = 0;
    rep(i, n- 1) sum += p[i];
    sum += p[n -1] / 2;
    put(sum)
    return 0;
}

Measured memory_bytes: 3628
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

//Colored Octahedra
public class Main{

	int id, res;
	Map<String, Integer> ref;
	int[] c;
	void reg(String s){
		if(ref.containsKey(s))c[ref.get(s)]++;
		else{
			c[id]++;
			ref.put(s, id++);
		}
	}
	
	int[][] d = {
			{0, 1, 2, 3, 4, 5, 6, 7},
			{4, 5, 1, 0, 7, 6, 2, 3},
			{4, 0, 3, 7, 5, 1, 2, 6},
			{1, 5, 6, 2, 0, 4, 7, 3},
			{5, 4, 7, 6, 1, 0, 3, 2},
			{3, 2, 6, 7, 0, 1, 5, 4}
	};
	
	char[] s;
	Set<String> u;
	void dfs(int k){
		if(k==8){
			String t = new String(s);
			if(u.contains(t))return;
			res++;
			for(int i=0;i<6;i++){
				String a = "", b = "";
				for(int j=0;j<4;j++)a+=t.charAt(d[i][j]);
				for(int j=4;j<8;j++)b+=t.charAt(d[i][j]);
				for(int j=0;j<4;j++){
					u.add(a+b);
					a = a.substring(1)+a.charAt(0); b = b.substring(1)+b.charAt(0);
				}
			}
			return;
		}
		for(int i=0;i<id;i++){
			if(c[i]==0)continue;
			s[k] = (char)(i+'0');
			c[i]--;
			dfs(k+1);
			c[i]++;
		}
	}
	
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			id = res = 0;
			ref = new HashMap<String, Integer>();
			c = new int[8];
			for(int i=0;i<8;i++)reg(sc.next());
			u = new HashSet<String>();
			s = new char[8];
			dfs(0);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 18000
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int c = 1;
    while(true)
    {
      int x = scan.nextInt();
      if (x==0) break;
      System.out.println("Case "+ c + ": " + x);
      c++;
    }
    scan.close();
  }
}


Measured memory_bytes: 41340
import numpy as np
a, b, c, d, e, f = map(int, input().split())

tmp = np.arange(f+1, dtype=int)
water = np.zeros(f+1, dtype=int)
water[0] = 1
for i in range(f):
    if water[i]:
        if i+100*a < f+1:
            water[i + 100 * a] = 1
        if i+100*b < f+1:
            water[i + 100 * b] = 1
water = tmp[water == 1]
capacity = water//100*e
capacity = np.minimum(capacity, f-water)

sugar = np.zeros(f + 1, dtype=int)
sugar[0] = 1
for i in range(f):
    if sugar[i]:
        if i+c < f+1:
            sugar[i + c] = 1
        if i+d < f+1:
            sugar[i + d] = 1
sugar = tmp[sugar == 1]

max_d = 0
pair = 100 * a, 0
s = np.searchsorted(sugar, capacity, side="right")
s = sugar[s-1]
s = s[1:]
water = water[1:]
i = np.argmax(s / (water + s))
print(water[i]+s[i], s[i])


Measured memory_bytes: 14428
// Vicfred
// https://atcoder.jp/contests/abc174/tasks/abc174_b
// math, implementation
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long N, D;
    readf("%s %s\n", &N, &D);

    long ans = 0;
    foreach(_; 0..N) {
        long x, y;
        readf("%s %s\n", &x, &y);

        if(x*x + y*y <= D*D)
            ans += 1;
    }

    ans.writeln;
}



Measured memory_bytes: 2800
package main

import (
	"fmt"
)

func solution(s, t, u string, a, b int) (m, n int) {
	switch {
	case s == u:
		a--
	case t == u:
		b--
	}
	return a, b
}

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t, &a, &b, &u)
	fmt.Println(solution(s, t, u, a, b))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t>vec(N);
    for (int64_t i=0; i <N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int64_t>());
    int64_t sum = 0;
    for (int i=K; i<N; i++){
        sum += vec[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

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

int main() {
	ll N;
	cin >> N;
	string s;
	map<string,ll>A;
	rep(i, 0, N) {

		cin >> s;
		A[s]++;
	}
	ll cnt = 0;
	for (auto i : A) {
		cnt++;

	}
	cout << cnt;

}

Measured memory_bytes: 19232
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

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

const int N = 100005;
LL A[N];
map<LL, int > M;
const LL LIM = 10000000000LL;

int P[2200];
vi primes;

void pre() {
  for(int i = 2; i < 2200; i++) if(!P[i]) {
    primes.push_back(i);
    for(int j = 2 * i; j < 2200; j += i) {
      P[j] = 1;
    }
  }
}

LL reduce(LL x) {
  rep(i,0,primes.size()) {
    LL y = primes[i] * 1LL * primes[i] * 1LL * primes[i];
    while(x % y == 0) x /= y;
  }
  return x;
}

LL comp(LL x) {
  LL y = x;
  LL res = 1;
  rep(i,0,primes.size()) if(y % primes[i] == 0) {
    LL tmp = primes[i] * 1LL * primes[i] * 1LL * primes[i];
    while(y % primes[i] == 0) {
      y /= primes[i];
      tmp /= primes[i];
    }
    res *= tmp;
    if(res > LIM) return -1;
  }
  if(y > 1) {
    LL q = sqrt(y);
    if (q * q == y) {
      if(res * q > LIM) return -1;
      return res * q;
    }
    if(y > 100000) return -1;
    res *= y;
    if(res > LIM) return -1;
    res *= y;
    if(res > LIM) return -1;
  }
  return res;
}

int main() {
  pre();
  int n;
  S(n);
  int ans = 0;
  rep(i,0,n) {
    LL x;
    scanf("%lld",&x);
    x = reduce(x);
    A[i] = x;
    M[x]++;
  }
  bool one = false;
  rep(i,0,n) if(A[i] != -1) {
    if(A[i] == 1) {
      one = true;
      continue;
    }
    if(M.find(A[i]) == M.end()) continue;
    LL x = comp(A[i]);
    if(x == -1) ans += M[A[i]];
    else ans += max(M[A[i]], M[x]);
    M.erase(A[i]);
    M.erase(x);
  }
  P(ans+one);
  return 0;
}


Measured memory_bytes: 7424
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}

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

int main(){
    int n, m;
    string s, t;
    
    cin >> n >> m >> s >> t;

    if(s[0] != t[0]){
        cout << -1 << endl;
        return 0;
    }

    if(n < m){
        swap(n, m);
        swap(s, t);
    }

    if(n % m == 0){
        string tmp = "";
        for(int i = 0; i < n; i += n/m) tmp += s[i];
        if(tmp == t){
            cout << n << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }

    if(gcd(n,m) != 1){
        ll g = gcd(n,m);
        ll astep = n/g, bstep = m/g;
        ll l = lcm(n, m);
        bool check = true;
        int apos = 0, bpos = 0;
        while(apos < n && bpos < m){
            if(s[apos] != t[bpos])  check = false;
            apos += astep;
            bpos += bstep;
        }
        if(check)   cout << l << endl;
        else        cout << -1 << endl;
    }else{
        cout << lcm(n,m) << endl;
    }

    return 0;
}

Measured memory_bytes: 512
n,a=int(input()),1
for i in range(2,int(n**.5)+1):
  a+=-~(~-n//i>i)*(~-n%i<1)
  if n%i<1:
    m=n
    while m%i<1:m//=i
    a+=m%i<2
print(a+(n>2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(b == c){
        cout << a << endl;
    } else if(a == c){
        cout << b << endl;
    } else {
        cout << c << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str;
	while(1){
		cin>>str;
		if (cin.eof())
			break;
		for(int i = (str.size()-1); i>=0; i--)
			cout<<str[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
n,m=gets.split(' ')
n=n.to_i
m=m.to_i
mp1=Array.new(n)
mp2=Array.new(m)
for i in 1..n do
    mp1[i-1]=gets.split(' ').map(&:to_i)
end
for j in 1..m do
    mp2[j-1]=gets.to_i
end

for x in 1..n do
    p=0
    r=0
    mp1[x-1].each do |i|
       r=r+i*mp2[p]
       p+=1
    end
    printf("%d\n",r)
end

Measured memory_bytes: 8856
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<int> digit(n);
    set<int> val;
    int cnt = 0;
    REP(i,n){
        digit[i] = s[i] - '0';
    }
    REP(i,10){
        REP(j,10){
            REP(k,10){
                
                REP(l,n){
                    if(digit[l] == i){
                        FOR(h, l + 1, n){
                            if(digit[h] == j){
                                FOR(u, h + 1, n){
                                    if(digit[u] == k){
                                        cnt++;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        break;
                    }
                }
                
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string[] W = { "Sunny", "Cloudy", "Rainy" };
        Console.WriteLine(W[(Array.IndexOf(W, S) + 1) % 3]);
        return;
    }
}

Measured memory_bytes: 25608
N, T = map(int, input().split())
t_list = list(map(int, input().split()))
i = 0
duration = 0
while i < N -1:
    diff = t_list[i+1] - t_list[i]
    if diff > T:
        duration += diff - T
    i += 1
print(t_list[-1] - duration + T)

Measured memory_bytes: 26708
line = [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]
print(line[int(input())-1])


Measured memory_bytes: 2940
fun dump(ary: IntArray, n: Int) {
  for (i in 0 until n) {
    if (i > 0) print(' ')
    print(ary[i])
  }
  println()
}

fun insertSort(ary: IntArray, n: Int) {
  for (i in 1 until n) {
    val v = ary[i]
    var j = i - 1
    while (j >= 0 && ary[j] > v) {
      ary[j + 1] = ary[j]
      --j
    }
    ary[j + 1] = v
    dump(ary,n)
  }
}

fun main(args: Array<String>) {
  var n = readLine()!!.toInt()
  val ary = readLine()!!.split(' ').map(String::toInt).toIntArray()
  
  dump(ary,n)
  insertSort(ary,n)
}



Measured memory_bytes: 39224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int INF = 1001001001;

int main(){
    int x,a;cin >>x>>a;
    cout << ((10+x-a)/10)*10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define SIZEN 100000

int main(){
  int n,S[SIZEN],q,t,i,count = 0,left = 0,right,mid;

  scanf("%d",&n);
  right = n;
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i = 0;i < q;i++){
    scanf("%d",&t);
    left = 0; right = n;
    while(left < right){
      mid = (left + right)/2;
      if(t == S[mid]){
         count++;
         break;
       }
      if(t > S[mid]) left = mid+1;
      else if(t < S[mid]) right = mid;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2132
import sys
import heapq
input = sys.stdin.readline

N, K = map(int, input().split())

Hs = [-int(c) for c in input().split()]
heapq.heapify(Hs)

for _ in range(min(K, len(Hs))):
    heapq.heappop(Hs)

print(-sum(Hs))


Measured memory_bytes: 25872
#include<bits/stdc++.h>
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 200001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pb push_back
#define db double
#define pu puts(" ")
using namespace std;
const int p=998244353;
int read()
{
	int x=0,f=1;
	char ch=gc;
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%p;a=(ll)a*a%p;
		
		b>>=1;
	}
	return ans%p;
}
ll sum,a[maxn];
int main()
{
    int n=rd,k=rd;
    fo(i,1,n)a[i]=rd;
    sort(a+1,a+n+1);
    fo(i,1,n-k)sum+=a[i];
    printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;
int digitsum(int n){
    string s=to_string(n);
    int sum=0;
    int d=1;
    for(int e=0;e<s.length();e++){
        sum+=(n/d)%10;
        d*=10;
    }
    return sum;
}

int main(){
    int n,minv,q;
    cin>>n;
    minv=n;
    rep(i,n){
        if(i==0)continue;
        q=n-i;
        minv=min(minv,digitsum(i)+digitsum(q));
    }
    cout<<minv<<endl;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[100002];
    for (int i = 1; i <=n; ++i)
    {
    	cin>>a[i];
    }
    ll dp[100002];
    for (int i = 0; i <=n; ++i)
    {
        dp[i]=1e16;
    }
    dp[n]=0;
    for (int i = n; i >0; --i)
    {
        for(int j=1;j<=k && i+j<=n;j++)
        {
            // cout<<i<<" "<<i+j<<'\n';
    	   dp[i]=min(dp[i+j]+abs(a[i]-a[i+j]),dp[i]);
        }
        // cout<<dp[i]<<'\n';
    }
    cout<<dp[1]<<'\n';
}


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

int N;
int main(){
	cin >> N;
	vector<long long> v(3*N);
	for(int i=0;i<3*N;i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	long long ans = 0;
	int count = 0,r = 3*N-1;
	while(count<N){
		ans += v[r-1];
		r -= 2;
		count++;
	}
	cout << ans << endl;
}

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

void sort(int*,int);
void swap(int*,int);

int main(){
	int W[10],K[10];
	int sw,sk;
	for(int i=0;i<10;i++){
		cin>>W[i];
	}
	for(int i=0;i<10;i++){
		cin>>K[i];
	}
	
	sort(W,10);
	
	sw=W[0]+W[1]+W[2];
	sort(K,10);
	sk=K[0]+K[1]+K[2];
	cout<<sw<<" "<<sk<<endl;
	return 0;
}

void sort(int a[],int n){
	int k=1;
	int p;
	while(k){
		k=0;
		for(int i=0;i<n-1;i++){
			if(a[i]<a[i+1]){
				swap(a,i);
				k=1;
			}
		}
		for(int i=n-1;i>0;i--){
			if(a[i]>a[i-1]){
				swap(a,i-1);
				k=1;
			}
		}
		
		
	}
}

void swap(int a[],int i){
	int p=a[i];
	a[i]=a[i+1];
	a[i+1]=p;
	return;
}
	


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        double count = 0;

        for(int i=1; i <= N; i++){
            double tmp02 = 1;

            for(int n=i; n < K; n=n*2){
                tmp02 = tmp02 * 0.5;
            }
            count = count + tmp02 / N;
        }
        System.out.print(count);
    }

}

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

using namespace std;

typedef long long ll;

ll n;

ll sum(ll x) {
  return x * (x + 1) / 2;
}

int main() {
  cin >> n;
  cout << sum(n) - 3 * sum(n / 3) - 5 * sum(n / 5) + 15 * sum(n / 15) << '\n';
  return 0;
}


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

using namespace std;

const int N = 1234567;

int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, a[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < mx - 1) {
      puts("No");
      return 0;
    }
    if (a[i] == mx) {
      cnt++;
    }
  }
  if (mx == n - 1 && cnt == n) {
    puts("Yes");
    return 0;
  }
  // a[i] == mx      ->  c[i] is not unique
  // a[i] == mx - 1  ->  c[i] is unique
  if (cnt == 1) {
    puts("No");
    return 0;
  }
  int min_c = (n - cnt) + 1;
  int max_c = (n - cnt) + cnt / 2;
  if (min_c <= mx && mx <= max_c) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

string A, S, C;

int main(){
	
	cin>>A>>S>>C;
	
	cout<<A[0]<<S[0]<<C[0]<<endl;
	
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    string s; cin >> s;
    VI x(n,0);
    FOR(i,1,n) if(s[i] == 'E') x[0]++;
    FOR(i,1,n){
        x[i] = x[i-1];
        if(s[i] == 'E') x[i]--;
        if(s[i-1] == 'W') x[i]++;
    }
    SORT(x);
    OUT(x[0]);
    return 0;
}

Measured memory_bytes: 2964
#include<stdio.h>
int main(){
  double n,max,min;
  scanf("%lf",&n);
  max=min=n;
  while(scanf("%lf",&n)!=EOF){
    if(max<n){
      max=n;
    }
    if(min>n){
      min=n;
    }
  }
  printf("%f\n",max-min);
  return(0);
}

Measured memory_bytes: 648