akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << a[i][j];
        }
        cout << endl;
        for(int j = 0; j < w; j++){
            cout << a[i][j];
        }
        cout << endl;
    }
}

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

int main() {
  int d, e;
  do {
    cin >> d >> e;
    if(d+e == 0) return 0;
    long double ans = 999999999;
    for(int x = 0; x <= d; x++) {
      int y = d - x;
      long double xx = (double)x;
      long double yy = (double)y;
      long double a = sqrt(xx*xx + yy*yy);
      ans = min(ans, abs(a - e));
    }
    printf("%.10Lf\n", ans);
  } while(1);
}



Measured memory_bytes: 3128
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$H = $in->nextInt();
$W = $in->nextInt();

$P = [];
for ($i = 0;$i < $H+2;$i++) {
	$Q = [];
	for ($j = 0;$j < $W+2;$j++) {
		if ($i === 0 || $i === $H+1 || $j === 0 || $j === $W+1) {
			$Q[] = '#';
		} else {
			$Q[] = '';
		}
	}
	$P[] = $Q;
}
for ($i = 1;$i < $H+1;$i++) {
	$S = $in->next();
	for ($j = 1;$j < $W+1;$j++) {
		$P[$i][$j] = $S[$j-1];
	}
}

for ($i = 0;$i < $H+2;$i++) {
	$s = '';
	for ($j = 0;$j < $W+2;$j++) {
		$s .= $P[$i][$j];
	}
	$out->println($s);
}

?>


Measured memory_bytes: 4604
#include <iostream>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;

    if (s[1] == 'B') {
        s[1] = 'R';
    } else {
        s[1] = 'B';
    }

    std::cout << s << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3616
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

ll arr[MAXN];

int n, ans;

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &arr[i]);
    }

    sort(arr + 1, arr + n + 1);

    for (int i = 2; i <= n; ++i) {
        if (arr[i] > arr[i - 1] * 2) {
            ans = i - 1;
        }

        arr[i] += arr[i - 1];
    }

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

int main() {
    int tt = 1;

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

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int a,b,c,d;
   int k;
   cin>>a>>b>>c>>k;
   d=max({a,b,c});

   rep(i,k){
      d=2*d;
   }
   cout<<a+b+c+d-max({a,b,c});
   
      return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
c = [0] * 5
for i in range(n):
  s = input()
  if s[0] == 'M':
    c[0] += 1
  elif s[0] == 'A':
    c[1] += 1
  elif s[0] == 'R':
    c[2] += 1
  elif s[0] == 'C':
    c[3] += 1
  elif s[0] == 'H':
    c[4] += 1
ans = 0
for t in itertools.combinations(range(5), 3):
  ans += c[t[0]] * c[t[1]] * c[t[2]]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  string s;
  cin >> s;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (i % 2 != 0) continue;
    int flag = 1;
    rep (j, i / 2) {
      // cout<< s[j] << " = " << s[j + (i / 2)] << endl;
      if (s[j] != s[j + i / 2]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      P(i);
      return 0;
    }
    // P("delete");
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }


int main()
{
    int v;
    cin >> v;
    
    if (v >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3636
def solve(s):
    (head_C, sep_C, tail_C) = s.partition('C')
    if sep_C == '':
        return 'No'
    (head_F, sep_F, tail_F) = tail_C.partition('F')
    if sep_F == '':
        return 'No'
    return 'Yes'

if __name__ == '__main__':
    s = input()
    print(solve(s))

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

int main() {
    string N;
    cin >> N;
    ll sum = 0;
    for (auto n : N) {
        sum += n - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-8;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

typedef pair<double,double> PD;
double Sqrt(double a){
    double BIG=a+1, SMALL=0;
    while(BIG>SMALL+DEL*0.01){
        double MID=(BIG+SMALL)/2;
        if(MID*MID>a) BIG=MID;
        else SMALL=MID;
    }
    return BIG;
}
double Jou(double a){
    return a*a;
}
double Dist(PD a, PD b){
    return Sqrt(Jou(a.first-b.first)+Jou(a.second-b.second));
}

PD Mid(PD a, PD b){
    PD ret=mp((a.first+b.first)/2, (a.second+b.second)/2);
    return ret;
}

PD Choku(PD a, PD b){
    double X=Dist(a,b);
    return mp((a.second-b.second)/X, (b.first-a.first)/X);
}

ll N;
vector<PD> d;

bool Able(double R){
    vector<PD> kou;
    rep(i,N-1) REP(j,i+1,N){
        double X=Dist(d[i],d[j])/2;
        if(X>R) return false;
        double A=Sqrt(Jou(R)-Jou(X));
        PD B=Mid(d[i],d[j]);
        PD C=Choku(d[i],d[j]);
        kou.pb(mp(B.first+(C.first*A),B.second+(C.second*A)));
        kou.pb(mp(B.first-(C.first*A),B.second-(C.second*A)));
    }
    rep(j,kou.size()) {
        bool kari=true;
        rep(i,N) if(Dist(kou[j],d[i])>=R+DEL*5) kari=false;
        if(kari) return true;
    }
    return false;
}


int main(){
    cin>>N;
    rep(i,N){
        double x,y; cin>>x>>y;
        d.pb(mp(x,y));
    }
    double BIG=2000, SMALL=0;
    while(BIG>SMALL+DEL){
        double MID=(BIG+SMALL)/2;
        if(Able(MID)) BIG=MID;
        else SMALL=MID;
    }
    cout<<setprecision(8)<<SMALL<<endl;

}

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

using namespace std;

int main() {
    int n;
    while (scanf("%d", &n), n) {
        int ans = 0, divi = 5;
        while (n / divi) {
            ans += n / divi;
            divi *= 5;
        }

        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  string str;
  MFP([&](auto gen, char cnt) {
    if(str.size() == N) {
      cout << str << endl;
      return;
    }
    for(char k = 'a'; k <= cnt; k++) {
      str.push_back(k);
      gen(max< char >(k + 1, cnt));
      str.pop_back();
    }

  })('a');
}




Measured memory_bytes: 1536
// you**can**do**anything :)  
#include <bits/stdc++.h>
#include<iostream> 
#include<algorithm> 
#include<vector> 
#define ll long long
const int maxn=5e5+10;
using namespace std;
 
int main() {
 string s;
 int flage=0;
cin>>s;
 for(int i=0 ;i<s.size() ;i++){
 	if(s[i]=='7')
 	flage=1;
 }
 if(flage)
 puts("Yes");
 else
 puts("No");
 
}

Measured memory_bytes: 3592
#include <cstdio>
#include <vector>
using namespace std;

//ax + b = 0
pair<int,int> solve(int a, int b){
	if(b==0) return make_pair(0,0);
	if(b>0) return make_pair(0,1);
	return make_pair(1,0);
}

//ax^2+bx+c=0
pair<int,int> solve(int a, int b, int c){
	if(c==0) return solve(a,b);
	int y4a = -b*b + 4*a*c;
	if(y4a > 0){
		return make_pair(0,0);
	}
	if(c < 0){
		return make_pair(1,1);
	}
	if(b > 0){
		return make_pair(0, 2);
	}
	return make_pair(2, 0);
}

//ax^3+bx^2+cx+d=0
pair<int,int> solve(long long a, long long b, long long c, long  long d){
	if(a < 0){
		return solve(-a,-b,-c,-d);
	}
	if(d == 0){
		return solve(a,b,c);
	}

	long long D = b*b*c*c - 4*a*c*c*c - 4*b*b*b*d - 27*a*a*d*d + 18*a*b*c*d;
	int DD = b*b - 3*a*c;
	bool minimal_x_plus = (b<0 || DD > b*b),
			maximal_x_minus = (b>0 || b*b < DD);
	if(D >= 0){
		if(DD == 0){
			if(b > 0){
				return make_pair(0,3);
			}
			else{
				return make_pair(3,0);
			}
		}
		if(d > 0){
			if(!minimal_x_plus){
				return make_pair(0,3);
			}
			else{
				return make_pair(2,1);
			}
		}
		else{
			if(!maximal_x_minus){
				return  make_pair(3,0);
			}
			else{
				return make_pair(1,2);
			}
		}
	}
	else{
		if(d > 0){
			return make_pair(0,1);
		}
		return make_pair(1,0);
	}

	return make_pair(-1,-1);
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int a, b, c, d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		pair<int,int> ans = solve(a,b,c,d);
		printf("%d %d\n", ans.first, ans.second);
	}
	return 0;
}

Measured memory_bytes: 0
n,m=map(int,input().split())
ans=[1]*n
for i in range(1,n):
  if ans[i]==1:ans[n-i]=0
c=0
x=[]
for i in range(1,n):
  if ans[i]==1:
    if len(x)%2==0:x.append(n-i)
    else:x.append(i)
x.sort(reverse=1)
for i in range(m):print(i+1,i+1+x[i])

Measured memory_bytes: 13940
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

ll a[1009];
vector<ll> r, tr;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll s = 0;
		for (int j = i; j < n; j++) {
			s += a[j];
			r.push_back(s);
		}
	}
	ll t = 1;
	while (t * 2 <= r[n - 1])
		t *= 2;
	while (t > 0) {
		tr.clear();
		for (int i = 0; i < r.size(); i++)
			if (r[i] & t)
				tr.push_back(r[i]);
		if (tr.size() >= k)
			r = tr;
		t /= 2;
	}
	ll ans = r[0];
	for (int i = 1; i < k; i++)
		ans = (ans & r[i]);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6124
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        ArrayList<Integer> mountain = new ArrayList<>(10);
        Scanner sc = new Scanner(System.in);
        for(int i=0;i<10;i++){
            mountain.add(sc.nextInt());
        }
        Collections.sort(mountain);
        System.out.println(mountain.get(mountain.size()-1));
        System.out.println(mountain.get(mountain.size()-2));
        System.out.println(mountain.get(mountain.size()-3));
    }
}

Measured memory_bytes: 26260
#include <iostream>

using namespace std;

int main(){
	int n, k;
	char tmp;

	cin >> n >> k;

	for(int i = 0; i < n; ++i){
		cin >> tmp;
		if(i == (k-1)){
			if(tmp == 'A'){
				cout << 'a';
			}else if(tmp == 'B'){
				cout << 'b';
			}else if(tmp == 'C'){
				cout << 'c';
			}
		}else{
			cout << tmp;
		}
	}

	return 0;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds
{   
    namespace io
    {
        const int MaxBuff = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
    }

    template<class Type> inline Type read()
    {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

}

using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("duliu.in", "r", stdin);
	freopen ("duliu.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

unsigned int n, a[N], b[N], va[N], vb[N], fa[N];

unsigned int find(unsigned int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

unsigned int tot;
inline unsigned int find_pos(unsigned int x) {
	return lower_bound(va + 1, va + tot + 1, x) - va;
}

bitset<N> vis;

int main () {

	File();

	n = read<unsigned int>() + 1;

	For (i, 1, n - 1)
		a[i] = read<unsigned int>(), a[n] ^= a[i];
	For (i, 1, n - 1)
		b[i] = read<unsigned int>(), b[n] ^= b[i];

	For (i, 1, n)
		va[i] = a[i], vb[i] = b[i];
	sort(va + 1, va + n + 1);
	sort(vb + 1, vb + n + 1);

	For (i, 1, n)
		if(va[i] != vb[i]) return puts("-1"), 0;

	tot = unique(va + 1, va + n + 1) - va - 1;
	For (i, 1, tot) fa[i] = i;

	For (i, 1, n) {
		a[i] = find_pos(a[i]); b[i] = find_pos(b[i]);
		int rtx = find(a[i]), rty = find(b[i]);
		if (rtx != rty) fa[rtx] = rty;
	}

	int ans = 0, sum = 0;
	For (i, 1, n - 1) if (a[i] != b[i])
		++ ans, vis[a[i]] = vis[b[i]] = true;
	vis[a[n]] = vis[b[n]] = true;

	For (i, 1, n) if (vis[i] && find(i) == i) ++ sum;

	printf ("%d\n", ans + max(0, sum - 1));

	return 0;

}


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

constexpr int mod = 1000000007;
struct Fact {
  static constexpr int S = 1000;
  int c[S + 1][S + 1];
  constexpr Fact() : c() {
    for (int n = 0; n <= S; ++n) {
      for (int r = 0; r <= n; ++r) {
        if (r == 0) {
          c[n][r] = 1;
        } else {
          c[n][r] = (c[n - 1][r - 1] + c[n - 1][r]) % mod;
        }
      }
    }
  }
};

int N, K;
int a[1000];
long dp[21][1001];

int main() {
  constexpr Fact f;
  scanf("%d %d", &N, &K);
  for (int k = 0; k < K; ++k) {
    scanf("%d", a + k);
  }
  
  dp[0][0] = 1;
  for (int k = 1; k <= K; ++k) {
    for (int n = 0; n <= N; ++n) {
      for (int x = 0; x <= min(n, a[k - 1]); ++x) {
        long add = dp[k - 1][n - x] * f.c[N - n + x][x] % mod * f.c[N - x][a[k - 1] - x] % mod;
        dp[k][n] = (dp[k][n] + add) % mod;
      }
    }
  }
  printf("%lld", dp[K][N]);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            Array.Sort(A);
            Array.Reverse(A);

            long result = 0;
            var PQ = new PriorityQueue<long>(false);
            PQ.Push(A[0]);
            for (int i = 1; i < N; i++)
            {
                result += PQ.Pop();
                PQ.Push(A[i]);
                PQ.Push(A[i]);
            }
            Console.WriteLine(result);
        }
    }
    class PriorityQueue<T> where T : IComparable<T>
    {
        private List<T> nodes;
        private Boolean isAsc;

        public PriorityQueue(Boolean _isAsc)
        {
            this.nodes = new List<T>();
            this.isAsc = _isAsc;
        }

        public int Count()
        {
            return this.nodes.Count;
        }
        public T Pop()
        {
            T returnNode = this.nodes[0];
            this.nodes[0] = this.nodes[nodes.Count - 1];
            this.nodes.RemoveAt(nodes.Count - 1);
            int root = 0;
            while (root * 2 + 1 < this.nodes.Count)
            {
                int child = root * 2 + 1;
                if (child + 1 < this.nodes.Count && compare(this.nodes[child + 1], this.nodes[child]) > 0) child += 1;
                if (compare(this.nodes[child], this.nodes[root]) > 0)
                {
                    swap(child, root);
                    root = child;
                }
                else
                {
                    break;
                }
            }
            return returnNode;
        }
        public T Top()
        {
            return this.nodes[0];
        }
        public void Push(T t)
        {
            this.nodes.Add(t);
            var addPosition = nodes.Count - 1;
            while (addPosition > 0)
            {
                var parent = (int)(addPosition - 1) / 2;
                if (compare(nodes[addPosition], nodes[parent]) > 0)
                {
                    swap(addPosition, parent);
                    addPosition = parent;
                }
                else
                {
                    break;
                }
            }
        }
        private int compare(T x, T y)
        {
            return this.isAsc ? y.CompareTo(x) : x.CompareTo(y);
        }
        private void swap(int x, int y)
        {
            T temp = nodes[x];
            nodes[x] = nodes[y];
            nodes[y] = temp;
        }
    }
}


Measured memory_bytes: 50640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    int a[N * 3];
    for (int i = 0; i < 3 * N; i++) {
        scanf("%d", &a[i]);
    }

    long long top_score[N + 1], bottom_score[N + 1];

    priority_queue<int, vector<int>, greater<int> > top;
    priority_queue<int> bottom;

    top_score[0] = 0;
    bottom_score[N] = 0;
    for (int i = 0; i < N; i++) {
        top.push(a[i]);
        top_score[0] += a[i];
        bottom.push(a[3 * N - 1 - i]);
        bottom_score[N] += a[3 * N - 1 - i];
    }

    for (int k = 1; k <= N; k++) {
        top.push(a[N - 1 + k]);
        top_score[k] = top_score[k - 1] + a[N - 1 + k] - top.top();
        top.pop();
        bottom.push(a[2 * N - k]);
        bottom_score[N - k] = bottom_score[N - k + 1] + a[2 * N - k] - bottom.top();
        bottom.pop();
    }

    long long maximum = top_score[0] - bottom_score[0];
    for (int k = 1; k <= N; k++) {
        maximum = max(maximum, top_score[k] - bottom_score[k]);
    }

    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 4084
#include <cstdio>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i, s, n) for(int i=(s); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;

int* const partition(int *a, int *r)
{
   const int x = *(--r);
   int* lt = a - 1;

   for(int *i = a; i != r; ++i)
      if( *i <= x ){
         ++lt;
         swap( *lt, *i );
      }

   ++lt;
   swap( *lt, *r );
   return (lt);
}

int N;
int a[100002];

signed main()
{
   scanf("%d", &N);
   rep(i, N)scanf("%d", a+i);

   int* q = partition(a, a+N);

   rep(i, N){
      printf( a+i == q ? "[%d]" : "%d", a[i] );
      putchar_unlocked( i+1 < N ? ' ' : '\n' );
   }
}




Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///ΑτΚοδερ ;)
int main(void){
    fastio;
    ll n;
    c(n);
    ll arr[2][n];
    f(i,0,2){
        f(j,0,n){
            cin>>arr[i][j];
        }
    }
    ll dp[3][n+1];
    f(i,0,3){
        f(j,0,n+1){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = arr[i-1][j-1] + max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    cout<<dp[2][n];
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var restaurants = new List<Restaurant>(n);
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine();
                var elems = line.Split(' ');
                restaurants.Add(new Restaurant(i + 1, elems[0], int.Parse(elems[1])));
            }

            restaurants.Sort(new RestaurantComparer());
            foreach (var restaurant in restaurants)
            {
                Console.WriteLine(restaurant.Number);
            }
        }
    }

    class Restaurant
    {
        public Restaurant(int number, string s, int p)
        {
            this.Number = number;
            this.S = s;
            this.P = p;
        }

        public int Number { get; private set; }

        public string S { get; private set; }
        public int P { get; private set; }
    }

    class RestaurantComparer : IComparer<Restaurant>
    {
        public int Compare(Restaurant a, Restaurant b)
        {
            if (a.S == b.S)
            {
                if (b.P < a.P) { return -1; }
                else if (a.P < b.P) { return 1; }
                else { return 0; }
            }
            else
            {
                return a.S.CompareTo(b.S);
            }
        }
    }
}


Measured memory_bytes: 13408
import java.util.Scanner;
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 e = sc.nextInt();
  int ans = a +  ((b-1)/10)*10 + ((c-1)/10)*10 + ((d-1)/10)*10 + ((e-1)/10)*10;
  ans = Math.min(ans, b +  ((a-1)/10)*10 + ((c-1)/10)*10 + ((d-1)/10)*10 + ((e-1)/10)*10);
  ans = Math.min(ans, c +  ((a-1)/10)*10 + ((b-1)/10)*10 + ((d-1)/10)*10 + ((e-1)/10)*10);
  ans = Math.min(ans, d +  ((a-1)/10)*10 + ((c-1)/10)*10 + ((b-1)/10)*10 + ((e-1)/10)*10);
  ans = Math.min(ans, e +  ((a-1)/10)*10 + ((c-1)/10)*10 + ((d-1)/10)*10 + ((b-1)/10)*10);
  System.out.println(ans+40);
}}

Measured memory_bytes: 21716
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortresult:
        div.sort()
    return div
# endregion
N = ri()
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = ri_()
dp = [[0] * 3 for _ in range(N)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, N):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]
print(max(dp[N - 1]))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, M; cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
    }else if(abs(N-M) == 1){
        ll res = modint(modint(fact[N]) * modint(fact[M]));
        cout << res << endl;
    }else{
        ll res = modint(modint(fact[N]) * modint(fact[M]) * modint(2));
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	double x[4],y[4];
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",x,y,x+1,y+1,x+2,y+2,x+3,y+3)){
		rep(i,2){
			x[i]=x[i*2]-x[i*2+1];
			y[i]=y[i*2]-y[i*2+1];
		}
		puts(x[0]*x[1]+y[0]*y[1]==0?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 1196
#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;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int N,K;cin>>N>>K;
    int mx = (N-1)*(N-2)/2;
    if(mx < K) {
        cout<<-1<<endl;
        return 0;
    }
    int num = mx - K;
    vector<vector<int>> g(N,vector<int>());
    num+=N-1;

    rep(i,N-1) {
        for(int j = i+1;j<N;j++) {
            if(num > 0) {
                g[i].push_back(j);
                num--;
            } else {
                cout<<mx-K+N-1<<endl;
                rep(i,N) {
                    if(g[i].size()!=0) {
                        for(auto to : g[i]) {
                            cout<<i+1<<" "<<to+1<<endl;
                        }
                    }
                }
                return 0;
            }
        }
    }
    cout<<mx-K+N-1<<endl;
    rep(i,N) {
        if(g[i].size()!=0) {
            for(auto to : g[i]) {
                cout<<i+1<<" "<<to+1<<endl;
            }
        }
    }

}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
const int MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll x[n];
    rep(i,n)cin >> x[i];

    ll dp[n] = {};
    ll now = 0;

    rep(i,n){
        if(i == 0){
            x[i] = 1;
            dp[i] = now;
        }else{
            dp[i] = now;
            if(x[i] < (i - now) * 2 + 1){
                now++;
            }
        }
    }


    ll ans = 1;

    rep(i,n){
        ans *= n - dp[i] - (n - 1 - i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c) {
    cout << "No" << endl;
  } else if (a!=b && b!=c && c!=a) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  return 0;
}

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

int main()
{
    long long int r, g, b, n, R, G;
    cin >> r >> g >> b >> n;
    long long int cnt = 0;

    for(long long int i = 0; i <= n / r ; i++){
        R = r * i;
        for(long long int j = 0; j <= (n - R) / g ; j++){
            G = g * j;
            if((n - R - G) % b == 0) cnt++;
        }
    }

    cout << cnt << endl;
}

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

int main(){
  int n, l;
  std::vector<std::string> str;
  std::cin >> n >> l;
  for(int i = 0; i < n; i++){
    str.push_back(" ");
    std::cin >> str[i];
  }
  std::sort(str.begin(), str.end());

  for(int i = 0; i < n; i++){
    std::cout << str[i];
  }
  std::cout << std::endl;
}

Measured memory_bytes: 384
from collections import deque
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for lk in range(min(K, N)+1):
    for rk in range(min(K, N)+1-lk):
        k = K - lk - rk
        v = V[:lk] + V[N-rk:]
        v.sort()
        ans = max(sum(v[k:]) + sum([x for x in v[:k] if x > 0]), ans)
if K >= 2 * N:
    ans = sum([v for v in V if v >= 0])
print(ans)

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    vector<vector<ll>> dp(N, vector<ll>(1 << N, 0));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> a[i][j];
            if (i == 0 && a[i][j])
            {
                dp[i][1 << j] = 1;
            }
        }
    }
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (!a[i][j])
                continue;
            for (int k = 0; k < (1 << N); k++)
            {
                if (k & (1 << j))
                {
                    dp[i][k] += dp[i - 1][k ^ (1 << j)];
                    dp[i][k] %= MOD;
                }
            }
        }
    }
    cout << dp[N - 1][(1 << N) - 1] << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> v2(N);
  int A;
  int maximum=0;
  int sec=0;
  for (int i=0; i<N;i++) {
    cin >> A;
    vec[i]=A;
    v2[i]=A;
  }
  
  sort(v2.begin(),v2.end());
  maximum=v2[N-1];
  sec=v2[N-2];
  if (maximum==sec){
    for (int i=0; i<N;i++) {
    	cout << maximum << endl;
    }
  } else {
    for (int i=0; i<N; i++) {
      if (vec[i]==maximum) {
        cout << sec << endl;
      } else {
        cout << maximum << endl;
      }
    }
  }
  
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
set<ll> good;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll a = 1; a * a <= N; a++) {
        ll delta = N - a;
        if(delta % a != 0) continue;
        ll m = delta / a;
        if(m == 0) continue;
        if((N/m) == (N%m)) ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define f(i,n) for(int i=1;i<=n;i++)
#define mkp make_pair
double dp[3001][3001];
double solve(vector<double>&v,int i,int x)
{
	if(x==0) return 1; 
	if(i==0)return  0;
	if(dp[i][x]>-0.9)
	return dp[i][x];
	return dp[i][x]=v[i]*(solve(v,i-1,x-1))+(1-v[i])*(solve(v,i-1,x));	
	}
int32_t main()
{
 int t=1;
 //cin>>t;
while(t--)
{
	int n;
    cin>>n;
    vector<double>v(n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<solve(v,n,(n+1)/2)<<endl;
    
    
}
   
}


Measured memory_bytes: 70912
//c++ D.cpp -std=c++14
#include <bits/stdc++.h>
using namespace std;

const string MINUSINF = "-";

int N,M;
string dp[10010];
int match[]={0,2,5,5,4,5,6,3,7,6};

void chmax(string &a, string b) {
	if ( a.size() < b.size() ) a=b;
	else if (a.size() == b.size()) {
		if (a<b) a=b;
	}
	
}

int main(){
	cin >> N >> M;
	vector<int> A(M);
	for(int i=0 ; i < M ; ++i )  cin>>A[i];
	for(int i=0 ; i < N+1 ; ++i )  dp[i]="-";
	dp[0]="";
	
	
	for(int i=0 ; i < N+1 ; ++i ) {
		if (dp[i]=="-") continue; 
		for (int a : A) {
			int match_cnt=match[a];
			chmax( dp[i+match_cnt], dp[i]+(char)( '0'+a ) );
		}
	}
	
	
	cout << dp[N] << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a*500 >= b){
    cout << "Yes" << endl;
  }
  else{cout << "No" << endl;}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }

int main()
{
    ll x;
    cin >> x;
    ll n = 0;
    ll y = 100;
    while(y < x)
    {
        string s = to_string(y);
        s = s.substr(0, s.size()-2);
        ll p = stoll(s);
        y = y + p;
        ++n;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3704
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=200005;
char s[N];
int a[N];
char cal(int x,int k){
    x^=k%2;return x?'A':'B';
}
int main(){
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n,k;
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);
    for (i=1;i<=n;i++) if (s[i]=='A') a[i]=1; else a[i]=0;
    int K=k;
    for (i=1;i<=n;i++) {if (a[i]^((i-1)%2)) k-=2; else k--;if (k<=0) break;}
    if (i<n||i==n&&k==-1){
        int tp,j;
        if (k==-1) {tp=1;printf("B");} else tp=0;
        for (j=i+1;j<=n;j++) if (a[j]^((i-tp)%2)) printf("A"); else printf("B");
        tp+=n-i;
        for (j=tp+1;j<=n;j++) if (j%2==n%2) printf("A"); else printf("B");
        puts("");return 0;
    } 
    if (n%2==0){
        for (i=1;i<=n;i++) if (i%2==1) printf("B"); else printf("A");
        puts("");return 0;
    }
    if (k%2==0) printf("A"); else printf("B");
    for (i=2;i<=n;i++) if (i%2==0) printf("B"); else printf("A");
    puts("");
    
  //  system("pause");
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int n = 0;
	int a;
	int i = 0;
	long int max = -10000000;
    int min = 10000000;
	long int S = 0;
	cin >> n;

	for (i = 0;i<n; i++){
		cin >> a;
		S=S + a;
			if (max<a){
				 max = a;
			}
			if (min>a){
				min=a;
			}
	}
	cout << min << " " << max << " " << S << endl;



	return 0;
}

Measured memory_bytes: 3076
import collections
import numpy as np

n = int(input())
li = list(map(int, input().split()))

di = collections.Counter(li)
#print(di)

arr = np.array(list(di.values()))
arrr = arr - 1
c = np.dot(arr, arrr) // 2
#print(c)

#(n * n-1)-(n-1 * n-2) / 2 = n-1

for v in li:
    x = int(di[v])
    if x == 1:
        print(c)
    else:
        print(c-(x-1))
        

Measured memory_bytes: 42840
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
int a[N],b[N],c[N];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ll p=lower_bound(a,a+n,b[i])-a;
        ll q=upper_bound(c,c+n,b[i])-c;
        ans+=p*(n-q);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
long long a[200];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
 
  int c = 0;
  bool flag = true;
  while (true) {
    for (int i = 0; i < n; i++) {
      if ( a[i] % 2 == 0 ) {
        a[i] /= 2;
      }else {
        flag = false;
       	break; 
      }
    }
    if (flag){
      c++;
    }else {
      break;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

f = [[] for i in range(n)]

for i in ab:
    f[i[0]-1].append(i[1]-1)
    f[i[1]-1].append(i[0]-1)
ans = 0
#print(f)
for i in range(n):
    flag = True
    for j in range(len(f[i])):
        #print("比べ,",i,f[i][j], h[i], h[f[i][j]])
        if h[i] <= h[f[i][j]]:
            #print("低い")
            flag = False
            break
    if flag:
        #print("good",i)
        ans += 1

print(ans)


Measured memory_bytes: 106596
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    s = input()
    n = len(s)
    if check(s) and check(s[:(n-1)//2]) and check(s[(n+3)//2-1:]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064