akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
 
int x , a;
cin>>x>>a;
if(x<a)cout<<0<<endl;
else cout<<10<<endl;


}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
    lli n, k;
    cin>>n>>k;
    vll A(n);
    loop(i, 0, n)
        cin>>A[i];
    vector<double> S(1001, 0.0);
    loop(i, 1, 1001){
        double ans = 0.0;
        loop(j, 1, i+1){
            ans += (double)j * ((1.0 / (double)i));
        }
        S[i] = ans;
    }
    vector<double> res(n, 0.0);
    loop(i, 0, n)
        res[i] = S[A[i]];
    double mx = 0.0;
    loop(i, 0, k)
        mx += res[i];
    double curr = mx;
    loop(i, k, n){
        curr += res[i];
        curr -= res[i-k];
        mx = max(mx, curr);
    }
    cout<<setprecision(15)<<mx<<"\n";
    return 0;
}   
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
/*char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))*/
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
int n,ans,a[100009];
int main(){
	n = rd();
	Rep(i,1,n){
		a[i] = rd();
	}sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	Rep(i,1,n){
		if(i+1 > a[i+1]){
			for(int j=i+1;a[j]==i;j++) ans^=1;
			ans |= (a[i]-i) & 1;
			puts(ans?"First":"Second");
			return 0;
		}
	}
	return 0;
}

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

int main(){
    int n, x;
    
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0)
            break;
    
        int count = 0;
        for(int a=1; a<=n; a++){
            for(int b=a+1; b<=n; b++){
                for(int c=b+1; c<=n; c++){
                    if(a + b + c == x)
                        count++; // count = count + 1;
                }
            }
        }
        cout << count << endl;
    }
        
    return 0;
}



Measured memory_bytes: 3036
def main():
    s = input()
    count = 0
    black_count = 0
    for i in range(len(s)):
        if s[i] == 'B':
            black_count += 1
        if s[i] == 'W':
            count += black_count

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67768
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <deque>
#include <cmath>
#include <iomanip>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
#define SORT(c) sort((c).begin(),(c).end())

bool cheak(int x, int y, int xMax, int yMax)
{
	return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 2147483647;


string	A[5010];
bool	d[5010][5010];
vector  <P> xa;
int		s[1010], t[1010];

int main()
{
	int n, m;
	cin >> n;
	REP(i, n)
	{
		int x;
		cin >> A[i] >> x;
		xa.push_back(P(x, i));
	}
	cin >> m;
	REP(i, m)
	{
		string S,T;
		cin >> S >> T;
		REP(j, n)
		{
			if (A[j] == S)
				s[i] = j;
			if (A[j] == T)
				t[i] = j;
		}
	}


	REP(i, m)
	{
		d[s[i]][t[i]] = true;
		d[t[i]][s[i]] = true;
	}

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

	bool f = true;
	while (f)
	{
		f = false;
		REP(i, n)
		{
			REP(j, n)
			{
				if (d[xa[i].second][xa[j].second])
				{
					if (xa[i].first != xa[j].first)f = true;
					int Min = min(xa[i].first, xa[j].first);
					xa[i].first = Min; xa[j].first = Min;
					
				}
			}
		}
		sort(xa.begin(), xa.end());
	}

	int ans = 0;
	REP(i, n)
		ans += xa[i].first;

	cout << ans << endl;

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n, l;
  while (cin >> n >> l) {
    vector<int> v;;
    for (int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      v.push_back(a);
    }

    int idx = -1;
    for (int i = 0; i + 1 < v.size(); ++i) {
      if (l <= v[i] + v[i + 1]) {
        idx = i;
        break;
      }
    }

    if (idx == -1) {
      cout << "Impossible" << endl;
      continue;
    }

    cout << "Possible" << endl;
    for (int i = 0; i < idx; ++i) {
      cout << i + 1 << endl;
    }
    for (int i = n - 2; idx <= i; --i) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1272
N = int(input())
S = [input() for _ in range(N)]

from collections import Counter
C = Counter(S)

maxC = max(C.values())

A=[]
for k,v in C.items():
  # print(k,v)
  if v==maxC: A.append(k)

A = sorted(A)

for a in A:
  print(a)



Measured memory_bytes: 38924
#include <stdio.h>
#include <math.h>
 
int isPrime(int);

int isPrime(int a){
  int i;
  if(a==2)
  return 1;
  if(a<2||a%2==0)
  return 0;
  i=3;
  while(i<=sqrt(a)){
    if(a%i==0)
     return 0;
    i+=2;
  }
  return 1;
}

int main(){
  int a[10000],i,n,k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(isPrime(a[i])==1)k++;
  }
 printf("%d\n",k);
 return 0;
}
     

Measured memory_bytes: 1808
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
	int n;
	cin >> n;
	vl a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll cnt = 0;
	rep(i, n) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
li read(){
	li x = 0,y = 1;
	char c;
	c = gc;
	while(!isdigit(c)){
		if(c == '-') y = -1;
		c = gc;
	}
	while(isdigit(c)){
		x = (x << 1) + (x << 3) + (c ^ '0');
		c = gc;
	}
	return x * y;
}
void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
int as,a,b,c,x,y;
int main(){
	a = read();b = read();c = read();x = read();y = read();
	int mn = min(x,y);
	as = min(c * 2,a + b) * mn;
	x -= mn;y -= mn;
	if(x) as += min(c * 2,a) * x; 
	else if(y) as += min(c * 2,b) * y;
	print(as);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;

vector<vector<P>> to;
vector<int> color;

void dfs(int v,int pa=-1,int c=0){
    int n=1;
    for(P p : to[v]){
        if(p.first==pa){continue;}
        if(n==c)n++;
        color.at(p.second)=n;
        n++;
        dfs(p.first,v,color.at(p.second));
    }
    return;
}

int main() {
    int N;
    cin>>N;
    to.resize(N,vector<P>(0));
    color.resize(N-1);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].pb({b,i});
        to[b].pb({a,i});
    }
    int num=0;
    rep(i,N){
        chmax(num,sz(to[i]));
    }
    cout<<num<<endl;
    dfs(0);
    rep(i,N-1){
        cout<<color.at(i)<<endl;
    }
}

Measured memory_bytes: 10960
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Seg():
    def __init__(self, na, default, func):
        if isinstance(na, list):
            n = len(na)
        else:
            n = na
        i = 1
        while 2**i <= n:
            i += 1
        self.D = default
        self.H = i
        self.N = 2**i
        if isinstance(na, list):
            self.A = [default] * (self.N) + na + [default] * (self.N-n)
            for i in range(self.N-1,0,-1):
                self.A[i] = func(self.A[i*2], self.A[i*2+1])
        else:
            self.A = [default] * (self.N*2)
        self.F = func

    def find(self, i):
        return self.A[i + self.N]

    def update(self, i, x):
        i += self.N
        self.A[i] = x
        while i > 1:
            i = i // 2
            self.A[i] = self.merge(self.A[i*2], self.A[i*2+1])

    def merge(self, a, b):
        return self.F(a, b)

    def total(self):
        return self.A[1]

    def query(self, a, b):
        A = self.A
        l = a + self.N
        r = b + self.N
        res = self.D
        while l < r:
            if l % 2 == 1:
                res = self.merge(res, A[l])
                l += 1
            if r % 2 == 1:
                r -= 1
                res = self.merge(res, A[r])
            l >>= 1
            r >>= 1

        return res


def main():
    n = I()
    h = LI()
    a = LI()

    def f(a,b):
        if a < b:
            return b
        return a

    seg = Seg(n+1,0,f)
    for b,c in zip(h,a):
        t = seg.query(0, b)
        seg.update(b, t + c)

    return seg.total()


print(main())


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

int main()
{
  int n, m, x, a, count_0_cost = 0;

  cin >> n >> m >> x;
  for (int i = 0; i < m; i++)
  {
    cin >> a;
    if (a < x)
      count_0_cost++;
  }
  cout << (count_0_cost <= m / 2 ? count_0_cost : m - count_0_cost) << endl;
}

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

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll A_num = min(A, K);
  if(A_num ==K){
      cout << A_num << endl;
      return 0;
  }
  ll B_num = min(B, K-A_num);
  if(A_num+B_num ==K){
    cout << A_num << endl;
    return 0;
  }
  ll C_num = K-A_num-B_num;
  cout << A_num-C_num << endl;
  return 0;
}

Measured memory_bytes: 3504
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const double PI=3.1415926535897932;
using namespace std;
typedef long long ll;

int main(void){
    ll h,w,q;
    cin>>h>>w>>q;
    int a[h][w];
    rep(i,h){
        rep(j,w){
            char c;
            cin>>c;
            if(c=='.')a[i][j]=1;
            else a[i][j]=0;
        }
    }
    int ans=0;
    for(int bit=0;bit<(1<<h);bit++){
        vector <int>ex;
        for(int i=0;i<h;i++){
            if(bit&1<<i){
                ex.push_back(i);
            }
        }
        for(int c=0;c<(1<<w);c++){
            vector <int> ew;
            for(int j=0;j<w;j++){
                if(c&1<<j){
                    ew.push_back(j);
                }
            }
            int s=0;
            rep(k,h){
                int fa=1;
                for(auto x:ex){
                    if(k==x)fa=0;
                }
                if(fa==0)continue;
                rep(l,w){
                    int f=1;
                    for(auto y:ew){
                        if(l==y)f=0;
                    }
                    if(f){
                        if(a[k][l]==0)s++;
                    }
                }
            }
            if(q==s)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=20010;
int f[N],a[N],b[N],n,h;
int main()
{
	h=gi();n=gi();memset(f,63,sizeof(f));f[0]=0;
	for(int i=1;i<=n;i++)a[i]=gi(),b[i]=gi();
	for(int i=1;i<=n;i++)
		for(int j=0;j<=20000;j++)
			if(j>=a[i])f[j]=min(f[j],f[j-a[i]]+b[i]);
	int ans=1e9+10;
	for(int i=h;i<=20000;i++)
		ans=min(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;cin >> n >> x;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans = 0;
	rep(i, n - 1){
		if(a.at(i) + a.at(i + 1) > x){
			int t = a.at(i) + a.at(i + 1) - x;
			if(t > a.at(i + 1)){
				ans += t;
				a.at(i + 1) = 0;
			}
			else{
				ans += t;
				a.at(i + 1) -= t;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    ll arr[n];
    rep(i,0,n)cin>>arr[i];
    sort(arr,arr+n);
    set<pair<ll,ll> > mp;
    ll cnt=arr[n-1];
    ll tmp=0;
    mp.insert({arr[n-2],tmp});
    tmp++;
    mp.insert({arr[n-2],tmp});tmp++;
    repn(i,n-3,0){
        //for(auto x : mp)cout<<x.first<<" ";cout<<"\n";
        auto it=mp.end();it--;
        cnt+=it->first;//cout<<it->first<<":\n ";
        mp.insert({arr[i],tmp});
        
        tmp++;
        mp.insert({arr[i],tmp});
        tmp++;
        mp.erase({it->first,it->second});
    }
    cout<<cnt;
 
return 0;
}

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

bool g[10][10];

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v;
  rep(i,n-1) v.push_back(i+1);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a][b]=true;
    g[b][a]=true;
  }
  int ans=0;
  do{
    if(g[0][v[0]]==false) continue;
    bool flag=true;
    rep(i,n-2){
      if(g[v[i]][v[i+1]]==false) flag=false;
    }
    if(flag) ans++;
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans<<endl;    
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    int t = 0;
    int ao = 0;
    for(int i=0; i<100; i++){
    if(c-b*i>0){
        t++;
        }
    if(a-d*i>0){
        ao++;
    }
}
        if(t<=ao){
       	System.out.println("Yes");
        }else{
        System.out.println("No");
    }
}
}


Measured memory_bytes: 35796
#include <stdio.h>

int main(){
        int N;
        scanf("%d",&N);
        int i,a[100]={};
        for(i=0;i<N;i++){
                scanf("%d",&a[i]);
        }
        int Max=0,Min=1000;
        for(i=0;i<N;i++){
                if(Max<=a[i]){
                        Max = a[i];
                }
                if(a[i]<=Min){
                        Min = a[i];
                }
        }
        if(N==1){
                Max = a[0];
                Min = Max;
        }
        if(N==2){
                if(a[0]>a[1]){
                        Max = a[0];
                        Min = a[1];
                }else{
                        Max = a[1];
                        Min = a[0];
                }
        }
        printf("%d",Max-Min);
        return 0;
}


Measured memory_bytes: 128
import sys

read = sys.stdin.buffer.read
#input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	s,t=input().split()
	a,b=map(int,input().split())
	u=input()
	
	if u==s:
		a-=1
	else:
		b-=1
	print(a,b)
	
	
	
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
a, b, c = gets.chomp.split(" ").map(&:to_i)
x = a
h = Hash.new()
while true
  k = (x + c) % b
  break if h.has_key?(k)
  h[k] = 1
  x += a
end
if h.has_key?(0) then
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define SIZE 6 // Hoshinaの文字数-1
typedef long long ll;

int main(void) {
    int n;
    scanf(" %d ", &n);
    for (int i = 0; i < n; i++) {
        string s;
        getline(cin, s);
        while (1) {
            string::size_type index = s.find("Hoshino");
            if (index == string::npos) break;
            else s[index + SIZE] = 'a';
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
class Mod:
    def __init__(self, mod, n_max):
        """
        イニシャライザ
        予め 1~nの階乗と階乗の逆元を計算しておく
        :param mod: 法
        :param n_max: nの最大値(100,000で約1秒)
        """
        self.mod = mod
        self.n_max = n_max
        self.facts = [1, 1]
        self.inverses = [None, 1]
        self.fact_inverses = [1, 1]

        for i in range(2, self.n_max + 1):
            self.facts.append(self.facts[i - 1] * i % self.mod)
            # self.inverses.append(mod_inverse(i, self.mod))
            self.inverses.append(
                self.mod - self.inverses[self.mod % i] *
                (self.mod // i) % self.mod
            )
            self.fact_inverses.append(
                self.fact_inverses[i - 1] * self.inverses[i] % self.mod
            )

    def combination(self, n, k):
        if k > n:
            raise ValueError
        elif k == n:
            return 1
        elif k == 0:
            return 1

        denominator = self.fact_inverses[k] * self.fact_inverses[n - k] % self.mod
        return self.facts[n] * denominator % self.mod

    def permutation(self, n, r):
        return self.facts[n] * self.fact_inverses[n - r] % self.mod


N, M = map(int, input().split(' '))
MOD = 10 ** 9 + 7

m = Mod(MOD, M)
mPn = m.permutation(M, N)

b = mPn
x = mPn

for k in range(1, N + 1):
    dup = m.permutation(M - k, N - k) * m.combination(N, k) % MOD
    if k % 2 == 1:
        b -= dup
    else:
        b += dup
    b %= MOD

print(mPn * b % MOD)


Measured memory_bytes: 68492
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long>vec(M);
  for(long long i =0;i < M;i++){
    cin >> vec.at(i);
  }
  for(long long i =0;i < M;i++){
    N -= vec.at(i);
  }
  if(N < 0){
    cout << "-1"<<endl;
  }
  else{
    cout<< N <<endl;
  }
  
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int ai, aj, ai2; 

int main() {
	int A[5];
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < 5; i++) {
	    if (A[i] % 10 == 0) ai = A[i] % 10;
	    else ai = 10 - (A[i] % 10);
		for (int j = i; j < 5; j++) {
		    if (A[j] % 10 == 0) aj = A[j] % 10;
	        else aj = 10 - (A[j] % 10);
			if (ai < aj) swap(A[i], A[j]);
		}
	}
	for (int i = 4; i > 0; i--) {
	    if (A[i] % 10 == 0) ai2 = A[i] % 10;
	    else ai2 = 10 - (A[i] % 10);
		A[i] += ai2;
	}
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		sum += A[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll gcd(ll x, ll y){
    return y?gcd(y,x%y):x;
}
vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for(ll i = 2; i*i <= n; ++i) {
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i == 0) {
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b; cin >> a >> b;
    ll g = gcd(a,b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

vector<ll> v;

void f(ll i) {
  if (i > 3234566667) return;
  v.push_back(i);
  ll p = i % 10;
  if (p == 0) {
    f(i * 10 + p);
    f(i * 10 + p + 1);
  }else if (p == 9) {
    f(i * 10 + p - 1);
    f(i * 10 + p);
  }else {
    f(i * 10 + p - 1);
    f(i * 10 + p);
    f(i * 10 + p + 1);
  }
}

int main()
{
  ll k;
  cin >> k;
  
  FOR(i, 1, 10) {
    f(i);
  }
  sort(ALL(v));
  cout << v[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (int i(0); i < (a); ++i)
#define FOR(i, a, b) for (int i(a); i <= (b); ++i)

#ifdef LOCAL
#define NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define F_1(F, ARG) F(ARG)
#define F_2(F, ARG, ...) F(ARG) F_1(F, __VA_ARGS__)
#define F_3(F, ARG, ...) F(ARG) F_2(F, __VA_ARGS__)
#define F_4(F, ARG, ...) F(ARG) F_3(F, __VA_ARGS__)
#define F_5(F, ARG, ...) F(ARG) F_4(F, __VA_ARGS__)
#define F_6(F, ARG, ...) F(ARG) F_5(F, __VA_ARGS__)
#define FOR_EACH(F, ...)                                                       \
  NTH_ARG(__VA_ARGS__, F_6, F_5, F_4, F_3, F_2, F_1)(F, __VA_ARGS__)

#define C_RED "\033[2;31m"
#define C_BLUE "\033[1;34m"
#define C_GREEN "\033[1;32m"
#define C_RESET "\033[0m"

#define watch(x) cerr << C_GREEN #x " = " C_BLUE << (x) << C_RESET "; ";
#define debug(...)                                                             \
  cerr << C_RED "Line " << __LINE__ << ": " C_RESET;                           \
  FOR_EACH(watch, __VA_ARGS__)                                                 \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  vector<ll> dp(1 << n);
  REP(i, n) REP(j, n) cin >> a[i][j];

#define onBit(mask, bit) (mask >> bit & 1)

  for(int mask = 0; mask < (1 << n); ++mask){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        if (onBit(mask, i) && onBit(mask, j)){
          dp[mask] += a[i][j];
        }
      }
    }
  }
  
  for(int mask = 0; mask < (1 << n); ++mask){
    for(int j = mask; j > 0; j = (j - 1) & mask){
      auto bmask = bitset<8>(mask);
      auto bj = bitset<8>(j);
      auto bjmask = bitset<8>(j ^ mask);
      debug(bmask, bj, bjmask);
      dp[mask] = max(dp[mask], dp[j] + dp[j ^ mask]);
    }
  }
  cout << dp[(1 << n) - 1] << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N;
    int C[51];
    int V[51];
   
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> V[i];
    }
    for(int i = 1; i <= N; i++) {
        cin >> C[i];
    }

    int ans = 0;

    for(int i = 1; i <= N; i++) {
        if(V[i] - C[i] > 0) {
            ans += V[i] - C[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	py = defaultdict(list)
	si_ban = []
	for _ in range(m):
		x,y = map(int,input().split())
		si_ban.append(y)
		py[x].append(y)
	ans = {}
	for k,v in py.items():
		v.sort()
		for i in range(1,len(v)+1):
			ans[v[i-1]] = str(k).zfill(6) + str(i).zfill(6)
	for i in si_ban:
		print(ans[i])

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 121556
N,Q=map(int,input().split())
E=[[] for _ in range(N)]
for i in range(N-1):
  x,y=map(int,input().split())
  x-=1
  y-=1
  E[x].append(y)
  E[y].append(x)
par=[-1]*N
par[0]=0
stack=[0]
order=[]
while stack:
  u=stack.pop()
  order.append(u)
  for v in E[u]:
    if par[v]==-1:
      stack.append(v)
      par[v]=u
counter=[0]*N
for i in range(Q):
  u,x=map(int,input().split())
  u-=1
  counter[u]+=x
for i in order:
  if i==0:
    pass
  else:
    counter[i]+=counter[par[i]]
for i in range(N):
  counter[i]=str(counter[i])
print(' '.join(counter))

Measured memory_bytes: 133132
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 1000000009
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
int main(){
    setIO();
    ll n,x,t;
    cin>>n>>x>>t;
    ll tmp=n/x;
    if(n%x)
      tmp++;
    tmp*=t;
    cout<<tmp;


}


Measured memory_bytes: 3640
n, m = map(int, input().split())
t, d = {}, []

if n > m:
    print(m)
else:
    for i in range(m):
        a, b = map(int, input().split())
        t[a] = t.get(a, 0) + 1
        t[b] = t.get(b, 0) + 1
        d.append((a, b))

    while True:
        b = 0
        for i in t:
            if t[i] == 1:
                for j in d:
                    if j[0] == i or j[1] == i:
                        for k in j:
                            if k != i and t[k] > 1:
                                t[k] -= 1
                                t[i] = 0
                                b += 1

        if b == 0:
            break

    b = 0
    for i in t:
        if t[i] == 0:
            b += 1
    print(b)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] > 0 && a[i]%2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define C getchar()
inline int read() {
	int num = 0;
	char c = C;
	for(;c<'0' || c>'9';c=C);
	for(;c>='0' && c<='9';c=C) num = (num << 1) + (num << 3) + (c ^ 48);
	return num;
}

//int nxt[200010],head[100010],to[200010],tot;
//
//inline void add(int x,int y) {
//	nxt[++tot] = head[x],head[x] = tot,to[tot] = y;
//}

int vis[100010][12];

vector<int> edge[100010];

inline void putc(int x,int d,int cl) {
	if (d == -1) return ;
	if (vis[x][d]) return ;
	vis[x][d] = cl;
	for(int i=0;i<edge[x].size();++i) putc(edge[x][i] , d - 1 , cl);
}

int n,m,Q;
struct node {
	int rt,d,cl;
}a[100010];

int main() {
//	freopen("1.in","r",stdin);
//	freopen("d.out","w",stdout);
	n = read(),m = read();
	for(int i=1;i<=m;++i) {
		int u = read(),v = read();
		edge[u].push_back(v);
		edge[v].push_back(u);
//		add(u , v);add(v , u);
	}
//	for(int i=1;i<=n;++i) add(i , i);
  for(int i=1;i<=n;++i) edge[i].push_back(i);
	
	Q = read();
	for(int i=1;i<=Q;++i) a[i].rt = read(),a[i].d = read(),a[i].cl = read();
	for(int i=Q;i>=1;--i) putc(a[i].rt , a[i].d , a[i].cl);
	for(int i=1;i<=n;++i) printf("%d\n",vis[i][0]);
	return 0;
}

Measured memory_bytes: 12408
use std::io::stdin;
use std::cmp::min;

#[allow(dead_code)]
fn input_ints() -> Vec<i64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => Vec::<i64>::new(),
    }
}

#[allow(dead_code)]
fn input_strs() -> Vec<String> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.to_string()).collect(),
        Err(_) => Vec::<String>::new(),
    }
}


#[allow(unused_variables)]
fn solve(){
    let inp = input_ints();
    let n = inp[0];
    let a = inp[1];
    let b = inp[2];

    let points = input_ints();

    let mut tired: i64 = 0;

    for i in 0..n-1 {
        tired += min(b, (points[i as usize +1] - points[i as usize]) * a);
    }

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

fn main() {
    solve();
}


Measured memory_bytes: 2684
#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  st first
#define  nd second
#define int long long

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
#define TIMES_PER_SEC (CLOCKS_PER_SEC)



double get_absolute_time()
{
	return (double)clock()/TIMES_PER_SEC;
}
double starttime_acrush;
void starttime()
{
	starttime_acrush=get_absolute_time();
}
double gettime()
{
	return get_absolute_time()-starttime_acrush;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define MOD   1000000007
#define maxn 100002
#define inf 1e18

int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int h , n  ;
  cin >> h >> n ;
  int ans[10001];
  for(int i = 0 ; i<10001; i ++)
    ans[i] = inf;
  ans[0] = 0 ;
  int A[10001];
  int B[10001];
  for(int i = 0 ; i < n ; i++)
    cin >>A[i] >> B[i];
  for( int i = 0 ; i <10001;i++){
    for( int j = 0 ; j < n ; j++ ){
        if(i-A[j]>0){
            ans[i] = min(ans[i],ans[i-A[j]]+B[j]);
        }
        else{
            ans[i] = min(ans[i],B[j]);
        }
    }
  }
  cout << ans[h];


  //cout <
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int x, a, b; cin >> x >> a >> b;

	if (a - b>=0) {
		cout << "delicious" << endl;
	}
	else {
		if (x + a < b) {
			cout << "dangerous" << endl;
		}
		else {
			cout << "safe" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{

          ll n,k;
          cin>>n>>k;
          if(500LL*n>=k){
                    cout<<"Yes"<<endl;
          }
          else{
                    cout<<"No"<<endl;
          }
}


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

using namespace std;

char date[105];
int ndate[105];

int main()
{
	while(scanf("%s",date)!=EOF)
	{
		for(int i=0;i<105;i++)
		{
			if(date[i]=='I')ndate[i]=1;
			if(date[i]=='V')ndate[i]=5;
			if(date[i]=='X')ndate[i]=10;
			if(date[i]=='L')ndate[i]=50;
			if(date[i]=='C')ndate[i]=100;
			if(date[i]=='D')ndate[i]=500;
			if(date[i]=='M')ndate[i]=1000;
		}
		int answer=0;
		for(int i=104;i>0;i--)
		{
			if(ndate[i]>ndate[i-1])
			{
				answer-=ndate[i-1];
			}
			else if(ndate[i]==0)
			{
				answer+=ndate[i-1];
			}
			else
			{
				answer+=ndate[i-1];
			}
		}
		printf("%d\n",answer);
		fill(date,date+105,'\0');
		fill(ndate,ndate+105,0);
	}
}

Measured memory_bytes: 0
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>

using namespace std;

int W,H,N;

int X1[1000],X2[1000],Y1[1000],Y2[1000];

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

bool fld[6000][6000];

int compress(int *x1,int *x2,int w){
  vector<int> xs;

  for(int i=0;i<N;i++){
    for(int d=-1;d<=1;d++){
      int tx1=x1[i]+d,tx2=x2[i]+d;
      if(1<=tx1&&tx1<=w) xs.push_back(tx1);
      if(1<=tx2&&tx2<=w) xs.push_back(tx2);
    }
  }

  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());

  for(int i=0; i<N; i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }

  return xs.size();
}

int main(){

while(1){

 scanf("%d%d",&W,&H);

 if(W==0) break;

 scanf("%d",&N);

 for(int i=0; i<N; i++){
  int x1,y1,x2,y2;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  X1[i]=x1+1;
  Y1[i]=y1+1;
  X2[i]=x2;
  Y2[i]=y2;
 }

 W=compress(X1,X2,W);
 H=compress(Y1,Y2,H);

 memset(fld,0,sizeof(fld));
 for(int i=0;i<N;i++){
  for(int y=Y1[i];y<=Y2[i];y++){
   for(int x=X1[i];x<=X2[i];x++){
      fld[y][x]=true;
   }
  }
 }

 int ans=0;
 for(int y=0;y<H;y++){
  for(int x=0;x<W;x++){
    if(fld[y][x]) continue;
    ans++;

    queue<pair<int,int> > que;
    que.push(make_pair(x,y));
   while(!que.empty()){
    int sx=que.front().first,sy=que.front().second;
    que.pop();

    for(int i=0; i<4; i++){
      int tx=sx+dx[i],ty=sy+dy[i];
      if(tx<0||W<=tx||ty<0||H<=ty) continue;
      if(fld[ty][tx]) continue;
      que.push(make_pair(tx,ty));
      fld[ty][tx]=true;
    }
   }
  }
 }

 printf("%d\n",ans);
 
 }

   return 0;

}

Measured memory_bytes: 36404
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#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 vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll N, M;
	cin >> N >> M;
	if (N > M / 2) {
		cout << M / 2 << endl;
	}
	else {
		ll ans = N;
		M -= N * 2;
		N = 0;
		ans += M / 4;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256