akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

ll x;

int main(int argc, char *argv[]){
    cin >> x;
    ll res = 0;
    ll score = 0;
    bool flag = true;
    res = x / 11 * 2;
    if(x % 11 >= 1 && x % 11 <= 6) res++;
    else if(x % 11 > 6) res += 2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	while(1){
		int a;
		cin >> a;
		if(a==0){
			break;
		}
		vector<int> judge(a);
		rep(i, 0, a) cin >> judge[i];
		sort(judge.begin(), judge.end());
		int sum = judge[1];
		rep(i,2,a-1){
			sum += judge[i];
		}
		cout << sum / (a - 2) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n,x,m;
    cin>>n>>x>>m;
    vector<ll>dp(100001);
    map<ll,ll>mp;
    dp[0]=x;
    mp.insert({dp[0],0});
    ll val,val1=1,val2=-1,ans=0,val3;
    for(int i=1;i<100001;i++)
    {
        dp[i]=(dp[i-1]*dp[i-1])%m;
        if(mp.find(dp[i])==mp.end())
        {
            val1++;
            mp.insert({dp[i],i});
        }
        else
        {
            val3=mp[dp[i]];
            break;
        }
    }   
    if(n==1)
    {
        cout<<dp[0]<<endl;
    }   
    else
    if(n==2)
    {
        cout<<dp[1]+dp[0]<<endl;
    }
    else
    {
        val=0;
        val1-=val3;
        for(int i=val3;i<val1+val3;i++)
        {
            val+=dp[i];
        }
        n-=val3;
        val2=n%val1;
        ans+=val*(n/val1);
        for(int i=0;i<val3+val2;i++)
        {
            ans+=dp[i];
        }
        cout<<ans<<endl;
    }
    //debug()<<dp;
}


Measured memory_bytes: 7156
def main():
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for i in range(h)]
  b=[list(map(int,input().split())) for i in range(h)]
  dp=[[[0]*(80*(h+w+1)+1) for i in range(w)] for j in range(h)]
  dp[0][0][abs(a[0][0]-b[0][0])]=1
  for i in range(h):
    for j in range(w):
      c=abs(a[i][j]-b[i][j])
      if i!=0 or j!=0:
        for k in range(80*(i+j+1)+1):
          dp[i][j][k]=dp[i-1][j][abs(k-c)]|dp[i-1][j][k+c]|dp[i][j-1][abs(k-c)]|dp[i][j-1][k+c]
  for i in range(80*(h+w+1)+1):
    if dp[h-1][w-1][i]==1:
      print(i)
      break

if __name__=='__main__':
  main()

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

using namespace std;

int main() {
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++) {
        if(i%2==0) {
            if(s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if(s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<math.h>
#include<map>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
#include<set>
#include<queue>
#include<tuple>
// #include<bits/stdc++.h>
// #include "unionFind.h"
using namespace std;
#define ll long long
#define int long long
typedef vector<ll> vi;
typedef pair<ll, ll>  ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

#define INF 1e9
#define INF64 (ll)1e18
#define pb push_back
#define F first
#define S second
#define MP make_pair
#define forn(i,l,r) for(ll i=l ; i<r ; i++)

void ain(vector<ll>& a) {for(ll i=0;i<(ll)a.size();i++) cin>>a[i];}
ll max(ll a, ll b) {return (a>b)?a:b;}
ll min(ll a, ll b) {return (a>b)?b:a;}

int Ceil(double x){
    return (((int)x==x)?x:(int)x+1);
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}
/*
10 7 8 3
3 10 4 9 2 7 6 10 4 8

*/


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

int main()
{
	string S;
	cin >> S;

	int cnt = 0;
	int ans = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			cnt++;
			ans = max(ans, cnt);
		}
		else
			cnt = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 3005;
double p[maxn];
double dp[maxn][maxn];
int n;

int main () {
    scan1(n);
    FORN(i, 1, n) scanf("%lf", &p[i]);
    dp[0][0] = 1;
    FORN(i, 1, n) FORN(j, 0, n) {
        if ( j > 0 ) dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i];
        else dp[i][j] = dp[i-1][j] * (1 - p[i]);
    }
    double ans = 0;
    FORN(i, n/2 + 1, n) ans += dp[n][i];
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 74192
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


vector<int> bit_digit(60,0);

int table[200010][60];

int main(){
    rep(i,200010){
        rep(j,60){
            table[i][j] = 0;
        }
    }

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){ 
        cin >> a[i];
        int tmp = a[i];
        int tmp2 = 1;
        int cnt = 0;
        int cnt2 = 0;
        while(tmp2 < a[i]){
            tmp2 *= 2;
            cnt++;
        }
        
        while(tmp > 0){
            cnt2++;
            if(tmp %2 ==1){
                bit_digit[cnt2]++;
                table[i][cnt2]++;
            }
            tmp /= 2;
        }
    }

    rep(i,n){
        ll base = 1;
        ll ans = 0;
        reps(j,1,60){
            if(((bit_digit[j]-table[i][j]) % 2 )== 1){
                ans += base;
            }
            base *= 2;
        }
        cout << ans << " ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 51036
from pprint import pprint
N = int(input())
digit_cnt = list([0] * 9 for _ in range(9))
now = 1
for i in range(1, N + 1):
    str_i = str(i)
    row = int(str_i[0])
    column = int(str_i[-1])
    if row != 0 and column != 0:
        digit_cnt[row - 1][column - 1] += 1
# pprint(digit_cnt)

ans = 0
for i in range(9):
    for j in range(9):
        ans += digit_cnt[i][j] * digit_cnt[j][i]
print(ans)


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

bool areEqual(vector <int> a, int arr[], int n){
    for(int i = 0; i < n; i++){
        if(a[i] != arr[i]){
            return false;
            break;
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    int arr[n];
    //int arr1[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        a[i] = arr[i];
    }
  	sort(a.begin(),a.end());
    int t1=0,t2 = 0;
    while(!areEqual(a,arr,n)){
        next_permutation(a.begin(),a.end());
        t1++;
    }  
  	for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(a.begin(),a.end());
    while(!areEqual(a,arr,n)){
        next_permutation(a.begin(),a.end());
        t2++;
    }
    int ans = t2 - t1;
    cout << abs(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    int n,l;
    cin >> n >> l;
    string s[n],t;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s+n);
    for(int i = 0; i < n; i++) {
        t += s[i];
    }
    cout << t;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    string s,t;
    cin>>s>>t;
    int len=s.size();
    bool found=false;
    for(int x=0;x<len;x++)
    {
        found=true;
        for(int i=0;i<len;i++)
        {
            if(s[i]!=t[(i+x)%len])
            {
                found=false;
                break;
            }
        }
        if(found)
            break;
    }
    if(found)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 2e4 + 5, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int x, int y, int p){
    int res = 1;
    x = x % p;

    while (y > 0){
        if (y & 1)  res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int modInverse(int n, int p){
    return power(n, p-2, p);
}

int n, a[N], b[N], deg[N], vis[N];
vector<int> adj[N];
set< pair < int, int> > s;

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

    //cout<<(53LL*modInverse(16, MOD))%MOD;//312500008
    cin>>n;
    for(int i = 1; i < n; i++){
        int u, v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        deg[v]++;
        deg[u]++;
    }

    for(int i = 1; i <= n; i++) cin>>a[i];
    sort(a + 1, a + n + 1);//, greater<int>());

    for(int i = 1; i <= n; i++){
        //s.insert({-deg[i], i});
        s.insert({deg[i], i});
    }
    int cnt = 1, sum = 0;

    while(cnt <= n){/*
        auto top = *s.begin();
        s.erase(top);
        b[top.second] = a[cnt];*/
        auto top = *s.begin();
        s.erase(top);
        vis[top.second] = 1;
        b[top.second] = a[cnt];
        //cout<<top.second<<' '<<a[cnt]<<endl;
        for(auto u: adj[top.second]){
            if(vis[u])  continue;
            s.erase({deg[u], u});
            deg[u]--;
            s.insert({deg[u], u});
        }


        cnt++;
    }

    for(int i = 1; i <= n; i++){

        for(auto u: adj[i]){
            sum += min(b[i], b[u]);
        }

    }

    sum /= 2;
    cout<<sum<<endl;

    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";


    return 0;
}


Measured memory_bytes: 2176
/*
* Problem Statement: 
* Author: ganpa
*/
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    string s;
    cin >> s;
    int ans = 0, l = 0;
    for (char i : s)
    {
        if (i == 'r' || i == 'R')
            l++;
        else
            l = 0;
        ans = max(ans, l);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, D; cin >> N >> D;

    int ans = (N + 2 * D) / (2 * D + 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll k, a, b; cin >> k >> a >> b;
    if (b - a <= 2 || k < a - 1) {
        cout << k + 1 << endl;
    } else {
        ll res = a;
        k -= a - 1;
        if (k % 2 == 1) {
            res++;
            k--;
        }
        res += (b - a) * (k / 2);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
    ans = (B - A) // 2
else:
    x = (B - A - 1)//2 + A
    y = (B - A - 1)//2 + N - B + 1
    ans = min(x,y)
print(ans)

Measured memory_bytes: 3060
using System;

namespace B___Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var input1 = Console.ReadLine().Split(' ');
            var ans = 0;
            for(var i=0; i<n; i++)
            {
                var v = int.Parse(input[i]);
                var c = int.Parse(input1[i]);
                if (v-c>0)
                {
                    ans += v - c;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
n = gets.chomp.to_i
t = []
x = []
y = []
n.times do |i|
  array = gets.chomp.split(' ').map(&:to_i)
  t << array[0]
  x << array[1]
  y << array[2]
end
ans = true
n.times do |i|
  if i == 0
    time = t[i]
    dist = x[i] + y[i]
  else
    time = t[i] - t[i - 1]
    dist = (x[i] - x[i - 1]).abs + (y[i] - y[i - 1]).abs
  end
  ans = false unless time >= dist && time % 2 == dist % 2
end
puts ans ? "Yes" : "No"


Measured memory_bytes: 4300
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int count = 0;
	REP(i, n + 1) {
		REP(j, n + 1) {
			if ((n - g * j-r*i) % b == 0&&n-g*j-r*i>=0) {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long A = H*W;

    	if(H==1||W==1){
			System.out.println("1");
		}else if(A%2==0){
			long ans = A/2;
			System.out.println(ans);
		}else{
			long ans = A/2+1;
			System.out.println(ans);
		}
    }
}


Measured memory_bytes: 35692
#include <stdio.h>
#include <string.h>
int H=0,A[2000001];
void maxHeapify(int);
void insert(int);
int extract();
int main(){
  char command[10];
  int k;
  while(1){
    scanf("%s",command);
    if(!strcmp(command,"insert")){
      scanf("%d",&k);
      insert(k);
    }
    else if(!strcmp(command,"extract")){
      k=extract();
      printf("%d\n",k);
    }
    else break;
  }

  return 0;
}
void insert(int k){
  int tmp,i;
  H++;
  i=H;
  A[H]=k;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i/2];
    A[i/2]=A[i];
    A[i]=tmp;
    i=i/2;
  }
}
int extract(){
  int i,k;
  k=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(1);
  return k; 
}
void maxHeapify(int i){
  int l=i*2,r=i*2+1,large,tmp;
  if(l<=H && A[l]>A[i])large=l;
  else large=i;
  if(r<=H && A[r]>A[large])large=r;
  if(large!=i){
    tmp=A[large];
    A[large]=A[i];
    A[i]=tmp;
    maxHeapify(large);
  }
}



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

int main() {
    int R, G, B, N, n, i, j, k;
    cin >> R >> G >> B >> N;
    if(R == 1 && G == 1 && B == 1){
        cout << (N + 1) * (N + 2) / 2 << endl;
    }
    else{
        n = 0;
        i = 0;
        while(R * i < N + 1){
            j = 0;
            while(R * i + G * j < N + 1){
                k = 0;
                while(R * i + G * j + B * k < N + 1){
                    if(R * i + G * j + B * k == N){
                        n++;
                    }
                    k++;
                }
            j++;
            }
        i++;
        }
        cout << n << endl;
    }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
  
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=3;i++)
    {
    	if(i!=a and i!=b)
    	{
    		cout<<i;
    		break;
    	}
    }
}

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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string str;
    cin >> str;
    rep(i, (int) str.size() - 1) {
        if (str.at(i) == str.at(i + 1)) {
            cout << "Bad" << endl;

            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

#define ll long long
#define in(params) cin >> (params);
#define p(params) cout << (params) << endl;
#define mod 1000000007LL

using namespace std;

int main()
{
    char b;
    in(b);

    switch (b)
    {
    case 'A':
        p('T');
        break;
    case 'T':
        p('A');
        break;
    case 'C':
        p('G');
        break;
    case 'G':
        p('C');
        break;
    }

    return 0;
}

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

int main() {
  int A,B,c,k;
  k=0;
  cin >>A >>B;
  for (int i=A; i<=B;i++){
    c=i;
    
    if( c-(c/10)*10==c/10000 && c/1000-(c/10000)*10 ==c/10-(c/100)*10){
      k++;
     }
  }
  cout << k << endl;      
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define max 6

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    long int in, i, j=0;
    long int fihun, fiv;
    
    scanf("%ld", &i);
    
    fihun = i/500;
    fiv = (i-fihun*500)/5;
    
    printf("%ld", fihun*1000+fiv*5);

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>

class Point
{
public:
	Point(double x, double y)
		: m_x(x)
		, m_y(y)
	{
	}

	Point(const Point& src)
		: Point(src.m_x, src.m_y)
	{
	}

public:
	Point& operator =(const Point& src)
	{
		src.m_x;
		src.m_y;
		return (*this);
	}

	Point operator +(const Point& rhs) const
	{
		Point tmp = (*this);
		tmp.m_x += rhs.m_x;
		tmp.m_y += rhs.m_y;
		return tmp;
	}

	Point& operator +=(const Point& rhs)
	{
		m_x += rhs.m_x;
		m_y += rhs.m_y;
		return (*this);
	}

	Point operator -(const Point& rhs) const
	{
		Point tmp = (*this);
		tmp.m_x -= rhs.m_x;
		tmp.m_y -= rhs.m_y;
		return tmp;
	}

	Point& operator -=(const Point& rhs)
	{
		m_x -= rhs.m_x;
		m_y -= rhs.m_y;
		return (*this);
	}

public:
	double GetLength() const
	{
		return sqrt((m_x * m_x) + (m_y * m_y));
	}

private:
	double m_x;
	double m_y;
};

int main(int argc, char** argv)
{
	double p1x, p1y, p2x, p2y;
	std::cin >> p1x >> p1y >> p2x >> p2y;

	Point p1(p1x, p1y);
	Point p2(p2x, p2y);

	printf("%.5lf\n", (p2 - p1).GetLength());

	return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int arr[5];
	for (int i = 0; i < 5; ++i)
	{
		cin>>arr[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if(arr[i]==0)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::map<std::string, int> MAP;
	std::vector<std::string> s(N);
	for (auto& r : s) {
		std::cin >> r;
		++MAP[r];
	}
	intt M; std::cin >> M;
	std::vector<std::string> t(M);
	for (auto& r : t) {
		std::cin >> r;
		--MAP[r];
	}
	int max = -201;
	for (auto& r : MAP)
		max = std::max(max, r.second);

	std::cout << std::max(max, 0) << std::endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    map<string,int> ans;
    rep(i,n){
        string s; cin>> s;
        ans[s]++;
    }
    printf("AC x %d\n",ans["AC"]);
    printf("WA x %d\n",ans["WA"]);
    printf("TLE x %d\n",ans["TLE"]);
    printf("RE x %d\n",ans["RE"]);
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b>=c)cout<<0<<endl;
    else cout<<c-(a-b)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static io;
public class CompetitiveProgramming
{
  public void Solve()
  {
    var n = Int1;
    var S = Ints;
    var q = Int1;
    var T = Ints;
    Array.Sort(S);
    Array.Sort(T);
    int ans = 0;
    int j = 0;
    for (int i = 0; i < q; ++i)
    {
      while (j < n && S[j] < T[i] && j < n) ++j;
      if (j > n - 1) continue;
      if (T[i] == S[j])
      {
        ++j;
        ++ans;
      }
    }
    Write(ans);
  }
}



class Program
{
  static void Main(string[] args)
  {
    var CompetitiveProgramming = new CompetitiveProgramming();
    CompetitiveProgramming.Solve();
  }
}
public static class io
{
  public static string Str => Console.ReadLine();
  public static string[] Strs => Str.Split(' ');
  public static long[] Longs => Strs.Select(long.Parse).ToArray();
  public static int[] Ints => Strs.Select(int.Parse).ToArray();
  public static char[] Chars => Str.ToArray();
  public static double[] Doubles => Strs.Select(double.Parse).ToArray();
  public static long Long1 => Longs[0];
  public static int Int1 => Ints[0];
  public static char Char1 => Chars[0];
  public static double Double1 => Doubles[0];
  public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; }
  public static void Write(string a) => Console.WriteLine(a);
  public static void Write(params object[] i) => Write(string.Join(" ", i));
  public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
  public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); }
  public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); }
}



Measured memory_bytes: 18488
import java.util.Scanner;

public class Main {
  public static void main(String args[]) throws Exception {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int x = Math.max(a, Math.max(b, c));
    System.out.println(a + b + c + x*9);
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main ()
{
    double t,n,sum;
    scanf ("%lf%lf",&t,&n);
    sum=0;
    while (t--)
    {
        double a,b;
        scanf ("%lf%lf",&a,&b);
        if(sqrt(a*a+b*b)<=n)
        {
            sum++;
        }
        else
            continue;
    }
    printf ("%.f\n",sum);
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int book[1000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>book[i];
	sort(book,book+n);
	double ans=book[0];
	for(int i=1;i<n;i++) ans=(ans+book[i])/2;
	cout<<fixed<<setprecision(8)<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000000000000000
int main(){
	int n,m,i;cin>>n>>m;//n駒で全地点を訪れたい
	vector<int> x(m);
	vector<pair<int,int>> minus(m);//二点間の距離
	minus[0]=make_pair(0,0);

	for(i=0;i<m;i++){
		cin>>x[i];
	}
	sort(x.begin(),x.end());//座標の小さい順


	for(i=1;i<m;i++){//2点間距離
		minus[i]=make_pair(x[i]-x[i-1],i);
	}
	sort(minus.begin(),minus.end(),greater<pair<int,int>>());//2点間距離の大きい順
	

	if(n>=m){cout<<0<<endl;return 0;}

	i=1;
	while(i<n){//2点間距離が大きいところに駒を置く(無効にできる距離差はn-1個まで)
		minus[i-1].second=10000000;
		i++;
	}

	int ans=0;
	for(i=0;i<m;i++){
		if(minus[i].second!=10000000){
			ans+=(minus[i].first);
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc100/tasks/abc100_b

D, N = read_ints()
if N == 100:
    N += 1
print(N * (100**D))


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

using namespace std;

int N, M;

int main() {
	cin >> N >> M;
	vector<int> A(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum % (4*M) != 0) { sum /= (4*M); sum++; }
	else { sum /= (4*M); }
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= sum) { cnt++; }
	}

	if (cnt >= M) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b;
    char op;
    
    while (op != 63)
    {
        scanf("%d %c %d",&a,&op,&b);
        // printf("%d %1c %d\n",a,op,b);
        if (op == 43)
            printf("%d\n", a + b);
        if (op == 45)
            printf("%d\n", a - b);
        if (op == 42)
            printf("%d\n", a * b);
        if (op == 47)
            printf("%d\n", a / b);
    }
}


Measured memory_bytes: 2068
import sys
readline = sys.stdin.buffer.readline

n,t = map(int,readline().split())
lst1 = list(map(int,readline().split()))
counter = []
mn = 10**9+1

for i in range(n):
    if lst1[i] < mn:
        mn = lst1[i]
    if mn < lst1[i]:
        counter.append(lst1[i]-mn)

from collections import Counter
c = Counter(counter)

ans = 0
mx = 0
for key,value in c.items():
    if key > mx:
        ans = value
        mx = key

print(ans)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> buttons(N);
  
  for (int i = 0; i < N; i++) {
    cin >> buttons.at(i);
  }
  
  int j = 1;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    j = buttons.at(j - 1);
    
    if (j == 2) {
      count = i + 1;
      break;
    } 
  }
  
  if (count != 0) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai > 0
    posi << ai
  elsif ai < 0
    nega << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!
posi_size = posi.size
nega_size = nega.size

ng = -(10**18 + 1)
ok = 10**18 + 1
while ok - ng > 1
  mid = (ok + ng) / 2
  cnt = 0

  if mid >= 0
    cnt += zeros * (zeros - 1) / 2 + zeros * (N - zeros)
  end

  if mid > 0
    cnt += posi_size * nega_size

    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        while l < r && a[l] * a[r] > mid
          r -= 1
        end
        cnt += l < r ? r - l : 0
        l += 1
      end
    end
  else
    r = nega_size - 1
    0.upto(posi_size - 1) do |l|
      while r >= 0 && posi[l] * nega[r] <= mid
        r -= 1
      end
      cnt += nega_size - r - 1
    end
  end

  if cnt >= K
    ok = mid
  else
    ng = mid
  end
end
puts ok

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

int main(){
string t;
  cin>>t;
  long long n=t.size();
 for(int i=0;i<n;i++){
if(t.at(i)=='?'){
t.at(i)='D';
}
 }
for(int i=0;i<n;i++){
cout<<t.at(i);
}
  cout<<endl;
}
 

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

int main() {
  int N;
    cin >> N;
    int l, r;
  	int i, j;
    for (i = 0; N > i; i++) {
      cin >> l >> r;
        j += r - l + 1;
    }   //forの終わり
  cout << j << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
 
#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
 
using namespace std;
 
const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

int n, k;
int a[51];
ll dp[51][51][2501], ans;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][0][0] = 1;
			for (int sum = 0; sum <= 2500; sum++) {
				dp[i][j][sum] = dp[i - 1][j][sum];
				if (sum - a[i] >= 0 && j > 0) {	
					dp[i][j][sum] 
						+= dp[i - 1][j - 1][sum - a[i]];
				}
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		ans += dp[n][i][k * i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 49152
#include<iostream>

using namespace std;

int main() {
	int N, T, A, H[1100], genzaiti,saiteki=1000000000, bangou=0;

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

	for (int i = 0; i < N; i++) {
		genzaiti = abs(A*1000 - (T*1000 - H[i] * 6));
		if (saiteki >genzaiti) {
			saiteki = genzaiti;
			bangou = i + 1;
		}
	}
	cout << bangou << endl;


	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b

def main():
    n, x = map(int, input().split())
    town = map(int, input().split())

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

using P = pair<int, int>;
using PI = pair<P, int>;

struct Edge { int to, cost; };

void input(int N, vector<vector<Edge>> &G, vector<PI> &A) {
    sort(A.begin(), A.end());
    rep(i, 1, N) {
        int cost = A[i].first.first - A[i-1].first.first;
        G[A[i].second].push_back({A[i-1].second, cost});
        G[A[i-1].second].push_back({A[i].second, cost});
    }
}

int main() {
    int N;
    cin >> N;
    vector<PI> A(N), B(N);
    rep(i, 0, N) {
        int a, b; cin >> a >> b;
        A[i] = {P(a, b), i};
        B[i] = {P(b, a), i};
    }
    vector<vector<Edge>> G(N);
    input(N, G, A);
    input(N, G, B);
    priority_queue<P, vector<P>, greater<P>> Q;
    vector<int> visited(N);
    Q.push(P(0, 0));
    int ans = 0;
    while(!Q.empty()) {
        P p = Q.top(); Q.pop();
        int cur = p.second;
        int cost = p.first;
        if(visited[cur]) continue;
        visited[cur] = 1;
        ans += cost;
        for(auto &e : G[cur]) {
            if(visited[e.to]) continue;
            Q.push(P(e.cost, e.to));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12152
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
void solve() {
    int n;
    cin>>n;
    if(n==0) cout<<1;
    else cout<<0;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int maxn=1*1e5+5;
int arr[maxn];
int main()
{
    FAST
   int t;
   cin>>t;
  pair<string,int> *v=new pair<string,int>[t];
  for(int i=0;i<t;i++)
  {
      string h;
      int a;
      cin>>h>>a;
      v[i]=make_pair(h,a);
  }
 string x;
 cin>>x;
 int j=0;
 for(int i=0;i<t;i++)
 {
     if(v[i].first==x)
     {
         j=i;
         break;
     }
 }
 ll sum=0;
 for(int i=j+1;i<t;i++)
 {
    sum+=v[i].second;
 }
 cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int X,A,B;
	cin>>X>>A>>B;
	if(B<=A)cout<<"delicious";
	else if(B>A+X)cout<<"dangerous";
	else cout<<"safe";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  char a;
  cin >> a;
  if (a >= 'A' && a <= 'Z')
  {
    cout << 'A' << endl;
  }
  else if (a >= 'a' && a <= 'z')
  {
    cout << 'a' << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<>());

	lint ans = 0, idx = 0;
	for (int i = 0; i < N; i++) {
		ans += A[idx];
		if (i & 1) idx++;
	}

	cout << ans - A.front() << "\n";

	return 0;
}



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

int main() {
  string S,T,Ans="Yes";
  cin>>S>>T;
  rep(i,S.size()){if(S.at(i)!=T.at(i)){Ans="No";break;}}
  cout<<Ans<<endl;
}


Measured memory_bytes: 3632
n,k,q=map(int,input().split())
l=[k for i in range(n+1)]
ll=[0 for i in range(n+1)]
for i in range(q):
  ind=int(input())
  ll[ind]+=1
for i in range(1,n+1):
  if l[i]-(q-ll[i])>0:
    print("Yes")
  else:
    print("No")
  # print(l[i]-(q-ll[i]))


Measured memory_bytes: 5476
require 'prime'
n = gets.to_i
array = Array.new(100,0)
ans = 0
2.upto(n) do |i|
  factoring = Prime.prime_division(i)
  factoring.map { |a|
    array[a[0]] += a[1]
    }
end

over_74 = array.count {|num| num >=74}
over_24 = array.count {|num| num >=24}
over_14 = array.count {|num| num >=14}
over_4 = array.count {|num| num >=4}
over_2 = array.count {|num| num >=2}

ans = over_74 + over_24*(over_2-1)  + over_14*(over_4-1) + (over_2-2)*over_4*(over_4-1)/2
puts ans


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
using namespace std;
#define N_MAX 500001

int main()
{
    string str;
    cin >> str;
    vector<pair<char,int>> stairs;
    int num = 0;
    char c = str[0];
    for(int i = 0; i < (int)str.size(); ++i)
    {
        if(c == str[i])
        {
            ++num;
        }
        else
        {
            stairs.push_back(make_pair(c,num));
            c = str[i];
            num = 1;
        }
    }
    stairs.push_back(make_pair(c, num));

    int n = str.size();
    vector<int> nums(n+1);
    int idx = 1;
    for(pair<char,int> p: stairs)
    {
        char tc = p.first;
        int tn = p.second;
        //cout << tc << " " << tn << endl;
        if(tc == '>')
        {
            nums[idx-1] = max(nums[idx-1],tn);
        }
        for(int i = 0; i < tn; ++i)
        {
            if(tc == '<')
            {
                nums[idx] = nums[idx-1]+1;
            }
            else
            {
                nums[idx] = tn-i-1;
            }
            ++idx;
        }
    }
    long long int sum = 0;
    for(int i : nums)
    {
        //cout << i << " ";
        sum += i;
    }
    //cout << endl;
    cout << sum << endl;
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    int ans = 0;
    REPP(i,n) {
        string s = to_string(i);
        ans += (s.size()%2==1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

   int a[3];

   cin >> a[0] >> a[1] >> a[2];

   sort(a, a + 3);

   cout << a[0] << " " << a[1] << " " << a[2] << endl;

   return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n, m, k;
vector<bool> seen;
vector<int> tree_num;
arr<int> G;
// arr<int> F;
arr<int> B;
vector<int> cand;

void bfs(int x, int num){
    vector<int> tree;
    tree.push_back(x);
    seen[x] = true;
    tree_num[x] = num;

    queue<int> que;
    que.push(x);

    while(!que.empty()){
        int a = que.front(); que.pop();
        for(int b: G[a]){
            if(seen[b]) continue;
            seen[b] = true;
            tree.push_back(b);
            tree_num[b] = num;
            que.push(b);
        }
    }

    for(int t: tree){
        int bl = 0;
        for(int b: B[t]){
            if(tree_num[t]==tree_num[b]) bl++;
        }

        cand[t] = tree.size() - G[t].size() - bl - 1;
    }
}


int main()
{
    cin >> n >> m >> k;
    seen.assign(n, false);
    tree_num.assign(n, -1);
    G.resize(n);
    B.resize(n);
    cand.resize(n);

    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, k){
        int a, b; cin >> a >> b;
        a--; b--;
        B[a].push_back(b);
        B[b].push_back(a);
    }

    int num = 0;
    rep(i, n){
        if(seen[i]==false) bfs(i, num++);
    }

    prvec(cand);
    return 0;}

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

using namespace std;

signed main(){
    int ramen = 700;
    string str;
    
    cin >> str;
    
    for(int i=0; i<str.size(); ++i){
        if((str.at(i)=='o')) ramen +=100;
    }
    
    cout << ramen << endl;
}

Measured memory_bytes: 256