akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_4_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();

            int q = ReadInt();
            for (int i = 0 ; i < q ; i++)
            {
                int[] items = ReadIntAr();

                var before = line.Take(items[0]).ToArray();
                var rotateBefore = line.Skip(items[0]).Take(items[1] - items[0]).ToArray();
                var rotateAfter = line.Skip(items[1]).Take(items[2] - items[1]).ToArray();
                var after = line.Skip(items[2]).Take(line.Length - items[2]).ToArray();
                line = before.Concat(rotateAfter).Concat(rotateBefore).Concat(after).ToArray();
            }
            Console.WriteLine(WriteAr(line));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

int main(void) {
	int a[3], b[3];
	int c[3][3] = { 0 };
	int flag;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)scanf("%d", &c[i][j]);
	}
	
	for (int i = 0; i <= 100; i++) {
		flag = 1;
		a[0] = i;
		b[0] = c[0][0] - a[0];
		b[1] = c[0][1] - a[0];
		b[2] = c[0][2] - a[0];
		a[1] = c[1][0] - b[0];
		a[2] = c[2][0] - b[0];
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (c[j][k] != a[j] + b[k]) {
					flag = 0;
					break;
				}
			}
		}
		if (flag) {
			printf("Yes");
			break;
		}
		else if (i == 100)printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
X, K, D = map(int, input().split(" "))
X = abs(X)

a = X // D
b = X % D

remain_count = K - a

if remain_count < 0:
    ans = X - K * D
else:
    if remain_count % 2 == 0:
        ans = b
    else:
        ans = abs(b - D)
    
print(ans)

Measured memory_bytes: 9196
n = int(input())
A = [int(a) for a in input().split()]
ans=0
for i in range (1,n-1):
  mid =A[i]
  top =A[i-1]
  bot =A[i+1]
  B =[top,mid,bot]
  ma =(max(B))
  mi =(min(B))
  if mi != mid and ma != mid:
    ans +=1
print(ans)
  

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine();
            var lst = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int cnt = 0;
            bool isEnd = false;

            do
            {

                for (int i = 0; i < lst.Count(); i++)
                {
                    if (lst[i] % 2 == 0)
                    {
                        lst[i] = lst[i] / 2;
                    }
                    else
                    {
                        isEnd = true;
                    }
                }

                if (!isEnd)
                {
                    cnt++;
                }

            } while (!isEnd);


            Console.WriteLine($"{cnt}");
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iostream>
using namespace std;
typedef long long LL;
typedef double DB;
const int Max = 1e5;
const int MOD = 1e9 + 7;


LL n, m, num[100005];
int main()
{
	scanf("%lld", &n);
	num[0] = 2;
	num[1] = 1;
	for(LL i = 2ll; i <= n; i++)
		num[i] = num[i - 1] + num[i - 2];
	printf("%lld\n", num[n]);
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int s, t;
  s = S.size(); t = T.size();
  if((t==s+1) && T.substr(0,s)==S){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}



Measured memory_bytes: 3624
local t={}
for i=2,10^5 do
    t[i]=1
end

local p={}
for i=2,10^5 do
    if t[i]>0 then
        p[i]=1
        for j=2,math.floor(10^5/i) do
            t[i*j]=0
        end
    end
end

local s={}
s[0],s[1]=0,0
for i=2,10^5 do
    if p[i] and p[math.floor((i+1)/2)] then
        s[i]=s[i-1]+1
    else
        s[i]=s[i-1]
    end
end

local q=io.read("n")
for i=1,q do
    local l,r=io.read("n","n")
    print(s[r]-s[l-1])
end

Measured memory_bytes: 5084
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int lcm(int a, int b) {
  return a*b/__gcd(a, b);
}

signed main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D;
  E = lcm(C, D);
  int all = B-A+1;
  int c = B/C - (A-1)/C;
  int d = B/D - (A-1)/D;
  int e = B/E - (A-1)/E;
  int ans = all - c - d + e;
  cout << ans << endl;
}


Measured memory_bytes: 256
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		// if(b>=0 && d>=0) cout<<b*d;
		// else if(b<0 && d<0) cout<<a*c;
// 		
		cout<<max(a*c,max(b*d, max(a*d, b*c)));
    }
    return 0;
} 


Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<functional>
#include<algorithm>
char map[101][101];
int ii,jj;
int h,w;
char temp[2];
void func(int ,int);
using namespace std;
int main(void){
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0){
			break;
		}
		int i,j,cnt=0;
		for(i=0;i<h;i++){
			scanf("%s",map[i]);
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(map[i][j]=='#' || map[i][j]=='*' || map[i][j]=='@'){
					temp[0]=map[i][j];
					map[i][j]='o';
					func(i,j);
					cnt++;
				}
			}/*
			for(j=0;j<h;j++){
				printf("%s\n",map[j]);
			}
			printf("\n");*/
		}
		printf("%d\n",cnt);
	}
}
void func(int y,int x){
	int dy[4]={0,1,-1,0},dx[4]={1,0,0,-1};
	int yy,xx;
	int i;
	for(i=0;i<4;i++){
		yy=y+dy[i];
		xx=x+dx[i];
		if(map[yy][xx]==temp[0] && yy>=0 && yy<h && xx<w && xx>=0){
			map[yy][xx]='o';
			func(yy,xx);
		}
	}
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int n, m; cin>>n>>m;
    vector<P> g(m);
    for(int i=0; i<m; i++) {
        int a, b; cin>>a>>b;
        g[i] = make_pair(b, a);
    }
    
    sort(g.begin(), g.end());

    int ans=1, x=g[0].first;
    for(int i=1; i<m; i++){
        if(g[i].second >= x){
            ans++;
            x = g[i].first;
        }
    }
    cout << ans << endl;    
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i+=2) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 512
import sys
from io import StringIO
import unittest


def resolve():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    if p == [] or x not in p:
        print(x)
    else:
        p = set(p)
        i = 1
        while 1:
            if x - i not in p:
                print(x - i)
                break
            elif x + i not in p:
                print(x + i)
                break
            else:
                i += 1



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6 5
4 7 10 6 5"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 5
4 7 10 6 5"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """100 0"""
        output = """100"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 70976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> d(n);rep(i,n)cin>>d[i];
    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    s = list(input())[::-1]
    ary_mod = [0] * 2019
    ary_mod[0] = 1
    now = 0
    digit = 1
    for i, ss in enumerate(s):
        now += int(ss) * digit % 2019
        digit *= 10
        digit %= 2019
        remind = now % 2019
        ary_mod[remind] += 1
    ans = 0
    for i, n in enumerate(ary_mod):
        ans += (n*(n-1)) // 2
    print(ans)
if __name__=='__main__':
    main()


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define SX(x) (x).begin(), (x).end()
typedef pair<int, int> P;
using ll =long long;

int main(){
  int n; cin >> n;
  
  vector<int> s(n);
  int sum =0;
  bool ok = true;
  
  rep (i, n)  {
    cin >> s[i];
    if (s[i]%10 != 0)	ok = false;
    sum += s[i];
  }
  if (sum%10 != 0) {
    cout << sum << endl;
    return 0;
  }
  else if (ok)  {
    puts("0");
    return 0;
  }
  sort(SX(s));
  rep(i,n)  {
    if ((sum-s[i])%10 == 0) {
      continue;
    }
    else {
      cout << sum-s[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;
using std::multiset;
using std::greater;
using std::priority_queue;
using std::less;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);
[[maybe_unused]] const ull modular = 998244353;

//....................................................................................................................//


int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(10);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    sum += min(k, a);
    k -= a + b;
    if (k > 0) {
        sum -= k;
    }
    cout << sum;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) ll((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// 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() {
  vector<int> v1,v2,v3;
  int n; cin >> n;
  string s; cin >> s;
  FOR(i,0,s.length()-1){
    if(s[i]=='R') v1.PB(i);
    if(s[i]=='G') v2.PB(i);
    if(s[i]=='B') v3.PB(i);
  }
  ll ans = SZ(v1) * SZ(v2) * SZ(v3);

  // v3.PB(-1001001001);
  // v3.PB(1001001001);

  // SORT(v3);

  // for(auto x: v1){
  //   for(auto y: v2){
  //     int a = min(x,y);
  //     int b = max(x,y);
  //     if(a-(b-a)>=0 && a-(b-a)<=n-1) {
  //       if(upper_bound(v3.begin(), v3.end(), a-(b-a)) - lower_bound(v3.begin(), v3.end(), a-(b-a))==1){ 
  //         --ans;
  //         // cout << a-(b-a) << " " << a << " " << b << "\n";
  //       }
  //     }
  //     if(b+(b-a)>=0 && b+(b-a)<=n-1) {
  //       if(upper_bound(v3.begin(), v3.end(), b+(b-a)) - lower_bound(v3.begin(), v3.end(), b+(b-a))==1) {
  //         --ans;
  //         // cout << a << " " << b << " " << b+(b-a) <<  "\n";
  //       }
  //     }
  //     if(b-a%2==0){
  //       if(upper_bound(v3.begin(), v3.end(), (b-a)/2) - lower_bound(v3.begin(), v3.end(), (b-a)/2)==1) {
  //         --ans;
  //         // cout << a << " " << b << " " << b+(b-a) <<  "\n";
  //       }
  //     }
  //   }
  // }

  FOR(wid,1,n){
    FOR(i,0,n-1){
      if(i+wid*2>n-1) continue;
      if(s[i]!=s[i+wid] && s[i+wid]!=s[i+wid*2] && s[i]!=s[i+wid*2]) --ans;
    }
  }

  cout << ans << "\n";
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<vector<double>>> dp(310,vector<vector<double>> (310,vector<double>(310,-1)));

double susi(int i,int j,int k)
{
    if(i == 0 && j ==0 && k ==0) return 0;
    if(i<0||j<0||k<0) return 0;

    if(dp[i][j][k] >0 )return dp[i][j][k];
    double ans = n + i*susi(i-1,j,k) + j*susi(i+1,j-1,k) + k*susi(i,j+1,k-1);
    return dp[i][j][k]=ans/(i+j+k);
}

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n;
    vector<int> arr(4,0);
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        arr[a]++;
    }
    //cout<<arr[1]<<arr[2]<<arr[3];
    cout<<fixed<<setprecision(13)<<susi(arr[1],arr[2],arr[3])<<'\n';
}


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

int main(){
    int N, K; cin >> N >> K;
    int a[101];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    bool dp[100100]; //trueなら先手必勝
    for(int i=0; i<=K; i++){
        dp[i]=false;
    }
    for(int i=0; i<=K; i++){
        for(int j=0; j<N; j++){
            if( i-a[j]>=0 && dp[i-a[j]]==false ){
                dp[i]=true; break;
            }
        }
    }
//    cout << dp[0] << dp[1] << dp[2] << dp[3] << dp[4] << endl;
    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
N,T = list(map(int,input().split()))
CT = [list(map(int,input().split())) for _ in range(N)]

result =float('inf')

for c,t in CT:
    if t<=T:
        result = min(result,c)

if result==float('inf'):
    print("TLE")
else:
    print(result)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//#include<mt19937>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	llint q,h,s,d,n,ans=0;
	cin>>q>>h>>s>>d>>n;
	mineq(h,q*2);
	mineq(s,h*2);
	mineq(d,s*2);
	ans+=n/2*d;
	ans+=n%2*s;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int dp[100005];
int main()
{
	int n,i,j;
	cin>>n;
	int h[n+1];
	for(i=1;i<=n;i++)
		cin>>h[i];
	dp[2] = abs(h[2] - h[1]);
	dp[1] = 0;
	for(i=3;i<=n;i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String S=sc.next();
		boolean f=true;
		ArrayList<Integer> a=new ArrayList<Integer>();
		for(int i=0;i<S.length();i++) {
			int temp=(int)S.charAt(i);
			if(a.contains(temp)) {
				f=false;
				break;
			}
			else {
				a.add(temp);
			}
		}
		System.out.println(f?"yes":"no");
	}
}

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

int main(){
  int N,M; cin >> N >> M;
  vector<int> X(M,0); for(int i = 0; i < M; i++) cin >> X.at(i);
  sort(X.begin(),X.end());
  
  vector<int> dis(M-1,0);
  for(int i = 0; i < M - 1; i++){
    dis.at(i) = X.at(i+1) - X.at(i);
    //cout << dis.at(i) << endl;
  }
  sort(dis.begin(),dis.end());
  
  int ans = 0;
  if(N >= M) ans = 0;
  else{
    int count = N-1;
    for(int i = 0; i < dis.size()-N+1; i++){
        ans += dis.at(i);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc063/tasks/arc075_b
# 問題文あなたが散歩していると、突然 N 体の魔物が出現しました。
# それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
# 体力が 0以下となった魔物は直ちに消滅します。
# 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
# 一回の爆発では、以下のように魔物の体力を減らすことができます。
# 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
# 爆発の中心となる魔物の体力は A 減り、
# その他の魔物の体力はそれぞれ B 減る。
# ここで、A と B はあらかじめ定まった値であり、A>B である。
# すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
# 制約入力値はすべて整数である。
# 1≤N≤10^5
# 1≤B<A≤10^9
# 1≤hi≤10^9

# N A B
# h1
# h2
# :
# hN

# 4 5 3
# 8
# 7
# 4
# 2

# 2

# 2 10 4
# 20
# 20

# 4

# 5 2 1
# 900000000
# 900000000
# 1000000000
# 1000000000
# 1000000000

# 800000000

N, A, B = gets.split.map(&:to_i)
H = []
N.times {
  H << gets.to_i
}
H.sort.reverse!

A_B = A - B

class Integer
  def able?
    counter = self
    bself = B * self
    b2 = - bself + A_B - 1
    H.each do |value|
      next if value <= bself
      counter -= ((value + b2)/(A_B))
      break if counter < 0
    end
    counter >= 0
  end
end

# T回で倒しきれるか？ を二分探索
# ng = 0, ok = h.max
ng = 0
ok = 1 << 30
mid = 0
while (ok - ng) > 1
  mid = (ng + ok)/2
  if mid.able?
    ok = mid
  else
    ng = mid
  end
end
puts ok

Measured memory_bytes: 4656
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,t,s,u,w;
    while(scanf("%d %d",&a,&b)!=EOF){
        u=a;
        s=b;
        t=a%b;

        while(t!=0){
            a=b;
            b=t;
            t=a%b;
        }
        u=u/b;
        s=s/b;
        w=u*s*b;
        printf("%d %d\n",b,w);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdint>

using namespace std;

struct Mod {
    static constexpr auto kMod = 1000000007L;
    static constexpr auto kIMod = 1000000005L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const {
        return (n * (m.n % kMod)) % kMod;
    }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p/2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kIMod);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const {
        return (n + m.n) % kMod;
    }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    int64_t n;
};


int64_t solve(int n, const vector<int64_t>& t, const vector<int64_t>& a) {
    vector<int64_t> h(n);
    h[0] = -1;
    for (int i = 1; i < n; ++i) {
        if (t[i] != t[i - 1]) {
            h[i] = -1;
        } else {
            h[i] = t[i];
        }
    }

    vector<int64_t> h2(n);
    h2.back() = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] != a[i + 1]) {
            h2[i] = -1;
        } else {
            h2[i] = a[i];
        }
    }

    Mod m(1);
    for (int i = 0; i < n; ++i) {
        if (h[i] == -1 && h2[i] == -1) {
            if (t[i] != a[i]) {
                return 0;
            } else {
                continue;
            }
        }

        if (h[i] == -1 && t[i] > h2[i]) {
            return 0;
        }

        if (h2[i] == -1 && a[i] > h[i]) {
            return 0;
        }

        if (h[i] == -1 || h2[i] == -1) {
            continue;
        }

        m *= min(h[i], h2[i]);
    }

    return m.n;
}


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

    vector<int64_t> t(n);
    for (auto&& tt : t) {
        cin >> tt;
    }

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    cout << solve(n, t, a) << endl;

    return 0;
}

Measured memory_bytes: 3328
import bisect
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    L = [list(map(int, input().split())) for _ in range(N)]

    dp = [[0, 0, 0] for _ in range(N)]
    dp[0][0] = L[0][0]
    dp[0][1] = L[0][1]
    dp[0][2] = L[0][2]
    for i in range(N-1):
        for j in range(3):
            for k in range(3):
                if j==k:
                    continue
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + L[i+1][k])
        # print(dp)
    
    print(max(dp[N-1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 72796
def main():
    N = int(input())
    S, P = [], []
    for _ in range(N):
        si, pi = input().split()
        S.append(si)
        P.append(int(pi))

    d = dict()
    for i in range(N):
        if S[i] not in d:
            d[S[i]] = [[P[i], i+1]]
        else:
            d[S[i]].append([P[i], i+1])
    output = []

    cities = sorted(d.keys())
    for c in cities:
        output += [x[1] for x in sorted(d[c], key = lambda x: x[0], reverse = True)]
    return output

if __name__ == '__main__':
    output = main()
    for i in range(len(output)):
        print(output[i])

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int a, b, c, tmp;

    scanf("%d%d%d", &a, &b, &c);
    tmp = a;
    a = b;
    b = tmp;
    tmp = a;
    a = c;
    c = tmp;
    printf("%d %d %d\n", a, b, c);

    return 0;
}

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

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

    int a,b,c;
    // 引数の受け取り
    //
    cin >> a >> b >> c;

if((a*100+b*10+c)%4==0){
    cout << "YES"  << endl;
}else{
    cout << "NO"  << endl;
}
    // 出力
    return 0;
}



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

#define MAX 1000
int top, S[MAX];

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= MAX - 1;
}
  
void push(int x){
  if (isFull()) {
    printf("overflow\n");
    exit(1);
  }
  top++;
  S[top] = x;
}

int pop(){
  if(isEmpty()){
    printf("underflow");
    exit(1);
  }
  top--;
  return S[top+1];
}


int main(){
  int x,a,b;
  char s[100];
  top =0;
  
  while( scanf("%s", s) == 1 ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    } 
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2104
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class RollingHash(object):
    _base1, _base2 = 1007, 1009
    _mod1, _mod2 = 10**9 + 9, 10**9 + 7

    def __init__(self,s):
        self._n=len(s)
        H1, H2 = [0] * (self._n + 1), [0] * (self._n + 1)
        P1, P2 = [1] * (self._n + 1), [1] * (self._n + 1)
        for i in range(self._n):
            H1[i + 1] = (H1[i] * self._base1 + ord(s[i])) % self._mod1
            H2[i + 1] = (H2[i] * self._base2 + ord(s[i])) % self._mod2
            P1[i + 1] = P1[i] * self._base1 % self._mod1
            P2[i + 1] = P2[i] * self._base2 % self._mod2
        self._H1, self._H2 = H1, H2
        self._P1, self._P2 = P1, P2

    def __len__(self):
        return self._n

    def __getitem__(self,x):
        l, r = x.start, x.stop;
        return ((self._H1[r] - self._P1[r - l] * self._H1[l] % self._mod1) % self._mod1,
                (self._H2[r] - self._P2[r - l] * self._H2[l] % self._mod2) % self._mod2)

from collections import defaultdict
def resolve():
    n = int(input())
    X = [input() for _ in range(n)]
    X.sort(key = len, reverse = 1)

    count = defaultdict(lambda:[0] * 26)
    ans = 0

    for S in X:
        k = len(S)
        rh = RollingHash(S)
        ok = [False] * 26
        ans += count[rh[1 : k]][ord(S[0]) - ord('a')]
        for i, c in enumerate(S):
            ok[ord(c) - ord('a')] = True
            for j in range(26):
                if ok[j]:
                    count[rh[i + 1 : k]][j] += 1
    print(ans)
resolve()

Measured memory_bytes: 525080
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int max = X;
    int min = Y;
    for(int i = 0; i < N; i++){
      max = Math.max(max, sc.nextInt());
    }
    for(int i = 0; i < M; i++){
      min = Math.min(min, sc.nextInt());
    }
    System.out.println(max < min ? "No War" : "War");
  }
}


Measured memory_bytes: 23764
import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);

      	int sc = s.nextInt();

        int judge = 0;
        for (int i = 1; i < sc+1; i++) {
            if((String.valueOf( i ).length())%2 ==1){
                judge++;
            }
        }
        System.out.println(judge);

    }
}

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

#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define de cout << "debug" << endl;

int main() {
  int N,A;
  cin >> N >> A;
  int ans = 0;  
  
  
  
  cout << N-A+1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

canBePlanned = 'Yes'
xprev = 0
yprev = 0
tprev = 0
for i in range(N):
    xdiff = abs(x[i] - xprev)
    ydiff = abs(y[i] - yprev)
    tdiff = t[i] - tprev
    if (t[i] - (x[i] + y[i])) % 2 != 0 or (tdiff - (xdiff + ydiff)) % 2 != 0 or tdiff < xdiff + ydiff:
        canBePlanned = 'No'
        break
    xprev, yprev, tprev = x[i], y[i], t[i]

print(canBePlanned)


Measured memory_bytes: 11764
N,x = map(int, input().split())

if x == 1 or x == 2*N-1:
    print("No")
else:
    print("Yes")
    L = [0]*(2*N-1)
    flag = False
    if x > N:
        x = 2*N-x
        flag = True
    for i in range(N-1, 2*N-1):
        L[i] = x+i-N+1
    for i in range(N-2, N-x-1, -1):
        L[i] = x+i-N+1
    for i in range(N-x-1, -1, -1):
        L[i] = 2*N-1-i

    if flag:
        for i in range(2*N-1):
            L[i] = 2*N-L[i]
    for l in L:
        print(l)

Measured memory_bytes: 12480
import fractions
A,B,C,D = map(int,input().split())

lcm = (C*D) // fractions.gcd(C,D)
Bnondiv = B - (B//C + B//D - B//lcm)
Anondiv = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
print(int(Bnondiv-Anondiv))

Measured memory_bytes: 5048
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string S;
	ll k;
	cin>>S>>k;

	int pos=0;
	for(int i=0;i<S.size();i++) {
		if(S[i] != '1'){
			pos = i;
			break;
		}
	}

	if(pos < k) cout<< S[pos] <<endl;
	else cout<< 1 <<endl;

	return 0;
}

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

int visited[200001] ;
ll final[200001] ;

void dfs(vector<vector<int>> &adj, int source){

	visited[source]=1 ;

	for(auto x:adj[source])
		{		
				if(visited[x]==0){		
					final[x]+=final[source] ;
					visited[x]=1 ;
					dfs(adj,x) ;
			}
		}
	
}


void solve(){

	int v,q ;
	cin>>v>>q ;

	vector<vector<int>> adj(v+1) ; 

	rep(i,v-1){
		int x,y ;
		cin>>x>>y ;
		x-- ;
		y-- ;

		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}

	memset(final,0,sizeof(final)) ;
	memset(visited,0,sizeof(visited)) ;

	rep(i,q){
		int n,x ;
		cin>>n>>x ;
		n-- ;
		final[n]+=x ;

	}

	dfs(adj,0) ;

	rep(i,v){
		cout<<final[i]<<"\n" ;
	}
	
}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 29104
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 102;
	string a, b;
	
	cin >> a >> b;

	if (a.size() == b.size()) {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == b[i]) {
				continue;
			} else if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return (0);
			} else {
				cout << "LESS" << endl;
				return (0);
			}
		}
		cout << "EQUAL" << endl;
	} else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	} else {
		cout << "LESS" << endl;
	}

	return (0);
}

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

using namespace std;

#define ll long long

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

	vector < ll > B(N);
	for (int i = 0; i < N; i++) {
		B[i] = A[i] - (i + 1);
	}

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

	ll center = B[N / 2];

	ll ans = 0;

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

	cout << ans << endl;
}


Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &x)

	cnt := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500 * i + 100 * j + 50 * k == x {
					cnt += 1
				}
			}
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s1 = str(input().rstrip('\n'))
    s2 = str(input().rstrip('\n'))
    cur = 0
    cnt = 1
    f = True
    lv = True
    while cur < n:
        if s1[cur] == s2[cur]:
            #縦の場合
            if f:
                cnt = (cnt * 3) % mod
                f = False
            else:
                if lv:
                    cnt = (cnt * 2) % mod
                else:
                    cnt = (cnt * 1) % mod
            cur += 1
            lv = True
        elif s1[cur] == s1[cur+1] and s2[cur] == s2[cur+1]:
            #横の場合
            if f:
                cnt = (cnt * 6) % mod
                f = False
            else:
                if lv:
                    cnt = (cnt * 2) % mod
                else:
                    cnt = (cnt * 3) % mod
            cur += 2
            lv = False
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
S = input()

ans = 0
def dfs(i, s=''):
    global ans
    if i == len(S) - 1:
        ans += eval(s+S[-1])
        return
    dfs(i+1, s+S[i])
    dfs(i+1, s+S[i]+'+')
    
dfs(0)
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed 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];

    vector<P> p(n);
    REP(i, n)
    {
        p[i] = make_pair(b[i], a[i]);
    }
    sort(all(p));

    int cur = 0;
    REP(i, n)
    {
        if(cur+p[i].second > p[i].first)
        {
            cout << "No" << endl;
            return 0;
        }
        cur+=p[i].second;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6528
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        // read inputs
        Scanner in = new Scanner(System.in);
        long ai = in.nextInt(), ao = in.nextInt(), at = in.nextInt(), aj = in.nextInt(),
                al = in.nextInt(), as = in.nextInt(), az = in.nextInt();

        // solve
        long ans = 0;
        // use i, j and l blocks
        if (ai > 0 && aj > 0 && al > 0
                && Stream.of(ai, aj, al).filter(a -> a % 2 == 1).count() >= 2) {
            ans += 3;
            ai--;
            aj--;
            al--;
        }
        // use i blocks
        ans += (ai / 2) * 2;
        // use l blocks
        ans += (al / 2) * 2;
        // use j blocks
        ans += (aj / 2) * 2;
        // use o blocks
        ans += ao;
        System.out.printf("%d\n", ans);
    }
}


Measured memory_bytes: 28876
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]<b[i]:
    ans+=a[i]
    if a[i+1]>b[i]-a[i]:
      ans+=(b[i]-a[i])
      a[i+1]-=(b[i]-a[i])
    else:
      ans+=a[i+1]
      a[i+1]=0
  else:
    ans+=b[i]
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 25
#define NIL -1

struct node{
  int p,l,r;
};

node A[MAX];

int D[MAX],H[MAX];

void setDepth(int v,int d){
  if(v==NIL) return;
  D[v]=d;
  setDepth(A[v].l,d+1);
  setDepth(A[v].r,d+1);
}

int setHight(int v){
  int h1=0,h2=0;
  if(A[v].l!=NIL) h1=setHight(A[v].l)+1;
  if(A[v].r!=NIL) h2=setHight(A[v].r)+1;
  return H[v]=max(h1,h2);
}



int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    A[i].p=A[i].l=A[i].r=NIL;
  }
  int v,r,l,root;
  for(int i=0;i<n;i++){
    cin>>v>>l>>r;
    if(l!=NIL){
      A[v].l=l;
      A[l].p=v;
   }
   if(r!=NIL){
     A[v].r=r;
     A[r].p=v;
   }
  }
  for(int i=0;i<n;i++){
    if(A[i].p==NIL) root=i;
  }
  setDepth(root,0);
  setHight(root);
  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<A[i].p<<", sibling = ";
    if(A[i].p==NIL) cout<<"-1";
    else if(A[A[i].p].l!=i) cout<<A[A[i].p].l;
    else cout<<A[A[i].p].r;
    cout<<", degree = ";
    if(A[i].l==NIL && A[i].r==NIL) cout<<"0, ";
    else if(A[i].l!=NIL && A[i].r!=NIL) cout<<"2, ";
    else cout<<"1, ";
    cout<<"depth = "<<D[i]<<", height = "<<H[i]<<", ";
    if(D[i]==0) cout<<"root";
    else if(A[i].l==NIL && A[i].r==NIL) cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;
  }
}



Measured memory_bytes: 3108
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const ll inf = 10e17;
const ll mod = 1000000007;
const ld eps = 10e-9;


ll solve(void);

ll mulmod(ll x, ll y, ll m = mod)
{
	return (x * y) % m;
}

ll power(ll n, ll r, ll m = mod)
{
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == 0) { return 0; }
	if (n == 1) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r / 2, m);
		return mulmod(y, y, m);
	}
	else
	{
		ll y = power(n, (r - 1) / 2, m);
		return n * mulmod(y, y, m) % m;
	}
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);

	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i - 1], i);
	}

	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

bool isBitSet(const ll target, const ll digit)
{
	ll p = power(2, digit, INT64_MAX);
	return (p & target) != 0;
}

ll solve(void)
{
	ll n;
	const ll m = 61;
	cin >> n;
	vll A(n);
	vector<vll> v(m, vll(2, 0));

	for (auto &a : A)
	{
		cin >> a;
		for (ll i = 0; i < m; i++)
		{
			bool b = isBitSet(a, i);
			v[i][b] ++;
		}
	}

	ll ans = 0;
	for (ll i = 0; i < m; i++)
	{
		ll d = mulmod(v[i][0], v[i][1]);
		ll p = mulmod(d, power(2, i));
		//cout << i << " " << v[i][0] << " " << v[i][1] << " "  << p << endl;
		ans = (ans + p) % mod;
	}

	cout << ans << endl;

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define maxN	100001
#define nl		"\n"
using namespace std;
using ll = long long;
struct cmp{
	bool operator()(const pair<int,int>& lhs, const pair<int,int>& rhs){
		return lhs.first < rhs.first;
	}
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	priority_queue<pair<int,int>, vector<pair<int, int>>, cmp> pq;
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int k = x + y;
	vector<int> r(a), g(b), u(c);
	for(int&t: r) cin >> t;
	for(int&t: g) cin >> t;
	for(int&t: u) cin >> t;
	for(int&t: r) pq.push(make_pair(t, 1));
	for(int&t: g) pq.push(make_pair(t, 2));
	for(int&t: u) pq.push(make_pair(t, 3));
	ll ans = 0LL;
	vector<int> process;
	while(k){
		auto z = pq.top();
		pq.pop();
		if(z.second == 2 && y) ans += z.first, --y, --k;
		else if(z.second == 1 && x) ans += z.first, --x, --k;
		else if(z.second == 3)
			process.push_back(z.first), --k;
	}
	for(int z: process) ans += z;
	cout << ans << nl;
	return 0;
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

map<int,int> mp;
int n;
int f(int i) {
  i %= n;
  if (mp.count(i)) return mp[i];
  cout<<i<<endl;
  string res;
  cin>>res;
  if (res[0] == 'V') exit(0);
  return mp[i] = (res[0] == 'M');
}

int g(int i, int j) { return (j-i+n)%n;}

int main() {
  scanf("%d",&n);
  int l = 0, r = n/2;
  int a = f(l);
  int b = f(r);
  if ((a^b) == g(l,r)%2) {
    swap(l,r); r += n;
  }
  while (1) {
    int c = (l+r)>>1;
    if ((f(l)^f(c)) == g(l,c)%2) l = c;
    else r = c;
  }
  return 0;
}






















Measured memory_bytes: 852
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    s = S()
    if s[:4] == 'YAKI':
        return 'Yes'

    return 'No'


print(main())




Measured memory_bytes: 5708
n,m = map(int,input().split())
t = []
res = 0
for i in range(n):
    a,b = map(int,input().split())
    t.append((a,b))
t = sorted(t)
for i in range(n):
    if m > t[i][1]:
        res += t[i][0]*t[i][1]
        m -= t[i][1]
    else:
        res += t[i][0]*m
        break
print(res)

Measured memory_bytes: 17788
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> a(n);
		string ans = "";
		rep(i, 0, n)cin >> a[i];
		rep(i, 0, n) {
			int cnt = 0;
			rep(j, i, n - 1) {
				if (a[j] + 1 == a[j + 1])cnt++;
				else break;
			}
			if (cnt >= 1) {
				ans += to_string(a[i]) + "-" + to_string(a[i + cnt]) + " ";
			}
			else {
				rep(j, i, i + cnt + 1) {
					ans += to_string(a[j]) + " ";
				}
			}
			i += cnt;
		}
		cout << ans.substr(0, ans.size() - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
  
if a > b:
    tmp = a
    a = b
    b = tmp
if b > c:
    tmp = b
    b = c
    c = tmp
if a > b:
    tmp = a
    a = b
    b = tmp
  
print(a, b, c)

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

signed main() {
	int m, d;
	cin >> m >> d;
	
	if(d >= m) cout<< m << endl;
	else cout << m-1 << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_K 100000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

llong K, A[MAX_K];

ipair solve() {
    ipair res = make_pair(2, 2);
    for(int i = K - 1; i >= 0; --i) {
        llong x_1 = (res.first + A[i] - 1) / A[i] * A[i];
        llong x_k = res.second / A[i] * A[i];

        if(x_1 > x_k)
            return make_pair(-1, -1);
        else
            res = make_pair(x_1, x_k + A[i] - 1);
    }
    return res;
}

int main(int argc, char **argv) {
    cin >> K;
    for(int i = 0; i < K; ++i)
        cin >> A[i];
    
    ipair res = solve();
    if(res.first != -1)
        cout << res.first << " " << res.second << endl;
    else
        cout << "-1" << endl;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = (1LL << 50);

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

vector<pint> list;









ll housou[31][100005];
ll kasanari[100005];


int main() {
	ll N, C;
	ll s, t, c;
	cin >> N >> C;

	
	rep(i, N) {
		cin >> s >> t >> c;
		for (int j = s; j <= t; j++) {
			if(housou[c][j] != 1)
			  housou[c][j] += 1;
		}

	}

	ll ans = 0;
	rep(i, 100005) {
		rep(j, C) {
			kasanari[i] += housou[j + 1][i];
		}

		ans = max(kasanari[i], ans);
    }
	

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 24448