akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>

//struct Path
//{
//  long a;
//  long b;
//};
//
//using Paths = std::vector<Path>;

using P = std::pair<long, long>;

struct Node
{
  long index;
  std::vector<Node*> peers;
};

using Nodes = std::vector<Node>;

void solve(long n, long m, const Nodes& nodes)
{
  std::vector<long> d(n);
  std::vector<long> prev(n);
  std::priority_queue<P, std::vector<P>, std::greater<P>> queue;
  queue.push(std::make_pair(d[0], 0));
  for (long i = 1; i < n; ++i) {
    d[i] = LONG_MAX;
    prev[i] = 0;
    queue.push(std::make_pair(d[i], i));
  }

  while (!queue.empty()) {
    auto e = queue.top();
    queue.pop();

    for (auto peer : nodes[e.second].peers) {
      const auto alt = d[e.second] + 1;
      if (d[peer->index] > alt) {
        d[peer->index] = alt;
        prev[peer->index] = e.second;
        queue.push(std::make_pair(alt, peer->index));
      }
    }
  }

  std::cout << "Yes" << std::endl;
  for (int i = 1; i < n; ++i) {
    std::cout << prev[i] + 1 << std::endl;
  }
}

int main()
{
  long n, m;
  std::cin >> n >> m;

  Nodes nodes(n);
  for (int i = 0; i < n; ++i) {
    nodes[i].index = i;
  }
  for (int i = 0; i < m; ++i) {
    long a, b;
    std::cin >> a >> b;
    --a;
    --b;
    nodes[a].peers.push_back(&nodes[b]);
    nodes[b].peers.push_back(&nodes[a]);
  }

  std::cout << std::setprecision(20);
  solve(n, m, nodes);
}


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

int main(void){
    ll n, m;
    cin >> n >> m;

    ll count;

    if(n == 1 && m == 1)
        count = 1;
    else if(n == 1){
        count = m - 2;
    }else if(m == 1){
        count = n - 2;
    }else{
        count = (n - 2) * (m - 2);
    }

    cout << count << endl;
    return 0;

}


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

int main(){
  int n, m;
  std::cin>>n>>m;
  int  h[n] ,ma[n];
  for(int i=1;i<=n;i++){
    std::cin>>h[i];
    ma[i]=0;
  }
  
  for(int i=0;i<m;i++){
    int a,b;
    std::cin>>a>>b;
    ma[a]=std::max(ma[a],h[b]);
    ma[b]=std::max(ma[b],h[a]);
  }
  
  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=h[i]>ma[i];
  }
  
  std::cout << ans;
}


Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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


int main(){
	set<int> s;
	rep(i, 3){
		int t;
		cin>>t;
		s.insert(t);
	}
	cout<<s.size()<<endl;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

MOD=10**9+7

sum1=0
for i in range(n):
    sum1+=a[i]
    sum1%=MOD

sum1*=sum1
sum1%=MOD
sum2=0
for i in range(n):
    sum2+=pow(a[i],2,MOD)
    sum2%=MOD

t = sum1-sum2
if t<0:
    t+=MOD

print((t)*pow(2,MOD-2,MOD)%MOD)


Measured memory_bytes: 30996
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    k, s = ns()
    ans = 0
    for x in range(k + 1):
        for y in range(k + 1):
            if k >= s - x - y >= 0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int a[1005][1005];
int black[2000]={};

int main()
{
  int h,w;
  cin >> h >> w;
  int black_sum = 0;
  char c;
  queue<pair<int,int>> qq;
  REP(i,h){
    REP(j,w){
      cin >> c;
      if(c=='#'){
        a[i][j]=1;
        qq.push(pair<int,int>(i,j));
        black[0]++;
        black_sum++;
      }
      else if(c=='.') a[i][j]=0;
    }
  }
  int cnt = 0;
  while(!qq.empty()&&black_sum<h*w){
    REP(k,black[cnt]){
	  int ii = qq.front().first;
      int jj = qq.front().second;
      qq.pop();
      if(ii>0 && a[ii-1][jj]==0){
        qq.push(pair<int,int>(ii-1,jj));
        a[ii-1][jj] = 1;
        black[cnt+1]++;
        black_sum++;
      }
      if(ii<h-1 && a[ii+1][jj]==0){
        qq.push(pair<int,int>(ii+1,jj));
        a[ii+1][jj] = 1;
        black[cnt+1]++;
        black_sum++;
      }
      if(jj>0 && a[ii][jj-1]==0){
        qq.push(pair<int,int>(ii,jj-1));
        a[ii][jj-1] = 1;
        black[cnt+1]++;
        black_sum++;
      }
      if(jj<w-1 && a[ii][jj+1]==0){
        qq.push(pair<int,int>(ii,jj+1));
        a[ii][jj+1] = 1;
        black[cnt+1]++;
        black_sum++;
      }
    }
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 12304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

/*
dp[dgt][d][isless] := 上位dgt桁目まで確定して各桁の数字の総和modDがdであり、K未満かどうかがislessである場合の数
*/

int dp[10101][111][2];

int main()
{
	string K;
	cin >> K;
	int D, N = K.size();
	cin >> D;

	dp[0][0][0] = 1;

	for (int digit = 0; digit < N; digit++) // 桁数
	{
		for (int d = 0; d < D; d++) // 総和 mod D
		{
			int c = K[digit] - '0';
			for (int isless = 0; isless < 2; isless++) // K 未満であるか (isless = true -> K 未満)
			{

				for (int next = 0; next < 10; next++) // digit 桁目にくる数字
				{
					if (c > next) // 上位の状態に依らずisless = trueになる
					{
						(dp[digit + 1][(d + next) % D][1] += dp[digit][d][isless]) %= mod;
					}
					if (c == next) // isless = false -> Kと同じ, isless = true -> 既にK以下
					{
						(dp[digit + 1][(d + next) % D][isless] += dp[digit][d][isless]) %= mod;
					}
					if (c < next) // isless = false だとnextは置けない(Kより大きくなる)
					{
						if (isless)
							(dp[digit + 1][(d + next) % D][isless] += dp[digit][d][isless]) %= mod;
					}
				}
			}
		}
	}
	int ans = (dp[N][0][1] + dp[N][0][0] - 1 + mod) % mod; // 0が含まれているので-1をする
	cout << ans << "\n";
}

Measured memory_bytes: 8960
s = input()
t = input()
sl = len(s)
tl = len(t)

cnt = 0
ans = 0

for i in range(sl-tl+1):
    for j in range(tl):
        if t[j] == s[i+j]:
            cnt += 1
    
    ans = max(cnt, ans)
    cnt = 0

print(tl - ans)

Measured memory_bytes: 8992
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double型変数));printf("%f",(double型変数));"
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;

#define MAX_N 50

int main(){
	int n;
	ll a[MAX_N];
	scanf("%d",&n);
	int k=0;
	for(int i=0;i<n;++i){
		scanf("%lld",&a[i]);
		if(abs(a[i])>abs(a[k])) k=i;
	}
	vector<pii> v;
	if(a[k]>0){
		for(int i=0;i<n;++i) if(i!=k){
			a[i]+=a[k];
			v.pb(mp(k+1,i+1));
		}
		for(int i=0;i<n-1;++i) v.pb(mp(i+1,i+2));
	}else if(a[k]<0){
		for(int i=0;i<n;++i) if(i!=k){
			a[i]+=a[k];
			v.pb(mp(k+1,i+1));
		}
		for(int i=n-1;i>0;--i) v.pb(mp(i+1,i));		
	}
	printf("%d\n",v.size());
	for(int i=0;i<v.size();++i) printf("%d %d\n",v[i].fi,v[i].sc);
	return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  constexpr int lim = 1e6;
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  sort(begin(a), end(a));
  int res = 0;
  vector<bool> b(lim + 1);
  for (int i = 0; i < n; ++i) {
    if (b[a[i]]) continue;
    res += i == n - 1 or a[i] < a[i + 1];
    for (int j = a[i]; j <= lim; j += a[i]) {
      b[j] = true;
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 4336
#include <iostream>
#include <cstdio>
#define MAX_N 100
using namespace std;

void display(int *aryptr, int size) {
	while(size > 0) {
		printf("%d", *aryptr);
		size--;
		if(size == 0) putchar('\n');
		else          putchar(' ');
		aryptr++;
	}
}

int main(void) {
	int N;
	int ary[MAX_N];

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

	for(int i = 0; i < N; i++) {
		int v = ary[i];
		int j = i - 1;

		while(j >= 0 && ary[j] > v) {
			ary[j+1] = ary[j];
			j--;
		}
		ary[j+1] = v;
		display(ary, N);
	}
	return 0;
}

Measured memory_bytes: 3240
a = list(map(int, input().split()))

a.sort()

n0 = abs(a[2]-a[0])//2 + abs(a[2]-a[1])//2
if a[2] % 2 == 1 and a[0] % 2 == 0 and a[1] % 2 == 0:
  n0 += 1
elif a[2] % 2 == 0 and a[0] % 2 == 1 and a[1] % 2 == 1:
  n0 += 2
elif a[2] % 2 == 1 and a[0] % 2 == 1 and a[1] % 2 == 1:
  pass
elif a[2] % 2 == 0 and a[0] % 2 == 0 and a[1] % 2 == 0:
  pass
else:
  n0 += 2
  
print(n0)

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  while(cin >> n) {
    ll cnt = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) rep(l, 10) {
      if(i + j + k + l == n) cnt++;
    }
    cout << cnt << endl;
  }

	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
vector<ll> a;

int main(){
    cin >> N;
    a.resize(N);
    rep(i,N) cin >> a[i];

    vector<ll> p1(N+2,0),p2(N+2,0);
    for(int i=0;i<N;i++){
        if(i%2==0) p1[i]=1;
        else p1[i]=-1;
        p2[i]=p1[i]*-1;
    }

    ll ans=0;
    ll ans1=0;
    ll sum=0;
    for(int i=0;i<N;i++){
        sum += a[i];
        if(sum >= 0 and p1[i] < 0){
            ans1 += abs(-1-sum);
            sum = -1;
        }else if(sum <= 0 and p1[i] > 0){
            ans1 += abs(1-sum);
            sum = 1;
        }
    }

    ll ans2=0;
    sum = 0;
    for(int i=0;i<N;i++){
        sum += a[i];
        if(sum >= 0 and p2[i] < 0){
            ans2 += abs(-1-sum);
            sum = -1;
        }else if(sum <= 0 and p2[i] > 0){
            ans2 += abs(1-sum);
            sum = 1;
        }
    }
    cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 2560
def main():
    orda = ord('a')

    N = int(input())

    ctr = [50] * 26
    for _ in range(N):
        s = input()
        t = [0] * 26
        for c in s:
            i = ord(c) - orda
            t[i] += 1

        for i, cnt in enumerate(t):
            ctr[i] = min(ctr[i], cnt)

    ans = ''
    for i, cnt in enumerate(ctr):
        ans += chr(i + orda) * cnt
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

const ull kMax = 1000000;
int main()
{
  ull m;
  cin >> m;
  const ull ub = (1ULL << m);
  cin >> m;
  vector<ull> dp(ub);
  
  for (ull i = 0; i < ub; ++i) {
    dp[i] = kMax;
  }
  for (ll i = 0; i < m; ++i) {
    ull a, b;
    cin >> a >> b;
    ull c = 0;
    for (ll j = 0; j < b; ++j) {
      ull v;
      cin >> v;
      c |= (1ULL << (v - 1));
    }
    dp[c] = min(dp[c], a);
  }

  for (ull i = 0; i < ub; ++i) {
    for (ull j = 0; j < i; ++j) {
      dp[i|j] = min(dp[i|j], dp[i] + dp[j]);
    }
  }

  if (dp[ub - 1] == kMax) {
    cout << -1;
  } else {
    cout << dp[ub - 1];
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 2005;
const int md = 1e9+7;
int n, k;
typedef long long ll;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2){
		if(n&1) (res *= b) %= md;
		(b *= b) %= md;
	}
	return res;
}
ll fact[mx] = {1}, invf[mx];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % md;
	invf[n] =  exp(fact[n] ,md-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % md;
}
ll comb(int a, int b){return a >= b ? fact[a] * invf[a-b] % md * invf[b] % md : 0;}
int main(){
	scanf("%d%d", &n, &k);
	setcomb(mx-1);
	for(int i = 1; i <= k; i++) printf("%lld\n", comb(n-k+1, i) * comb(k-1, i-1) % md);
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 2e5 + 10 ;
ll h[N] ;

ll nc2 ( ll n )
{
    n *= ( n - 1 ) ;
    n >>= 1 ;

    return n ;
}

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

    vi v ( n ) ;

    for ( int i=0 ; i < n ; i ++ )
    {
        int t ; cin >> t ;
        h[t] ++ ;

        v[i] = t ;
    }

    ll ans = 1 ;

    for ( int i = 0 ; i < N ; i ++ )
    {
        ll k = h[i] ;
        ans += nc2 ( k ) ;
    }

    for ( int i=0 ; i < n ; i ++ )
    {
        int t = v[i] ;
        cout << ans - h[t] ; line ;
    }
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 3968
gets
as = gets.split.map(&:to_i)

rates = Array.new(9, 0)
as.each do |a|
    rates[[a / 400, 8].min] += 1
end

fixed = rates[0..7].count{|n| n > 0}
min = [fixed, 1].max
max = fixed + rates[8]
puts "#{min} #{max}"

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <set>

int main() {
  std::set<char> ACGT={'A','C','G','T'};
  std::string S;
  std::cin >> S;
  int max_len = 0;
  int curr_len = 0;
  for(auto &s:S){
    if(ACGT.count(s)==0)
      curr_len = 0;
    else
      curr_len++;
    if(curr_len > max_len)
      max_len = curr_len;
  }
  std::cout << max_len << std::endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(tuple(map(int, input().split())), dtype=np.int64) - np.arange(N) - 1
median = np.median(A)
print(int(min(np.abs(A - median + 0.5).sum(), np.abs(A - median - 0.5).sum())) if int(median * 2) & 1 else int(np.abs(A - median).sum()))

Measured memory_bytes: 34424
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll> p,q,r;
	for(i=0;i<a;i++){
		cin>>j;
		p.ps(j);
	}
	sort(all(p),greater<ll>());
	for(i=0;i<b;i++){
		cin>>j;
		q.ps(j);
	}
	sort(all(q),greater<ll>());
	for(i=0;i<c;i++){
		cin>>j;
		r.ps(j);
	}

	for(i=0;i<x;i++){
		r.ps(p[i]);
	}
	for(i=0;i<y;i++){
		r.ps(q[i]);
	}

	sort(all(r),greater<ll>());
	ll an=0;
	for(i=0;i<x+y;i++){
		an+=r[i];
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 7152
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s;
  std::cin>>s;

  ll n=s.size();

  std::vector<P> a;

  ll temp1=0,temp2=0;

  ll sum=0;

  char mode='<';

  rep(i,0,n){
    if(s[i]=='<'){
      if(mode=='>'){
        a.push_back({temp1,temp2});
        temp1=1;
        temp2=0;
        mode='<';
      }else{
        temp1++;
      }
    }else{
      mode='>';
      temp2++;
    }
  }

  a.push_back({temp1,temp2});

  rep(i,0,a.size()){
    ll temp1=a[i].first,temp2=a[i].second;

    if(temp1>temp2)std::swap(temp1,temp2);

    sum+=temp1*(temp1-1)/2+temp2*(temp2+1)/2;
  }

  std::cout<<sum;

  return 0;
}

Measured memory_bytes: 3352
(defun input (n)
  (let ((a (make-array n)))
    (loop for i below n do (setf (aref a i) (read)))
    a)) 

(let* ((n (read))
       (v (input n))
       (c (input n)))
  (format t "~A~%"
          (loop for i below n
                when (> (aref v i) (aref c i))
                sum (- (aref v i) (aref c i)))))

Measured memory_bytes: 16484
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

int main() {
	int n;
	std::cin >> n;

	std::vector<int> a(n * 3);
	for (int i = 0; i < n * 3; i++) {
		std::cin >> a[i];
	}
	std::vector<int64_t> ll(n * 3);
	std::vector<int64_t> rr(n * 3);

	constexpr int64_t INF = 1e18;

	std::multiset<int> L;
	int64_t sl = 0;
	for (int i = 0; i < n * 3; i++) {
		L.insert(a[i]);
		sl += a[i];
		if (L.size() > n) {
			auto it = L.begin();
			sl -= *it;
			L.erase(it);
		}
		ll[i] = L.size() < n ? -INF : sl;
	}
	std::multiset<int> R;
	int64_t sr = 0;
	for (int i = n * 3 - 1; i >= 0; i--) {
		R.insert(-a[i]);
		sr += a[i];
		if (R.size() > n) {
			auto it = R.begin();
			sr -= -*it;
			R.erase(it);
		}
		rr[i] = R.size() < n ? INF : sr;
	}
	int64_t ans = -1e18;
	for (int i = 0; i + 1 < n * 3; i++) {
		ans = std::max(ans, ll[i] - rr[i + 1]);
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 15488
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 1050000000
 
using namespace std;

int main(void)
{
	priority_queue<int> que;
	string s;

	while (cin >> s) {
		if(s == "end") break;

		if(s == "insert") {
			int x;
			cin >> x;
            que.push(x);
		}

		if (s == "extract") {
			cout << que.top() << endl;
            que.pop();
        }
	}

	return (0);
}

Measured memory_bytes: 6776
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1'000'000'007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s);
    
    
    out(((s.find("7")!=string::npos)?"Yes":"No"));
}

Measured memory_bytes: 3672
from itertools import accumulate


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:]))) if k < n else str(p[-1])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 26316
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef vector<int> V;

int n, r;
V x;

int main(){
	while(scanf("%d%d", &n, &r), n){
		rep(i, n){
			x.push_back(n - i);
		}
		
		rep(i, r){
			int p, c;
			scanf("%d%d", &p, &c);
			V::iterator a = x.begin() + p - 1;
			V::iterator b = a + c;
			vector<int> y(a, b);
			x.erase(a, b);
			x.insert(x.begin(), y.begin(), y.end());
		}
		printf("%d\n", x[0]);

		x.clear();
	}
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
int ucrid(int x,int y){
  int a;
  int b;
  a=max(x,y);
  b=min(x,y);
  while (true){
    if (a%b==0){
      return b;
    }
    else {
      x=b;
      y=a%b;
      a=x;
      b=y;
    }
  }
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ml(n);
  vector<int> mr(n);
  vector<int> m(n);
  for (int i=0; i<n; i++){
    cin >> a[i] ;
  }
  ml[0]=a[0];
  mr[n-1]=a[n-1];
  for (int i=1; i<n; i++){
    ml[i] = ucrid(a[i], ml[i-1]);
    mr[n-i-1] = ucrid(a[n-i-1], mr[n-i]);
  }
  for (int i=1; i<n-1; i++){
    m[i] = ucrid(ml[i-1],mr[i+1]);
  }
  m[0]= mr[1];
  m[n-1]=ml[n-2];
  int answer;
  answer=m[0];
  for (int i=1; i<n; i++){
    answer=max(answer,m[i]);
  }
  cout << answer << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<vector<long>> A(N, vector<long>(N));
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            cin >> A[i][j];

    vector<vector<bool>> red(N, vector<bool>(N));

    bool bad = false;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j)
                continue;
            for (int k = 0; k < N; ++k) {
                if (i == k || j == k)
                    continue;

                if (A[i][k] + A[k][j] < A[i][j]) {
                    bad = true;
                    goto out;
                }
                if (A[i][k] + A[k][j] == A[i][j]) {
                    red[i][j] = red[j][i] = true;
                }
            }
        }
    }

out:
    long ans = -1;
    if (!bad) {
        ans = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                if (!red[i][j])
                    ans += A[i][j];
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-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; }

int main(){
    ll N,h,rt,ra,t=1,a=1;
    cin>>N;
    ll A[N],B[N];
    for(ll i=0;i<N;i++) cin>>A[i]>>B[i];
    for(ll i=0;i<N;i++){
        if(t%A[i]==0) rt=t/A[i];
        else rt=t/A[i]+1;
        if(a%B[i]==0) ra=a/B[i];
        else ra=a/B[i]+1;
        h=max(rt,ra);
        t=h*A[i];
        a=h*B[i];
        //cout<<t<<" "<<a<<endl;
    }
    cout<<t+a<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())
A = [a-1 for a in A]

# Douling(ダブリング)
i = 1
to = [[a for a in A]]
while pow(2, i) < K:
    t = [to[i-1][to[i-1][j]] for j in range(N)]
    to.append(t)
    i += 1

i -= 1
ans = [i for i in range(N)]
while i >= 0:
    if K & (1 << i) > 0:
        for j in range(N):
            ans[j] = to[i][ans[j]]
    i -= 1
print(ans[0]+1)

Measured memory_bytes: 218136
input_str = list(map(str,input().split()))
operand_list = ['+', '-', '*', '/']
stack = []
for str in input_str:
    if str in operand_list:
        top = stack.pop()
        top1 = stack.pop()
        if str == '+':
            stack.append(top + top1)
        elif str == '-':
            stack.append(top1 - top)
        elif str == '*':
            stack.append(top1 * top)
        elif str == '/':
            stack.append(top1 / top)
    else:
        stack.append(int(str))


print(stack[0])


Measured memory_bytes: 5600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;


//const int mod=1000000007;
const int mod=998244353;
//



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
    cin >> n;
    string s;
    map<string , int> map;
    a=0;
    for(int i=0; i<n; i++){
        cin >>s;
        if(map[s]==0){
            a++;
            map[s]++;
        }
    }
    cout << a << el;
    
    return 0;
    
}



Measured memory_bytes: 19272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	int[][]cost;
	int[][]time;
	int m;
	void start(){
		Scanner in  = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			m = in.nextInt();
			if(n == 0)break;
			cost = new int[101][101];
			time = new int[101][101];
			for(int i = 0; i < m+1; i++){
				for(int j = 0;  j< m+1; j++){
					cost[i][j] = time[i][j] = 1 << 29;	//?????¨??§?¶?????????????????????§Integer.MAX_VALUE???????????¨??±??????
				}
			}
			for(int i = 0; i < n; i++){
				int a = in.nextInt();
				int b = in.nextInt();
				cost[a][b] = cost[b][a] = in.nextInt();
				time[a][b] = time[b][a] = in.nextInt();
			}

			warshallFloyd();

			int k = in.nextInt();
			for(int i = 0; i < k; i++){
				int start = in.nextInt();
				int end = in.nextInt();
				int r = in.nextInt();
				if(r == 0) System.out.println(cost[start][end]);
				else System.out.println(time[start][end]);
			}

		}
		in.close();
	}
	void warshallFloyd(){
		for(int k = 0; k <= m; k++){
			for(int i = 0; i <= m; i++){
				for(int j = 0; j <= m; j++){
					cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
					time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
				}
			}
		}
	}

}

Measured memory_bytes: 73692
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int q; cin>>q;
	rep(i,q){
		int n; cin>>n;
		int cnt=0;
		while(n>=10){
			int div=10,tmp=0;
			while(div<n){
				if((n/div)*(n%div)>tmp) tmp=(n/div)*(n%div);
				div*=10;
			}
			n=tmp; cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll a[n*3];
    for(ll i = 0; i < n*3; i++)
        cin >> a[i];
    sort(a, a+n*3, greater<ll>());
    ll ans = 0;
    ll count = 0;
    ll i = 1;
    while(count<n){
        //cout << a[i] << endl;
        ans+=a[i];
        i+=2;
        count++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef unsigned long long ll;

int serch(int *a, int n, int key){
	int i = 0;
	a[n] = key;
	while(a[i] != key){
		i++;
	}
	return i != n;
}

int main(void){
	int n;
	cin >> n;
	int s[n + 1];
	rep(i, n) cin >> s[i];
	int q;
	cin >> q;
	int t[q];
	rep(i, q) cin >> t[i];

	int sum = 0;
	for(int i = 0; i < q; i++){
		if(serch(s, n, t[i])) sum++;
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000005

ll n, a[M], b[M], ans;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++){
        cin >> b[i];
        if (a[i] > b[i]) ans += a[i] - b[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
	vii a(3, vi(3));
	rep (i, 3) {
		rep (j, 3) {
			cin >> a[i][j];
		}
	}

	vi cnt1(3), cnt2(3), cnt3(2);
	int m;
	cin >> m;
	while (m--) {
		int x;
		cin >> x;
		rep (i, 3) {
			rep (j, 3) {
				if (a[i][j] == x) {
					cnt1[i]++;
					cnt2[j]++;
					if (i == j) cnt3[0]++;
					if (i == 2 - j) cnt3[1]++;
				}
			}
		}
	}

	bool flag = false;
	rep (i, 3) {
		if (cnt1[i] == 3) flag = true;
		if (cnt2[i] == 3) flag = true;
	}
	rep (i, 2) {
		if (cnt3[i] == 3) flag = true;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int64_t n;
    cin>>n;
    vector<int64_t> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int64_t step=0;
    int64_t high=a[0];
    for (int i = 1; i < n; i++)
    {
        if (a[i]>=high)
        {
            high=a[i];
        }else
        {
            step+=(high-a[i]);
        }
        
        
    }
    cout<<step<<endl;
    
    
    

    return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while(n-- > 0){
        int b = 0, c = 0;
        bool ok = true;
        for(int i=0; i<10; ++i){
            int a;
            cin >> a;
            if(a > b && a > c){
                if(b > c)
                    b = a;
                else
                    c = a;
            }else if(a > b)
                b = a;
            else if(a > c)
                c = a;
            else
                ok = false;
        }
        if(ok)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
char T[1010], S[1010];
int main()
{
	int ans = 999999;
    scanf("%s%s", S, T);
    int lens = strlen(S), lent = strlen(T);
    for(int i=0;i<lens;i++)
    {
    	if(lens-i<lent)
    	    break;
    	int diff = 0;
    	for(int j=0;j<lent;j++)
    	    if(T[j]!=S[i+j])
    	        diff++;
    	if(diff<ans)
    	    ans = diff;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;         
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll cnt=0;

void prime(ll x)
{
	ll ans=0;
	while(x%2==0)
	{
		ans++;
		x=x/2;
	}

	cnt+=(-1+sqrt(1+8*ans))/2;

	for(ll i=3;i*i<=x;i+=2)
	{
		ans=0;
		while(x%i==0)
		{
			ans++;
		x=x/i;
		}
		cnt+=(-1+sqrt(1+8*ans))/2;
	}

	if(x>2)
	{
		cnt++;
	}
}

int main()
{
	ll n;
	scanf("%lld",&n);
	prime(n);
	printf("%lld\n",cnt);
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000;
const char ENDL = '\n';
ll N, Ans = -pow(10, 9);
ll judge[15];

void makebit(ll x) {
	rep(i, 10) {
		if (x >= pow(2, 9 - i)) {
			judge[i] = 1;
			x -= pow(2, 9 - i);
		}
		else
			judge[i] = 0;
	}
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	ll F[MAX][15], P[MAX][15];
	rep(i, N) {
		rep(j, 10)
			cin >> F[i][j];
	}
	rep(i, N) {
		rep(j, 11)
			cin >> P[i][j];
	}

	rep1(i, pow(2, 10)) {
		makebit(i);
		ll sub = 0;
		rep(j, N) {
			ll lap = 0;
			rep(k, 10) {
				if ((F[j][k] == 1) && (judge[k] == 1))
					lap++;
			}
			sub += P[j][lap];
		}
		if (Ans < sub)
			Ans = sub;
	}
	cout << Ans << ENDL;
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    vector<bool> n(26,false);
    rep(i,s.size()){
        if(n[s[i]-'a']){
            cout<<"no"<<endl;
            return 0;
        }
        n[s[i]-'a']=true;
    }
    cout<<"yes"<<endl;
}


Measured memory_bytes: 256
X = int(input())
clear = 0
num = X

while True:
    judge = 1
    for i in range(2,int(num/2)+1):
        if num % i != 0:
            continue
        else:
            judge = 0
            break
    
            
        
    if judge == 1:
        break
    else:
        num += 1

if X == 1:
    num = 2
print(num)

Measured memory_bytes: 62468
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#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 pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n,m;
  bool open=true;

  cin >> n;
  string tou[500];
  REP(i,n){
	cin >> tou[i];
  }
  cin >> m;
  string kita;
  REP(i,m){
	cin >> kita;
	REP(j,n){
	  if(kita == tou[j]){
		if(open){
		  cout<<"Opened by "<<kita<<endl;
		  open = (not open);
		  break;
		}else{
		  cout<<"Closed by "<<kita<<endl;
		  open = (not open);
		  break;
		}
	  }
	  if(j==n-1)  cout<<"Unknown "<<kita<<endl;
	}
  }
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,s;
int x[100010];
long long p[100010];
int main()
{
	scanf("%d %d",&n,&s);
	for(int i=1;i<=n;i++)
		scanf("%d %lld",&x[i],&p[i]);
	long long ans=0;
	int l=1,r=n;
	int lst=0;
	while(1)
	{
		if(s<=x[l]){
			printf("%lld\n",ans+x[r]-s);
			return 0;
		}
		if(s>=x[r]){
			printf("%lld\n",ans+s-x[l]);
			return 0;
		}
		if(p[l]>=p[r]){
			if(lst!=1)ans+=x[r]-x[l];
			lst=1;
			p[l]+=p[r];
			r--;
		}
		else{
			if(lst!=2)ans+=x[r]-x[l];
			lst=2;
			p[r]+=p[l];
			l++;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//const ll MOD=1e9+7;
//static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}



const int MAX = 510000;
const int MOD = 1000000007;

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(){

    COMinit();
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll ans = 0;

    for(int i=n-1;i>=k-1;i--){
        ans += v[i]*COM(i,k-1);
        ans%=MOD;
    }

    //cout<<ans<<endl;
    for(int i=0;i<=n-k;i++){
        //ans = (ans-v[i]*COM(n-i-1,k-1)+MOD)%MOD;
        //ans%=MOD;
        ans -= v[i]*COM(n-i-1,k-1)%MOD;
        if(ans<0){
            ans+=MOD;
        }
        ans%=MOD;

    }
    cout<<ans%MOD<<endl;




    
return 0;
}


Measured memory_bytes: 12928
N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
idx=[]
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)

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

int main()
{
	string a;
	cin>>a;
	if(a.size()%2!=0)
	{
		printf("No\n");
		return 0;
	}
	for(int i=0;i<=a.size()/2-1;i++)
	{
		if(a[i]=='p'&&a[a.size()-1-i]=='q')continue;
		else if(a[i]=='q'&&a[a.size()-1-i]=='p')continue;
		else if(a[i]=='d'&&a[a.size()-1-i]=='b')continue;
		else if(a[i]=='b'&&a[a.size()-1-i]=='d')continue;
		else
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512