akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

vi a[3];
vi b[333333];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	init(555555);
	map<char,int> ma;
	ma['B']=0;
	ma['R']=1;
	ma['G']=2;
	for(int i=0;i<3*n;i++)
	{
		a[ma[s[i]]].pb(i);
	}
	int ans=1;
	for(int i=0;i<n;i++)
	{
		b[i] = {a[0][i],a[1][i],a[2][i]};
		sort(b[i].begin(),b[i].end());
	}
	{
		int ptr=0;
		for(int i=0;i<n;i++)
		{
			while(ptr+1<n&&b[ptr+1][0]<=b[i][1])
			{
				ptr++;
			}
			//[0,ptr] works
			ans=mult(ans,ptr+1-i);
		}
	}
	{
		int ptr=0;
		for(int i=0;i<n;i++)
		{
			while(ptr+1<n&&b[ptr+1][1]<=b[i][2])
			{
				ptr++;
			}
			//[0,ptr] works
			ans=mult(ans,ptr+1-i);
		}
	}
	ans=mult(ans,fact[n]);
	cout<<ans<<'\n';
}


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

int	main()
{
    int N;
    cin >> N;
    vector<int> P_vec(N), Q_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> P_vec.at(i);
    for (int i = 0; i < N; ++i)
        cin >> Q_vec.at(i);
    vector<int> perm(N);
    for (int i = 0; i < N; ++i)
        perm.at(i) = i + 1;
    int a = -1, b = -1;
    int cnt = 0;
    do {
        ++cnt;
        if (equal(P_vec.begin(), P_vec.end(), perm.begin(), perm.end()))
            a = cnt;
        if (equal(Q_vec.begin(), Q_vec.end(), perm.begin(), perm.end()))
            b = cnt;
        if (a > 0 && b > 0)
            break;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int ans = 0;
    bool sleep = false;
    for (int i = 0; i < n; i++) {
        if (sleep) ans += t[i];
        if (s[i] == x) sleep = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

total = 0

for i in range(N):
  day = 1
  while 1:
    if day > D:
      break
    else:
      total += 1
      day += A[i]
else:
  print(X + total)

Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int n,a,b,p1,p2,p3;
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		int s;
		cin>>s;
		if(s<=a)
			p1++;
		else if(s<=b)
			p2++;
		else
			p3++; 
	}
	cout<<min(p1,min(p2,p3));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    ll time = 0;
    vector<pair<ll,ll> > p(N);
    for (int i = 0; i < N; i++){
        ll a,b; cin >> a >> b;
        p[i] = {b,a};
    }
    sort(p.begin(),p.end());
    for (int i = 0; i < N; i++){
        time += p[i].second;
        if (time > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	char s[100000+2];

	while(scanf("%d\n%100000[a-z]\n", &n, s)==2)
	{
		int ans=1;
		for(int i=1;i<n;i++)
		{
			if(s[i]!=s[i-1]) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2-x1, dy = y2-y1;
    
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
    
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	v := scanInts(n)

	cnt := []map[int]int{map[int]int{}, map[int]int{}}
	for i := 0; i < n; i++ {
		cnt[i&1][v[i]]++
	}
	cnt[0][0], cnt[1][0] = 0, 0
	p := make([]pairs, 2)
	for i := 0; i < 2; i++ {
		for v, c := range cnt[i] {
			p[i] = append(p[i], pair{v, c})
		}
	}
	sort.Sort(p[0])
	sort.Sort(p[1])
	if p[0][0].v == p[1][0].v {
		ma := p[0][0].c
		ma = max(ma, p[0][1].c+p[1][0].c)
		ma = max(ma, p[0][0].c+p[1][1].c)
		fmt.Fprintln(wr, n-ma)
	} else {
		fmt.Fprintln(wr, n-p[0][0].c-p[1][0].c)
	}

}

type pair struct{ v, c int }
type pairs []pair

func (a pairs) Len() int           { return len(a) }
func (a pairs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a pairs) Less(i, j int) bool { return a[i].c > a[j].c }


Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

const int inf = 1e9;

int first(int n){
    if(n<10) return n;
    return first(n/10);
}

int end(int n){
    return n%10;
}


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

    vector<vector<int>> c(10, vector<int>(10, 0));
    for(int i=0;i<10;i++)for(int j=0;j<10;j++){
        for(int k=1;k<=n;k++){
            if(first(k) == i && end(k) == j) c[i][j]++;
        }
    }
    ll ans = 0;
    for(int i=0;i<10;i++)for(int j=0;j<10;j++){
        ans += c[i][j]*c[j][i];
    }
    cout << ans << endl;
}

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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           100011

long long  md=MD;


int solve(){
	int n,i,j,k,m;
	cin>>n>>m;
	priority_queue<int> pq;
	ll p=0;
	for(i=1;i<=n;++i){
		int x;cin>>x;pq.push(x);
	}
	while(m){
		int t=pq.top();pq.pop();
		pq.push(t/2);
		--m;
	}
	while(pq.size()){
		p+=pq.top();pq.pop();
	}
	cout<<p<<"\n";




	return 0;
}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t,i;

    t=1;
    // cin>>t;

    while(t--){
    	solve();
    }



    

}



Measured memory_bytes: 892
function Main(input) {
	var str = input;
	var ans = "";
	str = str.split("\n")[0];
	str = str.split(" ")[0];
	var arr = str.split('');
	var n = arr.length;
	var c = (n+3)/2-1;
	var f = arr.splice(c, n-c);
	var b = arr.splice(0,c-1);
	
	f = f.join("");
	b = b.join("");


	if(b === f){
		ans = "Yes"
	}else{
	ans = "No"
	}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define for0(i, n) for (int i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (ll)(n); ++i)
#define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i)
#define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (ll)(n); i >= 1; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) ll((a).size())
#define mod 1000000007
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool prime[1000001];
void sieve()
{
  memset(prime, true, sizeof(prime));
  prime[1]=false;
  for (int p=2; p*p<=1000000; p++)
  {
    if (prime[p] == true)
    {
        for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
    }
  }
}

void solve()
{
    string s;
    cin >> s;
    if(s[s.size()-1]=='s') s+="es";
    else s+="s";
    cout << s << endl;
}
int main()
{
  fast();
  /*ll t;
  cin >> t;
  while(t--)*/
  solve();

return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
void ssssssssssssss()
{
    int a1,a2a,a3,a4,a5,a6,a7,a8,a9;
}
void xxxxxxxxx()
    {
        cout << "6666666666666";
    }
int n,i,f;
int main()
{
    cin>>n;
    for(i=1;i<=n;i*=2)
      if(i==n)  {f=1;break;}
    if(!f)
      cout<<i/2<<endl;
    else  cout<<i<<endl;
    ssssssssssssss();
    return 0;
}

Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

main(){
    fast();per(0);
    //get_fact();
    string s;cin>>s;
    s[3]='8';
    cout<<s;
}


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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<string> s(N); cin >> s;
    int M; cin >>M;
    vector<string> t(M); cin >> t;
    
    int ans = 0;
    map<string, int> profit;

    for (auto& word : t) {
        if (profit.count(word) == 0)
            profit[word] = 0;
        profit[word]--;
    }
    for (auto& word : s) {
        if (profit.count(word) == 0)
            profit[word] = 0;
        profit[word]++;
        chmax(ans, profit[word]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n,k; cin >> n >> k;
    if(n % k == 0) puts("0");
    else puts("1");
}


Measured memory_bytes: 256
def main():
    n = int(input())
    xn = list(map(int,input().split()[:n]))

    minsum = 0
    for point in range(min(xn),max(xn)):
        tmp = 0
        for xi in xn:
            tmp += (xi - point)**2
        if tmp < minsum or minsum == 0:
            minsum = tmp

    print(minsum)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

unordered_map<int,int> ans;

//素因数分解
unordered_map<int,int> factor(ll x){
    unordered_map<int,int> prime;
    for (ll i = 2; i<=sqrt(x); i++) {
        if(x%i==0){
            while(x%i == 0){
                prime[i]++;
                x/=i;
            }
        }
        if(x==1)break;
    }
    if(x != 1) prime[x]++;
    return prime;
}

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x%mod;
    else return ex(x*x%mod,n/2)%mod;
};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    unordered_map<int,int> flcm;
    ll lcm = 1;
    ll fans = 0;

    for(int i = 0 ; i < n; i++){
        cin >> a[i];
        unordered_map<int,int> pf = factor(a[i]);
        for(auto p:pf) flcm[p.first] = max(flcm[p.first],p.second);
    }

    for(auto p:flcm){
        lcm *= ex(p.first,p.second);
        lcm %= mod;
    }

    for(int i = 0; i < n; i++){
        fans += lcm*ex(a[i],mod-2);
        fans %= mod;
    }

    cout << fans << endl;
    return 0;
}


Measured memory_bytes: 3984
#include<iostream>
using namespace std;
long long power(long long a,long long b)
{
    if(b==0)
    {
        return 1;
    }
    else if(b%2==0)
    {
        return power((a*a),b/2);
    }
    else
    {
        return a*power((a*a),(b-1)/2);
    }
}
long long height(long long n)
{
    long long c=0;
    while(n>0)
    {
        c++;
        n=n>>1;
    }
    return c;
}
int main()
{
    long long n,b;
    cin>>n;
    b=height(n);
    cout<<power(2,b)-1<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    if(n%2==1) cout << 0 << endl;
    else{
        ll ans=0;
        ll md = 10;
        while(n/md != 0){
            ans += n/md;
            md*=5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
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(){
  char s; cin>>s;
  if(0<=s-'A'&&s-'A'<=26)cout << "A" << endl;
  if(0<=s-'a'&&s-'a'<=26)cout << "a" << endl;
}

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

int main() {
  int d;
  while(cin >> d && d!=0) {
    int n,m;
    cin >> n >> m;
    int a[n+1],b[m];
    a[0]=0;
    a[n]=d;
    for(int i=1; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++) cin >> b[i];
    sort(a,a+n+1);
    sort(b,b+m);
    int k=0,sum=0;
    for(int i=0; i<n+2; i++) {
      if(b[k]>=a[i] && b[k]<=a[i+1]) {
	sum+=min(a[i+1]-b[k],b[k]-a[i]);
	k++;
	i--;
      }
      if(k>=m) break;
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 1608
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2e6+100;
const ll bits = 35;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;
 

int main(){
    FASTIO;
    PRECISION;

    ld a,b;
    cin>>a>>b;

    for(ld i=0; i<N;i+=1.0){
        if(floor(i*0.08)==a && floor(i*0.1)==b){
            cout<<(ll)i;
            return 0;
        }
    }

    cout<<-1<<"\n";






    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll N, A, B;

int main() {
    cin >> N >> A >> B;

    ll tmp = N / (A + B);

    cout << A * tmp + min(N - (A + B) * tmp, A) << endl;
}

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

using namespace std;
/*
void hissatsu(vector<long> &input){
    int ans;
    for(int i = 1; i < input.size(); i++){
        if(input[i] > input[ans]) ans = i;
    }
    input.erase(ans);
}
*/
int min(vector<long> &input){
    int ans = 0;
    for(int i = 1; i < input.size(); i++){
        if(input[i] < input[ans]) ans = i;
    }
    return ans;
}
/*
long sum(vector<long> input){
    if(input.begin() == input.end()) return 0;
    long ans = 0;
    for(int i = 0; i < input.size(); i++) ans += input[i];
    return ans;
}
*/



vector<long> inputArray(int num){
    long input;
    vector<long> array;
    for(int i = 0; i < num; i++){
        cin >> input;
        array.push_back(input);
    }
    return array;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<long> h = inputArray(n);
    if(h.size() <= k){
        cout << 0 << endl;
        return 0;
    }
    long ans = 0;
    int tmp;
    sort(h.begin(), h.end());
    for(int i = 0; i < n - k; i++){
        //tmp = min(h);
        //ans += h[tmp];
        //h.erase(h.begin() + tmp);
        ans += h[i];
    }

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


Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] ai = new int[N];
		int index = 0;
		int[] nums = new int[3];
		int[] numsCount = {0, 0, 0};
		boolean isNo = false;
		for (int i=0; i<N; i++) {
			ai[i] = in.nextInt();
			boolean isSame = false;
			for (int j=0; j<index; j++) {
				if (nums[j] == ai[i]) {
					isSame = true;
					numsCount[j]++;
					break;
				}
			}
			if (isSame == false && index >= 3) {
				isNo = true;
				break;
			}
			if (isSame == false) {
				nums[index] = ai[i];
				numsCount[index] = 1;
				index++;
			}
		}
		in.close();
		
		if (isNo) {
			System.out.println("No");
			return;
		}
		
		if (index == 1) {
			if (nums[0] == 0) {
				System.out.println("Yes");
				return;
			} else {
				System.out.println("No");
				return;
			}
		}
		if (N % 3 != 0) {
			System.out.println("No");
			return;
		}
		int unit = N/3;
		for (int i=0; i<index; i++) {
			if (numsCount[i] % unit != 0) {
				System.out.println("No");
				return;
			}
			if (numsCount[i] / unit == 2) {
				nums[2] = nums[i];
			}
		}
		int total = 0;
		for (int i=0; i<3; i++) {
			total = total ^ nums[i];
		}
		if (total == 0) {
			System.out.println("Yes");
			return;
		} else {
			System.out.println("No");
			return;
		}
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 49400
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

char a[9][9];
int main()
{
    ios_base::sync_with_stdio(0);
     string s;
     cin>>s;
     string a="",b="";
     a+=s[0];
     a+=s[1];
     b+=s[2];
     b+=s[3];
    ll x = tolong(a);
    ll y = tolong(b);
    if(x >= 1 && x <= 12)
    {

        if(y >= 1 && y <= 12)
            cout << "AMBIGUOUS";
        else cout << "MMYY";
    }
    else
    {

        if(y >= 1 && y <= 12)
            cout << "YYMM";
        else cout << "NA";
    }
}
///


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ??\?????°????????????????????°
		int input = sc.nextInt();

		// ?????????????????°
		int cnt;

		// ??\??????????????°????????\????????????
		int[] matrix = new int[input];

		// ???????????°????????\??????
		for (cnt = 0; cnt < input; cnt++) {

			matrix[cnt] = Integer.parseInt(sc.next());

		}

		// ????????????????????????
		for (cnt = input - 1; cnt >= 0; cnt--) {

			if (cnt > 0) {

				System.out.print(matrix[cnt] + " ");

			} else {

				System.out.println(matrix[cnt]);

			}

		}
		sc.close();
	}

}

Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll ans=0, a[10000001];
int main() {
    cin >> n;
    for (int i=1; i<=n; i++) {
        for (int j=i; j<=n; j+=i) {
            a[j]+=j;
        }
        ans+=a[i];
        //cout << a[i] << " ";
    }
    cout << ans;
}

Measured memory_bytes: 81716
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A, B,C = inputMap()

	tmp = A-B


	print(max(0,C-tmp))


if __name__ == "__main__":
	main()


Measured memory_bytes: 38524
#include<cstdio>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

int main(){
	int y, m, d;
	string gengo[] = {"pre-meiji","meiji","taisho","showa","heisei"};
	string comp[] = {"18680908","19120730","19261225","19890108","99999999"};
	int years[] = {1868,1912,1926,1989};
	while( scanf("%d %d %d",&y,&m,&d) == 3 ){
		char in[10];
		sprintf(in, "%04d%02d%02d",y,m,d);
		int i=0;
		for( ; i<5; i++ ){
			if( atoi(in) < atoi(comp[i].c_str()) ){
				cout << gengo[i];
				break;
			}
		}
		if( i>0 ){
			cout << " " << (y-years[i-1]+1) << " " << m << " " << d;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
N=int(input())
A=[int(input()) for i in range(N)]
A.sort(reverse=True)
mae=0
ushiro=0
if N%2==0:
    if N>3:
        for i in range(N//2-1):
            mae+=A[i]
        for i in range(N//2+1,N):
            ushiro+=A[i]
    a0=A[N//2-1]
    a1=A[N//2]
    print((mae-ushiro)*2+a0-a1)
else:
    if N>3:
        for i in range(N//2-1):
            mae+=A[i]
        for i in range(N//2+2,N):
            ushiro+=A[i]
    a0=A[N//2-1]
    a1=A[N//2]
    a2=A[N//2+1]
    print((mae-ushiro)*2+max(2*a0-a1-a2,a0+a1-2*a2))

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int A, B; cin >> A >> B;
    int X = (25 * A + 1) / 2, Y = 10 * B;
    int ans = max(X, Y);
    int CA = ans * 0.08, CB = ans * 0.1;
    if (CA != A || CB != B) {
        ans = -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

def readString() :
    return  stdin.readline().rstrip()

def solve() :
    S = readString()
    pos = S.find('C')
    if(pos ==-1):
        print("No")
        return
    pos = S[pos:].find('F')
    if(pos !=-1):
        print("Yes")
    else :
        print("No")

solve()

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main()
{
	int S,h,m,s = 0;
	cin >> S;
	h = S / 3600;
	S -= h * 3600;
	m = S / 60;
	S -= m * 60;
	s = S;
	cout << h << ":" << m << ":" << s << "\n";
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define EACH(i, a) for(auto&& i:a)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for(ll i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(v) (v).begin(),(v).end()

const ll linf = 1e18;
const ll inf = 1e9;

template<class T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}

const ll dx[] = {0, 1, 0, -1};
const ll dy[] = {-1, 0, 1, 0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W; cin >> H >> W;
    auto inRange = [&](int x, int y) {
        return 0 <= x && x < W && 0 <= y && y < H;
    };
    vector<string> m(H); cin >> m;
    int gx = -1, gy = -1;
    REP(y, H) REP(x, W) if (m[y][x] == '%') {
        gx = x, gy = y;
    }
    vector<vector<ll>> dist(H, vector<ll>(W, -1));
    queue<P> Q; Q.push({gx, gy});
    while ( !Q.empty() ) {
        P p = Q.front(); Q.pop();
        ll x, y; tie(x, y) = p;
        REP(d, 4) {
            ll nx = x + dx[d];
            ll ny = y + dy[d];
            if ( inRange(nx, ny) && m[ny][nx] != '#' && dist[ny][nx] < 0 ) {
                dist[ny][nx] = dist[y][x]+1;
                Q.push({nx, ny});
            }
        }
    }
    ll sdist = linf, pdist = linf;
    REP(y, H) REP(x, W) {
        if (m[y][x] == '$') {
            sdist = min(sdist, dist[y][x]);
        }
        if (m[y][x] == '@') {
            pdist = min(pdist, dist[y][x]);
        }
    }
    if (pdist == linf || pdist >= sdist) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using Int = long long;
using namespace std;
int main(){
    int N; cin >> N;
    vector<Int>v(N);
    for(auto& e : v) cin >> e;
    reverse(v.begin(),v.end());
    Int ans = 0;
    multiset<Int>S;
    for(int i = 0; i < N; ++i){
        auto itr = S.lower_bound(v[i] + 1);
        if(itr == S.end()){
            ++ans;
        } else {
            S.erase(itr);
        }
        S.insert(v[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 5760
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    sort(all(vec));
    ll sum=1e18;
    rep(i,101){
        ll temp=0;
        rep(j,n){
            temp+=pow((vec[j]-i),2);
        }
        chmin(sum,temp);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	bool ans=true;
	set<ll> s;
	rep(i,n){
		ll in;
		cin>>in;
		ans&=(s.find(in)==s.end());
		s.insert(in);
	}
	YN(ans);
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>

int partition(int *,int,int);

int main(void){
	
	int i,n,*A,p=0,r,mid;
	
	scanf("%d",&n);
	A=(int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	
	r=n-1;
	mid=partition(A,p,r);
	
	for(i=0;i<n;i++){
		if(i==mid)printf("[");
		printf("%d",A[i]);
		if(i==mid)printf("]");
		if(i!=n-1)printf(" ");
	}
	printf("\n");
	
	return 0;
}
int partition(int *A,int p,int r){
	int x,i,j,temp;
	x=A[r];
	i=p-1;
	for(j=p;j<r;j++){
		if(A[j]<=x){
			i++;
			temp=A[i];
			A[i]=A[j];
			A[j]=temp;
		}
	}
	temp=A[i+1];
	A[i+1]=A[r];
	A[r]=temp;
	return i+1;
}

Measured memory_bytes: 996
x = int(input())

is_get = False
for a in range(10000):
    for b in range(a + 1):
        aa = a ** 5
        bb = b ** 5
        xx = abs(x)
        if aa - bb == xx:
            if x >= 0:
                print(a, b)
            else:
                print(-a, -b)
            is_get = True
            break
        elif aa + bb == xx:
            if x >= 0:
                print(a, -b)
            else:
                print(-a, b)
            is_get = True
            break
    if is_get:
        break

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

int main() {
  int N,X;
  cin >> N >> X;
  int L[110];
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  
  int d = 0;
  int count = 0;
  int i = 0;
  
  while (d <= X) {
    count++;
    d += L[i];
    i++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;


int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> cnt(n,0);
    cnt[0]=3;

    ll ans=1;
    rep(i,n){
        ans=(ans*cnt[a[i]])%MOD;
        cnt[a[i]]--;
        cnt[a[i]+1]++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4784
x=int(input())
value=0
index=0
hashmap=dict()
while value<int(1e18)+1:
    value=pow(index,5)
    hashmap[value]=index
    index+=1
for i in range(1,1000):
    b1=x+int(pow(i,5))
    b2=x+int(pow(-i,5))
    if hashmap.get(b1)!=None:
        print(hashmap[b1],i)
        break
    if hashmap.get(b2)!=None:
        print(hashmap[b2],-i)
        break    

Measured memory_bytes: 9528
# AOJ 1037 Midnight Teatime
# Python3 2018.7.6 bal4u

def calc():
	global sz
	n = sz
	sz += 1
	if tree[0] == '(':
		del tree[0]
		left = calc()
		del tree[0]
		right = calc()
		del tree[0]
		for i in range(16):
			for j in range(16):
				k = left[i] * right[j]
				if k:
					buf[n][i & j] += k
					buf[n][i | j] += k
					buf[n][i ^ j] += k
	else: buf[n][info[int(tree.pop(0))-1]] = 1
	return buf[n]

while True:
	tree = list(input())
	if tree[0] == 'E': break
	buf, sz = [[0 for j in range(16)] for i in range(20)], 0
	info = [0]*10
	for i in range(int(input())):
		p = list(map(int, input().split()))
		for j in range(4):
			if p[j]: info[i] |= (1<<j)
	print(calc()[15])


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ,k ;
	cin >> n >>k ;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	SORT(l);
	rSORT(l);
	ll ans = 0 ;
	rep(i,k) ans += l[i];
	cout << ans << endl;

}


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo INT_MAX

const int N = (1 << 21) + 5;
int n , mod = 1e9 + 7;
int dp[N][22] , a[22][22];
vector < int > g[25];
/// dp[mask][i] là số cách để kết hợp từ 1 -> i + 1 người nam đầu  và mask tượng trưng cho các người phụ nữ được chọn.

int main()
{
    //freopen("O.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    REP(i , n)
        REP(j , n)
            cin >> a[i][j];
    REP(j , n)
    REP(i , n)
        if(a[j][i] == 1)
            dp[(1 << i)][j] = 1;
    REP(j , (1 << n))
    {
        int cnt = 0;
        REP(x , n)
            if((j >> x) & 1 == 1)
                cnt++;
        g[cnt].pb(j);
    }
    FOR(i , 1 , n - 1)
        REP(s , g[i + 1].size())
        {
            int j = g[i + 1][s];
            REP(x , n)
                if(((j >> x) & 1) == 1 && a[i][x] == 1)
                    dp[j][i] = (dp[j][i] + dp[(j ^ (1 << x))][i - 1]) % mod;
        }
    cout << dp[(1 << n) - 1][n - 1];
}


Measured memory_bytes: 189884
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = Integer.parseInt(as.next());
		int l = n;
		int[] a;
		int b = 0;
		int c = (int)Math.pow(2, n);
		a = new int[c];
		for(int i=0;i<c;i++){
			a[i]  = Integer.parseInt(as.next());
		}
		for(int s=0;s<n;s++){
			for(int i=0;i<(int)(Math.pow(2, l));i+=2){
				if(a[i]<a[i+1]){
					a[i+1]-=a[i];
					a[b]=a[i+1];
					b+=1;
				}else if(a[i]>a[i+1]){
					a[i]-=a[i+1];
					a[b]=a[i];
					b+=1;
				}else{
					a[b]=a[i];
					b+=1;
				}
			}
			l-=1;
			b = 0;
		}
		System.out.println(a[0]);
	}
}

Measured memory_bytes: 47944
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N-1; i++) {
			a[sc.nextInt()]++;
		}		
		for (int i = 1; i < N; i++) {
			System.out.println(a[i]);
		}
		System.out.println(0);
	}
}

Measured memory_bytes: 67484
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define ppb pop_back
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,k[100005],dp[100005];
	cin>>n;
	for (int i=0;i<n;i++) cin>>k[i];
	dp[0]=0;
	dp[1]=abs(k[0]-k[1]);
	for (int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(k[i]-k[i-1]),dp[i-2]+abs(k[i]-k[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define dbg(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);


inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
    x*=f;
    return x;
}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const int N = 200213;
int a[N];

int main(){
#ifdef LOCAL_DEFINE
    f_in
#else
    _
#endif
    int n = nxt();
    a[0] = -1;
    rep(i,1,n + 1) a[i] = nxt();
    ll ans = 0;
    rep(i,1,n + 1){
        if(a[i] - a[i - 1] > 1) return cout << "-1\n", 0;
        if(a[i] - a[i - 1] == 1) ans++;
        else ans += a[i];
    }
    cout << ans - 1 << '\n';

#ifdef LOCAL_DEFINE
    cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n";
 #endif
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int n = s.length();
    for(int i = 0;s[i];i++) {
        if(s[i]=='?') {
            if(s[i+1]) {
                if(s[i+1]=='?') {
                    if(i > 0) {
                        if(s[i-1]=='D')
                            s[i]='P';
                        else
                            s[i]='D';
                    } else {
                        s[i]='P';
                    }
                }
                else {
                    if(i > 0) {
                        if(s[i-1]=='D' && s[i+1]=='D')
                            s[i]='P';
                        else
                            s[i]='D';
                    } else {
                        if(s[i+1]=='P')
                            s[i]='D';
                        else
                            s[i]='P';
                    }
                }
            } else {
                s[i]='D';
            }
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

typedef vector<vector<pair<int, bool>>> Graph;
Graph graph;
vector<int> color;

void bfs(int v, int paint_color) {

	color[v] = paint_color;
	// キューを用意して、初期探索点をセット
	queue <pair<int, int>> que;
	que.push(make_pair(v, color[v]));

	while (!que.empty()) { // BFSループ
		// ★★　この中で迂闊に break しないこと

		// キューの先頭のセルを取得
		pair<int,int> data = que.front(); que.pop();
		int from = data.first;
		int from_color = data.second;
		
		// 取得したセルに対する処理

		// そのセルからつながるセルに処理を移行
		for (int j = 0; j < graph[from].size(); j++) {
			int to = graph[from][j].first;
			int if_odd = graph[from][j].second;
			if (color[to] == -1) {
				color[to] = (from_color + if_odd) % 2;
				que.push(make_pair(to, color[to]));
			}
		}
	}
}

int main() {

	int N;
	cin >> N;
	graph.resize(N + 1);

	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		graph[u].push_back(make_pair(v, w % 2));
		graph[v].push_back(make_pair(u, w % 2));
	}

	color.resize(N + 1);
	fill(color.begin(), color.end(), -1);

	for (int i = 1; i < N + 1; i++) {
		if (color[i] == -1) {
			bfs(i, 0);
		}
	}

	for (int i = 1; i < N + 1; i++) {
		cout << color[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<int> V(n);
  for(int i=0; i<n; i++) cin >> V[i];
  vector<int> C(n);
  for(int i=0; i<n; i++) cin >> C[i];

  vector<int> D(n);
  for(int i=0; i<n; i++) D[i]=V[i]-C[i];

  int ans=0;
  for(int i=0; i<n; i++){
    if(D[i]>=0) ans+=D[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
using namespace std;
const int INF = 1 << 30;
const int NIL = 0;
const int MAXN = 10005;
int vis[MAXN];
int d[MAXN];
int head[500005];
int n;
int cnt;
struct Edge {
	int to, next, w;
	Edge() {}
} edge[500005];

void add(int u, int v, int w)
{
	edge[cnt].to = v;
	edge[cnt].w = w;
	edge[cnt].next = head[u];
	head[u] = cnt++;
}

struct Node {
	int u, w;
	Node (int _u, int _w) :u(_u), w(_w) {}
	friend bool operator<(const Node& a, const Node& b)
	{
		return a.w > b.w;
	}
};

void dijkstra(int s)
{
	priority_queue<Node> q;
	for (int i = 0; i < n; ++i)
		d[i] = INF, vis[i] = false;
	d[s] = 0;
	
	Node t(s, 0);
	q.push(t);
	int u, v, w;
	int count = 0;
	while (!q.empty() && count < n - 1)
	{
		t = q.top();
		q.pop();
		u = t.u;
		if (d[u] < t.w)
			continue;
		vis[u] = true;
		++count;
		for (int i = head[u]; i != NIL; i = edge[i].next)
		{
			v = edge[i].to;
			w = edge[i].w;
			if (!vis[v] && d[v] > d[u] + w)
			{
				d[v] = d[u] + w;
				q.push(Node(v, d[v]));
			}
		}
	}
	if (count == n - 1)
		for (int i = 0; i < n; ++i)
			cout << i << " " << d[i] << endl;

}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, s, e, w;
	cin >> n;
	//memset(head, NIL, sizeof(-1));
	cnt = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> s >> k;
		while (k--)
		{
			cin >> e >> w;
			add(s, e, w);
		}
	}
	dijkstra(0);

	return 0;
}

Measured memory_bytes: 9124
N, Q = map(int, input().split())
S = input()
lis = []
for _ in range(Q):
    l, r = map(int, input().split())
    lis.append((l, r))
count = 0
count_lis = [0, 0]
pre_string = S[0]
for string in S[1:]:
    if pre_string == 'A' and string == 'C':
        count += 1
    count_lis.append(count)
    pre_string = string
for (l, r) in lis:
    print(count_lis[r] - count_lis[l])

Measured memory_bytes: 19824
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    string s;
    cin >> s;
    if (regex_match(s, regex("(dream|dreamer|erase|eraser)*")))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 39808
#include<cstdio>
const int N = 2005;
const long long p = 1e9 + 7;
long long f[N];

int main()
{
	int n;
	register int i,j;
	scanf("%d",&n);
	for(i = 3;i <= n;++ i) f[i] = 1;
	for(i = 3;i <= n;++ i)
		for(j = 3;j <= i;++ j)
			f[i] = (f[i] + f[i - j]) % p;
	printf("%lld",f[n]);
	return 0;
}

Measured memory_bytes: 1716