akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

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

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

const long long N = 200100;
const long long M = 1001005;
const long long MOD = 998244353;

long long n, a[N], f[M], ans[M], sum;

long long powMod(long long base, long long exp) {
	if(exp == 0)return 1;
	long long tmp = powMod(base, exp / 2);
	tmp = (1LL * tmp * tmp) % MOD;
	if(exp % 2) tmp = (tmp * base) % MOD;
	return tmp;
}

long long invMod(long long a) {
	return powMod(a, MOD - 2);
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(long long i = 1; i <= n; i++)  {
		cin >> a[i];
		f[a[i]]++;
		sum += a[i];
		sum %= MOD;
	}
	// dbg(sum);

	for(long long g = M - 1; g ; g--) {
		long long scad = 0;
		long long adun = 0;
		for(long long i = 2 * g; i < M; i += g) {
			scad += ans[i];
			scad %= MOD;
		}

		for(long long i = g; i < M; i += g) {
			adun += i * f[i];
			adun %= MOD;
		}
		ans[g] = (adun * adun - scad) % MOD; 
	}

	long long big_ans = 0;
	for(long long i = 1; i < M; i++) {
		big_ans += ans[i] * invMod(i);
		big_ans %= MOD;
	}

	// dbg(big_ans, sum);
	big_ans -= sum;
	big_ans = big_ans * invMod(2);
	big_ans += MOD * MOD;

	cout << big_ans % MOD << '\n';
	// dbg_v(ans, 10);
}	

	

Measured memory_bytes: 17408
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
// x_1,...,x_j から k 枚選んで x_i の合計を s にするような選び方の総数
int dp[55][55][2510];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	// 気づきにくいポイント
	// 解法: DP
	// ただしX = max{x_1,...,x_n,a}とおく。
	int n, a; cin >> n >> a;
	VE x(n); rep(i, n)cin >> x[i];
	int X = 0;
	rep(i, n)chmax(X, x[i]);
	chmax(X, a);
	for (int j = 0; j <= n; j++) {
		for (int k = 0; k <= n; k++) {
			for (int s = 0; s <= X * n; s++) {
				if (j == 0 && k == 0 && s == 0) {
					dp[j][k][s] = 1;
				}
				else if (j >= 1 && s < x[j - 1]) {
					dp[j][k][s] = dp[j - 1][k][s];
				}
				else if (j >= 1 && k >= 1 && s >= x[j - 1]) {
					dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
				}
				else {
					dp[j][k][s] = 0;
				}
			}
		}
	}
	int ans = 0;
	for (int k = 1; k <= n; k++) {
		ans += dp[n][k][k*a];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 55424
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

int main()
{
  ll n;
  cin>>n;
  string s;
  cin>>s;
  vecint cnt(26, 0);
  for(char c : s) {
    ++cnt[c - 'a'];
  }
  ll mul = 1;
  REP(i,26) {
    mul *= cnt[i]+1;
    mul %= MOD;
  }
  mul += MOD - 1;
  mul %= MOD;
  cout << mul << endl;
  return 0;
}


Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 1048576
#define PI 3.1415926535
int grid[100][100] = {};
int dijk[100][100] = {};
int visited[100][100] = {};
int main() {
	int ans = 0;
	int h, w;
	cin >> h >> w;
	for (int i = 0;i < h;++i) {
		string s;
		cin >> s;
		for (int q = 0;q < w;++q) {
			if (s[q] == '.') {
				ans++;
			}
			else {
				grid[i][q] = 1;
			}
			dijk[i][q] = 100000;
		}
	}
	if (grid[0][0] == 1 || grid[h - 1][w - 1] == 1) {
		cout << -1 << endl;
		return 0;
	}
	queue<pair<int, int>> next;
	next.push(make_pair(0, 0));
	int x[4] = { 1,-1,0,0 }, y[4] = { 0,0,1,-1 };
	dijk[0][0] = 0;
	while (next.empty() == false) {
		pair<int, int> now = next.front();
		next.pop();
		for (int q = 0;q < 4;++q) {
			if (now.first + x[q] >= 0 && now.first + x[q] < h&&now.second + y[q] >= 0 && now.second + y[q] < w) {
				if (dijk[now.first + x[q]][now.second + y[q]] > dijk[now.first][now.second] + 1&&grid[now.first + x[q]][now.second+y[q]] == 0) {
					dijk[now.first + x[q]][now.second + y[q]] = dijk[now.first][now.second] + 1;
					next.push(make_pair(now.first + x[q], now.second + y[q]));
				}
			}
		}
	}
	if (dijk[h - 1][w - 1] == 100000) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans - dijk[h - 1][w - 1] - 1 << endl;
	return 0;
}

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

#define MIN_N 1
#define MAX_N 200000
#define MIN_A 0
#define MAX_A 1000000000

int array[MAX_N];
long invcnt = 0;

void merge(int *array, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int i, j, k, *left_array, *right_array;

	left_array = malloc(sizeof(int) * n1 + 100);
	right_array = malloc(sizeof(int) * n2 + 100);

	for(i = 0; i < n1; i++) 
		left_array[i] = array[left + i];
	for(i = 0; i < n2; i++)
		right_array[i] = array[mid + i];
	left_array[n1] = MAX_A + 1;
	right_array[n2] = MAX_A + 1;
	i = 0;
	j = 0;
	for(k = left; k < right; k++) {
		if(left_array[i] <= right_array[j]) 
			array[k] = left_array[i++];
		else {
			invcnt += n1 - i;
			array[k] = right_array[j++];
		}
		
	}
	free(left_array);
	free(right_array);
}

void merge_sort(int *array, int left, int right)
{
	if(left + 1 < right) {
		int mid;

		mid = (left + right) / 2;
		merge_sort(array, left, mid);
		merge_sort(array, mid, right);
		merge(array, left, mid, right);
	}

}

int main(void)
{
	int i, n;

	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		array[i] = a;
	}
	merge_sort(array, 0, n);
	printf("%ld\n", invcnt);

	return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define int long long int

signed main(){
    int t = 1; //cin >> t;
    while(t--){
    	int mod; cin >> mod;
    	int rem = 0;
    	set<int> all;
    	for(int i = 1; ; i++)
    	{
    		rem = ((rem*10) % mod + 7) % mod;
    		if(rem == 0){
    			cout << i ;
    			return 0;
    		}
    		if(all.find(rem) == all.end())
    			all.insert(rem);
    		else{
    			cout << -1;
    			return 0;
    		}
    	}
    }    
}

Measured memory_bytes: 50484
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    double a[5];
    int mini = INT_MAX;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if ((int) a[i] % 10) {
            mini = min(mini, (int) a[i] % 10);
        }
    }

    int ans = 0;
    for (double e : a) {
        ans += (ll) ceil(e / 10) * 10;
    }

    if (mini == INT_MAX) {
        cout << ans;
    }

    else {
        cout << ans - 10 + mini;
    }



}




Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	char x[110];
	unsigned long long int y;
	int f=0;
	
	scanf("%s", x);
	scanf("%llu", &y);
	
	for(int i=0;i<y;i++)
	{
		if((x[i]-'0')>1)
		{
			printf("%d\n", (x[i]-'0'));
			f=1;
			break;
		}
	}
	
	if(f==0)
	{
		printf("1\n");
	}
	
	return 0;
}

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

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


Measured memory_bytes: 3088
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
   int n;
   int k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<i;j++)
       {
           if(arr[j]>arr[i])
           {
               int temp= arr[i];
               arr[i]=arr[j];
               arr[j]=temp;
           }
       }
   }
   int sum=0;
     for(int i=0;i<k;i++)
   {
      sum += arr[i];
   }
   cout<<sum;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); 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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    vl A(N);
    rep(i, N) cin >> A[i];
    vl sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + A[i];

    ll l = 1, r = 3, ans = INF;
    ll l1, l2, r1, r2;
    repe(c,2,N-1){
        chmax(r, c + 1);
        l1 = sum[l], l2 = sum[c] - sum[l], r1 = sum[r] - sum[c], r2 = sum[N] - sum[r];
        while (l < c - 1 && abs(l2-l1) > abs(l2-l1-2*A[l])) {
            l1 += A[l], l2 -= A[l];
            l++;
        }
        while(r<N-1&&abs(r2-r1)>abs(r2-r1-2*A[r])){
            r1 += A[r], r2 -= A[r];
            r++;
        }
        // cout << l << " " << c << " " << r << endl;
        // cout << l1 << " " << l2 << " " << r1 << " " << r2 << endl;
        auto pl = minmax(l1, l2), pr = minmax(r1, r2);
        chmin(ans, max(pl.second, pr.second) - min(pl.first, pr.first));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
fun main(args: Array<String>) {
  var N = readLine()!!.toInt()
  var D = readLine()!!.split(" ").map(String::toInt)
  var D2 = D.drop(1)
  var total = 0
  for (d in D) {
      for (d2 in D2) {
          total += d*d2
      }
      D2 = D2.drop(1)
  }
  println(total)
}

Measured memory_bytes: 36028
import * as fs from 'fs';

namespace AtCoder.abc162 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const s: string = this.args[0];
            const ans: boolean = s.split('').some(x => {
                return (x === '7');
            });
            console.log(ans ? 'Yes' : 'No');
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc162.Program(args);
prg.main();


Measured memory_bytes: 29604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	for _, r := range s {
		if int(r) >= 97 {
			fmt.Println("a")
		} else {
			fmt.Println("A")
		}
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 3000000000000000000
#define inf -100000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
ll int power(ll int x,ll int y) 
{ 
    ll int res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
int main()
{
    fast;
  //  #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    ll int k,a,b,i;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
    	if(i%k==0)
    	{
    		cout<<"OK";exit(0);
    	}
    }
    cout<<"NG";
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  string s; cin >> s;
  if(s[0] == 'S') cout << "Cloudy";
  else if(s[0] == 'C') cout << "Rainy";
  else cout << "Sunny";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {

    priority_queue<pair<int,int>> pq;
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    Rort(v);
    ll ans=v[0];
    {
        pair<int,int> p=mp(min(v[0],v[1]),max(v[0],v[1]));
        pq.push(p);
    }
    for(int i=2;i<n;i++){
        auto t=pq.top();
        if(i!=2)pq.pop();
        ans+=t.fi;
        {
            pair<int,int> p=mp(min(v[i],t.fi),max(v[i],t.fi));
            pq.push(p);
        }
        {
            pair<int,int> p=mp(min(v[i],t.se),max(v[i],t.se));
            pq.push(p);
        }
    
    }
    fin(ans);
}


Measured memory_bytes: 6144
#include <stdio.h>

int main() {
  int H1, M1, H2, M2, K;
  scanf("%d%d%d%d%d", &H1, &M1, &H2, &M2, &K);
  int l = H2 * 60 + M2 - H1 * 60 - M1 - K;
  printf("%d\n", l);
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    long int x;cin>>x;
  	long long int ans=(x/500)*1000;
  	x%=500;
  	ans+=5*(x/5);
  	cout<<ans<<"\n";
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<pii> ab;
  rep(i, 2 * n) {
    int x;
    cin >> x;
    ab.eb(mp(x, (i < n ? 1 : -1)));
  }

  sort(all(ab));

  ll ans = 1;
  int cnt = 0;
  rep(i, ab.size()) {
    if (cnt > 0) {
      if (ab[i].S > 0)
        cnt++;
      else {
        ans = ans * cnt % MOD;
        cnt--;
      }
    } else if (cnt < 0) {
      if (ab[i].S < 0)
        cnt--;
      else {
        ans = ans * cnt * -1 % MOD;
        cnt++;
      }
    } else {
      cnt += ab[i].S;
    }
  }

  cout << ans << endl;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A+B <= C || C+D <= A){
    cout << "0" << endl;
    return 0;
  }
  int s = A, t=B;
  if(s<C) s=C;
  if(t>D) t=D;
  cout << abs(t-s) << endl;
  return 0;
}

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

int main(void)
{
  int ih, im, is;
  while (true)
  {
    cin >> ih >> im >> is;
    if (ih == -1 and im == -1 and is == -1) break;
    int time3, time;
    time3 = time = 120 * 60 - ih * 3600 - im * 60 - is;
    time3 *= 3;

    int oh = time / 3600;
    time %= 3600;
    int om = time / 60;
    time %= 60;
    int os = time;

    int o3h = time3 / 3600;
    time3 %= 3600;
    int o3m = time3 / 60;
    time3 %= 60;
    int o3s = time3;

    printf("%.2d:%.2d:%.2d\n", oh, om, os);
    printf("%.2d:%.2d:%.2d\n", o3h, o3m, o3s);
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 200000+66
ll a[maxn];
int main()
{
    ll h,k;
    a[0]=1;
    for(int i=1;i<=100000;i++)
    {
        a[i]=2*a[i-1]+1;
    }
    while(cin>>h)
    {
        ll ans=0;
        int cnt=0;
        while(h>0)
        {
            h/=2;
            cnt++;
        }

        cout<<a[cnt-1]<<endl;
    }
}


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

int sumOfDigits(int n){
  if (n == 0) return 0;
  return n%10 + sumOfDigits(n/10);
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for (int i = 1; i <= n; i++) {
    if(a<=sumOfDigits(i) && sumOfDigits(i)<=b) ans+=i;
  }
  cout << ans;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int n, k;

bool read () {
	if (scanf("%d%d", &k, &n) != 2)
		return false;
	return true;
}

void solve() {
	printf("%d\n", n == 1 ? 0 : k - (n - 1) - 1);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if (read()){
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			char[] c=sc.next().toCharArray();
			String str="";
			for(int i=0;i<c.length;i++){
				if(c[i]=='@'){
					for(int j=0;j<Integer.parseInt(c[i+1]+"");j++){
						str+=(c[i+2]+"");
					}
					i+=2;
				}else{
					str+=(c[i]+"");
				}
			}
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    int n,i;
    scanf("%d",&n);
    lli a[n];
    for(i=0;i<n;i++)
    scanf("%lld",&a[i]);
    lli ans[n]={0};
    ans[n-1]=0;
    ans[n-2]=abs(a[n-2]-a[n-1]);
    for(i=n-3;i>=0;i--)
    ans[i]=min(ans[i+1]+abs(a[i]-a[i+1]),ans[i+2]+abs(a[i]-a[i+2]));
    printf("%lld",ans[0]);
}

Measured memory_bytes: 5340
#include<stdio.h>
#include<string.h>

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MAX 2000000
#define INFINITY (1<<30)

int h,A[MAX+1];

void maxHeapify(int i){
	int left,right,largest;
	left = 2*i;
	right = 2*i+1;
	
	if(left <= h && A[left] > A[i]){
		largest = left;
	}else{
		largest = i;
	}

	if(right <= h && A[right] > A[largest]){
	largest = right;
	}
	
	if(largest != i){
	SWAP(A[i],A[largest]);
	maxHeapify(largest);
	
	}
}

int extract(){
	int maxv;
	if(h < 1)return -INFINITY;
	maxv = A[1];
	A[1] = A[h--];
	maxHeapify(1);	
	return maxv;
}



void increaseKey(int i,int key){
	if(key < A[i])return;
	
	A[i] = key;
	while(i > 1 && A[i / 2] < A[i]){
		SWAP(A[i],A[i/2]);
		i = i/2;
	}
}

void insert(int key){
	h++;
	A[h] = -INFINITY;
	increaseKey(h,key);
	
}
	
int main(){
	int key;
	char com[10];
	
	while(1){
		scanf("%s",com);
		if(com[0] == 'e' && com[1] == 'n')break;
		if(com[0] == 'i'){
			scanf("%d",&key);
			insert(key);
		}else{
			printf("%d\n",extract());
		}
	
	}
	return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}



int32_t main() {
	

	int a;
	cin >> a;

	cout << a + a * a + a * a * a;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

class UnionFind{
public:
  vector<int> uni;
  UnionFind(int s) : uni(s, -1) {}

  int root(int a){
    if(uni[a] < 0) return a;
    return uni[a] = root(uni[a]);
  }

  bool connect(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(uni[a] > uni[b]) swap(a, b);
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
  }

  bool isConnect(int a, int b){
    return root(a) == root(b);
  }

  int size(int a){
    return -uni[root(a)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  rep(i, 0, M) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
  }
  vector<ll> ans(M);
  UnionFind uf(N);
  rem(i, M-1, 0) {
    if(uf.isConnect(A[i], B[i])) continue;
    ans[i] = (ll)uf.size(A[i]) * (ll)uf.size(B[i]);
    uf.connect(A[i], B[i]);
  }
  rep(i, 1, M) ans[i] += ans[i - 1];
  rep(i, 0, M) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[5][105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			a[i][j]+=max(a[i-1][j],a[i][j-1]);
		}
	printf("%d",a[2][n]);
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < k; i++) {
			int snack = sc.nextInt();
			for (int j = 0; j < snack; j++) {
				int people = sc.nextInt();
				// System.out.println("people: " + people);
				set.add(people);
			}
		}
		System.out.println(n - set.size());
	}
}

 
 

 
 
 
 


Measured memory_bytes: 46160
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>

using std::min;
using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::ios;
typedef long long ll;
const int N = 100010;
const int MOD = 1e9+7;
const ll INFLL = 2e18;
int _w;

void add_mod( int &a, int b ) {
	a += b;
	a -= a >= MOD ? MOD : 0;
}

int n, f[N][2];
ll a, b, s[N];

int find( int i, ll v ) {
	int low = i+1, high = n+1;
	while( low < high ) {
		int mid = (low + high)/2;
		if( s[mid] - s[i] >= v ) high = mid;
		else low = mid+1;
	}
	return low;
}

namespace RMQ {
	ll minv[N*4], qv;
	int ql, qr;
	void _init( int o, int L, int R ) {
		if( L == R ) {
			minv[o] = s[L+1] - s[L];
		} else {
			int M = (L+R)/2, lc = o<<1, rc = lc|1;
			_init(lc, L, M), _init(rc, M+1, R);
			minv[o] = min( minv[lc], minv[rc] );
		}
	}
	void init() {
		_init(1, 1, n-1);
	}
	void _query( int o, int L, int R ) {
		if( L >= ql && R <= qr ) {
			qv = min( qv, minv[o] );
		} else {
			int M = (L+R)/2, lc = o<<1, rc = lc|1;
			if( ql <= M ) _query(lc, L, M);
			if( qr > M ) _query(rc, M+1, R);
		}
	}
	ll query( int l, int r ) {
		ql = l, qr = r, qv = INFLL;
		_query(1, 1, n-1);
		return qv;
	}
}

bool check( int L, int R, ll v ) {
	if( L == R ) return true;
	return RMQ::query(L, R-1) >= v;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> a >> b;
	if( n == 1 ) return puts("2"), 0;
	for( int i = 1; i <= n; ++i )
		cin >> s[i];
	RMQ::init();
	s[0] = -INFLL, s[n+1] = INFLL;
	f[1][0] = 1;
	for( int i = 1; i <= n; ++i ) {
		if( f[i][0] ) {
			if( s[i] - s[i-1] >= a ) {
				add_mod( f[i+1][0], f[i][0] );
				add_mod( f[i+1][1], f[i][0] );
			} else {
				int j = find(i-1, a);
				if( check(i, j-1, b) )
					add_mod( f[j][1], f[i][0] );
			}
		}
		if( f[i][1] ) {
			if( s[i] - s[i-1] >= b ) {
				add_mod( f[i+1][1], f[i][1] );
				add_mod( f[i+1][0], f[i][1] );
			} else {
				int j = find(i-1, b);
				if( check(i, j-1, a) )
					add_mod( f[j][0], f[i][1] );
			}
		}
	}
	cout << (f[n+1][0] + f[n+1][1]) % MOD << endl;
	return 0;
}


Measured memory_bytes: 4992
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n;

	scanf("%d",&n);
	if(n==0)return !printf("0\n");
	string ans = "";
	int k = -2;
	while(n){
		if(n%k){
			ans='1'+ans;
			n--;
		}
		else	ans = '0'+ans;
		n/=-2;
	}
	printf("%s\n",ans.c_str() );
}	



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int n,q,b,c;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];

    VI cnt(100000+1);
    REP(i,0,n) cnt[a[i]]++;
    LL sum = 0;
    REP(i,0,n) sum += a[i];
    cin >> q;
    REP(qqq,0,q) {
        cin >> b >> c;
        int m = cnt[b];
        cnt[c] += m;
        cnt[b] = 0;
        sum += (c - b) * m;
        cout << sum << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  int i, j;
  i = (a - '0') * 10 + (b - '0');
  j = (c - '0') * 10 + (d - '0');
  if ((0 < i && i < 13) && (0 < j && j < 13))
    cout << "AMBIGUOUS" << endl;
  else if ((0 < i && i < 13) && not (0 < j && j < 13))
    cout << "MMYY" << endl;
  else if (not (0 < i && i < 13) && (0 < j && j < 13))
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long  a,b,tmp,x,r;
  cin>>a>>b;
   x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout<<x/b<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k = 0, m = 0;
    cin >> n;
    int d[n], p[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> d[i];
        p[i] = 0;
    }
    p[0] = 1;
    sort(d, d + n);
    for (int i = 1; i < n; i++)
    {
        if (d[i] != d[i - 1]) 
        {
            k++;
            p[k] = 1;
        }
        else p[k]++;
    }
    for (int i = 0; i < n; i++)
        if (p[i] > 0) m++;
    cout << m;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll M, K;
	cin >> M >> K;

	if (K < (1ll << M))
	{
		if (M == 1)
		{
			if (K == 0)
			{
				cout << "0 0 1 1" << endl;
			}
			else
			{
				cout << -1 << endl;
			}
		}
		else
		{
			cout << K << " ";
			for (auto i = 0l; i < (1ll << M); ++i)
			{
				if (i == K)
				{
					continue;
				}
				cout << i << " ";
			}
			cout << K << " ";
			for (auto i = (1ll << M) - 1; i >= 0; --i)
			{
				if (i == K)
				{
					continue;
				}
				cout << i;
				if (i > 0)
				{
					cout << " ";
				}
			}
			cout << endl;
		}
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a[3];
    rep(i,3) cin>>a[i];
    sort(a,a+3);
    printf("%d %d %d\n",a[0],a[1],a[2]);
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, A, B, C;
vector<int> L;
int dfs(int cur, int arg_A, int arg_B, int arg_C) {
    if(cur == N) {
        if (min({arg_A, arg_B, arg_C}) <= 0) {
            return INF;
        } else {
            return abs(arg_A - A) + abs(arg_B - B) + abs(arg_C -C) - 30;
        }
    }
    int ret0 = dfs(cur + 1, arg_A, arg_B, arg_C);
    int ret1 = dfs(cur + 1, arg_A + L[cur], arg_B, arg_C) + 10;
    int ret2 = dfs(cur + 1, arg_A, arg_B + L[cur], arg_C) + 10;
    int ret3 = dfs(cur + 1, arg_A, arg_B, arg_C + L[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}
void solve() {
    cin >> N;
    cin >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;
use std::collections::BinaryHeap;

fn main() {
    input! {
        N: usize,
        M: usize,
    }

    let mut Ps = vec![0; M];
    let mut Ys = vec![0; M];
    let mut Xs = vec![0; M];

    for m in 0..M {
        input! {
            P: usize,
            Y: i32,
        }

        Ps[m] = P - 1;
        Ys[m] = Y;
    }

    let mut Heaps = vec![BinaryHeap::new(); N];

    for m in 0..M {
        let P = Ps[m];
        let Y = Ys[m];

        let t = (-Y, m);
        Heaps[P].push(t);
    }

    for n in 0..N {
        let mut x = 0;
        while Heaps[n].peek() != None {
            let t = Heaps[n].pop().unwrap();
            // let Y = - t.0;
            let m = t.1;

            Xs[m] = x;
            x += 1;
        }
    }

    for m in 0..M {
        let P = Ps[m] + 1;
        let x = Xs[m] + 1;
        println!("{:06}{:06}", P, x);
    }
}


Measured memory_bytes: 10584
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

C = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      C += 1
    
S[0][0] = 0
for l in range(C-1):
  for i in range(H):
    for j in range(W):
      if S[i][j] == l:     
        for k in [[0,1],[1,0],[-1,0],[0,-1]]:
          if not(0 <= i + k[0] < H):
            continue
          elif not(0 <= j + k[1] < W):
            continue
          elif S[i+k[0]][j+k[1]] != ".":
            continue
          else:
            S[i+k[0]][j+k[1]] = S[i][j]+1
        
if S[H-1][W-1] == ".":
  print(-1)
  exit()
  
ans = C - S[H-1][W-1] -1
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

ll mpow(ll a, ll b) {
  ll ans = 1;
  while(b) {
    if(b & 1) ans *= a, ans %= mod;
    a *= a, a %= mod, b >>= 1;
  }
   return ans;
}

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld%lld", &n, &k);
  ll cnt[k + 1];
  for(i = k; i; --i) {
    cnt[i] = mpow(k / i, n);
    for(j = 2; i * j <= k; ++j) cnt[i] += mod - cnt[i * j], cnt[i] %= mod;
    ans += cnt[i] * i, ans %= mod;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2416
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val ABC = Array(3) { sc.next() }
        pw.println("%s %s %s".format(ABC[2], ABC[0], ABC[1]))

    }
}


Measured memory_bytes: 31256
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21
ll min(ll a, ll b) { return b < a ? b : a; }
ll max(ll a, ll b) { return b < a ? a : b; }

int main() {
  int N;
  cin >> N;
  int B[N];
  for (int i = 1; i <= N - 1; i++) {
    cin >> B[i];
  }

  int A[N + 1];
  A[1] = B[1];
  A[N] = B[N - 1];
  for (int i = 2; i <= N - 1; i++) {
    A[i] = min(B[i], B[i - 1]);
  }

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

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

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    ll x;
    cin >> x;
    ll n = 0;
    ll amt = 100;
    while (amt < x) {
        amt = amt * (1.01);
        ++n;
    }
    cout << n << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3612
import math

n = int(input())
p = [x- 1 for x in map(int, input().split())]

cnt, flag = 0, 0
ans = 0
for i in range(n):
    if p[i] == i and flag:
        cnt += 1
    elif p[i] == i:
        cnt += 1
        flag = 1
    elif p[i] != i and flag:
        if cnt == 1:
            ans += 1
        else:
            ans += math.ceil(cnt/2)

        cnt, flag = 0, 0
if flag:
    if cnt == 1:
        ans += 1
    else:
        ans += math.ceil(cnt/2)

print(ans)

Measured memory_bytes: 20576
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

double dp[N];

void solve(){
    ll n;
    double x, ans;
    cin >> n;
    dp[0] = 1;
    for(int i = 0; i < n; ++i){
        cin >> x;
        for(int j = i + 1; j >= 0; --j){
            dp[j] = ((j == 0 ? 0 : dp[j - 1] * x) + dp[j] * (1 - x));
        }
    }    
    for(int i = 0; i <= n; ++i){
        if(n - i < i)   ans += dp[i];
    }
    cout << fixed << setprecision(10) << ans;
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 384
#!/usr/bin/env python3
#ABC140 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
b = LI()
a = b[0]
for i in range(n-2):
    a += min(b[i],b[i+1])
a += b[-1]
print(a)


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

using ll = long long;

int main(void)
{
    ll n;
    cin >> n;
    ll sq = sqrt(n);

    while (n % sq != 0 && sq > 1) sq--;
    ll ans = (sq - 1) +  (n / sq) - 1;
    cout << ans << "\n";
}

Measured memory_bytes: 888
#include <stdio.h>

int min(int a, int b){
    if(a<b)return a;
    else return b;
    }
int main(){
    int a,b,n,c;
    scanf("%d %d %d",&n,&a,&b);
    printf("%d",min(a*n,b));
    return 0;
}


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

#define BUF_SIZE 15

int calc_digit(int res) {
  int cnt = 0;
  while(res) {
    res /= 10;
    cnt++;
  }
  return cnt;
}


int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  long num;
  int i;
  sscanf(line, "%ld", &num);
  int root = (int)sqrt(num);
  i = 0;
  int ans = -1;
  for(i = root; i >= 1; i--) {
    if(num % i) continue;
    int res = (num / i);
    ans = calc_digit(res);
    break;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
using ll = long long;
using veci = vector<int>;
bool binarysearch(vector<int> a, int key){
    int right=0;
    int left = a.size();
    int mid;
    while (left - right){
        mid = (right + left)/2;
        if (a[mid] == key) return true;
        if (a[mid] > key) left = mid;
        else if(a[mid] < key) right = mid+1;
    }
    return false;
}
int main(){
    int n; cin >> n;
    veci s(n);
    rep(i, n) cin >> s[i];
    int q; cin >> q;
    veci t(q);
    rep(i, q) cin >> t[i];
    int left=0;
    int right=n;
    int i=0;
    int mid;
    int ans=0;
    for (int i=0; i<q; i++){
        if (binarysearch(s, t[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3824