akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> hCount(h), wCount(w);
    int hMax = 0, wMax = 0;
    set<pair<int, int>> bombs;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y, x--, y--;
        hMax = max(hMax, ++hCount[x]), wMax = max(wMax, ++wCount[y]);
        bombs.insert({x, y});
    }

    vector<int> hCand, wCand;
    for (int i = 0; i < h; i++) {
        if (hCount[i] == hMax)hCand.push_back(i);
    }
    for (int i = 0; i < w; i++) {
        if (wCount[i] == wMax)wCand.push_back(i);
    }

    for (auto &x:hCand) {
        for (auto &y:wCand) {
            if (bombs.count({x, y}) == 0) {
                cout << hMax + wMax << endl;
                return 0;
            }
        }
    }

    cout << hMax + wMax - 1 << endl;
    return 0;
}

Measured memory_bytes: 23876
N = int(input())
B = [int(i) for i in input().split()]

A_sum = 0
for i in range(N):
    if i == 0:
        A_sum += B[i]
    elif i == N-1:
        A_sum += B[i-1]
    else:
        A_sum += min(B[i], B[i-1])
print(A_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll L,N;
ll X[200000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>L>>N;
    rep(i,0,N) cin>>X[i];
    ll ans=max(X[N-1], L-X[0]);
    ll res=N*X[0];
    rep(i,1,(N-1)/2+1){
        res+=(X[i]-X[i-1])*(N-2*i);
    }
    res+=(N-1)*(L-X[N-1]);
    rep(i,1,N/2){
        res+=(X[N-i]-X[N-1-i])*(N-1-2*i);
    }
    ans=max(ans,res);
    rep(i,1,N-1){
        res+=X[(N+i-1)/2];
        res-=L-X[(N+i)/2];
        res-=2*X[i-1];
        ans=max(res,ans);
    }
    res=N*(L-X[N-1]);
    rep(i,1,(N-1)/2+1){
        res+=(X[N-i]-X[N-i-1])*(N-2*i);
    }
    res+=(N-1)*(X[0]);
    rep(i,1,N/2){
        res+=(X[i]-X[i-1])*(N-1-2*i);
    }
    ans=max(ans,res);
    rep(i,1,N-1){
        res-=X[N-1-(N+i-1)/2];
        res+=L-X[N-1-(N+i)/2];
        res-=2*(L-X[N-i]);
        ans=max(res,ans);
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		int flg = 0;

		while (c > 0) {
		    list.add(c % 10);
		    c /= 10;
		}
		for (int n : list){
			if (n == 7){
				flg = 1;
			}
		}
		if (flg == 1){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35720
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
using namespace std;

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<pair<int, int>> a(N);
    for (int i = 0; i < N; i++)
        a[i] = make_pair(A[i], i + 1);

    sort(a.begin(), a.end());

    for (int i = 0; i < N; i++)
        cout << a[i].second << (i == N - 1 ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n; 
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(all(a));

  int cnt = 0;
  rep(i, n) {
    if (a[i] != b[i]) cnt++;
  }

  if (cnt <= 2) cout << "YES" << endl;
  else puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

int n, k, s;

int main()
{
	//File("");
	n = gi(), k = gi(), s = gi();
	for (int i = 1; i <= k; i+=1) cout << s << ' ';
	if (s != 1000000000)
	{
		for (int i = k + 1; i <= n; i+=1) cout << 1000000000 << ' ';
		puts("");
		return 0;
	}
	else
	{
		for (int i = k + 1; i <= n; i+=1) cout << 99999999 << ' ';
		puts("");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 1280
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(list);

        int ans = Integer.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            int candidate = gcd(list.get(i - 1), list.get(i));
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);
    }

    // a >= b
    static int gcd(int a, int b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }

}


Measured memory_bytes: 58000
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

const ll mod = 1000000007;

// ユークリッドの互除法
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll g = a; x = 1; y = 0;
	if (b != 0) {
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<ll>fact;
void mod_fact(ll n, ll m) {
	fact.resize(n + 1);
	fact[0] = 1;
	for (ll i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

// nCk mod p
ll mod_comb(ll n, ll k, ll m) {
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

// (num ^ x) % mod
ll pow_mod(ll num, ll x, ll mod) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) res = (res * num) % mod;
		(num *= num) %= mod;
		x >>= 1;
	}
	return res;
}

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

	ll n, a, b, c;
	cin >> n >> a >> b >> c;

	ll ans = 0;
	mod_fact(2 * n, mod);
	for (ll i = n; i <= 2*n- 1; i++) {
		ll bunsi = (pow_mod(a, n, mod) * pow_mod(b, i - n, mod) % mod + pow_mod(a, i - n, mod) * pow_mod(b, n, mod) % mod) * i * 100 % mod;
		ll bunbo = pow_mod(a + b, i, mod) * (100 - c) % mod;
		(ans += mod_comb(i - 1, n - 1, mod) * bunsi % mod * mod_inverse(bunbo, mod) % mod) %= mod;
	}

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


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>

int main()
{
        unsigned int count=0;
        std::cin>>count;
        std::string* res;
        res=new std::string [count+1];
        for(unsigned int i=0;i<=count;i++)
        {
                std::string str;
                getline(std::cin,str);
                unsigned int a,b,c;
                std::stringstream s(str);
                s>>a>>b>>c;
                if((a*a==b*b+c*c)||(b*b==a*a+c*c)||(c*c==a*a+b*b))
                        res[i]="YES";
                else
                        res[i]="NO";
        }
        for(unsigned int i=1;i<=count;i++)
                std::cout<<res[i]<<std::endl;
        return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int x,a;
  cin >> x >> a;
  if(x < a) cout << 0;
  else cout << 10;
  hinata;
}

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

enum State { NG, OK, UNKNOWN };

int main() {
  int a, b, c;
  while (cin >> a >> b >> c, a | b | c) {
    vector<State> states[3] = {
      vector<State>(a, UNKNOWN), vector<State>(b, UNKNOWN), vector<State>(c, UNKNOWN) };
    vector<vector<int>> failed;
    int N; cin >> N;
    for (int i = 0; i < N; ++i) {
      int x, y, z, r; cin >> x >> y >> z >> r; --x; --y; --z; y -= a; z -= a+b;
      if (r)
        states[0][x] = OK, states[1][y] = OK, states[2][z] = OK;
      else
        failed.push_back({x, y, z});
    }
    for (const vector<int>& f : failed) {
      int count = 0;
      for (int i = 0; i < 3; ++i)
        if (states[i][f[i]] == OK)
          ++count;
      if (count == 2)
        for (int i = 0; i < 3; ++i)
          if (states[i][f[i]] != OK)
            states[i][f[i]] = NG;
    }
    for (auto s : states)
      for (int v : s)
        cout << v << endl;
  }
}

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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i, m) cin >> b[i];

	int ans = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			int a; cin >> a;
			sum += a * b[j];
		}
		if (sum > -c) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<ll> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

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

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<ll> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    ll BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();

    ll count = 0;
    while (1)
    {
        vector<ll> t(d + 1, 1);
        t = BestT;

        ll a, b;
        do
        {
            a = rand() % d + 1;
            b = rand() % d + 1;
        } while (a == b);

        swap(t[a], t[b]);

        ll score = scoring(t);

        if (score > BestScore)
        {
            BestT = t;
            BestScore = score;
            count++;
        }

        auto end = std::chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                      // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            // printf("%lld\n", count);
            break;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%lld\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 3832
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)


Measured memory_bytes: 82268
#include <stdio.h>

int main(){
	int n,i,j,k;
	int sum,count=0;
	
	scanf("%d\n",&n);
	while(n!=0){
		count=0;
	for(i=2;i<=n;i++){
		sum=0;
		for(j=1;j<=n;j++){
			sum=0;
			for(k=0;k<i;k++){
				sum+=j+k;
			}
			if(sum==n){
				count++;
				break;
			}
		}
	}
		printf("%d\n",count);
		scanf("%d\n",&n);
	}
	return 0;
}
		

Measured memory_bytes: 1028
#include <iostream>
#include<math.h>
using namespace std;
int baisu(int a){
    int x;
    x=0;
    while(true){
        if(a%2==1)break;
        a=a/2;
        x++;
    }
    return x;
}
int main(void){
    // Your code here!
    int n,s;
    int a[20000];
    cin >>n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    s=0;
    for(int i=0;i<n;i++){
        s+=baisu(a[i]);
    }
    cout << s <<endl;
    
}


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

using namespace std;

int main() {
    int H, W;
    vector<vector<char>> grid;
    cin >> H >> W;
    vector<int> dot_count_row(H, 0);
    vector<int> dot_count_col(W, 0);

    for (size_t i = 0; i < H; i++) {
        vector<char> row;
        for (size_t j = 0; j < W; j++) {
            char c;
            cin >> c;
            row.push_back(c);
            if(c == '.') {
                dot_count_row[i]++;
                dot_count_col[j]++;
            }
        }
        grid.push_back(row);
    }

    for (size_t i = 0; i < H; i++) {
        if(dot_count_row[i] != W) {
            for (size_t j = 0; j < W; j++) {
                if(dot_count_col[j] != H) {
                    cout << grid[i][j];
                }
            }
            cout << endl;
        }
    }
}


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

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

  bool can = false;

  for( int i = 1; i <= 9; i++ )
    for( int j = 1; j <= 9; j++ )
      if( i * j == N )
	can = true;

  if( can )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

long gcd(long x, long y) { return y ? gcd(y, x % y) : x; }
long lcm(long x, long y) { return x / gcd(x, y) * y; }

int main() {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  long a = B / C - A / C;
  long b = B / D - A / D;
  long L = lcm(C, D);
  long l = B / L - A / L;
  cout << B - A - a - b + l << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    long long int n,d,a,b;
    cin>>n>>d;
    while(n--)
    {
        cin>>a>>b;
        if(a*a+b*b<=d*d)
        {
            cnt++;
        }
    }
    
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3628
S = input()

def check_if_kaibun(string):
  # odd
  if len(string) % 2 == 1:
    middle = int((len(string) - 1)  / 2)
    # print(string[0:middle])
    # print(string[middle + 1:])
    if (string[0:middle]) == (string[middle + 1:][::-1]):
      return True
    else:
      return False
  else:
    middle = int(len(string) / 2)
    if (string[0:middle]) == (string[middle:][::-1]):
      return True
    else:
      return False
    
a = int((len(S) - 1) / 2)
b = int((len(S) + 3) / 2)
# print(a, b)
# print(check_if_kaibun("asabasa"))
# print(check_if_kaibun("aabbaa"))

if check_if_kaibun(S):
  # print(S[0:a])
  if check_if_kaibun(S[0:a]):
    # print(S[b-1:])
    if check_if_kaibun(S[b-1:]):
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

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

int main(){
  int n;
  cin>>n;
  vector<int> h;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    h.push_back(temp);
  }
  vector<int> minval(n+1,INT_MAX);
  minval[0] = 0;
  for(int i=0;i<n-1;i++){
    minval[i+1] = min(minval[i+1], minval[i]+abs(h[i]-h[i+1]));
    minval[i+2] = min(minval[i+2], minval[i]+abs(h[i]-h[i+2]));
  }
  cout<<minval[n-1];
}
  
  

Measured memory_bytes: 1144
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int R, G, B, N;

int main() {

	scanf("%d%d%d%d", &R, &G, &B, &N);

	int ans = 0;
	rep(r, 3001) {
		rep(g, 3001) {
			if (N - R * r - G * g < 0) break;
			ll b = (N - R * r - G * g) / B;
			if (R * r + G * g + B * b == N) ans++;
		}
	}


	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		long[] cols = new long[a];

		int cnt = 0;
		int max = 0;

		for (int i = 0; i < a; i++) {
			cols[i] = sc.nextInt();
			if (i != 0 && cols[i] <= cols[i - 1]) {
				cnt++;
			} else {
				if (max < cnt) {
					max = cnt;
				}
				cnt = 0;
			}
		}
		if (max < cnt) {
			max = cnt;
		}


		System.out.println(max);
	}

}



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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll a; cin >> a;
  cout << a * a * a + a * a + a << endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  ll N,M,ans=0; cin>>N>>M;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin>>a.at(i);
    ans+=a.at(i);
  }
  sort(ALL(a));
  if(4*M*a.at(N-M)<ans){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+9;

int dp[1<<12];
int main()
{
    int n,m; cin>>n>>m;

    for(int i=1;i<(1<<n);i++) dp[i]=INF;

    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        int mask=0;
        for(int j=0;j<b;j++){
            int c; cin>>c;
            c--;
            mask|=(1<<c);
        }
       for(int j=0;j<(1<<n);j++) dp[j|mask]=min(dp[j|mask],dp[j]+a);
    }

    (dp[(1<<n)-1]==INF ? cout<<-1 : cout<<dp[(1<<n)-1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<ll> q, q1, q2;

	rep(i,a){
		ll tmp; cin >> tmp;
		q1.push(tmp);
	}

	rep(i,b){
		ll tmp; cin >> tmp;
		q2.push(tmp);
	}

	rep(i,c){
		ll tmp; cin >> tmp;
		q.push(tmp);
	}

	rep(i,x) {
		q.push(q1.top()); q1.pop();
	}
	rep(i,y) {
		q.push(q2.top()); q2.pop();
	}

	ll res = 0;
	rep(i,x+y){
		res += q.top(); q.pop();
	}

	cout << res << endl;
	return 0;

	
}

int main(){

	return mainsolve();
}

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

#define MAXK 75

int N;
string S;
int Q;
int k[MAXK];

int main()
{
	cin >> N;
	cin >> S;
	cin >> Q;
	for( int i = 0; i < Q; i++ ) {
		cin >> k[i];
	}


	for( int j = 0; j < Q; j++ ) {
		long long ans = 0, a = 0, b = 0, ab = 0;
		for( int i = 0; i < N; i++ ) {
			if( S[i] == 'D' ) {
				a++;
			}
			else if( S[i] == 'M' ) {
				ab += a;
				b++;
			}
			else if( S[i] == 'C' ) {
				ans += ab;
			}
			if( i >= k[j] - 1 ) {
				if( S[ i - k[j] + 1 ] == 'D' ) {
					a--;
					ab -= b;
				}
				if( S[ i - k[j] + 1 ] == 'M' ) {
					b--;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i=0; i<n; i++)
		cin >> l[i];
	int d=0, ans=1;
	for(int i=0; i<n; i++){
		d = d+l[i];
		if(d <= x)
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mod 1000000007
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll t=1;
//    cin>>t;
    while(t--){
    	ll n;
    	cin>>n;
    	ll a[n],b[n]={0};
    	for(ll i=0;i<n;i++)cin>>a[i];
    	ll mx=a[0],ans=0;
    	b[0]=a[0];
		for(ll i=1;i<n;i++){
    		mx=max(mx,a[i]);
    		b[i]=mx;
    		ans+=abs(a[i]-b[i]);
		}
		cout<<ans;
	}
}

Measured memory_bytes: 6736
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    ll v[200000] = {0};
    REP(i, N) {
        in >> v[i];
    }
    ll ans = 0;
    ll recent_distance = 0;
    double min_distance = LLINF;
    ll distance = 0;
    ll total = 0;
    for(ll i = 0; i < N; ++i) {
        total += v[i];
    }
    for(ll i = 0; i < N; ++i) {
        distance += v[i];
        auto ds = abs((double)distance - ((double)total /2));
        if (ds < min_distance) {
            min_distance = ds;
            recent_distance = distance;
        }
    }
    ans = abs((total - recent_distance) - recent_distance);
    out << ans << endl;
    debug(ans);
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 1792
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<climits>

#include<iomanip>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<sstream>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;
const int MAX = 110;
char f[MAX][MAX];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void dfs(int x,int y){
  char fruit = f[x][y];
  if(fruit == '.')return;
  f[x][y] = '.';

  for(int i = 0;i < 4;i++){
    int nx = x+dx[i],ny = y+dy[i];
    if(fruit == f[nx][ny])dfs(nx,ny);
  }
}
int main(){
  ios::sync_with_stdio(false);
  int w,h;

  while((cin >> h >> w) && (w+h) > 0){
    fill(*f, *(f+MAX), '.');
    for (int i = 1; i <= h; ++i){
      for (int j = 1; j <= w; ++j){
	cin >> f[j][i];
      }
    }

    int cnt = 0;
    for (int i = 1; i <= h; ++i){
      for (int j = 1; j <= w; ++j){
	if(f[j][i] != '.'){
	  dfs(j,i);
	  cnt++;
	}
      }

    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1684
num_s = input()
num = int(num_s)

def check(num):
    n = []
    for i in range(1, int(num**0.5)+1):
        if i > num:
            break
        if (num % i == 0):
            n.append(i)
    return n
ans = check(num)
a = max(ans)
b = int(num / a)


a = a - 1
b = b - 1

print(a + b)

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

using namespace std;

int main() {
  int n, x[200000], a[200000];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    a[i] = x[i];
  }
  sort(a, a + n);
  int a1 = a[n / 2 - 1], a2 = a[n / 2];
  for (int i = 0; i < n; i++) {
    printf("%d\n", x[i] <= a1 ? a2 : a1);
  }
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int n,m;
int main(){
	cin>>n>>m;
	if(500*n>=m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()

  val t = Range(0, n).map(_ => sc.nextInt())
    .sortBy(x => x)
    .map(i => math.min(i/400, 8))
    .groupBy(x => x)
    .toStream
    .sortBy(t => t._1)
    .foldLeft((0, 0)) {
      case ((minV, maxV), (id, seq)) => id match {
        case 8 => (math.max(minV, 1), maxV + seq.size)
        case _ => (minV + 1, maxV + 1)
      }
    }

  println(s"${t._1} ${t._2}")
}


Measured memory_bytes: 27072
def main():
    n, a, b = map(int, input().split())

    tmp = n // (a + b)

    if n - tmp * (a + b) > a:
        print(tmp * a + a)
    else:
        print(tmp * a + n - tmp * (a + b))

    # TLE
    # while n >= leng:
    #     if a < (n - leng):
    #         ans += a
    #         leng += (a + b)
    #     else:
    #         ans += n - leng
    #         leng += (a + b)

    # if a >= n:
    #     print(n)
    # else:
    #     print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	ll n = s.size();
	ll ans = n * (n - 1) / 2 + 1;
	vi cnt(26);
	REP(i, n)
	{
		cnt[s[i] - 'a']++;
	}
	for(auto i : cnt)
	{
		if(i > 0) ans -= i * (i - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include <map>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

map <long long, long long> m;

int main() {
	int n;
	cin >> n;
	long long x, sum = 0;
	for(int i = 1; i <= n; i++) {
		cin >> x;
		m[x]++;
		sum = x + sum;
	}
	int q;
	cin >> q;
	long long b, c;
	while(q--) {
		cin >> b >> c;
		sum = m[b] * (c - b) + sum;
		m[c] += m[b];
		m[b] = 0;
		cout << sum <<endl;
	}	
	return 0;
}


Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dp[10000007];

int main(){
  ll a, b;
  cin >> a >> b;
  if(a>0&&b>0){
    print("Positive");
  }
  else if(a<=0&&0<=b){
    print("Zero");
  }
  else{
    ll c = b - a;
    if(c%2==0){
      print("Negative");
    }
    else{
      print("Positive");
    }
  }
}

Measured memory_bytes: 3640
n = gets.chomp.to_i
a = gets.chomp.split(" ").map{|x| x.to_i}
min = 1000000
max = -1000000
sum = 0
for i in 0..(n-1) do
  if a[i] < min
    min = a[i]
  end
  if max < a[i]
    max = a[i]
  end
  sum += a[i]
end
printf("%d %d %d\n",min, max, sum)


Measured memory_bytes: 7268
from fractions import gcd

def lcm(x, y):
    return x * y // gcd(x, y)

A, B, C, D = map(int, input().split())

x = B // C - (A - 1) // C
y = B // D - (A - 1) // D
E = lcm(C, D)
z = B // E - (A - 1) // E
print(B - A + 1 - (x + y - z))


Measured memory_bytes: 65772
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX
#define MAX_LL

int main(){
    int n;cin>>n;
    vector<ll>a(n),b(n),c(n);
    rep(i,n)cin>>a[i];sort(ALL(a));
    rep(i,n)cin>>b[i];sort(ALL(b));
    rep(i,n)cin>>c[i];sort(ALL(c));
    ll ans=0;
    rep(i,n){
        ll a_n=lower_bound(ALL(a),b[i])-a.begin();
        ll c_n=c.end()-upper_bound(ALL(c),b[i]);
        ans+=a_n*c_n;
    }
    cout<<ans<<endl;

}

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

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    ll absx = abs(x);
    ll rep = absx/d;
    if(rep >= k){
        cout << absx-(k*d) << endl;
        return 0;
    }
    absx -= (d*rep);
    k -= rep;
    if(k%2 == 0) cout << absx << endl;
    else cout << abs(absx-d) << endl;
    return 0;
}

Measured memory_bytes: 3628
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        int k = sc.NextInt();
        int[] a = sc.IntArray();
        int[] b = sc.IntArray();

        long aTime = 0;
        long bTime = 0;
        int bIndex = 0;
        while (bIndex < m && bTime + b[bIndex] <= k)
        {
            bTime += b[bIndex++];
        }

        int ans = bIndex;
        for (int i = 0; i < n; i++)
        {
            aTime += a[i];
            if (aTime > k) break;
            while (aTime + bTime > k)
            {
                bTime -= b[--bIndex];
            }

            // Console.WriteLine($"{i+1} {aTime} {bIndex} {bTime}");
            ans = Math.Max(ans, i + 1 + bIndex);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 68160
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int X[MAX_M], Y[MAX_M], Z[MAX_M];

static const int MAX_UF = MAX_N;

template <class T> class UnionFind {
private:
  T par[MAX_UF];
  T rank[MAX_UF];
  
public:
  T find(T x);
  void init(T n);
  void unite(T x, T y);
  bool same (T x, T y);
};

template <class T> void UnionFind<T>::init(T n) {
  for (T i = 0; i < n; ++i) {
    par[i] = i;
    rank[i] = 0;
  }
}

template <class T> T UnionFind<T>::find(T x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

template <class T> void UnionFind<T>::unite(T x, T y) {
  x = find(x); y = find(y);
  if (x == y) {
    return;
  } else {
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) ++rank[y];
    }
  }
}

template <class T> bool UnionFind<T>::same(T x, T y) {
  return find(x) == find(y);
}

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

  cin >> N >> M;
  rep(i, M) cin >> X[i] >> Y[i] >> Z[i];

  UnionFind<int> uf;
  uf.init(N);

  rep(i, M) uf.unite(--X[i], --Y[i]);

  set<int> st;
  rep(i, N) st.insert(uf.find(i));

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

  return 0;
}


Measured memory_bytes: 6912
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

for _ in range(N):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
             print(" {}".format(room[i][j][k]),end="")
        print()
    if i!=3:
        print("####################")
        


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

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

    
    vector<int> A(N);

    

    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    int Asum = 0;
    int Bsum = 0;

    for(int i = 0; i < N; i++)
    {
        if(i % 2 == 0)Asum += A.at(i);
        else Bsum += A.at(i);
    }

    cout << Asum - Bsum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
int main(){
  
  int N;
  std::cin >> N;
  
  long long Sum = 0;
  while(N>0){
    if(N%5!=0 && N%3!=0){
      Sum += N;
    }
    N--;
  }
  
  std::cout << Sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> f(n + 1, 0);
    for(int x = 1; x <= 110; ++ x) {
        for(int y = 1; y <= 110; ++ y) {
            for(int z = 1; z <= 110; ++ z) {
                int m = x * x + y * y + z * z + x * y + y * z + z * x;
                if(m <= n) f[m] ++;
            }
        }
    }
    for(int i = 1; i <=n; ++ i) {
        cout << f[i] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  ll n,a[111111],b[111111];
  cin>>n;
  ll sum_a=0,sum_b=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum_a+=a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    sum_b+=b[i];
  }
  
  if(sum_b>sum_a){
    cout<<-1<<endl;
    return 0;
  }

  ll ans=0;
  vector<ll> dif;
  ll sum_dif=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i])continue;
    if(a[i]<b[i]){
	 sum_dif+=b[i]-a[i];
	 ans++;
	 continue;
    }
    dif.PB(b[i]-a[i]);
  }
  sort(ALL(dif));
  if(ans==0){
    cout<<ans<<endl;
    return 0;
  }
  for(int i=0;i<dif.size();i++){
    sum_dif+=dif[i];
    ans++;
    if(sum_dif<=0)break;
  }
  cout<<ans<<endl;	 
  return 0;
}


Measured memory_bytes: 2428
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
INF = float('inf')


def main():
    H, W, K = map(int, readline().split())
    x1, y1, x2, y2 = map(int, readline().split())
    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1
    C = read().split()

    dist = [[INF] * W for i in range(H)]
    dist[x1][y1] = 0
    d = deque([[x1, y1]])
    dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    while d:
        x, y = d.popleft()
        if (x, y) == (x2, y2):
            print(dist[x][y])
            quit()
        for dx, dy in dxy:
            xx = x
            yy = y
            for i in range(K):
                xx += dx;
                yy += dy
                if 0 <= xx < H and 0 <= yy < W and C[xx][yy] != '@':
                    if dist[xx][yy] <= dist[x][y]:
                        break
                    if dist[xx][yy] == INF:
                        d.append([xx, yy])
                    dist[xx][yy] = dist[x][y] + 1
                else:
                    break

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 125828
#include<bits/stdc++.h>
using namespace std;
int M[111][111];
int main(){
  int n,u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<' ';
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return(0);
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, b;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> b;

    int ans = 0;
    while (n) {
        n /= b;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main(){
ll n ,sum=0,i;
cin >> n;
ll a[n];
for(i=1;i<=n;i++){
if(i%3==0 && i%5==0)
a[i]=0;
else if(i%3==0 && i%5!=0)
a[i]=0;
else if(i%3!=0 && i%5==0)
a[i]=0;
else
a[i]=i;
}
for(i=1;i<=n;i++){
sum=sum+a[i]; }
cout << sum ;
}

Measured memory_bytes: 11400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();

		int sum = 0;
		int check = 0;
		for (int i = 1; i <= N; i++) {
			int a = i;
			check = 0;
            while (a > 0) {
                check += a % 10;
                a /= 10;
            }
			if (check >= A && check <= B) {
				sum += i;
			}

		}
		System.out.println(sum);

	}

}


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

using namespace std;
long long dp[30305][3305];

int main() {
    string s, t;
    cin >> s >> t;
    string ans;
    int n = s.length();
    int m = t.length();
    memset(dp, 0, sizeof(dp));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    int i = 0;
    int j = 0;
    while (i < n && j < m) {
        if (s[i] == t[j]) {
            putchar(s[i]);
            i++;
            j++;
        } else if (dp[i][j] == dp[i + 1][j]) {
            i++;
        } else {
            j++;
        }
    }

    return 0;
}

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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int main()
 {  fast();
   char alpha;
   cin>>alpha;
   if(isupper(alpha))
   cout<<'A'<<endl;
   else
   cout<<'a'<<endl;
	return 0;
}

Measured memory_bytes: 3648
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, L = lr()
INF = 10 ** 19
dis = [[INF for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    a, b, c = lr()
    if c > L:
        continue
    dis[a][b] = c
    dis[b][a] = c

for k in range(N+1): # kが中継地点
    for i in range(N+1):
        for j in range(i+1, N+1):
            x = dis[i][k] + dis[k][j]
            if x < dis[i][j]:
                dis[i][j] = dis[j][i] = x

supply = [[INF] * (N+1) for _ in range(N+1)]
for i in range(N+1):
    for j in range(i+1, N+1):
        if dis[i][j] <= L:
            supply[i][j] = supply[j][i] = 1

for k in range(N+1): # kが中継地点
    for i in range(N+1):
        for j in range(i+1, N+1):
            y = supply[i][k] + supply[k][j]
            if y < supply[i][j]:
                supply[i][j] = supply[j][i] = y

Q = ir()
for _ in range(Q):
    s, t = lr()
    if supply[s][t] == INF:
        print(-1)
    else:
        print(supply[s][t] - 1)

# 59 

Measured memory_bytes: 70108
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	int D, E, min, im;
	while (cin >> D >> E, D || E) {
		min = 100000000;
		for (int i = 0; i < D; i++) {
			if (min > abs(i * i + (D - i) * (D - i) - E * E)) {
				min = abs(i * i + (D - i) * (D - i) - E * E);
				im = i;
			}
		}
		cout << fixed << setprecision(4) << abs(sqrt((double)(im * im + (D - im) * (D - im))) - E) << endl;
	}
	return 0;
}

Measured memory_bytes: 3292