akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main() {
	int N;
	cin >> N;
	int ptr = 0;
	int res = 0;
	int a[100001];
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a, a + N);
	while (ptr < N) {
		int cc = a[ptr], f = 0;
		while (ptr < N&&a[ptr] == cc) {
			f++, ptr++;
		}
		res += f % 2;
	}
	cout << res << endl;
	return 0;
}

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

int main()
{
  long n, a, b;
  cin >> n >> a >> b;
  long q, r, sum;
  q = n / (a + b);
  r = n % (a + b);
  sum = q * a;
  if (r != 0)
  {
    if (r < a)
    {
      sum = sum + r;
    }
    else
    {
      sum = sum + a;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2583().doIt();
    }
    class aoj2583{
    	char map[][] = new char[1000][1051];
    	int MAX = 0;
    	void clear(){
    		for(int i = 0;i < 1000;i++){
    			for(int j = 0;j < 1051;j++){
    				map[i][j] = '-';
    			}
    		}
    	}
    	void set(int n){
    		for(int i = 0;i < n;i++){
				String str = sc.next();
				MAX = Math.max(MAX,str.length());
				char ctr[] = str.toCharArray();
				for(int j = 0;j < ctr.length;j++){
					map[i][j] = ctr[j];
					if(ctr[j] == '.')map[i][j] = ' ';
					if(j > 0){
						if(ctr[j] != '.' && ctr[j-1] == '.')map[i][j-1] = '+';
					}
				}
			}
    	}
    	void join(int n){
    		for(int i = 1;i < n;i++){
    			for(int j = 0;j < MAX;j++){
    				if(map[i][j] != '+')continue;
    				int ii = i - 1;
    				while(ii > 0){
    					if(map[ii][j] != ' ')break;
    					else map[ii][j] = '|';
    					ii--;
    				}
    			}
    		}
    	}
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			if(n == 0)break;
    			clear();
    			set(n);
    			join(n);
    			for(int i = 0;i < n;i++){
    				for(int j = 0;j < 1051;j++){
    					if(map[i][j] == '-')break;
    					System.out.print(map[i][j]);
    				}
    				System.out.println();
    			}
    		}
    	}
    }
}

Measured memory_bytes: 75104
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int main(){
  int x[5];
  int answer;
  for(int i=0;i<5;i++){
    cin>>x[i];
    if(x[i]==0) answer=i+1;
  }
  cout<<answer<<endl;
  
  return 0;
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll n,a,b,min=0;
    cin >> n>>a>>b;

    if((b-a)%2==0)
    {
          min=(b-a)/2;
      cout<<min<<endl;
  return 0;
    }

    if(b-1>n-a)
    {
      cout<<n-b+1+(b-a)/2 <<endl;
      // if(min!=0 && min<n-a)
      // {
      //    cout<< n-a-1<<endl;
      // }else{
      //    cout<< n-a<<endl;
      // }
     
    }else
    {
      cout<<a-1+1+(b-a)/2<<endl;
//       if(min!=0 && min<b-1)
//       {
//         cout<<min<<endl;
//       }else
//       {
// cout << b-1 << endl;
//       }

    }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int a[2][100100];

int main() {
	cin >> n;
	rep(i, n)cin >> a[0][i];
	rep(i, n)cin >> a[1][i];
	int ans = 0;
	rep(i, n) {
		int num = 0;
		rep(j, n) {
			if (j < i)num+= a[0][j];
			else if (j == i)num += (a[0][j] + a[1][j]);
			else num += a[1][j];
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

vector<vector<vector<ll>>> dp(110, vector<vector<ll>>(110,vector<ll>(410)));

int main(){
    ll N,W;
    cin >> N >> W;
    rep(i,110) rep(j,110) rep(k,410) dp[i][j][k] = 0;
    vector<ll> v(N),w(N);
    rep(i,N){
       cin >> w[i] >> v[i];
    }
    ll base = w[0];
    rep(i,N){
       w[i] -= base;
    }
    rep(i,N) {
       rep(j,N) {
          rep(k,410) {
            if(w[i] <= k){
             dp[i+1][j+1][k] = max(dp[i][j][k-w[i]] + v[i],dp[i][j+1][k]);
            }else{
             dp[i+1][j+1][k] = dp[i][j+1][k];
            }
         }
      }
   }
   ll ans = 0;
   rep(i,N+1){
      if(W - i*base < 0) break;
      ans = max(ans,dp[N][i][min(W-base*i,3*N)]);
   }
   cout << ans << endl;
}


Measured memory_bytes: 39936
#include <iostream>
#include <vector>

int main(void){
    int N, M, ans_n=0, ans_p=0;
    std::cin >> N >> M;
    std::vector<std::vector<int>> A(N, std::vector<int>(2, 0));

    for (int i=0; i<M; ++i){
        int p;
        std::string s;
        std::cin >> p >> s;
        if (s == "AC"){
            A.at(p - 1).at(1) = 1;
        } else if (A.at(p - 1).at(1) == 0){
            ++A.at(p - 1).at(0);
        }
    }

    for (std::vector<int> x: A){
        if (x.at(1) == 1){
            ++ans_n;
            ans_p += x.at(0);
        }
    }

    std::cout << ans_n << " " << ans_p << std::endl;

    return 0;
}


Measured memory_bytes: 8780
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string S;
  cin >> S;

  vector<int> a(S.size(),0);
  REP(i,S.size()){
    if(S.at(i) == 'A'||S.at(i) == 'G'||S.at(i) == 'C'||S.at(i) == 'T'){
      a.at(i) = 1;
    }
  }

  int MAX = 0;
  int cnt = 0;
  REP(i,a.size()){
    if(a.at(i) == 1){
      cnt++;
      MAX = max(MAX,cnt);
    }else{
      cnt = 0;
    }
  }
  cout << MAX <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var s = ReadText();
            var K = ReadLong();
            K--;//インデックス変換
            var l = new SortedSet<string>();
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 1; j < s.Length - i + 1; j++)
                {
                    var sub = s.Substring(i, j);
                    if (l.Count > K && l.ToList()[(int)K].CompareTo(sub) < 0)
                    {
                        break;
                    }
                    l.Add(sub);
                }
            }

            return l.ToList()[(int)K];
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 38076
Qs = readlines.drop(1).map{|l| l.split.map(&:to_i)}

class PQ
  attr :s

  def initialize
    @q = [nil]
    @s = 0
  end

  def b_up(i)
    p = i / 2
    return if i <= 1 || @q[p] <= @q[i]
    @q[i], @q[p] = @q[p], @q[i]
    b_up(p)
  end

  def add(e)
    @q << e
    @s += e
    b_up(@q.size - 1)
  end

  def b_down(i)
    c = i * 2
    return if c >= @q.size
    c += 1 if c != @q.size - 1 && @q[c] > @q[c + 1]
    return if @q[i] <= @q[c]
    @q[i], @q[c] = @q[c], @q[i]
    b_down(c)
  end

  def pop
    @q[1], @q[-1] = @q[-1], @q[1]
    r = @q.pop
    @s -= r
    b_down(1)
    r
  end

  def top
    @q[1]
  end
end

l, r = PQ.new, PQ.new
_, a, c = Qs.shift
l.add(-a)
r.add(a)
Qs.each do |q, a, b|
  if q == 1
    c += b
    case
    when a < -l.top
      m = -l.pop
      c += m - a
      r.add(m)
      l.add(-a)
      l.add(-a)
    when r.top < a
      m = r.pop
      c += a - m
      l.add(-m)
      r.add(a)
      r.add(a)
    else
      l.add(-a)
      r.add(a)
    end
  else
    puts "#{-l.top} #{c}"
  end
end

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

int n,k;
long long x[55],y[55];
long long cx[55],cy[55];
int main(){
  std::cin>>n>>k;
  for(int i=0;i<n;++i)
    std::cin>>x[i]>>y[i];
  
  std::copy(x,x+n,cx);
  std::copy(y,y+n,cy);
  std::sort(x,x+n);
  std::sort(y,y+n);
  
  long long ans=9223372036854775807;
  
  for(int xl=0;xl<n;++xl)
    for(int xr=xl+1;xr<n;++xr)
      for(int yl=0;yl<n;++yl)
        for(int yr=yl+1;yr<n;++yr){
          auto x1=x[xl],x2=x[xr];
          auto y1=y[yl],y2=y[yr];
          int num=0;
          for(int i=0;i<n;++i)
            if(x1<=cx[i]&&cx[i]<=x2&&y1<=cy[i]&&cy[i]<=y2)
              ++num;
          if(num>=k)
            ans=std::min(ans,(x2-x1)*(y2-y1));
        }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
///#pragma GCC optimize("O3,unroll-loops")
///#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

int n;
vector<pair<ll, ll> >v;
ll dp[2004][2004];

ll solve(int pos, int i, int j)
{
    if(pos >= n)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll x = solve(pos+1, i+1, j) + (v[pos].first*(abs(v[pos].second - i)));
    ll y = solve(pos+1, i, j-1) + (v[pos].first*(abs(v[pos].second - j)));
    dp[i][j] = max(x, y);
    return dp[i][j];
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    mem(dp, -1);
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        ll a;
        cin>>a;
        v.push_back({a, i});
    }
    sort(v.rbegin(), v.rend());
    cout<<solve(0, 0, n-1)<<endl;

    //End();
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  vector<int> b(n);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  vector<int> c(n - 1);
  for(int i = 0; i < n - 1; i++) cin >> c.at(i);
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += b.at(a.at(i) - 1);
    if((i < n-1) && (a.at(i + 1) == a.at(i) + 1)){
      ans += c.at(a.at(i) - 1);
    }
  }
  cout << ans << endl;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    A.at(0) -= 32;
    B.at(0) -= 32;
    C.at(0) -= 32;
    cout << A.at(0) << B.at(0) << C.at(0) << endl;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
int a[100][100];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >>n>>m>>x;
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >>c[i];
    for(int j=0;j<m;j++) cin >>a[i][j];
  }
  lol ans=mod;
  for(lol i=1;i<(1LL<<n);i++){
    lol sum=0;
    int p[20]={};
    for(int j=0;j<n;j++){
      if(i&(1LL<<j)){
	sum+=c[j];
	for(int q=0;q<m;q++){
	  p[q]+=a[j][q];
	}
      }
    }
    bool uu=true;
    for(int j=0;j<m;j++){
      if(p[j]<x) uu=false;
    }
    if(uu) chmin(ans,sum);
  }
  if(ans==mod) cout <<"-1\n";
  else   cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 3668
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b;
    //char a,b='.';
    //int i=1;
    cin>>a>>b;
    a=a+b;
    if(a%2==0) cout<<a/2;
    else cout<<(a+1)/2;
    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;
      	double result = 0.0;
		for (int i = 0; i < a; i++){
          	b = sc.nextInt();
      		result =result + (1.0 / b);
	    }
      System.out.println(1.0 / result);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  string a;
  cin>>a;
  if(a[1]=='7'||a[0]=='7'||a[2]=='7')
    cout<<"Yes"<<endl;
  else
    cout<<"No";
}


Measured memory_bytes: 3624
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Long> one = nextLongArray();
		long A = one.get(0);
		long B = one.get(1);
		long C = one.get(2);
		long X = one.get(3);
		long Y = one.get(4);
		long output = 1L << 50;
		for(long i = 0; i <= 100000; i++){
			output = Math.min(output, i * 2 * C + Math.max(0, X - i) * A + Math.max(0, Y - i) * B);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ull unsigned long long
#define ld long double
#define uint unsigned int
struct debug {
~debug() {cerr << "\n";}template<class C> debug& operator<<(C c) {cerr << c;return *this;}
};
#define var(x) " [" << #x << ": " << x << "]"

int n, k;

struct uf {
    vector<int> p;
    uf(int x) {
        p.assign(x, -1);
    }
    int root(int v) {
        return p[v]<0?v:(p[v]=root(p[v]));
    }
    bool same(int x, int y) {
        return root(x)==root(y);
    }
    void unite(int x, int y) {
        x=root(x), y=root(y);
        if(x!=y) {
            if(p[x]>p[y]) swap(x, y);
            p[x]+=p[y];
            p[y]=x;
        }
    }
};

void solve() {
    cin >> n >> k;
    uf a(n);
    for(int i=0; i<k; ++i) {
        int u, v;
        cin >> u >> v;
        u-=1, v-=1;
        a.unite(u, v);
    }
    int ans=0;
    for(int i=0; i<n; ++i) {
        if(a.root(i)==i) ans+=1;
    }
    cout << ans-1 << "\n";
}

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

    solve();
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


signed main(){

	lli n,m;
	cin>>n>>m;
	vector<vector<lli>> v(n);
	REP(i,0,m){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	vector<lli> per;
	REP(i,0,n)per.push_back(i);

	lli ans=0;
	do{
		if(DEBUG)REP(i,0,per.size())cout<<per[i]<<" ";

		bool ok=true;
		lli s = per[0];
		if(s!=0)continue;
		REP(i,1,n){
			lli next = per[i];

			if(DEBUG)cout<<"s="<<s<<"next="<<next<<endl;
			bool fOk = false;
			REP(k,0,v[s].size()){
				if(DEBUG)cout<<"v="<<v[s][k]<<endl;
				if(v[s][k]==next){
					fOk = true;
					break;
				}
			}
			if(!fOk){
				ok=false;
				break;
			}
			s = next;
		}
		if(ok){
			ans++;
		}

	}while(next_permutation(per.begin(),per.end()));

	cout<<ans<<endl;

  return 0;
}

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

int used[5522];
int main()
{
    int prime[55556], n;
    vector <int> lul;
    for(int i = 2; i <= 55555; i++)
        for(long long j = 1LL * i * i; j <= 55555; j += i)
            prime[j] = 1;

    for(int i = 2; i <= 55555; i++)
        if(!prime[i])
            lul.push_back(i);
    cin >> n;
    //for(int i = 0; i < n; i++)
        //cout << lul[i] << " ";
    for(int i = 0, cnt = 0; i < lul.size() && cnt < n; i++)
        if(lul[i] % 5 == 2)
            cout << lul[i] << " ", cnt++;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){

    
    int K,N;
    cin >> K >> N;
    vi A(N);
    in(N,A);
    
    vi B;
    reps(i,1,N) B.pb(A[i]-A[i-1]);
    B.pb(K-A[N-1]+A[0]);
    sort(all(B));
    int ans = 0;
    rep(i,N-1) ans += B[i];
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 2168
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
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();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

typedef vector<double> vd;
const int INF = INT_MAX/2-1;

struct state {
	int p, c;
	state(int p, int c) : p(p), c(c) {};
	bool operator<(const state &o)const {
		return c>o.c;
	}
};

int main() {
	int n;
	while(cin >> n, n) {
		int m;
		cin >> m;
		vvi cost(n, vi(n, INF));
		int a, b, d;
		char c;
		REP(i, m) {
			cin >> a >> c >> b >> c >> d;
			cost[a][b] = d/100-1;
			cost[b][a] = d/100-1;
		}

		vi used(n, 0);
		priority_queue<state> Q;
		Q.push(state(0, 0));
		int ans = 0;
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();
			
			if(used[st.p]) {
				continue;
			}

			used[st.p] = true;
			ans += st.c;

			REP(i, n) {
				if(cost[st.p][i] != INF && st.p != i) {
					Q.push(state(i, cost[st.p][i]));
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1380
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

ll solve(ll A, ll B)
{
	ll P8begin = -1, P8end = -1;
	ll P10begin = -1, P10end = -1;

	P8begin = A / 0.08;
	P8end = (A + 1) / 0.08;
	P10begin = B / 0.1;
	P10end = (B + 1) / 0.1;
	//debug_cout(P8begin);
	//debug_cout(P8end);
	//debug_cout(P10begin);
	//debug_cout(P10end);

	ll ret = max(P8begin, P10begin);
	if (ret >= P8end || ret >= P10end)
		return -1;
	else
		return ret;
}

void Main()
{
	ll A, B;
	cin >> A >> B;

	ll ret = -1;
	rep(i, 15000)
	{
		if (ll(i * 0.08) == A && ll(i * 0.1) == B)
		{
			ret = i;
			break;
		}
	}
	cout << ret;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)2e5 + 5;
const int mod = (int)1e9 + 7;
using namespace std;

int a[maxn];

int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	ll ans = 0, h = 0;
	int j = 0;
	for(int i = 0; i < n; i++){
		for( ; j < n; j++){
			if((h^a[j]) != h + a[j]) break;
			else{
				h += a[j];
				ans += (j - i + 1);
			}
		}
		h -= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;

typedef long long ll; 
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(void)
{
    int a[3]={};
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    int min=114514,max=0;
    REP(i,3)
    {
        if(a[i]<min)min=a[i];
        if(a[i]>max)max=a[i];
    }
    printf("%d\n",max-min);
    return 0;
}

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

int main(){
    vector<int> x(5);
    int i, ans;
    for(i=0;i<5;i++){
        cin >> x.at(i);
        if(x.at(i) == 0)
            ans = i + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3152
#include <stdio.h>
int main(void){
    int s,i,j,a[10000];
    scanf("%d",&s);
    a[0]=s;
    for (i=1;i<10000; i++) {
        if(a[i-1]%2==0){
            a[i]=a[i-1]/2;
        }
        else{
            a[i]=a[i-1]*3+1;
        }
        for(j=0;j<i;j++){
            if(a[i]==a[j]){
                printf("%d\n",i+1);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;
    cin>>n;
    vector<vector<P>> p(n);
    REP(i,n-1){
        ll a,b,c;cin>>a>>b>>c;
        a--; b--;
        p[a].push_back(make_pair(b,c));
        p[b].push_back(make_pair(a,c));
    }
    ll q,k;cin>>q>>k;
    k--;

    ll dis[n];
    REP(i,n) dis[i] = inf;
    dis[k] = 0;

    stack<ll> st;
    st.push(k);
    while(st.size()){
        ll now = st.top();
        st.pop();
        for(auto nex: p[now]){
            if (dis[nex.first]!=inf) continue;
            st.push(nex.first);
            dis[nex.first] = dis[now]+nex.second;
        }
    }

    REP(i,q){
        ll x,y;cin>>x>>y; 
        x--; y--;
        cout<<dis[x] + dis[y]<<endl;
    }
    return 0;
}


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

set<int> kagami;
int N;
int main(){
    int d; 
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d", &d);
        kagami.insert(d);
    }
    printf("%d", (int)kagami.size());

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


set<ll> ship[200010];

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

    ll n, m, a, b;
    cin >> n >> m;
    rep(i, m){
        cin >> a >> b;
        ship[a].insert(b);
        ship[b].insert(a);
    }

    for(auto island : ship[1]){
        if(ship[island].find(n) != ship[island].end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }else{
            continue;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
bool judge(char x) {
    if(x=='A'||x=='T'||x=='C'||x=='G') return true;
    else return false;
}
int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        for(int j=i;j<n;j++) {
            if(judge(s[j])) cnt++;
            else break;
        }
        ans = max(ans, cnt);
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    
    String str[] = new String[h];
    char a[][] = new char[h][w];
    
    //入力値をいったん配列に入れる
    for(int i = 0 ; i < h ; ++i){
      str[i] = sc.next();
    }
    //分割して多次元配列に入れる
    for(int i = 0 ; i < h ; ++i){
      for(int j = 0 ; j < w ; ++j){
        a[i][j] = str[i].charAt(j);
      }
    }
    
    
    int h_result[] = new int[w];
    
    //縦でチェック
    for(int i = 0 ; i < w ; ++i){
      int count = 0;
      for(int j = 0 ; j < h ; ++j){
        if(a[j][i] == '.'){
          count++;
        }else{
          break;
        }
        if(count == h){
          h_result[i] = 1;
        } 
      }
    }
    //縦全部白のところは１になっている
    
    int w_result[] = new int[h];
    //横でチェック
    for(int i = 0 ; i < h ; ++i){
      int count = 0;
      for(int j = 0 ; j < w ; ++j){
        if(a[i][j] == '.'){
          count++;
        }else{
          break;
        }
        if(count == w){
          w_result[i] = 1;
        } 
      }
    }
    //横全部白のところは１になっている
    
    for(int i = 0 ; i < h ; ++i){
      for(int j = 0 ; j < w ; ++j){
        if(h_result[j]!=1 && w_result[i]!=1){
          System.out.print(a[i][j]);
        }
      }
      if(w_result[i]==1){
        continue;
      }
      System.out.println("");
    }
    
    
    
  }
}

Measured memory_bytes: 38760
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by mixnector on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception
    {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        int N = ni();
        long C = nl();
        long K = nl();
        long T[] = new long[N];
        for(int i = 0; i < N; i++) { T[i] = nl(); }
        Arrays.sort(T);
        long count = 1;
        long nowTime = T[0];
        long countTime = 0;
        long result = 1;

        for(int i = 1; i < N; i++)
        {
            count++;
            countTime += T[i] - nowTime;
            if(count > C || countTime > K)
            {
                result++;
                count = 1;
                countTime = 0;
            }
            nowTime = T[i];
        }
        out.println(result);
        out.flush();
    }
    static int ni() { return Integer.parseInt(in.next()); }
    static long nl() { return Long.parseLong(in.next()); }
}

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

const int MAX_N = 10010;

bool isPrime[MAX_N];
vector<int> prime;
void eratosthenes(int n){
    for(int i=0; i<=n; i++) isPrime[i] = true;
    isPrime[0] = false, isPrime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(isPrime[i]){
            for(int j=2; i*j<=n; j++){
                isPrime[i*j] = false;
            }
        }
    }

    for(int i=0; i<MAX_N; i++){
        if(isPrime[i]){
            prime.emplace_back(i);
        }
    }
}

int main(){
    eratosthenes(10005);

    vector<int> twinLarge;
    for(int i=0; i<prime.size()-1; i++){
        if(prime[i] + 2 == prime[i+1]){
            twinLarge.emplace_back(prime[i+1]);
        }
    }

    int cnt = 0;
    int m = twinLarge.size();
    vector<int> ans(10010, -1);
    for(int i=5; i<=10000; i++){
        if(twinLarge[min(cnt+1, m-1)] == i){
            cnt++;
        }

        ans[i] = twinLarge[min(cnt, m-1)];
    }

    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        cout << ans[n] - 2 << " " << ans[n] << endl;
    }
}


Measured memory_bytes: 3144
s = input()
t = input()
ret = "z"*51
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] != "?" and s[i+j] != t[j]:
            break
    else:
        ls = list(s)
        ls[i:i+len(t)] = list(t)
        for i in range(len(s)):
            if ls[i] == "?" : ls[i] = "a"
        ret = min(ret,"".join(ls))

print(ret if ret != "z"*51 else "UNRESTORABLE")


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

int main(){
	int N;
	cin >> N;
	map<int, int> M;
	rep(i, N){
		int A;
		cin >> A;
		M[A]++;
	}
	
	int odd = 0, even = 0;
	for(auto m : M){
		if(m.second % 2 == 0){
			even++;
		}
		else{
			odd++;
		}
	}
	
	int ans = odd + even;
	if(even % 2 == 1){
		ans -= 1;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n + 1);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n) b[i + 1] = b[i] + a[i];

  int ans = 1;
  for (int i = n - 1; i >= 1; i--) {
    if (2 * b[i] < a[i]) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}

#define ll long long
using namespace std;
int main(){
	ll a,b,c,i;
   cin>>a;
   ll k[a];
   c=0;
  for(i=0;i<a;i++){
  	cin>>k[i];
  }
  while(k[i]%2==0){
  for(i=0;i<a;i++){
  	if(k[i]%2==1) break;
  	if(i==a-1 && k[a-1]%2==0) c++;
  	k[i]=k[i]/2;
  }
}
  cout<<c;
 return 0;
}


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

using namespace std;

int main(){
  int x;
  int y;
  int ans=0;
  cin >> x;
  cin >> y;

  if(x == 1){
    ans=ans+300000;
  }
  if(x==2){
    ans+=200000;
  }
  if(x==3){
    ans+=100000;
  }
  if(y==1){
    ans+=300000;
  }
  if(y==2){
    ans+=200000;
  }
  if(y==3){
    ans+=100000;
  }
  if(x==1&&y==1){
    ans+=400000;
  }

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


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

struct IO_Tp
{
	const static int _I_Buffer_Size = 25 << 20;
	char _I_Buffer[_I_Buffer_Size], *_I_pos = _I_Buffer;
	
	IO_Tp() { fread(_I_Buffer, 1, _I_Buffer_Size, stdin); }
	
	IO_Tp &operator>>(int &res)
	{
		bool neg = false;
		while (!isdigit(*_I_pos))
			neg = *_I_pos++ == '-';
		res = *_I_pos++ & 15;
		while (isdigit(*_I_pos))
			res = res * 10 + (*_I_pos++ & 15);
		res = neg ? -res : res;
		return *this;
	}
} IO;

const int Max_N = 500005, Mod = 1000000007;

int N;
std::pair<int, int> p[Max_N];
int lmax[Max_N], rmin[Max_N];
int prev[Max_N];
int F[Max_N], pF[Max_N];

int main(int argc, char **argv)
{
	IO >> N;
	for (int i = 1; i <= N; ++i)
		IO >> p[i].first >> p[i].second;
	std::sort(p + 1, p + 1 + N);
	lmax[1] = p[1].second;
	for (int i = 2; i <= N; ++i)
		lmax[i] = std::max(lmax[i - 1], p[i].second);
	rmin[N] = p[N].second;
	for (int i = N - 1; i; --i)
		rmin[i] = std::min(rmin[i + 1], p[i].second);
	for (int i = 1; i <= N; ++i)
	{
		int lc = std::upper_bound(lmax + 1, lmax + i, p[i].second) - lmax;
		int rc = std::lower_bound(rmin + i + 1, rmin + 1 + N, p[i].second) - 1 - rmin;
		prev[rc] = std::max(prev[rc], lc);
	}
	F[0] = pF[0] = 1;
	for (int i = 1; i <= N + 1; ++i)
	{
		prev[i] = std::max(prev[i], prev[i - 1]);
		F[i] = prev[i - 1] ? (pF[i - 1] + Mod - pF[prev[i - 1] - 1]) % Mod : pF[i - 1];
		pF[i] = (pF[i - 1] + F[i]) % Mod;
	}
	printf("%d", F[N + 1]);
	
	return 0;
}

Measured memory_bytes: 17408
import sys
input =  sys.stdin.readline

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  G[u].append(v)
  G[v].append(u)
seen = [-1]*n
p, q, r = 0, 0, 0
def dfs(v):
  global p, q
  stack = [(v, 0)]
  seen[v] = 0
  f = False
  while stack:
    v, c = stack.pop()
    for nv in G[v]:
      if seen[nv] == -1:
        seen[nv] = c^1
        stack.append((nv, c^1))
      else:
        if seen[nv]^c == 0:
          f = True
  if f:
    p += 1
  else:
    q += 1
for v in range(n):
  if seen[v] != -1:
    continue
  if not G[v]:
    r += 1
  else:
    dfs(v)
ans = r*(2*n-r) + (p+q)*(p+q) + q*q
print(ans)

Measured memory_bytes: 91676
import sys

def num2alpha(c):
    return chr(c+64)

def alpha2num(c):
    return ord(c) - ord('A') + 1

def solve(n, s):
    for s_i in s:
        print(num2alpha((alpha2num(s_i) + n - 1) % 26 + 1), end="")
    print("")

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    solve(n, s)

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

struct x
{
    int q;
    string s;
    int p;
};

bool cmp(x a, x b)
{
    if (a.s == b.s)
        return a.p > b.p;
    return a.s < b.s;
}

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

    int n;
    cin >> n;
    vector<x> y(n);
    rep(i, n)
    {
        y[i].q = i + 1;
        string ss;
        int pp;
        cin >> ss >> pp;
        y[i].s = ss;
        y[i].p = pp;
    }
    sort(y.begin(), y.end(), cmp);
    rep(i, n) cout << y[i].q << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int ans = (H2-(H1+1))*60 + 60-M1+M2;
  ans = max(0, ans-K);
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 200002;
struct syo{ll s1,s2,s3,s4;};
ll n,k;
vector<P> p;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	ll XR=-1e9,XS=1e9,YR=-1e9,YS=1e9;
	FOR(i,0,n){
		ll x,y;
		cin>>x>>y;
		if(x<XS)XS=x;
		if(x>XR)XR=x;
		if(y<YS)YS=y;
		if(y>YR)YR=y;
		p.pb(mp(x,y));
	}
	SORT(p);
	ll ans=(XR-XS)*(YR-YS);
	FOR(i,0,n){
		FOR(j,0,n){
			FOR(a,0,n){
				FOR(b,0,n){
					ll xs,xr,yr,ys,ko=0;
					xs=p[i].fi;
					xr=p[j].fi;
					ys=p[a].se;
					yr=p[b].se;
					if(xs>xr || ys>yr)continue;
					FOR(o,0,p.size()){
						if(p[o].fi<=xr&&p[o].fi>=xs&&p[o].se>=ys&&p[o].se<=yr)ko++;
					}
					if(ko>=k)ans=min(ans,(xr-xs)*(yr-ys));
				}
			}
		}
	}
	pri(ans);
	return 0;
}


Measured memory_bytes: 384