akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		
		int h = x / 3600;
		x %= 3600;
		int m = x / 60;
		int s = x % 60;
		
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   ll n,ans;
   cin>>n;
   ans=lcm(n,2);
   cout<<ans;
   

   
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        String[] words = {"dream", "dreamer", "erase", "eraser"};

        for (int i = 0; i < 4; i++) {
            words[i] = reverseString(words[i]);
        }

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String S = null;
        try {
            S = bufferedReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        S = reverseString(S);

        String answer = "YES";
        boolean isMatch;
        for (int i = 0; i < S.length();) {
            isMatch = false;
            for (String word : words) {
                if (isStartWith(i, S, word)) {
                    isMatch = true;
                    //S =  S.substring(word.length());
                    i += word.length();
                    break;
                }
            }
            if (!isMatch) {
                answer = "NO";
                break;
            }
        }
        System.out.format(answer);
    }

    private static boolean isStartWith(int index, String s, String word) {
        if (s.length() < word.length()) {
            return false;
        }
        boolean reslut = false;
        try {
            reslut = s.substring(index, index + word.length()).equals(word);
        } catch (Exception e) {
            return false;
        }
        return reslut;
    }

    private static String reverseString(String input) {
        StringBuilder builder = new StringBuilder();
        builder.append(input);
        return builder.reverse().toString();
    }
}

Measured memory_bytes: 27348
H, N = map(int, input().split())
AB = []
ma = -1
for _ in range(N):
    a, b = map(int, input().split())
    ma = max(ma, a)
    AB.append([a, b])


inf = float('inf')
dp = [inf] * (H + ma + 1)
dp[0] = 0

for h in range(H + 1):
    for a, b in AB:
        dp[h + a] = min(dp[h + a], dp[h] + b)

# print(dp)

ans = inf
for i in range(H, H + ma + 1):
    ans = min(dp[i], ans)

print(ans)


Measured memory_bytes: 43584
#!python3.4
# -*- coding: utf-8 -*-
# abc158/abc158_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = set(i2s())
    if len(S) == 1:
        print('No')
    else:
        print('Yes')
    return

main()


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long T = in.nextLong();
			long[] t = in.nextLongArray(n);

			long ans = 0;
			for (int i = 0; i < n-1; i++) {
				if (t[i+1] <=  t[i] + T) {
					ans += t[i+1] - t[i];
				} else {
					ans += T;
				}
			}
			ans += T;

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

const long long MODULO = 1e9 + 7LL;

int main() {
	int m, n; cin >> m >> n;
	if (m < n) swap(m, n);
	if (m > n + 1) {
		cout << 0 << endl;
		return 0;
	}
	long long res = 1LL;
	if (m == n + 1) {
		for (int i = 1; i <= n; ++i) {
			res *= i;
			res %= MODULO;
			res *= (i + 1);
			res %= MODULO;
		}
		cout << res << endl;
	} else {
		res = 2LL;
		for (int i = 2; i <= n; ++i) {
			res *= i;
			res %= MODULO;
			res *= i;
			res %= MODULO;
		}
		cout << res << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    string s;
    void solve(){
        cin >> s;
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 <<"\n";
        }else if((int)s.size()<26){
            vector<int> cnt(26);
            for(int i=0; i<(int)s.size(); ++i){
                cnt[s[i]-'a']++;
            }
            int ok = -1;
            for(int i=0; i<26; ++i){
                if(cnt[i]==0){
                    ok =i;
                    break;
                }
            }
            s+='a'+ok;
            cout << s <<"\n";
        }else{
            int p = s.size()-2;
            for(;p>=0;--p){
                if(s[p]<s[p+1])break;
            }
            DBG(p)
            vector<int> cnt(26);
            for(int i=0; i<p; ++i){
                cnt[s[i]-'a']++;
            }
            string ans="";
            for(; p>=0; --p){
                int ok = -1;
                for(int i=s[p]-'a'+1; i<26; ++i){
                    if(cnt[i]==0){
                        ok =i;
                        break;
                    }
                }
                if(ok>-1){
                    ans = s;
                    ans[p] = 'a'+ok;
                    DBG(ans)
                    ans = ans.substr(0,p+1);
                    break;
                }
            }
            cout << ans <<"\n";

        }
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    Problem::Solver sol;
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC40(void);
void ABC41(void);
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);
void ABC49(void);

int main(void){
    ABC42();
}

void ABC42(){
    int n,l,i;
    cin>>n>>l;
    vector<string> s(n);
    for(i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    for(i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
a=input()
def check(n):
	if n[0]==n[1]:
		if n[1]==n[2]:
			return "Yes"
		else:
			return "No"
	else:
		if n[1]==n[2]:
			if n[2]==n[3]:
				return "Yes"
			else:
				return "No"
		else:
			return "No"
print(check(a))

Measured memory_bytes: 3060
X, Y, A, B, C = map(int, input().split())
 
p = sorted(list(map(int,input().split())), reverse=True)[:X]
q = sorted(list(map(int,input().split())), reverse=True)[:Y]
r = sorted(list(map(int,input().split())), reverse=True)
 
colored_p = []
colored_q = []
 
for i in r:
    p_min = p[len(p) - 1] if len(p) > 0 else colored_p[len(colored_p) - 1]
    q_min = q[len(q) - 1] if len(q) > 0 else colored_q[len(colored_q) - 1]
 
    if p_min > i and q_min > i:
        break
 
    p_min_diff = i - p_min
    q_min_diff = i - q_min
 
    if p_min_diff >= q_min_diff and p_min_diff > 0:
        if len(p) > 0:
            p.pop()
        colored_p.append(i)
    elif q_min_diff >= p_min_diff and q_min_diff > 0:
        if len(q) > 0:
            q.pop()
        colored_q.append(i)
 
print(sum(p) + sum(q) + sum(colored_p) + sum(colored_q))

Measured memory_bytes: 22452
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALLA(arr, sz) arr, arr + sz
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<vi> vvi;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";

vi graph[100005];
vector<bool> visited(100005);
vi deg(100005); //deg[v]= no of edges going into node v. 
vi dist(1000005);

void dfs(int v) {
    visited[v] = true;
    for (int a : graph[v]) {
        dist[a] = max(dist[a], dist[v] + 1);
        deg[a]--;
        if(deg[a]==0)
            dfs(a);
    }
}

int main()
{
    IOS;
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--){
        int x,y;
        scanf("%d%d", &x, &y);
        graph[x].pb(y);
        deg[y]++;
    }
    for (int a = 1; a <=n; a++) {
        if (!visited[a] && deg[a] == 0)
            dfs(a);
    }
    int res = 0;
    for (int a = 1; a <= n; a++)
        res = max(res, dist[a]);
    printf("%d", res);
}


Measured memory_bytes: 17516
"""
NTC here
"""
 

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def iin(): return int(input())
 
 
def lin(): return list(map(int, input().split()))

def main():
    T = 1
    while T:
        T-=1
        n = iin()
        a = lin()
        ans = [0]*(n)
        for i in a:
            ans[i-1]+=1
        print(*ans, sep='\n')

        
        








# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 94836
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
int dp[100005][104], arr[110];
int n, k;
//int DP(int rem, int pos)
//{
//    cout<<rem<<" "<<pos<<endl;
//    if(rem==0)
//        return 1;
//    if(rem<0) return -1;
//    if(dp[rem][pos])
//        return dp[rem][pos];
//    for(int i=0; i<n; i++)
//    {
//       // cout<<"X";
//        if(DP(rem-arr[pos], i)==-1)
//        {
//            return dp[rem][pos]=1;
//        }
//    }
//    return dp[rem][pos]=-1;
//}
int main()
{
    for(int i=0; i<=105; i++)
        dp[0][i]=1;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        scanf("%d", &arr[i]);
//    cout<<DP(5, 0)<<endl;
//    cout<<DP(5, 1)<<endl;
    for(int i=1; i<=k; i++)
    {

        for(int j=1; j<=n; j++)
        {
            if(i-arr[j]<0)
                dp[i][j]=1;
            else
            {
                int tt=-1;
                for(int kk=1; kk<=n; kk++)
                {
                    if(dp[i-arr[j]][kk]==-1)
                    {
                        tt=1;
                        break;
                    }
                }
                dp[i][j]=tt;
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(dp[k][i]==-1)
        {
            printf("First\n");
            return 0;
        }
    }
    printf("Second\n");
    return 0;
}


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

using namespace std;

const int MAXN=1e5+4;

int main()
{
    int n, a[MAXN], ss[MAXN], cgcd, sol=1;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    cgcd = a[0];
    ss[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--) ss[i] = __gcd(ss[i+1], a[i]);
    sol = ss[1];
    for(int i=1;i<n-1;i++){
        sol = max(sol, __gcd(cgcd, ss[i+1]));
        cgcd = __gcd(cgcd, a[i]);
    }
    sol = max(sol, cgcd);
    cout << sol;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#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 show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
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;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vp student(N);
  vp check(M);
  rep(i,N) {
    int x,y;
    cin >> x >> y;
    student[i] = P(x,y);
  }
  rep(i,M) {
    int x,y;
    cin >> x >> y;
    check[i] = P(x,y);
  }
  rep(i,N) {
    int minD = INF;
    int point = -1;
    rep(j,M) {
      int dis = abs(check[j].first-student[i].first)+ abs(check[j].second-student[i].second);
      if(minD > dis) {
        minD = dis;
        point = j+1;
      }
    }
    cout << point << endl;
  }
  return 0;
}

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

const int N = 1e4 + 5;
vector<int> adj[N];
bool vis[N];
int ans[N] = {0};
int c[N];
int cur = 0;
void dfs(int n)
{
	vis[n] = true;
	ans[n] = c[cur];
	//~ cout << ans[n] << " ";
	++cur;
	for(int x:adj[n])
	{
		if(!vis[x])
		dfs(x);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n-1;++i)
	{
		int a,b;
		cin >> a >> b;
		--a, --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int sum = 0;
	for(int i=0;i<n;++i) 
	{cin >> c[i];
		sum += c[i];
	}
	sort(c,c+n,greater<int>());
	//~ for(int i=0;i<n;++i) cout << c[i] << " ";
	//~ cout << "\n";

	//~ for(int i=0;i<n;++i)
	//~ cout << ans[i] << " ";
	//~ cout << "\n";
	for(int i=0;i<n;++i)
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
	cout << (sum - c[0]) << "\n";
	for(int i=0;i<n;++i)
	cout << ans[i] << " ";
	cout << "\n";
}


Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      long X = sc.nextLong();
      
      // 5乗テーブルの作成
      long[] fiveExp = new long[1000];
      for(int i = 0; i < 1000; i++){
        fiveExp[i] = 1L;
        for(int j = 0; j < 5; j++){
          fiveExp[i] = fiveExp[i] * i;
        }
      }
      
      // A,Bの探索
      int A = 0;
      int B = 0;
      
      LOOP : for(int i = 0; i < 1000; i++){
        for(int j = 0; j < 1000; j++){
          long work = X - fiveExp[j];
          if(work == fiveExp[i]){
            A = i;
            B = j * (-1);
            break LOOP;
          }
          
          work = X + fiveExp[j];
          if(work == fiveExp[i]){
            A = i;
            B = j;
            break LOOP;
          }
        }
      }
      
      
      // 出力
      System.out.println(A + " " + B);
    }

}

Measured memory_bytes: 38804
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define Icin(s) ll (s);cin>>(s);
#define Scin(s) ll (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
//ここから
struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};
//BipartiteMatching(n)　頂点n個
//add_edge(s,t)
//bipartite_matching()最大マッチング数

int main(){
    ll x,y,e;cin>>x>>y>>e;
    BipartiteMatching g(x+y);
    rep(i,e){
        ll X,Y;cin>>X>>Y;
        g.add_edge(X,x+Y);
    }
    cout<<g.bipartite_matching()<<endl;
}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define maxn 5005
using namespace std;
ll dp[maxn];
ll a[maxn];
int n;
ll k;
ll sum;

int main()
{
    scanf("%d%lld",&n,&k);
    sum=0;
    for(int i=1;i<=n;i++)
        {scanf("%lld",&a[i]);
        a[i]=min(a[i],k);
        sum+=a[i];
        }
        sort(a+1,a+n+1);
        dp[0]=1;

        for(int i=n,flag=0;i>=0;sum-=a[i--],flag=0)
        {

                for(int j=k-1;j>=k-sum&&j>=0;j--)
                    if(dp[j])
                    flag=1;

            if(!flag)
            {
                printf("%d\n",i);
                return 0;
            }
            for(int j=k;j>=a[i];j--)
                dp[j]|=dp[j-a[i]];

        }
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = 3;
        int[][] t = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                t[i][j] = sc.nextInt();
            }
        }
        
        for (int i = 0; i < n - 1; i++) {
            int dif0 = t[i][0] - t[i + 1][0];
            for (int j = 1; j < n; j++) {
                int difj = t[i][j] - t[i + 1][j];
                if (dif0 != difj) {
                    System.out.println("No");
                    return;
                }
            }
        }
        
        for (int j = 0; j < n - 1; j++) {
            int dif0 = t[0][j] - t[0][j + 1];
            for (int i = 1; i < n; i++) {
                int difi = t[i][j] - t[i][j + 1];
                if (dif0 != difi) {
                    System.out.println("No");
                    return;
                }
            }
        }
        
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    n--;
    int b[n],a[n+1],sum=0;
    for(int i=0;i<n;i++)cin>>b[i];
    fill(a,a+(n+1),INT_MAX);
    for(int i=0;i<n;i++)
    {
        if(b[i]<a[i])
            a[i]=b[i];
        a[i+1]=b[i];
    }
    for(int i=0;i<n+1;i++)sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T> using v=vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define pb push_back
#define sz(a) ((int)(a).size())
const long long inf=4611686018427387903;//2^62-1
#if 0 //FileIO
ifstream fin ("input.txt" );
ofstream fout("output.txt");
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read(){}             template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get   (arg)     ;read(args...) ;}
void print(){}            template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put   (arg)<<" ";print(args...);}
void debug(){cerr<<endl;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){cerr<<(arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
void run(){int ans=0;
    int n;get n;str s;get s;
    int w1=0,e2=0;for(char i:s)if(i=='E')e2++;
    ans=inf;
    rep(i,0,n){
        if(s[i]=='E')e2--;
        ans=min(ans,e2+w1);
        if(s[i]=='W')w1++;
    }put ans;eol;
}
int32_t main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 720
#include <iostream>

using namespace std;
int main(void){
	int w, h, n;
	cin >> w >> h >> n;
	int grid[100][100] = { 0 };
	while(n--){
		int x, y, a;
		cin >> x >> y >> a;
		for(int j=0; j<h; j++){
			for(int i=0; i<w; i++){
				switch(a){
					case 1:
						grid[j][i] = i<x || grid[j][i];
						break;
					case 2:
						grid[j][i] = i>=x || grid[j][i];
						break;
					case 3:
						grid[j][i] = j<y || grid[j][i];
						break;
					case 4:
						grid[j][i] = j>=y || grid[j][i];
						break;
				}
			}
		}
	}
	int sum = 0;
	for(int j=h-1; j>=0; j--){
		for(int i=0; i<w; i++){
			sum += !grid[j][i];
		}
	}
	cout << sum << endl;
}

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

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

  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;

  string S;

  for (int i = 0; i < N; i++)
  {
    cin >> S;

    if (S == "AC")
      AC++;
    else if (S == "WA")
      WA++;
    else if (S == "TLE")
      TLE++;
    else
      RE++;
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}


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

int main() {
    string s;
    int K;
    vector<string> subs;

    cin >> s >> K;

    for (int i=0; i<s.size(); i++) {
        for (int j=1; j<=K; j++) {
            subs.push_back(s.substr(i, j));
        }
    }

    sort(subs.begin(), subs.end());
    subs.erase(unique(subs.begin(), subs.end()), subs.end());

    cout << subs[K-1] << endl;

}


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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int main() {
    int n = read(), m = read();
    printf("%d", (n * (n - 1) + m * (m - 1)) >> 1);
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

string s, t;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s >> t;
    int res = 0;
    FOR(i,0,SZ(s)-1) res += s[i] != t[i];
    cout << res;
    return 0;
}


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

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

int main() {
  /////////// INPUT ///////////
  int N, M, R; cin >> N >> M >> R;
  vector<int> r(R);
  REP(i, R) {
    cin >> r[i];
    r[i]--;  // 0-based index
  }
  // dist[i][j]: Distance from i-th node to j-th.
  vector<vector<int>> dist(N, vector<int>(N, 1000000000));
  REP(i, M) {
    int A, B, C; cin >> A >> B >> C;
    A--; B--;  // 0-based index
    dist[A][B] = dist[B][A] = C;
  }
  
  /////////// SOLVE ///////////
  // Compute minimum distances for all pairs of towns.
  REP(k, N) REP(i, N) REP(j, N)
    dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);

  // Compute total distance for all possible visiting order.
  int answer = 1000000000;
  sort(r.begin(), r.end());  // r must be sorted array to start next_permutation.
  do {
    int total_distance = 0;
    REP(i, R-1)
      total_distance += dist[r[i]][r[i+1]];
    answer = min(answer, total_distance);
  } while (next_permutation(r.begin(), r.end()));

  /////////// OUTPUT ///////////
  cout << answer << endl;
}


Measured memory_bytes: 384
def cc048
    n,x = gets.chomp.split(/\s/).map{|x| x.to_i}
    an = gets.chomp.split(/\s/).map{|x| x.to_i}

    s = 0
    for i in 1..n
        if x == 0
            s += an[i-1]
            next
        end

        if i == n
            break
        end

        d = an[i-1] + an[i]
        if d > x
            e = d - x
            s += e
            an[i] -= (an[i] >= e) ? e : an[i]
        end
    end

    puts s
end

cc048

Measured memory_bytes: 10780
abcd = list(input())
op = ['+', '-']

for op1 in op:
    for op2 in op:
        for op3 in op:
            formula = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
            if eval(formula) == 7:
                print(formula + '=7')
                exit()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c-b == b-a ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  string s,t; cin>>s>>t;
  int ans = 2*n;
  rep(i,n){
    rep(j,n-i){
      if(s[i+j]!=t[j]) break;
      if(j==n-i-1){
        ans = min(ans,n+i);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
P = [int(x) for x in input().split(' ')]

ans = 0
for i in range(1, n-1):
  if P[i-1] < P[i] < P[i+1] or P[i+1] < P[i] < P[i-1]:
    ans = ans + 1
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n,k;
    cin>>n>>k;
    int r,s,p;
    map<char,int> mp;
    cin>>r>>s>>p;
    mp['r']=p;
    mp['s']=r;
    mp['p']=s;
    string t;
    cin>>t;

    int ans=0;
    for(int i=0;i<k;i++){
        int now=i;
        while(now<n){
            if(now<k){
                ans+=mp[t[now]];
                now+=k;
            }else{
                if(t[now]!=t[now-k]){
                    ans+=mp[t[now]];
                }else{
                    t[now]='!';
                }
                now+=k;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
long long n,m,K;
int main(){
  cin >> n >> m >> K;
  long long l[m],r[m],p[K],q[K],imos[n][n+1]={},ans=0;
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i];
    imos[l[i]-1][l[i]-1]++;
    imos[l[i]-1][r[i]]--;
  }
  for(int i=0;i<n;i++){
    for(int j=1;j<=n;j++){
      imos[i][j]+=imos[i][j-1];
    }
  }
  for(int i=0;i<K;i++){
    cin >> p[i] >> q[i];
    ans=0;
    for(int j=p[i]-1;j<q[i];j++){
      if(imos[j][j]==0){
        continue;
      }
      ans+=imos[j][j]-imos[j][q[i]];
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<int> x, y;
    vector<int> x1(n), y1(n), x2(n), y2(n);
    for (size_t i=0; i<n; ++i) {
        scanf("%d %d %d %d", &x1[i], &y1[i], &x2[i], &y2[i]);
        x.push_back(x1[i]);
        x.push_back(x2[i]);
        y.push_back(y1[i]);
        y.push_back(y2[i]);
    }

    sort(x.begin(), x.end());
    size_t xl=unique(x.begin(), x.end())-x.begin();
    vector<size_t> xi1(n), xi2(n);
    for (size_t i=0; i<n; ++i) {
        xi1[i] = lower_bound(x.begin(), x.begin()+xl, x1[i])-x.begin();
        xi2[i] = lower_bound(x.begin(), x.begin()+xl, x2[i])-x.begin();
    }

    sort(y.begin(), y.end());
    size_t yl=unique(y.begin(), y.end())-y.begin();
    vector<size_t> yi1(n), yi2(n);
    for (size_t i=0; i<n; ++i) {
        yi1[i] = lower_bound(y.begin(), y.begin()+yl, y1[i])-y.begin();
        yi2[i] = lower_bound(y.begin(), y.begin()+yl, y2[i])-y.begin();
    }

    vector<vector<int>> imos(yl+1, vector<int>(xl+1));
    for (size_t i=0; i<n; ++i) {
        ++imos[yi1[i]][xi1[i]];
        --imos[yi1[i]][xi2[i]];
        --imos[yi2[i]][xi1[i]];
        ++imos[yi2[i]][xi2[i]];
    }

    long long res=0;
    vector<vector<int>> sum(yl+1, vector<int>(xl+1));
    for (size_t i=0; i<yl; ++i)
        for (size_t j=0; j<xl; ++j) {
            sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + imos[i][j];
            if (sum[i+1][j+1] > 0)
                res += 1LL * (x[j+1]-x[j]) * (y[i+1]-y[i]);
        }

    printf("%lld\n", res);
    return 0;
}

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

const ll N = 1e6 + 10;
const ll mod = 1e9 + 7;

map<int, int> tot;

int mi_p[N];

ll binpow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

ll inv(ll x) {
	return binpow(x, mod - 2);
}

void init() {
	for (int i = 2; i < N; i++) {
		if (mi_p[i]) continue;
		for (int j = i; j < N; j += i)
			mi_p[j] = i;
	}
}

void update_tot(ll x) {
	while (x != 1) {
		int p = mi_p[x];
		int cnt = 0;
		while (x % p == 0) x /= p, ++cnt;
		tot[p] = max(tot[p], cnt);
	}
}

int main() {
	init();
	int n; cin >> n;
	int a[n] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		update_tot(a[i]);	
	}
	ll L = 1;
	for (auto pr : tot) {
		L = L * binpow(pr.first, pr.second) % mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += L * inv(a[i]) % mod, ans %= mod;
	}
	cout << ans << "\n";
}

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

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

    vector<int> R;
    vector<int> G;
    vector<int> B;
    R.reserve(S.size());
    G.reserve(S.size());
    B.reserve(S.size());

    for (int i = 0; i < S.size(); ++i) {
        if ('R' == S[i]) {
            R.push_back(i);
        } else if ('G' == S[i]) {
            G.push_back(i);
        } else if ('B' == S[i]) {
            B.push_back(i);
        }
    }

    int64_t ans = R.size() * G.size() * B.size();

    for (int i = 0; i < S.size() - 1; ++i) {
        for (int j = i + 1; j < S.size(); ++j) {
            if (S[i] != S[j]) {
                int k = j + j - i;
                if (k < S.size() && S[k] != S[i] && S[k] != S[j]) {
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    ll x, y, a, b, c;   cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    vector<P> apple;
    for(int i = 0; i < a; i++){
        cin >> p[i];
    }
    p.push_back(0);
    for(int i = 0; i < b; i++){
        cin >> q[i];
    }
    q.push_back(0);
    for(int i = 0; i < c; i++){
        cin >> r[i];
    }
    r.push_back(0);

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());

    ll num = 0;
    ll pSum = 0, qSum = 0, rSum = 0;
    for(int i = 0; i < x; i++){
        pSum += p[i];
        num++;
    }
    ll qNext = 0, rNext = 0;
    ll greenNum = 0;
    while(num < x + y){
        if(q[qNext] < r[rNext]){
            rSum += r[rNext++];
            greenNum++;
        }
        else{
            qSum += q[qNext++];
        }
        num++;
    }
    ll res = pSum + qSum + rSum;

    ll aLast = x-1;
    while(aLast >= 0){
        if(greenNum == 0 && rNext == c){
            break;
        }
        pSum -= p[aLast--];
        if(q[qNext] < r[rNext] || greenNum == 0){
            rSum += r[rNext++];
        }
        else{
            greenNum--;
            qSum += q[qNext++];
        }
        res = max(res, pSum + qSum + rSum);
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3424
// ===== 2018/06/16 21:13:17 =====

// ../../../lib/template/includes.hpp

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// ../../../lib/template/const_value.hpp

namespace sub {
  template <typename T>
  constexpr typename std::enable_if<std::is_integral<T>::value, T>::type
  inf_sub() {
    return std::numeric_limits<T>::max() / 2 - 1000;
  }

  template <typename T>
  constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type
  inf_sub() {
    return std::min(std::numeric_limits<T>::max() / 2 - 1000, T(1e50));
  }
}

template <typename T> constexpr T inf() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return sub::inf_sub<T>();
}

template <typename T> constexpr T zero() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return T(0);
}

const long double pi = acos(-1.0);

// ../../../lib/template/initialize.cpp

struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

struct Initialize {
  Initialize() {
    std::locale loc(std::locale(), new yes_no);
    std::cout << std::boolalpha << std::setprecision(11) << std::fixed;
    std::cout.imbue(loc);
  }
};

const Initialize init;

// ../../../lib/template/macros.hpp

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

// ../../../lib/template/misc.hpp

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }

template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// ../../../lib/template/range.hpp

class range {
  class index_type {
    int x;

  public:
    index_type(int x_) : x(x_) {}
    int operator*() const { return x; }
    bool operator!=(index_type &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  index_type i, n;

public:
  range(int n_) : i(0), n(n_) {}
  range(int i_, int n_) : i(i_), n(n_) {}
  index_type &begin() { return i; }
  index_type &end() { return n; }
};

// ../../../lib/template/typedef.hpp

using ll = long long;
using ld = long double;
using Point = std::complex<ld>;

// ../../../lib/template/template.cpp

using namespace std;

// B.cpp

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

ll cnt(ll n) {
  if (n % 100) return 0;
  else return cnt(n / 100) + 1;
}
void solve(ll D, ll N) {
  for (ll i = 1;; ++i) {
    if (cnt(i) == D) --N;
    if (N == 0) { cout << i << endl; return; }
  }
}

int main() {
	ll N;
	ll D;
	scanf("%lld", &D);
	scanf("%lld", &N);
	solve(D, N);
	return 0;
}
// ===== 2018/06/16 21:13:17 =====



Measured memory_bytes: 256
import itertools
l=[int(input()) for _ in range(5)]
l=list(itertools.permutations(l))
ans=[0]*120
for i in range(120):
  for k in range(4):
    ans[i]=ans[i]+((-1)*l[i][k]//10)*(-10)
  ans[i]+=l[i][4]
print(min(ans))
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;

int main(){
    cin >> n;
    ll ans = 0;
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=1; i<n; i++){
        ans+=max(0LL,a[i-1]-a[i]);
        a[i]=max(a[i],a[i-1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5140
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


int n, k;
int h[110000];
ll dp[110000];

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

    for(int i = 0; i < 110000; i++){
        dp[i] = inf;
    }


    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1656