akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,b,res=0;
  vector<int> B;  
  cin >> N;

  REPI(N-1)
  {
    cin >> b;
    B.push_back (b);
  }

  res += B[0];
  res += B[N-2];

  REPI(N-2)
    res += min(B[i],B[i+1]);

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
int w[110], v[110];
ll dp[100010][110];

int main() {
	int N,W; cin >> N >> W;

	rep(i, N)cin >> w[i] >> v[i];

	memset(dp, 0, sizeof(dp));
	rep(i, N) {
		For(j, 0, W+1) {
			if (j >= w[i])dp[j][i + 1] = max(dp[j - w[i]][i] + v[i], dp[j][i]);
			else dp[j][i + 1] = dp[j][i];
		}
	}
	cout << dp[W][N] << endl;

	return 0;
}


Measured memory_bytes: 86144
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, a, b, sum=0;
    cin >> n >> a >> b;
    for(int i=0;i<=9; i++) {
        for(int j=0;j<=9;j++) {
            for(int k=0;k<=9;k++) {
                for(int l=0; l<=9;l++) {
                    for(int m=0; m<=9;m++) {
                        int num = m + 10*l + 100*k + 1000*j + 10000*i;
                        if(num > n) {
                            goto endloop;
                        }
                        int s = i+j+k+l+m;
                        if(s >= a && s <= b) {
                            sum += num;
                        }
                    }
                }
            }
        }
    }
endloop:
    cout << sum << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans1 = 1
ans2 = 1
mod = 10**9 + 7

if abs(n-m) >= 2:
    print(0)
    exit()


for i in range(1, n+1):
    ans1 *= i
    ans1 %= mod
for j in range(1, m+1):
    ans2 *= j
    ans2 %= mod

if abs(m-n) == 1:
    print(ans1 * ans2 % mod)
else:
    print(2 * ans1 * ans2 % mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n,c,k; cin >> n >> c >> k;
  vector<ll> t(n);
  rep(i,n) cin >> t[i];
  sort(t.begin(),t.end());
  ll current_first_number = 0;
  ll current_first_time = t.at(0);
  ll current_limit = t.at(0) + k;
  // ll wait_people = 0;
  ll bus = 0;

  rep(i,n) {
    if(t.at(i) > current_limit) {
      ll wait_people = (i - 1) - current_first_number + 1;
      if(wait_people <= c) {
        bus++;
        current_first_number = i;
        current_limit = t.at(i) + k;
      //  cout << current_first_number << endl;
        i--;
        continue;
      }
      else if(wait_people > c){
        bus++;
        current_first_number = current_first_number + c;
        current_limit = t.at(current_first_number) + k;
      //    cout << current_first_number << endl;
        i--;
        continue;
      }
    }
    else if(i == n - 1) {
      ll wait_people_n = i - current_first_number + 1;
      if(wait_people_n <= c){
        bus++;
        break;
      }
      else if(wait_people_n > c){
        ll syo = wait_people_n / c;
        ll amari = wait_people_n % c;
        if(amari == 0) {
          bus += syo;
        }
        else{
          bus += syo + 1;
        }
      }
    }
    
  }

  cout << bus << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a,b;
ll v[51];
ll dp[55][55];
ll cnt[55][55];

int main(void){
	scanf("%d %d %d",&n,&a,&b);
	for(int i=0;i<n;i++){
		scanf("%lld",&v[i]);
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	cnt[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=50;j++){
			if(dp[i][j]>=0){
				if(dp[i+1][j]<dp[i][j]){
					cnt[i+1][j]=0;
				}
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(dp[i+1][j]==dp[i][j]){
					cnt[i+1][j]+=cnt[i][j];
				}

				if(dp[i+1][j+1]<dp[i][j]+v[i]){
					cnt[i+1][j+1]=0;
				}
				dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+v[i]);
				if(dp[i+1][j+1]==dp[i][j]+v[i]){
					cnt[i+1][j+1]+=cnt[i][j];
				}
			}
		}
	}
	ll v=a;
	ll ans=dp[n][a];
	ll trans=cnt[n][a];
	for(ll i=a+1;i<=b;i++){
		if(ans*i==v*dp[n][i]){
			trans+=cnt[n][i];
		}
		if(ans*i<v*dp[n][i]){
			v=i;
			ans=dp[n][i];
			trans=cnt[n][i];
		}
	}
	printf("%.10f\n",(double)ans/v);
	printf("%lld\n",trans);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
left = []
right = []

for i in range(m):
    left.append(lr[i][0])
    right.append(lr[i][1])

ans = min(right) - max(left) + 1

if ans < 0:
    ans = 0

print(ans)

Measured memory_bytes: 29096
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#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 namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

using Data = int;
const Data INF = 1000000001;

vector<Data> lis(const vector<Data>& a) {
  const int n = a.size();
  if (n == 0) return vector<Data>(0);
  vector<Data> A(n, INF);
  vector<int> id(n);
  for (int i = 0; i < n; i++) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  int m = *max_element(id.begin(), id.end());
  vector<Data> res(m + 1);
  for (int i = n - 1; i >= 0; i--)
    if (id[i] == m) res[m--] = a[i];
  return res;
}

void dfs(const vector<vecint>& g, const vecint& a, vecint& dp, vecint& ans, int mx, int i, int p = -1) {
  int idx = lower_bound(ALL(dp), a[i]) - begin(dp);
  int old = dp[idx];
  dp[idx] = a[i];
  mx = max(mx, idx+1);
  ans[i] = mx;
  for (auto&& to : g[i]) {
    if (to == p) continue;
    dfs(g, a, dp, ans, mx, to, i);
  }
  dp[idx] = old;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecint a(n);
  for(auto&& e:a)cin>>e;
  vector<vecint> g(n);
  REP(i,n-1) {
    int x,y;
    cin>>x>>y;
    --x;--y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vecint dp(n, INF);
  vecint ans(n);
  dfs(g, a, dp, ans, 0, 0);
  for (auto&& e: ans) {
    cout<<e<<"\n";
  }
  return 0;
}


Measured memory_bytes: 36680
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        if (s[0] == s[1] && s[1] == s[2] ||
            s[1] == s[2] && s[1] == s[3])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll mxval , n , mxw , w[105] , val[105];
///  index , value --> weight
ll memo[105][100005];
ll solve(int i , ll sum)
{
    if(sum == 0)
        return 0;
    if(i == n)
        return 1e12;
    if(memo[i][sum] != -1)
        return memo[i][sum];
    ll ans = solve(i + 1 , sum);
    if(sum - val[i] >= 0)
        ans = min(ans , solve(i + 1 , sum - val[i]) + w[i]);
    memo[i][sum] = ans;
    return memo[i][sum];
}

int main()
{
    em3
    memset(memo , -1 , sizeof memo);
    cin >> n >> mxw;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> w[i] >> val[i];
        mxval += val[i];
    }
    ll ans = 0;
    for(int i = 1 ; i <= mxval ; i++)
    {
        if(solve(0 , i) <= mxw)
                    ans = i;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
#define ll long long
#define rll(a,b,c) for(ll a=(b);a<(c);++a)

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

    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
cin>>a>>b;
  cout<<(((b-a)*(b-a)+b-a)/2-b)<<endl;

















    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

bool aiueo(char c) {
	return c == 'a' | c == 'i' | c == 'u' | c == 'e' | c == 'o';
}

int main() {
	int n;
	while (cin >> n, n) {
		vector<string> name(n);
		vector<string> name2(n,"");
		int ma = 0;
		REP(i, n) {
			cin >> name[i];
			name2[i] += name[i][0];
			FOR(j, 0, name[i].length() - 1)
				if (aiueo(name[i][j]))
					name2[i] += name[i][j + 1];
			ma = max(ma, (int)name2[i].length());
		}
		int ans = -1;
		FOR(i, 1, ma+1) {
			set<string> ss;
			REP(j, n)
				ss.insert(name2[j].substr(0,min(i,(int)name2[j].length())));
			if (ss.size() == n) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3176
n=int(input())
*m,=map(int,input().split())
l=[]
l=[m[0]]+[m[i] for i in range(1,n) if m[i]!=m[i-1]]

c=1
i=2

while i<len(l):
  if (l[i-2]<l[i-1] and l[i-1]>l[i]) or (l[i-2]>l[i-1] and l[i-1]<l[i]):
    c+=1
    i+=1
  i+=1

print(c)

Measured memory_bytes: 14252
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a[] = new long[3*n];
		for(int i=0; i<3*n; i++) {
			a[i]=sc.nextLong();
		}

		PriorityQueue<Long> pq1 = new PriorityQueue<Long>();
		long sum1 = 0;
		for(int i=0; i<n; i++) {
			pq1.add(a[i]);
			sum1 += a[i];
		}

		PriorityQueue<Long> pq2 = new PriorityQueue<Long>((x,y)->Long.compare(y, x));
		long sum2 = 0;
		for(int i=3*n-1; i>=2*n; i--) {
			pq2.add(a[i]);
			sum2 += a[i];
		}

		long tmp1[] = new long[n+1];
		tmp1[0]=sum1;
		long tmp2[] = new long[n+1];
		tmp2[0]=sum2;

		for(int k=n; k<2*n; k++) {
			pq1.add(a[k]);
			sum1 += a[k];
			long sub1 = pq1.poll();
			sum1 -= sub1;
			tmp1[k-(n-1)] = sum1;

			pq2.add(a[3*n-k-1]);
			sum2 += a[3*n-k-1];
			long sub2 = pq2.poll();
			sum2 -= sub2;
			tmp2[k-(n-1)] = sum2;
		}
		long ans = -Long.MAX_VALUE;
		for(int i=0; i<=n; i++) {
			ans = Math.max(ans, tmp1[i] - tmp2[n-i]);
		}
		System.out.println(ans);
		sc.close();
	}
}




Measured memory_bytes: 101732
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();

    let n = sc.cin();

    let mut xs = vec![0; 3 * n];
    let mut a = vec![0; n + 1];
    let mut b = vec![0; n + 1];

    for i in 0..(3 * n) {
        let x: i64 = sc.cin();
        xs[i] = x;
    }

    {
        let mut sum = 0;
        let mut top = BinaryHeap::new();
        for i in 0..n {
            let x = xs[i];
            top.push(-x);
            sum += x;
        }
        a[0] = sum;
        for i in 0..n {
            let x = xs[i + n];
            let y = -top.pop().unwrap();
            if x > y {
                sum = sum - y + x;
                top.push(-x);
            } else {
                top.push(-y);
            }
            a[i + 1] = sum;
        }
    }

    {
        let mut sum = 0;
        let mut top = BinaryHeap::new();
        for i in 0..n {
            let x = xs[3 * n - 1 - i];
            top.push(x);
            sum += x;
        }
        b[n] = sum;
        for i in 0..n {
            let x = xs[2 * n - 1 - i];
            let y = top.pop().unwrap();
            if x < y {
                sum = sum - y + x;
                top.push(x);
            } else {
                top.push(y);
            }
            b[n - i - 1] = sum;
        }
    }

    trace!(xs);
    trace!(a);
    trace!(b);
    {
        let mut ans = a[0] - b[0];
        for i in 0..n {
            ans = max(ans, a[i + 1] - b[i + 1]);
        }
        println!("{}", ans);
    }

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


Measured memory_bytes: 28856
program transport
  implicit none
  integer(8) n,a,b,c,d,e,neck
  read *, n
  read *, a
  read *, b
  read *, c
  read *, d
  read *, e
  neck = min(a,b,c,d,e)
  if (mod(n,neck) == 0 ) then
    print '(i0)', n/neck+4
  else
    print '(i0)', n/neck+5
  end if 
  stop
end program transport

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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



int main() {

    long long n, k,cnt;
    cin >> n >> k;
    vector<long long> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    cnt = 0;
    h.erase(h.begin() + k - 1, h.end());
    rep(i,n-k)
    {
        cnt += h[i];
    }
    cout << cnt << endl;
    return 0;
}

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

string S[2][505];

int main(){
  int H,W; cin>>H>>W;
  rep(i,H){
    cin>>S[0][i];
    S[1][i]=S[0][i];
  }

  rep(i,H) rep(j,W) if(S[0][i][j]!='#'){
    if(j==0) S[1][i][j]='#';
    else if(j==W-1) S[0][i][j]='#';
    else S[i%2][i][j]='#';
  }
  rep(i,2){
    rep(j,H) cout<<S[i][j]<<endl;
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
N,Q=map(int,input().split())
S=input()
C=[0]*N

for i in range(1,N):
    C[i]=C[i-1]
    if S[i-1:i+1]=="AC":
        C[i]+=1

for i in range(Q):
    l,r=map(int,input().split())
    print(C[r-1]-C[l-1])



Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    int A[100010] = {0}, P[100010] = {0};
    rep(i,q) cin >> A[i];
    rep(i,q) P[A[i]-1]++;
    rep(i,n){
        if(k - q + P[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
M=1000000007
fpc=[1]
fp=->r{
  fpc[r]||=( fp[r/2]**2 * (r.odd? ? 2 : 1) )%M
}

n=gets.to_i
zzc=0
cc={}
$<.read.split.map(&:to_i).each_slice(2){|(a,b)|
  if a==0
    if b==0
      zzc+=1
    else
      (cc[0r]||=[0,0])[1]+=1
    end
  else
    if b==0
      (cc[0r]||=[0,0])[0]+=1
    else
      c=b.to_r/a
      if c>0
        (cc[c]||=[0,0])[0]+=1
      else
        (cc[-1r/c]||=[0,0])[1]+=1
      end
    end
  end
}
ans=1
cc.values.each{|(x,y)|
  ans=ans*(fp[x]+fp[y]-1)%M
}
ans=(ans+zzc-1)%M
puts ans


Measured memory_bytes: 73292
class BitSet
  def initialize(size)
    words_size = ((size - 1) >> 6) + 1
    @words = Array.new(words_size, 0)
  end

  def <<(bit_index)
    @words[bit_index >> 6] |= 1 << (bit_index & 63)
  end

  def [](bit_index)
    (@words[bit_index >> 6] & (1 << (bit_index & 63))) != 0
  end
end

bound = 1000000
sieve_size = (bound - 1) % 6 < 4 ? bound / 6 * 2 + 1 : (bound + 1) / 3
sieve = BitSet.new(sieve_size)
limit = (bound ** 0.5).to_i
loop.with_index(1).each do |_, i|
  unless sieve[i]
    p = i * 3 + (i & 1) + 1
    break if p > limit
    (p * 2 + i    ).step(sieve_size, p * 2) {|j| sieve << j }
    (p * 2 - i - 1).step(sieve_size, p * 2) {|j| sieve << j }
  end
end

@primes = (1...sieve_size).select {|i| !sieve[i] }.map {|i| i * 3 + (i & 1) + 1 }
@plimit = @primes.last
def f(n)
  return @primes.size + 2 if n >= @plimit
  return 0 if n < 2
  return 1 if n == 2
  @primes.find_index {|x| x > n } + 2
end

while line = gets
  puts f(line.to_i)
end

Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
int main(){
	int a, b; cin>>a>>b;
	cout<<(1 + (b-a)/(a-1) + ((b-a) % (a-1) > 0));
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll A,B,C;
    cin >> A >> B >> C;

    cout << B + min(C, A+B+1) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define EPS 1e-9
/*
	XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    No, nothing good starts in a getaway car
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi=3.1416;
    long double r; cin>>r;
    cout<<setprecision(5)<<(long double)(2*pi*r)<<endl;
    return 0;
}


Measured memory_bytes: 3812
program-id. abc169c.

data division.
  working-storage section.
  77 ab   pic x(21).
  77 a    pic 9(16).
  77 b    pic 9v99.
  77 ans  pic z(16)9.

procedure division.
  accept ab.
  unstring ab delimited by space into a b.
  compute ans = a * (b * 100) / 100.
  display ans.
  stop run.


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

const long long N = 1e5+7;
long long a[N], ans[N];
long long p[N];
bool vis[N];

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

    long long n;
    cin>>n;

    for (long long i=0; i<n; i++) cin>>a[i];
    for (long long i=n-1; i>0; i--) a[i] -= a[i-1];

    long long m;
    long long k;
    cin>>m>>k;

    for (long long i=1; i<n; i++) p[i] = i;

    while (m--) {
        long long x;
        cin>>x;
        swap(p[x-1], p[x]);
    }
//
//    for (long long i=1; i<n; i++) cout<<a[i]<<" - "; cout<<endl;
//    for (long long i=1; i<n; i++) cout<<p[i]<<" - "; cout<<endl;

    for (long long i=1; i<n; i++) {
        if (vis[i]) continue;
        vector<long long> cycle;

        long long u = i;
        while (!vis[u]) {
            cycle.push_back(u);
            vis[u] = 1;
            u = p[u];
        }

//        for (int x: cycle)  cout<<x <<" --> "; cout<<endl;

        long long sz = cycle.size();
        for (long long i=0; i<cycle.size(); i++) {
            long long frm = cycle[i];
            long long to = cycle[(i+k)%sz];
            ans[frm] = a[to];
        }
    }
    ans[0] = a[0];
    for (long long i=1; i<n; i++)     ans[i] += ans[i-1];
    for (long long i=0; i<n; i++)     cout<<ans[i]<<" ";

}


Measured memory_bytes: 6476
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int ch(int n, int k) {
	return n < k ? 0 : k == 0 ? 1 : ch(n - 1, k - 1) * n / k;
}

int power(int a, int k) {
	return k == 0 ? 1 : power(a, k - 1) * a;
}

int main() {
	string s; cin >> s;
	int n = s.length();
	int k; cin >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		if (d)
			cnt++;
	}
	int ans = cnt == k;
	cnt = 0;
	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		if (d == 0)
			continue;
		ans += ch(n - 1 - i, k - cnt) * power(9, k - cnt);
		if (k > cnt)
			ans += ch(n - 1 - i, k - cnt - 1) * power(9, k - cnt - 1) * (d - 1);
		if (cnt++ == k)
			break;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
//#define e 2.718

#define ll long long

using namespace std;

int pos_x[1005];
int pos_y[1005];
int pos_z[1005];


char a[9][5005];
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)>=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
	int h, w, i = 0;
	while (cin >> h >> w&&(h!=0||w!=0))
	{
		i++;
		if (i >= 2)
		{
			cout << endl;
		}
		for (int a = 0; a < h; a++)
		{
			if (a == 0 || a == h-1)
			{
				for (int c = 0; c < w; c++)
				{
					cout << "#";
				}
				cout << endl;
			}
			else
			{
				for (int b = 0; b < w; b++)
				{
					if (b == 0 || b == w-1)
					{
						cout << "#";
					}
					else
					{
						cout << ".";
					}
				}
				cout << endl;
			}
		}		
	}
	cout << endl;
}


Measured memory_bytes: 3092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := scanInt(), scanInt()
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = scanInt()
	}
	sort.Ints(h)

	ans := h[K-1] - h[0]
	for i := K; i < N; i++ {
		ans = intMin(ans, h[i]-h[i+1-K])
	}
	fmt.Println(ans)
}


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

int main()
{
	using namespace std;
	string c1, c2;
	int nc1,nc2;
	cin>> c1;
	cin>> c2;
	cin >> nc1 ;
	cin>> nc2 ;
	cin.ignore();
	string colour;
	getline(cin, colour);
	if (c1 == colour) {
		cout <<nc1 - 1 <<" "<< nc2;
	}
	if (c2 == colour) {
		cout << nc1 <<" "<< nc2 - 1;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int n;
	cin >> n;

	deque<int> B;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if (n % 2 != i % 2)
			B.push_front(a);
		else
			B.push_back(a);
	}
	for (int i = 0; i < n; ++i)
	{
		if (i)
			cout << " ";
		cout << B[i];
	}
	cout << endl;
}



Measured memory_bytes: 4460
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int n, a[100001], mid = 1;
int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a+1, a+n+1);
  for(int i = 2; i < n; ++i) {
     if(abs(a[mid]*2-a[n]) > abs(a[i]*2-a[n])) mid = i;
  }
  printf("%d %d\n", a[n], a[mid]);
}

Measured memory_bytes: 512
from collections import deque
A,B,C,D = list(input())

dq = deque()
dq.append("")
while dq:
    op = dq.popleft()
    if len(op) == 3:
        res = A + op[0] + B + op[1] + C + op[2] + D
        if eval(res) == 7:
            ans = res + "=7"
            print(ans)
            break
    else:
        dq.append(op+"+")
        dq.append(op+"-")

Measured memory_bytes: 3316
N,K = map(int,input().split())
ps = tuple(map(int,input().split()))

max_sum = sum(ps[:K])
num = sum(ps[:K])

for i in range(N-K):
    num = num - ps[i] + ps[i+K]
    max_sum = max(max_sum,num)
    

print((max_sum+K)/2)

Measured memory_bytes: 71816
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((g * 10 + b) % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  ll a,b,c,d,n;
  cin >> a >> b >> c >> d >> n;
  
  a*=4;
  b*=2;
  
  ll best = min(min(a,b),c); // 1Lの最高値
  
  if(best*2 <= d) cout << best*n << endl;
  else  cout << d*(n/2) + (n%2)*best;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;

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

int main()
{
    ll H, W; cin >> H >> W;
    vector<string> board(H); rep(i, H) cin >> board[i];

    vvll costs(H, vll(W, inf));
    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> que;
    que.push({0, {0, 0}});
    costs[0][0] = 0;

    while (que.size()) {
        auto p = que.top(); que.pop();
        ll cost = p.first;
        auto point = p.second;

        if (costs[point.first][point.second] < cost) continue;

        rep(i, 4) rep(j, 4) {
            ll ny = point.first + dy[i];
            ll nx = point.second + dx[i];
            if (0 <= nx && nx < W && 0 <= ny && ny < H && board[ny][nx] == '.' && costs[point.first][point.second] + 1 < costs[ny][nx]) {
                costs[ny][nx] = costs[point.first][point.second] + 1;
                que.push({costs[ny][nx], {ny, nx}});
            }
        }
    }

    ll b_count = 0;
    rep(i, H) {
        rep(j, W) {
            b_count += (board[i][j] == '#');
        }
    }

    if (costs[H-1][W-1] == inf) {
        cout << -1 << endl;
        return 0;
    }

    cout << H * W - costs[H-1][W-1] - b_count - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = 5;
		int count = 0;
		int[] x = new int[N];
		for(int i = 0; i < N; i ++){
			x[i] = sc.nextInt(); 

			if(x[i] == 0){
				count = i + 1;
				break;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 35604
#include <stdio.h>

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

Measured memory_bytes: 128
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]
def main():
    R, C, K = NMI()
    grid = make_grid_int(R, C, 0)

    for i in range(K):
        r_, c_, v_, = NMI()
        grid[r_ - 1][c_ - 1] = v_

    dp = [[[0 for _ in range(C + 2)] for _ in range(R + 2)] for _ in range(4)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                a = dp[k][i][j]
                try:
                    v = grid[i][j]
                except:
                    v = 0

                if k == 3:
                    dp[0][i + 1][j] = max(a, dp[0][i + 1][j])
                    continue
                dp[0][i + 1][j] = max(a, a + v, dp[0][i + 1][j])
                dp[k][i][j + 1] = max(a, dp[k][i][j + 1])
                dp[k + 1][i][j + 1] = max(a + v, dp[k + 1][i][j + 1])

    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 460664
//
// Created by Hideaki Imamura on 2020-03-07.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

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

int A, B;

int main() {
    cin >> A >> B;

    int ans = -1;
    for (int N = 25 * A / 2 + A % 2; N < 25 * (A + 1) / 2 + 1 - A % 2; ++N) {
        if (N / 10 == B) {
            ans = N;
            break;
        }
    }
    for (int N = 10 * B; N < 10 * (B+1); ++N) {
        if (N * 8 / 100 == A) {
            if (ans > N) {
                ans = N;
            }
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template <typename Type>
class SegmentTree {
  size_t sz = 1;
  std::vector<Type> node;
  const std::function<Type(Type, Type)> f;
  const Type e;

 public:
  SegmentTree(const size_t n, const std::function<Type(Type, Type)> f,
              const Type e)
      : f(f), e(e) {
    while (sz < n) {
      sz *= 2;
    }
    node.resize(2 * sz, e);
  }

  SegmentTree(const std::vector<Type> &vec,
              const std::function<Type(Type, Type)> f, const Type e)
      : f(f), e(e) {
    while (sz < vec.size()) {
      sz *= 2;
    }
    node.resize(2 * sz, e);
    for (size_t i = 0; i < vec.size(); i++) {
      node[i + sz] = vec[i];
    }
    for (size_t i = sz - 1; i < sz; i--) {
      node[i] = f(node[2 * i], node[2 * i + 1]);
    }
  }

  void update(size_t i, const Type x) {
    i += sz;
    node[i] = f(node[i], x);
    while (i > 0) {
      i /= 2;
      node[i] = f(node[2 * i], node[2 * i + 1]);
    }
  }

  Type query(int l, int r) {
    Type left = e, right = e;
    for (l += sz, r += sz; l < r; l /= 2, r /= 2) {
      if (l & 1) left = f(left, node[l++]);
      if (r & 1) right = f(right, node[--r]);
    }
    return f(left, right);
  }
};

template <typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    std::swap(a, b);
  }
  return b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int res = 0;
  SegmentTree<int> sg(A, gcd<int>, 0);
  for (int i = 0; i < N; i++) {
    res = max(res, gcd(sg.query(0, i), sg.query(i + 1, N)));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1664
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 2 ** 61 - 1
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    T = SI()
    P = SI()

    lenP = len(P)
    lenT = len(T)
    h1 = 0
    base = ord('0') - 1
    for a in P:
        h1 = (h1 * 76 + ord(a) - base) % MOD

    h2 = 0
    for a in T[:lenP]:
        h2 = (h2 * 76 + ord(a) - base ) % MOD

    for i in range(lenT - lenP + 1):
        if h1 == h2: print(i)
        if i < lenT - lenP:
            h2 = (h2 * 76 + ord(T[i+lenP])-base - (ord(T[i])-base) * pow(76,lenP,MOD)) % MOD

if __name__ == '__main__':
    main()


Measured memory_bytes: 9856
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <math.h>

void sort_str(char* str) {
  int i, j;
  int len = strlen(str);
  char tmp;
  for (i = 0; i < len; i++) {
    for (j = i + 1; j < len; j++) {
      if (str[i] > str[j]) {
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
      }
    }
  }
}
void comp_strs(char* str1, char* str2, char* cor) {
  int i, j;
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  i = 0; j = 0;
  int cor_len = 0;
  int tmp = 0;
  while (i < len1) {
    j = tmp;
    while (j < len2) {
      if (str1[i] == str2[j]) {
        cor[cor_len++] = str1[i];
        tmp = j + 1;
        break;
      }
      else j++;
    }
    i++;
  }
  cor[cor_len] = '\0';
}

int n;
char** Ss;
int main() {
  int i;
  char cor[100];
  char cortmp[100];
  scanf("%d*c", &n);
  Ss = (char**)malloc(sizeof(char*) * n);
  for (i = 0; i < n; i++)
    Ss[i] = (char*)malloc(sizeof(char) * 100);
  for (i = 0; i < n; i++) {
    scanf("%s%*c", Ss[i]);
    sort_str(Ss[i]);
  }
  if (n == 1) {
    printf("%s\n", Ss[0]);
    for (i = 0; i < n; i++)
      free(Ss[i]);
    free(Ss);
    return 0;
  }
  comp_strs(Ss[0], Ss[1], cortmp);
  strcpy(cor, cortmp);
  for (i = 2; i < n; i++) {
    comp_strs(cor, Ss[i], cortmp);
    strcpy(cor, cortmp);
  }
  printf("%s\n", cor);
  
  for (i = 0; i < n; i++)
    free(Ss[i]);
  free(Ss);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
ld dp[3001][3001],n,m;
ld  a[3000];
ll mod=1e9+7;
void solve()
{
  int n;cin>>n;
  rep(i,n)cin>>a[i];
  int m=(n+1)/2;
  rep(i,m+1){dp[0][i]=0;}dp[0][0]=1;
  repA(i,1,n+1){dp[i][0]=(1-a[i-1])*dp[i-1][0];}
  repA(i,1,n+1)
  {
    repA(j,1,i+1)
    {
      dp[i][j]=a[i-1]*dp[i-1][j-1]+(1-a[i-1])*dp[i-1][j];
    }
  }
  repA(i,m+1,n+1){dp[n][i]+=dp[n][i-1];}
  cout<<setprecision(10)<<dp[n][n];
  
}
int main()
{
  fastio;
  //fopen();
  //int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


Measured memory_bytes: 139136
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7;
ll OO=1e6;  
const int N=1e6 + 2;
int arr1[N];
int arr2[N];


ll n,m,k,cnt,SU,idx,len,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;

vector<int> vec;


bool cmp(int s,int f){
	return s>f;
}

int main(){
	
	cin>>n>>m>>a>>b>>c;
	for(int i=0;i<a;++i)
		cin>>arr1[i];
		
	for(int i=0;i<b;++i)
		cin>>arr2[i];
		
		
	for(int i=0;i<c;++i)
		vec.push_back(D());
	
	sort(arr1,arr1+a,cmp);
	sort(arr2,arr2+b,cmp);
	
	
	for(int i=0;i<n;++i)
		vec.push_back(arr1[i]);
	for(int i=0;i<m;++i)
		vec.push_back(arr2[i]);
	
	sort(vec.rbegin(),vec.rend());
	
	for(int i=0;i<n+m;++i)
		cnt+=vec[i];
	
	cout<<cnt<<endl;
	
}
 
 
 
 
 
 
 
 


Measured memory_bytes: 6900
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    N, M = map(int, input().split())
    X = np.array(sorted(list(map(int, input().split()))))
    Y = X[1:] - X[:-1]
    Y.sort()
    Z = Y[::-1][N-1:].sum()
    res = Z
    return str(res)
if __name__ == '__main__':
    print(solve())


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  char c;
  cin >> c;
  set<char> st{'a','e', 'i', 'o', 'u'};
  auto res = st.insert(c);
  if(res.second) {
    cout<<"consonant"<<endl;
  }
  else {
    cout<<"vowel"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import itertools

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0

for k in itertools.combinations_with_replacement(range(1,m+1),n):
    t=0
    for j in l:
        if k[j[1]-1]-k[j[0]-1]==j[2]:
            t+=j[3]
    
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



int main() {

  int a;
  cin >> a;

  int ans = a + a*a + a*a*a;
  cout << ans << endl;
  return 0;
  
}


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

int main()
{
  string s; cin >> s;
  map<char, int> ma;
  rep(i, s.size())
  {
    ma[s[i]]++;
  }
  bool f = true;
  for (auto it : ma)
  {
    if (it.second != 2)
    {
      f = false;
      break;
    }
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
sum=0
container=[]
for i in range(n):
    container.append(i+1)
j=0
while j<len(container):
    if container[j]%3==0:
        sum+=0
    elif container[j]%5==0:
        sum+=0
    elif container[j]%3==0 and container[j]%5==0:
        sum+=0
    else:
        sum+=container[j]
    j+=1
print(f"{sum}\n")


Measured memory_bytes: 142380
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int l = parseInt(sc.next());
		String[] s = new String[n];
		for (i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		sc.close();
		Arrays.parallelSort(s);
		StringBuilder sb = new StringBuilder(s[0]);
		for (i = 1; i < n; i++) {
			sb.append(s[i]);
		}
		out.println(sb.toString());
	}
}


Measured memory_bytes: 21204
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    S=readline().strip()
    N=len(S)

    #S[0]=="1"
    count0=0
    count1=0
    for i in range(N):
        if i%2==0:
            if S[i]=="0":
                count0+=1
            elif S[i]=="1":
                count1+=1
        else:
            if S[i]=="1":
                count0+=1
            elif S[i]=="0":
                count1+=1

    print(min(count0,count1))
        
if __name__=="__main__":
    main()

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

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

  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> S(N, 0);
  vector<ll> C(N, 0);
  for (ll i = 0; i < M; i++) {
    cin >> S[i] >> C[i];
  }
  ll MAX = 10, MIN = 0;
  if (N == 2) MAX = 100, MIN = 10;
  if (N == 3) MAX = 1000, MIN = 100;

  ll ans = -1;
  for (ll i = MIN; i < MAX; i++) {
    ll temp = i;
    vector<ll> d(5, 0);
    for (ll j = 0; j < N; j++) {
      d[j] = temp % 10;
      temp = temp / 10;
    }
    bool ok = true;
    for (ll i = 0; i < M; i++) {
      if (d[N - S[i]] != C[i]) ok = false;
    }
    if (ok) {
      ans = i;
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		int d = reader.nextInt();
		long n = reader.nextLong();


		long pow = 1;
		for (int i=0; i<d; i++)
			pow *= 100;

		if (n<100)
			writer.println (n*pow);
		else
			writer.println ((n+1)*pow);

		writer.close();
	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 24660
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e4+5;

vi v[N],vis(N);

void solve()
{
    int n;
    cin>>n;

    vi deg(n+1);
    for(int i=1;i<n;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    vi val(n);
    for(int i=0;i<n;++i)
        cin>>val[i];

    sort(all(val));
    reverse(all(val));

    queue<int> q;
    q.push(1);
    vis[1]=1;

    vi ans(n);
    int cur=0;
    while(!q.empty())
    {
        auto x=q.front();
        q.pop();

        ans[x-1]=val[cur++];

        for(auto c:v[x])
        {
            if(vis[c])
                continue;

            vis[c]=1;
            q.push(c);
        }
    }

    int res=accumulate(all(val),0)-val[0];
    cout<<res<<"\n";
    show(ans);
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1408