akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include<algorithm>
#include<vector>
#define PI (6.28318530717958623200/2)
using namespace std;

int main()
{
    int N,K;
   cin >> N >> K;

    vector<int> A(N);

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

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

    int sum =0;
    for(int i=0; i<K; i++){
        sum += A[i];
    }
    cout << sum;
   return 0;
}
        
    


Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>//strcmp、strncmp関数を使うために必要
#include<math.h>

int main(){
    int n,judge_1 = 0,judge_0 = 0,ans = 0;
    char s[200000];
    scanf("%s",s);//printf("%s\n",s);
    for(int i = 0;s[i] != '\0';i++){
        if(i % 2 == 0){
            if(strncmp("1",&s[i],1) == 0){
                judge_1++;
            }
            else{
                judge_0++;
            }
        }
        else{
            if(strncmp("1",&s[i],1)){
                judge_1++;
            }
            else{
                judge_0++;
            }
        }
    }
    ans = fmin(judge_0,judge_1);
    printf("%d\n",ans);
    
}   

Measured memory_bytes: 256
N,M,X=[int(s) for s in input().split()]
Book=[[int(s) for s in input().split()] for _ in range(N)]
INF=10**7

ans=set()
ans.add(INF)
#深さ優先探索
def DFS(n,cost,Xls):
  if n==N:
    if min(Xls)>=X:
      ans.add(cost)
  else:
    Xnext=[Xls[i]+Book[n][i+1] for i in range(M)]
    DFS(n+1,cost+Book[n][0],Xnext)
    DFS(n+1,cost,Xls)

DFS(0,0,[0 for _ in range(M)])
if min(ans)==INF:
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 9280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int h,w;
  cin >> h >> w;
  char s[h+2][w+2];
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin >> s[i][j];
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      bool is=false;
      if(s[i][j]=='.'){
        continue;
      }
      if(s[i][j-1]=='#' || s[i][j+1]=='#' || s[i+1][j]=='#' || s[i-1][j]=='#'){
          is=true;
        }
      if(is==false){
        cout << "No";
        return 0;
      }
    }
  }
  cout<<"Yes";
}
      


Measured memory_bytes: 384
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        if y == 0:
            print(-x)
        elif x == 0:
            print(y)
        elif 0 < x and 0 < y:
            print(y - x)
        elif x < 0 and 0 < y:
            print(abs(y - abs(x)) + 1)
        else:
            print(y - x)
    else:
        if y == 0:
            print(x + 1)
        elif x == 0:
            print(-y + 1)
        elif 0 < y and 0 < x:
            print(x - y + 2)
        elif y < 0 and 0 < x:
            print(abs(x - abs(y)) + 1)
        else:
            print((x - y) + 2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 79816
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, k, m=1, w;
    string s;
    vector<int> v;
    char c='*';
    cin >> n >> k >> s;
    //v.push_back(0);
    for(int i=0;i<n;i++){
        if(s[i]!=c)v.push_back(i);
        c=s[i];
    }
    v.push_back(n);
    
    m=0;
    w=v.size();
    
    if(s[0]=='0'){
        if(w<=2*k)m=v[w-1];
        for(int i=k*2;i<w;i+=2){
            m = max(m, v[i] - v[max(0,i-k*2-1)]);
        }
    }else{
        if(w<=2*k+2)m=v[w-1];
        for(int i=k*2+1;i<w;i+=2){
            m = max(m, v[i] - v[max(0,i-k*2-1)]);
        }
    }
    if(s[n-1]=='0'){
        m=max(m, v[w-1]-v[max(0, w-1-k*2)]);
    }
    cout << m << endl;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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;
  }
};

vector<vector<bool>> dp(100001, vector<bool>(2, false));
//dp.at(i).at(j)はj=0なら太郎君の手番で山が残りi個のときに太郎君が勝つかどうか
//j=1なら次郎君の手番で山が残りi個のときに太郎君が勝つかどうか

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N){
    cin >> a.at(i);
  }
  dp.at(0).at(1) = true;
  rep(i, K){
    dp.at(i+1).at(0) = false;
    dp.at(i+1).at(1) = true;
    rep(j, N){
      if(i+1 >= a.at(j)){
        dp.at(i+1).at(0) = dp.at(i+1).at(0) || dp.at(i+1-a.at(j)).at(1);
        dp.at(i+1).at(1) = dp.at(i+1).at(1) && dp.at(i+1-a.at(j)).at(0);
      }
    }
  }
  if(dp.at(K).at(0)){
    cout << "First" << endl;
  }
  else{
    cout << "Second" << endl;
  }
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;

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

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

    
    int n,x;
    cin >> n >> x;

    vector<int> arr;
    rep(i,0,n){
        int t;
        cin >> t;
        arr.push_back(t);
    }

    sort(arr.begin(),arr.end());
    arr.insert(lower_bound(arr.begin(),arr.end(),x),x);
    
    vector<int> sub;
    rep(i,1,n+1) sub.push_back(arr[i] - arr[i-1]);
    int g = sub[0];
    rep(i,1,n) g = gcd(g,sub[i]);
    cout << g << endl;


}

Measured memory_bytes: 1400
#include <stdio.h>
#include <algorithm>

using namespace std;

int t[200001];

int main() {
    int N, T;
    scanf("%d %d", &N, &T);
    for (int i = 0; i < N; i ++) {
        scanf("%d", &t[i]);
    }
    int total = 0;
    int time = 0;
    for (int i = 0; i < N; i ++) {
        int nexttime = i < N - 1 ? min(t[i] + T, t[i+1]) : t[i] + T;
        total += nexttime - max(time, t[i]);
        time = nexttime;
    }
    printf("%d\n", total);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
  cout<<a*b/2;
	
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
    int n,i,tail;
    char s;
    char dic[256];
    while(cin>>n,n){
	    for(i=0;i<256;i++) dic[i]=i;
	    while(n--){
		    cin>>s;
		    cin>>dic[(int)s];
	    }
	    cin>>n;
	    while(n--){
		    cin>>s;
		    cout<<dic[(int)s];
	    }
	    cout<<endl;
    }
}

Measured memory_bytes: 856
#include<bits/stdc++.h>
using namespace std;
#define N 100055
#define ll long long
int n,k, dp[N], ar[N],pre[N];
const int mod = 1e9+7;
void mod_add(int &a, int b) {
    a += b;
    while(a>=mod)
        a-=mod;
    while(a<0)
        a+=mod;
}
int main() {

    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; ++i) {
        scanf("%d",&ar[i]);
    }
    dp[0] = 1;
    for(int i = 1 ; i<=n; ++i) {
        for(int used = k; used>=0; --used) {
            int L = used + 1;
            int R = used + min(ar[i], k-used);
            if(L <= R){
                mod_add(pre[L], dp[used]);
                if(R + 1 <= k)
                    mod_add(pre[ R + 1 ], -dp[used]);
            }
        }
        int ss = 0;
        for(int x=0; x<=k; ++x) {
            mod_add(ss, pre[x]);
            mod_add(dp[x], ss);
            pre[x]=0;
        }
    }
    cout << dp[k];
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int N = 110;
int n, m;

char s[N][N];

int vis[N][N];

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1 ; i <= n ; ++ i) {
		scanf("%s", s[i] + 1);
	}
	for(int i = 1 ; i <= n ; ++ i) {
		bool flag = 1;
		for(int j = 1 ; j <= m ; ++ j) {
			if(s[i][j] == '#') {
				flag = 0;
			}
		}
		if(flag) {
			for(int j = 1 ; j <= m ; ++ j) {
				vis[i][j] = 1;
			}
		}
	}
	for(int j = 1 ; j <= m ; ++ j) {
		bool flag = 1;
		for(int i = 1 ; i <= n ; ++ i) {
			if(s[i][j] == '#') {
				flag = 0;
			}
		}
		if(flag) {
			for(int i = 1 ; i <= n ; ++ i) {
				vis[i][j] = 1;
			}
		}
	}
	// for(int i = 1 ; i <= n ; ++ i) {
	// 	for(int j = 1 ; j <= m ; ++ j) {
	// 		cout << vis[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	for(int i = 1 ; i <= n ; ++ i) {
		bool flag = 0;
		for(int j = 1 ; j <= m ; ++ j) {
			if(!vis[i][j]) {
				flag = 1;
				putchar(s[i][j]);
			}
		}
		if(flag) puts("");
	}
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int d(int x0, int y0,
      int x, int y) {
  int dx = abs(x - x0);
  int dy = abs(y - y0);
  if (dx + dy == 0) return 0;
  if (dx + dy == 1) return 1;
  if (max(dx, dy) == 1) return 2;
  if (dx + dy == 2) return 3;
  else return 100;
}

int main() {

  const int N = 10 + 2 + 2;
  int f[N][N];
  rep (i, N) rep (j, N) f[i][j] = 0;

  char comma;
  loop {
    int x, y, s;
    cin >> x >> comma >> y >> comma >> s;
    if (!cin) break;

    for (int xx = x - 2; xx < x + 3; ++xx) {
      for (int yy = y -  2; yy < y + 3; ++yy) {
        if (d(x,y,xx,yy) <= s) f[xx+2][yy+2]++;
      }
    }
  }

  int cx = 0,
      ac = -INF;
  for (int x = 2; x < N - 2; ++x) {
    for (int y = 2; y < N - 2; ++y) {
      if (!f[x][y]) ++cx;
      ac = max(ac, f[x][y]);
    }
  }

  cout << cx << endl;
  cout << ac << endl;


  return 0;
}

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

using namespace std;

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

	vector<string> t;
	for (int i = 0; i < s.length(); i++) {
		for (int j = 1; j <= min(7, (int)s.length() - i); j++) {
			t.emplace_back(s.substr(i, j));
		}
	}

	sort(t.begin(), t.end());
	unique(t.begin(), t.end());

	cout << t[k - 1] << endl;

	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int D, E; cin >> D >> E && (D|E);) {
    double ans = inf;
    rep(x, 101) rep(y, 101) {
      if(x + y == D) {
        ans = min(ans, abs(sqrt(x * x + y * y) - E));
      }
    }

    printf("%.15f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = a; i <= b; ++i) {
    if (c%i == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b){
    bool f = false;
    set<int> se;
    for(auto a :b)se.insert(a);
    for(int i = 0;i < 3;i++){
        bool ff = true;
        for(int j = 0;j < 3;j++){
            if(se.find(A[i][j]) == se.end()){
                ff = false;
            }
        }
        f = ff | f;
    }
    for(int i = 0;i < 3;i++){
        bool ff = true;
        for(int j = 0;j < 3;j++){
            if(se.find(A[j][i]) == se.end()){
                ff = false;
            }
        }
        f = ff | f;
    }
    //cout<<f<<endl;
    int uku[] = {A[0][0], A[1][1], A[2][2]};
    int uku1[] = {A[0][2], A[1][1], A[2][0]};
    bool ff = true;
    for(int i = 0;i < 3;i++){
        if(se.find(uku[i]) == se.end()){
            ff = false;
        }
    }
    f = ff | f;

    ff = true;
    for(int i = 0;i < 3;i++){
        if(se.find(uku1[i]) == se.end()){
            ff = false;
        }
    }
    f = ff | f;
    if(f){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

int main(){
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    ll cur = 0;
    ll l = 0;
    ll ans = 0;
    for (int r = 0; r < n; r++) {
        while (cur & a[r]) {
            cur ^= a[l];
            l++;
        }
        cur ^= a[r];
        ans += r - l + 1;
        //cout << r << ": " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
S=input()
a=[0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=="<":
        # a[i+1]=max(a[i+1],a[i]+1)
        a[i+1]=a[i]+1
for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        a[i]=max(a[i],a[i+1]+1)
print(sum(a))

Measured memory_bytes: 28860
A=[]
b=[]
n=list(map(int,input().split()))
for i in range(n[0]):
	A.append(list(map(int,input().split())))
for i in range(n[1]):
	b.append(int(input()))
	
for i in range(n[0]):
	num=0
	for j in range(n[1]):
		num=num+A[i][j]*b[j]
	print(num)


Measured memory_bytes: 6008
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/
struct Timer {
    int64_t start;
    const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32);
    }
};

Timer timer;

bool multicase = false;

ll n, m, k, w, num, a, b, c, d, e, h, q, ans, sum, l, r;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll x[500005], y[500005], z[500005];
ll dp[500005];

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    sort(x, x + n);
    reverse(x, x + n);
    for(int i=0;i<n;i++){
        int idx = i / 2;
        ans += x[idx];
    }
    ans -= x[0];
    p(ans);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 5216
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 100005;
const int MM = 1000000007;

ll A[MX], B[MX];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%lld%lld", A+i, B+i);

	ll s = 0, e = 3e18, m;
	while(s <= e){
		m = (s+e) / 2;
		ll tot = 0;
		for(int i = 1; i <= N; i++){
			if(m >= A[i]) tot += (m-A[i]) / B[i] + 1;
		}
		if( tot >= K ) e = m-1;
		else s = m+1;
	}swap(s, e);
	printf("%lld\n", e);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N;
	cin >> N;
	vector<LL> sum(100, 1);
	REPA(i, N+1){
		int d = i;
		for(int j=2;j*j<=d;++j){
			while(d%j==0){
				++sum[j];
				d/=j;
			}
		}
		if(d>1)++sum[d];
	}
	vector<LL> dp(76, 0);
	dp[1]=1;
	foreach(i, sum){
		vector<LL> dp2(76, 0);
		for(int j=1;j<=i;++j){
			PER(k, 75/j+1){
				dp2[k*j]+=dp[k];
			}
		}
		dp = dp2;
	}
	cout << dp[75] << endl;
	return 0;
}


Measured memory_bytes: 256
// N
// d1,d2,d3,d4,d5,,,,,,dn


//inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
		
	var i = 0;
   var d = [];                               //横並びの数字を配列にする
   for (var i = 0; i < n ; i++){
   var r= parseInt(tmp[i], 10);
   d[i] = r;}
 // console.log(d);
  
  tl=0;
  for(i=0;i<n;i++){
   for(j=i+1;j<n;j++){//console.log(d[i],d[j],tl);
                tl = tl+ d[i]*d[j];}
   }
  console.log(tl);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

ll _sum_vector(pair<int, int> pairs){
  if(pairs.first == 0 || pairs.second == 0){
    return 0;
  }
  return (pairs.first - 1) * (pairs.second - 1);
}

bool compare_pair(pair<ll, ll> pair1, pair<ll, ll> pair2){
  return (pair1.second < pair2.second);
}

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

    int n, k;
    cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if (mx < k){
      puts("-1");
      return 0;
    }
    vector<P> ans;
    rep(i,n-1){
      ans.push_back(P(i+1,n));
    }

    int add = mx-k;
    vector<P> edge;
    rep(i,n-1)rep(j,i) edge.push_back(P(i+1,j+1));
    rep(i,add) ans.push_back(edge[i]);
    cout << ans.size() << endl;
    rep(i, ans.size()){
      cout << ans[i].first << " " << ans[i].second << endl;
    }


    return 0;
}

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

int main(){
	string s;
	cin>>s;
	int paper = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'p')paper++;
	}
	cout<<(s.size() / 2) - paper<<endl;
	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0;i < n;i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  int kekka = 2000000000,cur;
  for(int i = 0;i < n - k + 1;i++){
    cur = abs(h.at(i) - h.at(i + k - 1));
    kekka = min(kekka,cur);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  vector<bool> dp(x+110);
  dp[0] = true;
  for (int i = 0; i <= x; i++) {
    if (dp[i]) {
      for (int j = 0; j <= 5; j++)
        dp[i+j+100] = true;
    }
  }
  cout << dp[x] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while( true ) {
	double n;
	cin >> n;
	if ( n == -1.0 ) break;

	int m = (int)( n * 16 );
	if ( n * 16 - m > 0 ) {
	  cout << "NA" << endl;
	} else {
	  for ( int i = 7; i >= 0; i-- ) {
		if ( ( 1 << ( i + 4 ) ) & m ) {
		  cout << 1;
		} else {
		  cout << 0;
		}
	  }
	  cout << ".";
	  for ( int i = 3; i >= 0; i-- ) {
		if ( ( 1 << i ) & m ) {
		  cout << 1;
		} else {
		  cout << 0;
		}
	  }
	  cout << endl;
	}	
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int a,b,c;cin >> a >> b >> c;
    if((c-a)*(c-b)<0) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int l,n;
  string s[105];
  cin>>n>>l;
  rep(i,n){
    cin>>s[i];
  }
  sort(s,s+n);
  rep(i,n){
    cout<<s[i];
  }
  cout<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    ll H;
    int N;
    cin >> H >> N;
    rep(i,N){
        ll a;
        cin >> a;
        H-=a;
    }
    if(H<=0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

class Pascal
{
  private:
    int sz;
    vector<vector<long long>> comb;

  public:
    Pascal(int sz) : sz(sz)
    {
        comb = vector<vector<long long>>(sz+1, vector<long long>(sz+1));
        for(int i = 0; i <= sz; i++)
        {
            for(int j = 0; j <= i; j++)
            {
                if(j == 0 || j == i) comb[i][j] = 1LL;
                else comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            }
        }
    }
    
    long long Combination(int n, int r)
    {
        if (r < 0 || n < r) return 0;
        return comb[n][r];
    }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, a, b;
    cin >> n >> a >> b;
    vector<LL> v(n);
    REP(i, n) cin >> v[i];

    sort(all(v), greater<LL>());

    LL sum = 0;
    REP(i, a) sum += v[i];

    Pascal ct(50);
    if(v[0] == v[a-1])
    {
        printf("%.6f\n", 1.0 * sum / a);

        int cnt = 0;
        REP(i, n) if(v[0] == v[i]) cnt++;
        LL ans = 0;
        FOR(i, a, b + 1) ans += ct.Combination(cnt, i);
        printf("%lld\n", ans);
    }
    else
    {
        printf("%.6f\n", 1.0 * sum / a);

        int cnt1 = 0, cnt2 = 0;
        REP(i, n) if(v[a-1] == v[i]) cnt1++;
        REP(i, a) if(v[a-1] == v[i]) cnt2++;
        LL ans = 0;
        ans += ct.Combination(cnt1, cnt2);
        printf("%lld\n", ans);
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, T;
int c[110], t[110];


signed main(){
	cin >> N >> T;
	rep(i, 0, N) cin >> c[i] >> t[i];

	int ans = INF;
	rep(i, 0, N)
		if(t[i] <= T) chmin(ans, c[i]);

	if(ans == INF) cout << "TLE" << endl;
	else cout << ans << endl;

	return 0;
}

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

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

bool cmp(const int a, const int b)
{
  return a > b;
}

int main(int argc, char** argv)
{
  int h[10];

  for (int i = 0; i < 10; i ++)
    std::cin >> h[i];

  std::sort(h + 0, h + 10, cmp);

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

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    int n;
    cin >> n;
    vector<vpii> xy(n);
    REP(i, n) {
        int a;
        cin >> a;
        REP(j, a) {
            int x, y;
            cin >> x >> y;
            xy[i].push_back(make_pair(x - 1, y));
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        bitset<15> b(bit);
        bool f = false;
        REP(i, n) {
            if(b[i]) {
                REP(j, xy[i].size()) {
                    if(b[xy[i][j].first] != (xy[i][j].second == 1)) {
                        f = true;
                        break;
                    }
                }
            }
            if(f) break;
            else if(i == n - 1) ans = max(ans, (int)b.count());
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,r,x,y;
    cin>>n>>r;
    if(n<=10){
        x=100*(10-n);
        y=x+r;
    }

    else
    {
        y=r;
    }
    cout<<y;
 return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    string a,b,c;
    cin >> a >> b >> c;
    //int n = a.size()+b.size()+c.size();
    bool aa=true,bb=false,cc=false;

    while(true){
        if(aa){
            if(a.size()==0){
                cout << 'A' << endl;
                return 0;
            }
            if(a[0]=='b'){
                aa=false;
                bb=true;
                a.erase(a.begin());
            }else if(a[0]=='c'){
                aa=false;
                cc=true;
                a.erase(a.begin());
            }else{
                a.erase(a.begin());
            }
        }else if(bb){
            if(b.size()==0){
                cout << 'B' << endl;
                return 0;
            }
            if(b[0]=='a'){
                aa=true;
                bb=false;
                b.erase(b.begin());
            }else if(b[0]=='c'){
                bb=false;
                cc=true;
                b.erase(b.begin());
            }else{
                b.erase(b.begin());
            }
        }else{
            if(c.size()==0){
                cout << 'C' << endl;
                return 0;
            }
            if(c[0]=='b'){
                cc=false;
                bb=true;
                c.erase(c.begin());
            }else if(c[0]=='a'){
                cc=false;
                aa=true;
                c.erase(c.begin());
            }else{
                c.erase(c.begin());
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<Pll> v(n);
    rep(i,n) cin >> v[i].fi >> v[i].se;
    sort(ALL(v));
    priority_queue<ll> pq;
    int idx=0;
    ll ans=0;
    for(int i=0;i<=m;i++){
        while(idx<n&&v[idx].fi<=i){
            pq.push(v[idx].se);
            idx++;
        }
        if(!pq.empty()){
            ans+=pq.top(); pq.pop();
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 5808
#include <cstdio>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
int a[100010], b[100010];
int n, k = 0,l = 1;
using namespace std;
int main()
{
    int n, k = 0,l = 1;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){scanf("%d", &b[i]);}
    for(int i = n; i >= 1;)//倒序搜索
    {
        if(b[i] == i) {
            a[l] = b[i],l++,k++;//把插出的数字填补上
            REP_(j, i, n){b[j] = b[j + 1];}
            i = n;
        }
        i--;
    }
    if(k == n)
    {
        for(int i = n; i >= 1; i--)
        {
            printf("%d\n",a[i]);//倒序输出
        }
    }
    else return printf("-1\n") * 0;
    return 0;
}





Measured memory_bytes: 128
#include <algorithm>

int uf[100010];
void inituf(int n){ for(int i = 0; i < n; i++) uf[i] = -1; }
int find(int x){ return uf[x] < 0 ? x : uf[x] = find(uf[x]); }
void unite(int x, int y){ if((x = find(x)) != (y = find(y))){ uf[x] += uf[y]; uf[y] = x; } }
bool same(int x, int y){ return find(x) == find(y); }

#include <cstdio>

int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    inituf(n);
    while(q--){
        int c,x,y;
        scanf("%d%d%d",&c,&x,&y);
        if(c){
            printf("%d\n",same(x,y));
        } else {
            unite(x,y);
        }
    }
}

Measured memory_bytes: 1048
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

AC = 0
WA = 1
TLE = 2
RE = 3

def main(argv)
  n = InputLine.to_i

  c = [0] * 4
  n.times do
    s = InputLine.to_s
    case s
    when 'AC' then
      c[AC] += 1
    when 'WA' then
      c[WA] += 1
    when 'TLE' then
      c[TLE] += 1
    when 'RE' then
      c[RE] += 1
    end
  end

  puts 'AC x '  + c[AC].to_s
  puts 'WA x '  + c[WA].to_s
  puts 'TLE x ' + c[TLE].to_s
  puts 'RE x '  + c[RE].to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  int y, m, d;
  char l1, l2;
  string ans="Heisei";
    cin >> y >> l1 >> m >> l2 >>d;
    if(2020<=y) ans="TBD";
    else if(y==2019 && 4<m) ans="TBD";
    cout << ans << endl;



}


Measured memory_bytes: 256
N = int(input())
works = []
for i in range(N):
  a, b = list(map(int, input().split()))
  work = {"time": a, "expired": b}
  works.append(work)

works = sorted(works, key=lambda x:x["expired"])

time = 0
res = "Yes"
for w in works:
  time += w["time"]
  if w["expired"] < time:
    res = "No"
    break

print(res)

Measured memory_bytes: 123736
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){

map<long long ,int>A;
map<int,int>B;

int N;
cin >>N;
long long a;
for(int i=0;i<N;i++){
cin >>a;
auto it=A.find(a);
if(A.find(a)!=A.end()){
    it->second++;
}
else{
A.insert(make_pair(a,1));
}
}
/* auto iter=A.begin();
int b;
for(int i=0;i<N;i++){
    b=A.count(iter->first);
    B.insert(make_pair(iter->first,b));//値とその個数
    iter++;
}
*/
auto it=A.begin();
long long Ans=0;
while(it!=A.end()){

if(it->second!=it->first){
    if(it->second>it->first){
    Ans+=it->second-it->first;
    }
    else{
    Ans+=it->second;
    }
}
it++;
}
cout<<Ans<<endl;

 return 0;
}


Measured memory_bytes: 6272
n=int(input())
x=list(map(int,input().split()))
k=0
for i in range(2,n):
	if x[i-2]<x[i-1]<x[i]:
		k=k+1
	elif x[i-2]>x[i-1]>x[i]:
		k=k+1
		
print(k)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,M;
ll dp[2003][2003];

int main(){
    cin >> N >> M;
    vector<int> s(N),t(M);
    rep(i,N) cin >> s[i];
    rep(i,M) cin >> t[i];

    dp[0][0] = 1;
    rep(i,N+1) dp[i][0]=1;
    rep(i,M+1) dp[0][i]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            dp[i+1][j+1] = (((dp[i+1][j] + dp[i][j+1])%mod)-dp[i][j]+mod)%mod;
            if(s[i] == t[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= mod;
            }
        }
    }

    /* for(int i=0;i<=N;i++){ */
    /*     for(int j=0;j<=M;j++){ */
    /*         cout << dp[i][j] << " "; */
    /*     } */
    /*     cout << endl; */
    /* } */

    cout << dp[N][M] << endl;
}


Measured memory_bytes: 31616