akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=Counter(A)

S=[]
for i,j in A.items():
  if j>=2:
    S.append(i)
S=list(set(S))
S.sort()
if len(S)>=2:
  ans=S[-1]*S[-2]
else:
  print(0)
  exit()

Q=[]

for i,j in A.items():
  if j>=4:
    Q.append(i)
if Q==[]:
  print(ans)
  exit()
print(max(ans, (max(Q))**2))


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

using namespace std;

class dsu {
  public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  dsu d(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    d.unite(x, y);
  }
  vector< vector<int> > comp(n);
  for (int i = 0; i < n; i++) {
    comp[d.get(i)].push_back(a[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (!comp[i].empty()) {
      cnt++;
    }
  }
  if (cnt == 1) {
    puts("0");
    return 0;
  }
  int choose = 2 * cnt - 2;
  long long ans = 0;
  vector<int> other;
  for (int i = 0; i < n; i++) {
    if (!comp[i].empty()) {
      sort(comp[i].begin(), comp[i].end());
      ans += comp[i][0];
      choose--;
      for (int j = 1; j < (int) comp[i].size(); j++) {
        other.push_back(comp[i][j]);
      }
    }
  }
  if (choose > (int) other.size()) {
    puts("Impossible");
    return 0;
  }
  sort(other.begin(), other.end());
  for (int i = 0; i < choose; i++) {
    ans += other[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
import sys
N, K = map(int, input().split())
if N == 1:
    print(1)
    sys.exit()
S = input()
cnt = [0]
flag = False
for c in S:
    if c == '0':
        if flag:
            cnt.append(cnt[-1])
        else:
            flag = True
            cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])
        flag = False
ans = 0
left, right = 0, 0
while right < N:
    while right < N:
        right += 1
        if right < N:
            if S[right - 1] == '1' and S[right] == '0':
                break
        else:
            break
    if cnt[right] - cnt[left] <= K:
        ans = max(ans, right - left)
    else:
        while left < N:
            left += 1
            if S[left - 1] == '0' and S[left] == '1':
                break
        if cnt[right] - cnt[left] <= K:
            ans = max(ans, right - left)
print(ans)

Measured memory_bytes: 5496
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    vc<int> ans(s.size(), 0);

    int l, m, r;

    for(int i = 0; i < (int)s.size(); ){
        l = i;
        do i ++; while(s[i] == 'R');
        m = i;
        do i ++; while(s[i] == 'L');
        r = i;
        
        // [0, x) 中の偶数の個数 = 1 + x/2
        // [0, x) 中の奇数の個数 = x - (1 + x/2)
        int even = (1+r/2) - (1+l/2);
        int odd = (r-(1+r/2)) - (l-(1+l/2));
        
        // Cout(l, " ", m, " ", r, "; ", even, " ", odd);
        
        if(m % 2 != 0){
            ans[m] = even;
            ans[m-1] = odd;
        }
        else{
            ans[m] = odd;
            ans[m-1] = even;
        }
    }
    Couts(ans);
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int ss;
            cin>>ss;
            ss--;
            s[i].push_back(ss);
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];

    int ans=0;
    rep(bit,1<<n){
        bool ok=true;
        rep(i,m){
            int cnt=0;
            rep(j,s[i].size()){
                int x=s[i][j];
                if(bit & 1<<x) cnt++;
            }
            if(cnt%2!=p[i]) ok=false;
        }
        if(ok) ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3540
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 1e6;
const int mod = 1e9+7;
int n, a[N];
int main(void)
{
    cin >> n;
    for(int i  =1;i<=n;++i)
        cin>>a[i];
    for(int i=1;i<=n;++i){
        if(a[i]%2==0){
            if(a[i]%3 != 0 && a[i]%5 != 0){
                cout <<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

// NUM未満の素数を求める
void PrimeNumber(int NUM, vector<bool>& prime) {
	const int sqnum = (int)sqrt(NUM);
	for (int i = 0; i < NUM; ++i) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i < sqnum; ++i) {
		if (prime[i]) {
			for (int j = i; i * j < NUM; j++) {
				prime[i * j] = false;
			}
		}
	}
}


int main(void) {

	vb prime(55556);
	PrimeNumber(55556, prime);
	
	vi tmp;
	rep(i, 55556) {
		if (prime[i] && i % 5 == 1) tmp.push_back(i);
	}
	
	int N;
	cin >> N;

	rep(i, N) {
		cout << tmp[i] << " ";
	}

	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int fr[SIZE], ba[SIZE];

map<P, LL> mp;

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

    int n;
    cin >> n;
    LL res = 0;
    for( int i = 1; i <= n; ++i ) {
        int f = i % 10;
        int tmp = i;
        while( tmp >= 10 ) {
            tmp /= 10;

        }
        int s = tmp % 10;
        mp[MP(f, s)]++;

    }

    for( int i = 1; i <= n; ++i ) {
        int f = i % 10;
        int tmp = i;
        while( tmp >= 10 ) {
            tmp /= 10;

        }
        int s = tmp % 10;
        res += mp[MP(s, f)];
    }
    cout << res << endl;
    return 0;
}



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


struct Barricada {
    long long S, T, X;
    bool operator<(const Barricada& rhs) const
    {
        return X > rhs.X;
    }
};

bool compare_barr(Barricada lhs, Barricada rhs){
    if (lhs.S - lhs.X < rhs.S - rhs.X) return true;
    return false;
}

Barricada barr[200000];
long long people[200000];
long long people_ans[200000];
long long ans[200000];
map <long long, long long> mapeo;

int main(){
    int n, q, pointer = 0;
    long long s, t, x, d;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> s >> t >> x;
        barr[i] = {s,t,x};
    }
    sort(barr, barr+n, compare_barr);
    priority_queue<Barricada> que;
    for (int j = 0; j < q; ++j) {
        cin >> people[j];
        people_ans[j] = people[j];
        mapeo[people[j]] = j;
    }
    sort(people, people+q);
    for (int k = 0; k < q; ++k) {
        while (pointer < n) {
            if (people[k] >= barr[pointer].S - barr[pointer].X) {
                que.push({barr[pointer].S, barr[pointer].T, barr[pointer].X});
                //cout << que.top().X << "a "<< k<<"\n";
                pointer++;
                continue;
            }
            break;
        }
        while (que.size()){
            if(people[k] >= que.top().T - que.top().X){
                que.pop();
                continue;
            }
            break;
        }
        if (que.size()) ans[mapeo.find(people[k])->second] = que.top().X;
        else ans[mapeo.find(people[k])->second] = -1;
    }
    for (int l = 0; l < q; ++l) {
        cout << ans[l] << "\n";
    }
    return 0;
}

Measured memory_bytes: 30100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n); rep(i, n) cin >> A[i];
  SegmentTree<int> seg(n, [](int a, int b) { return min(a, b); }, INT_MAX);
  rep(i, n) seg.update(i, A[i]);
  auto bsearchl = [&](int i) {
                    auto test = [&](int k) {
                                  return (seg.query(k, i+1) == A[i]);
                                };
                    int ok = i, ng = -1;
                    while(ok-ng>1) {
                      int mid = (ok+ng)/2;
                      (test(mid) ? ok : ng) = mid;
                    }
                    return ok;
                  };
  auto bsearchr = [&](int i) {
                    auto test = [&](int k) {
                                  return (seg.query(i, k+1) == A[i]);
                                };
                    int ok = i, ng = n;
                    while(ng-ok>1) {
                      int mid = (ok+ng)/2;
                      (test(mid) ? ok : ng) = mid;
                    }
                    return ok;
                  };
  ll ans = 0;
  rep(i, n) {
    int l = bsearchl(i);
    int r = bsearchr(i);
    ans += 1LL * A[i] * (i-l+1) * (r-i+1);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 6096
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
using namespace std;
 
lli gcd(lli a, lli b) { return (b == 0 ? a : gcd(b, a % b)); }
 
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
 
 
 
const int N = 1e6 + 30;
const lli mod = 998244353;

lli n, m, v, p;
lli a[N];
int pat;
lli pr[N];
int main()
{
	fastio;
	cin >> n >> m >> v >> p;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = p - 1; i < n; i++)
	{
		pr[i] = pr[i - 1] + a[i];
		//cout << pr[i] << " ";
	}
	//cout << endl;
	for (int i = 0; i < n; i++)
	{
		if(i > p - 1)
		{
			lli ss = max(0LL, v - (n - i));
			if(ss <= p - 1)
			{
				if(a[i] + m < a[p - 1]) break;
			}
			else
			{
				ss -= (p - 1);
				//cout << i << " " << ss << endl;
				lli l = a[p - 1], r  = 1e14, ans = a[p - 1];
				while(l <= r)
				{
					lli mid = (l + r)/2LL;
					if(mid * 1LL * (i - (p - 1)) - pr[i - 1] >= m * ss)
					{
						ans = mid;
						r = mid - 1;
					}
					else
					{
						l = mid + 1;
					}
				}
				if(a[i] + m < ans) break;
			}
		}
		int sm = 1;
		while (i < n - 1 && a[i] == a[i + 1])
		{
			i++;
			sm++;
		}
		pat += sm;
	}
	cout << pat << endl;
	return 0;
}

Measured memory_bytes: 5120
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

lst = [list(map(int, input().split())) + [i] for i in range(M)]
# print (lst)

lst.sort(key = lambda x: x[1]) #x番目が小さい順に並べる
lst.sort(key = lambda x: x[0])


ans = [0] * M

count = 0
tmp = 0 #１つ前の県の番号
for p, y, i in lst:
    if tmp == p:
        count += 1
    else:
        count = 1
        tmp = p
    tmp_ans = str(p).zfill(6) + str(count).zfill(6)
    ans[i] = tmp_ans

print (*ans, sep = '\n')





Measured memory_bytes: 33308
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	a,b,x =MI()
	V = a*a*b
	if(V*0.5 >= x):
		t=2*x/(a*b)
		ans = 90 -math.degrees(math.atan(t/b))
	else:
		t=(2*x-(a**2)*b)/(a**2)
		t=b-t
		ans = math.degrees(math.atan(t/a))
	print(ans)
main()

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

int main() {
	int k;
	cin >> k;
	for ( int l = 0; l < k; l++ ) {
		int gx, gy;
		cin >> gx >> gy;
		int a[17][17];
		int tate[17][16];
		int yoko[16][17];
		fill( a[0], a[17], 0 );
		fill( tate[0], tate[17], 0 );
		fill( yoko[0], yoko[16], 0 );
		a[1][1] = 1;
		int n;
		cin >> n;
		for ( int i = 0; i < n; i++ ) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if ( x1 == x2 ) 
				tate[x1 + 1][min( y1, y2 ) + 1] = 1;
			else
				yoko[min( x1, x2 ) + 1][y1 + 1] = 1;
		}
		for ( int i = 1; i < 17; i++ ) {
			for ( int j = 1; j < 17; j++ ) {
				if ( tate[i][j - 1] == 0 )
					a[i][j] += a[i][j - 1];
				if ( yoko[i - 1][j] == 0 )
					a[i][j] += a[i - 1][j];
			}
		}
		if ( a[gx + 1][gy + 1] != 0 )
			cout << a[gx + 1][gy + 1] << endl;
		else
			cout << "Miserable Hokusai!" << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int rock = 0, scissor = 1, paper = 2;

int main(){
	int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	for( int l = 0; l < k; ++l ){
		char prev = 'x';
		for( int i = l; i < n; i += k ){
			if( prev == t[i] ){
				prev = 'x';
				continue;
			}
			if( t[i] == 'r' ) ans += p;
			else if( t[i] == 's' ) ans += r;
			else if( t[i] == 'p' ) ans += s;
			prev = t[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
  string a = {"LR"};
  string n;
  cin >> n;
  
  for(int i = 0; i < n.size(); i++){
    if(n[i] == a[i%2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s; cin>>s;
  vector<int> a(3);
  int st=s[0]-'0';
  rep(i,3){
    a[i]=s[i+1]-'0';
  }

  for(int bit=0;bit<(1<<3);bit++){
    int sum=st;
    rep(i,3){
      int k=(1<<i);
      if((k&bit)!=0) sum+=a[i];
      else sum-=a[i];
    }
    if(sum==7){
      cout<<s[0];
      rep(i,3){
        int k=(1<<i);
        if((k&bit)!=0) cout<<'+';
        else cout<<'-';
        cout<<s[i+1];
      }
      cout<<"=7"<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
ans=1
B=[0,0,0]
for i in range(n):
  ct=0
  chk=False
  for j in range(3):
    if B[j]==A[i]:
      ct+=1
      if not chk:
        B[j]+=1
        chk=True
  ans=(ans*ct)%mod
print(ans)



Measured memory_bytes: 13964
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll N,suma=0,sumb=0,sumc=0,ans=0;

int main(){
    cin>>N;
    ll A[N],B[N],C[N];
    rep(i,N){
        cin>>A[i];
        suma+=A[i];
    }
    rep(i,N){
        cin>>B[i];
        sumb+=B[i];
    }
    if(suma<sumb){
        out("-1");
        return 0;
    }
    rep(i,N){
        C[i]=A[i]-B[i];
        if(C[i]<0)ans++,sumc+=C[i];
    }
    if(sumc>=0){
        out("0");
        return 0;
    }
    sort(C,C+N,greater<ll>());
    rep(i,N){
        sumc+=C[i];
        ans++;
        if(sumc>=0)break;
    }
    out(ans);

    
}


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


int main(void){
  int box[27]={};

  string x,ans="yes";
  cin>>x;

  r(i,x.size()){
    int y=x.at(i)-'a';
    //cout<<y<<endl;
    box[y]++;
    if(box[y]==2){ans="no";break;}
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
from functools import reduce
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7

def f(a):
    num = reduce(lambda x,y:x * y % mod,range(n,n-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

ans = pow(2,n,mod)-f(a)-f(b)-1
ans %= mod
print(ans)


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

int main(){
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	if(a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000) cout << 1 << endl; 
	else cout << 0 << endl; 
}

Measured memory_bytes: 1160
import math
while True:
    n = int(input())
    if n == 0:
        break

    l = list(map(int, input().split()))
    m = sum(l) / n
    amount = 0
    for s in l:
        amount += (s - m)**2
    stdev = math.sqrt(amount / n)
    print(stdev)



Measured memory_bytes: 5700
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 110
#define EPS 1e-7
using namespace std;
const double Pi=acos(-1);
struct node{
    double x,y;
    int id;
    node(){}
    node(double xx,double yy):x(xx),y(yy) {}
    node operator + (const node &a) const {
        return node(x+a.x,y+a.y);
    }
    node operator - (const node &a) const {
        return node(x-a.x,y-a.y);
    }
    node operator * (const double &t) const {
        return node(x*t,y*t);
    }
    double operator *(const node &a) const{
        return x*a.x+y*a.y;
    }
    double operator ^(const node &a) const{
        return x*a.y-y*a.x;
    }
    bool operator <(const node &a) const {
        return fabs(y-a.y)<EPS?x<a.x:y<a.y;
    }
}p[MAXN],l1[MAXN];
stack<node> s1,s;
double ans[MAXN];
int n,cnt1;
void solve(node a1[],int &cnt){
    s.push(p[1]);
    s1.push(p[1]);
    s1.push(p[2]);
    for(int i=3;i<=n;i++){
        while(!s.empty()&&((p[i]-s.top())^(s1.top()-s.top()))<-EPS){
            s.pop();
            s1.pop();
        }
        s.push(s1.top());
        s1.push(p[i]);
    }
    while(!s1.empty()){
        a1[++cnt]=s1.top();
        s1.pop();
    }
    while(!s.empty())
        s.pop();
}
bool cmp(node a,node b){
    return b<a;
}
double len(node a){
    return sqrt(a.x*a.x+a.y*a.y);
}
pair<long long,long long> b[MAXN];
bool check(){
    for(int i=1;i<=n;i++){
        b[i].first=(long long)(p[i].x);
        b[i].second=(long long)(p[i].y);
    }
    for(int i=2;i<n;i++){
        long long xx1=b[i].first-b[i-1].first;
        long long xx2=b[i+1].first-b[i].first;
        long long yy1=b[i].second-b[i-1].second;
        long long yy2=b[i+1].second-b[i].second;
        if(yy1*xx2!=yy2*xx1)
            return 0;
    }
    return 1;
}
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    SF("%d",&n);
    for(int i=1;i<=n;i++){
        SF("%lf%lf",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    sort(p+1,p+1+n);
    if(n==2){
        PF("0.50000\n");
        for(int i=2;i<n;i++)
            PF("0.00000\n");
        PF("0.50000\n");
        return 0;
    }
    solve(l1,cnt1);
    sort(p+1,p+1+n,cmp);
    cnt1--;
    solve(l1,cnt1);
    cnt1--;
    for(int i=1;i<=cnt1;i++){
        int las,nxt;
        if(i==1)
            las=cnt1;
        else
            las=i-1;
        if(i==cnt1)
            nxt=1;
        else
            nxt=i+1;
        double d=((l1[nxt]-l1[i])*(l1[las]-l1[i]))/(len(l1[nxt]-l1[i])*len(l1[las]-l1[i]));
        //PF("[%lf]",fabs((l1[nxt]-l1[i])*(l1[i]-l1[las])));
        d=acos(-d);
        ans[l1[i].id]=d/(2.0*Pi);
    }
    for(int i=1;i<=n;i++)
        PF("%.20lf\n",ans[i]);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
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;
    cin >> N;
    map<string, int> map;
    vector<string> ans;
    rep(i,N){
        string s;
        cin >> s;
        map[s] += 1;
    }


    cout << map.size() << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 19232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inp_vecN for(int i=0;i<n;i++)cin>>v[i]; 
vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=2; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }

      v.push_back(1);

      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    ll n,m;
    cin>>n>>m;
    std::vector<ll> heights(n+1);
    std::vector<bool> good(n+1,true);

    good[0]=false;
    heights[0]=-1;

    std::vector<pair<int,int>> pr;

    for(int i=1;i<=n;i++)
    {
      cin>>heights[i];
    }

    for(int i=0;i<m;i++)
    {
      int a,b;
      cin>>a>>b;
      pr.push_back(make_pair(a,b));

      if(heights[a]>heights[b])
      {
            good[b]=false;
      }
      else if(heights[a]<heights[b])
      {
            good[a]=false;
      }
      else
      {
            good[a]=false;
            good[b]=false;
      }
    }

    int ans=0;
    for(int i=0;i<good.size();i++)
    {
      if(good[i]==true)
            ans++;
    }

    cout<<ans;


    



    return 0;
}

Measured memory_bytes: 5076
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>b) {
        	System.out.printf("a > b\n");
        }
        if(a<b) {
       	 	System.out.printf("a < b\n");
        }
        if(a==b) {
       	 	System.out.printf("a == b\n");
        }
    }
}


Measured memory_bytes: 26320
//ARC 87D-2
#include<bits/stdc++.h>
using namespace std;

bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
    
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
    
	dp[t][n+8000]=1;
}

int main()
{
	string s;
	cin>>s>>x>>y;
    
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
    
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
    
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]==1?1:0;
    
	memset(dp,0,sizeof(dp));
    
	dfsy(0,0);
	bool yy=dp[ty][8000+y]==1?1:0;
    
	if(xx&&yy)
        cout<<"Yes\n";
	else
        cout<<"No\n";
    
    return 0;
    
}


Measured memory_bytes: 62976
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    String[] a = new String[n];
    String[] b = new String[m];
    for(int i = 0; i < n; i++){
      a[i] = sc.next();
    }
    for(int i = 0; i < m; i++){
      b[i] = sc.next();
    }
    
    for(int i = 0; i <= n - m; i++){
      for(int j = 0; j <= n - m; j++){
        boolean hit = true;
        if(a[i].substring(j, j + m).equals(b[0])){
          for(int k = 1; k < m; k++){
            if(!a[i + k].substring(j, j + m).equals(b[k])){
              hit = false;
              break;
            }
          }
        }else{
          hit = false;
          continue;
        }
        
        if(hit){
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int ketawa(int a){
    int ans=0;
    while(a>0){
        ans+=a%10;
        a/=10;
    }
    return ans;
}
int main(void){
    int n; cin>>n;
    int m=INF;
    FOR(i,1,n){
        m=min(m,ketawa(i)+ketawa(n-i));
    }
    co(m);
}


Measured memory_bytes: 256
from heapq import heappush, heappop
n,m=map(int,input().split())
works = []
for _ in range(n):
	a,b=map(int,input().split())
	if a>m:
		continue
	works.append((a,b))
works.sort(reverse=True)
q=[]
ans=0

for dayleft in range(1,m+1):
	while works and works[-1][0]<=dayleft:
		a,b=works.pop()
		heappush(q,-b)
	if q:
		b = -heappop(q)
		ans+=b
print(ans)

Measured memory_bytes: 17128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mmod 1000000007
#define pi acos(-1)
int main()
{
    faster;
    ll n;
    cin>>n;
    ll a[n+5];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll maxi=a[0];
    ll cnt=1;
    for (int i=1;i<n;i++)
    {
        if (maxi<=a[i])
            cnt++;
        maxi=max(maxi,a[i]);
        //cout<<maxi<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; ll n = s.size();
  
  string s1,s2; s1 = s2 = "";
  
  rep(i,n){
    if(i % 2 == 0){
      s1 += "0";
      s2 += "1";
    }
    else{
      s1 += "1";
      s2 += "0";
    }
  }
  
  ll ans1,ans2; ans1 = ans2 = 0;
  for(ll i=0; i < n; i++){
    if(s1[i] != s[i]) ans1++;
    if(s2[i] != s[i]) ans2++;
  }
  
  cout << min(ans1,ans2) << endl;
  
  
}

Measured memory_bytes: 3984
# coding: utf8

n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '357') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[20][20];
int val[1<<20],dp[1<<20];
void solve(){
    cin>>n;
    rep(i,0,n){
        rep(j,0,n){
            cin>>a[i][j];
        }
    }
    rep(i,0,1<<n){
        rep(j,0,n){
            rep(k,j+1,n){
                if((i>>j)&1 and (i>>k)&1){
                    val[i]+=a[j][k];
                }
            }
        }
    }
    rep(i,0,1<<n){
        for(int j=i;j>=0;j=i&(j-1)){
            int group=i^j;
            dp[i]=max(dp[i],dp[j]+val[group]);
            if(j==0) break;
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


pll A[MAXN+5];
bool cmp(pll a,pll b){
	if(a.fi!=b.fi)re a.fi<b.fi;
	re a.se<b.se; 
}
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	cin>>c>>y>>n>>m>>k;
	vp vec;
	while(n--){
		sc(x);
		 vec.pb(mp(x,1));
	}
	while(m--){
		sc(x);
		 vec.pb(mp(x,2));
	}
	while(k--){
		sc(x);
		 vec.pb(mp(x,3));
	}
	sort(all(vec),cmp);
	x=c+y;
	ll X=c;
	ll Y=y;	
	while(x){
		if(vec.back().se==1 and X){
			ans+=vec.back().fi;
		//	debug(vec.back().fi);
			X--;
			x--;
		}
		if(vec.back().se==2 and Y){
			ans+=vec.back().fi;
		//	debug(vec.back().fi);
			Y--;
			x--;
		}
		if(vec.back().se==3){
			ans+=vec.back().fi;
			//debug(vec.back().fi);
			x--;
		}
		 vec.pob;
	}
	pr(ans);
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 10604
#include<iostream>
#include<string>
using namespace std;
string s;
int l;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++){
        if(s[i]=='C'){
            for(register int j=i+1;j<l;j++){
                if(s[j]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main()
{
    long long N, M;
    cin >> N >> M;
    map<long long, long long, greater<long long>> cardCounts;
    for (long long i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        if(cardCounts.find(a) == cardCounts.end()){
            cardCounts.insert(pair<long long, long long>(a, 1));
        }else{

            cardCounts[a]++;
        }
    }
    for (long long i = 0; i < M; i++)
    {
        long long b, c;
        cin >> b >> c;
        if(cardCounts.find(c) == cardCounts.end()){
            cardCounts.insert(pair<long long, long long>(c, b));
        }else{
            cardCounts[c] += b;
        }
    }

    long long answer = 0;
    long long leftCount = N;
    for (auto it = cardCounts.begin(); it != cardCounts.end(); ++it) {
        pair<long long, long long> card = *it;
        long long cardNum = card.first;
        long long cardCount = card.second;
        cardCount = min(leftCount, cardCount);
        answer += cardNum * cardCount;
        leftCount -= cardCount;
        if(leftCount == 0){
            break;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 12800
int main()
{
  int x, y;
  scanf("%d %d", &x, &y);
  int turu;
  for (turu = 0; turu <= x; turu++)
  {
    if (turu * 2 + (x - turu) * 4 == y)
    {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    fori(i, 0, n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < (int) v.size() && x >= v[i]; i++) {
        ans++;
        x -= v[i];
    }
    if(x && ans == n) {
        ans--;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int search(int[] a, int key) {
		int left=0, right=a.length;
		int mid;
		while (left < right) {
			mid = (left+right) / 2;
			if (key == a[mid]) return mid;
			if (key > a[mid]) left = mid+1;
			else if (key < a[mid]) right = mid;
		}
		return -1;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		
		int sum = 0;
		
		int q = sc.nextInt();
		for (int i=0; i<q; i++) {
			int key = sc.nextInt();
			if (search(a, key) >= 0)
				sum ++;
		}
		
		sc.close();
		
		System.out.println(sum);
	}

}



Measured memory_bytes: 67968
from collections import deque
def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = deque([0])
    s = 0
    while q:
        v = q.popleft()
        for w in E[v]:
            if V[w] == -1:
                s = w
                V[w] = V[v] + 1
                q.append(w)
    # s = V.index( max(V))
    p = deque([s])
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.popleft()
        for w in E[v]:
            if W[w] == -1:
                W[w] = W[v] + 1
                p.append(w)
    return max(W)

N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)


Measured memory_bytes: 94796
///Code by: Luis Alejandro
///Handle: Sekai
///Country: Cuba

#include <bits/stdc++.h>
#define endl '\n'
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN=1e5+5;
const int MOD=1e9+7;
const int INF=1e9;
const ld PI=acos(-1);
const ld EPS=1e-9;

#define lg2(x) 31-__builtin_clz(x)
#define logx(a,b) (log(a)/log(b))
#define pow2(a) a*a
#define pow3(a) a*a*a
#define lcm(a,b) (a*b)/__gcd(a,b)

pii mkp(int a, int b){
    if(a>b)swap(a,b);
    return make_pair(a,b);
}

int mod_pow(int a, int b){
    if(!b)return 1;
    if(b&1)return mod_pow(a,b-1)*a%MOD;
    int power=mod_pow(a,b>>1);
    return power*power%MOD;
}

int modular_inverse(int a){
    return mod_pow(a,MOD-2);
}

vector<int> movy={0,0,1,-1};
vector<int> movx={1,-1,0,0};

void solve(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        int tmp=0;
        for(int j=i;j<s.length();j++){
            if(s[j]=='R'){tmp++;ans=max(tmp,ans);}
            if(s[j]=='S')break;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    //freopen("OUT.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int n, w, h[11];
	while(cin >> n >> w, n){
		memset(h, 0, sizeof(h));
		int mx = 0, tmp;
		for(int i=0;i<n;i++){
			cin >> tmp;
			mx = max(mx, tmp);
			h[tmp/w]++;
		}
		int size = mx/w, hist = 0;
		for(int i=0;i<=size;i++)
			hist = max(hist, h[i]);
		double ans = 0.01;
		for(int i=0;i<size;i++)
			ans += ((double)(size-i)*h[i])/(hist*size);
		printf("%.6lf\n", ans);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n, cnt = 0;
    ll tmp;
    vector<ll> l(n);
    cin >> n;
    rep(i, n) {
        cin >> tmp;
        l.push_back(tmp);
    }
    for(int i = 0; i < n-2; i++) {
        for(int j = i + 1; j-1 < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if((l[i] < l[j] + l[k]) && (l[j] < l[i] + l[k]) &&
                   (l[k] < l[j] + l[i]) && (l[i] != l[j]) && (l[i] != l[k]) &&
                   (l[j] != l[k])) {
                    cnt++;
                    // cout << l[i] << l[j] << l[k] << endl;
                }
            }
        }
    }
 
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
const int N=111111;
int t[N][3];
int dp[N+10][4];//dp[i][j]=i日目にjの活動をした時の最大値

int main(){
  cin>>n;
  rep(i,n)cin>>t[i][0]>>t[i][1]>>t[i][2];

  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j==k)continue;
        dp[i+1][j]=max(dp[i+1][j],dp[i][k]+t[i][k]);
      }
    }
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[0] == '7' or s[1] == '7' or s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	
}


Measured memory_bytes: 3568