akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >>b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 1000000007  # type: int


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N = int(input())
    P = list(map(int, input().split()))

    # 確定している道でグルーピングする
    uf = UnionFind(N)
    K = 0
    undef = []                  # 要請未完ノードは記録
    for i, p in enumerate(P):
        if p != -1:
            uf.union(i, p-1)
        else:
            K += 1
            undef.append(i)

    # 階乗の事前計算
    factorial = [1]*K
    for i in range(K-1):
        factorial[i+1] = ((i+1)*factorial[i]) % MOD

    # 要請が未完のノードが属するグループサイズをメモ
    size_undef = []
    for u in undef:
        size_undef.append(uf.size(u))

    # dp[i, j]: i個の根付き木を見てj個を選んだ時の\sum{\prod_v S_v}
    # 「メモリ削減したdpとN^2確保するDP、どっちが早いんやろなあ」
    dp = [0]*(K+1)
    dp[0] = 1
    dp_new = dp[:]
    for i in range(1, K+1):
        for j in range(i):
            dp_new[j+1] += dp[j]*size_undef[i-1]
        dp = dp_new[:]

    # ただしj=1個を選んだ時のものは特別にsize[i]-1を考える必要がある
    if K >= 1:
        tot = 0
        for s in size_undef:
            tot += s-1
        dp[1] = tot

    # cycleをカウントする
    cycle_count = 0
    for i in range(1, K+1):
        # i個のグループからなるサイクルがひとつできる
        buf = dp[i]*factorial[i-1]
        buf %= MOD
        buf *= pow(N-1, K-i, MOD)
        buf %= MOD
        cycle_count += buf

    # すでに固定サイクルがあれば数える
    cycle_count += (uf.group_count()-K)*pow(N-1, K, MOD)

    # 求めます
    ans = N*pow(N-1, K, MOD) - cycle_count
    ans %= MOD

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 185056
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
//  cin>>t;
  int tt=1;
  while(t--){
    int n,a,b;
    cin>>n>>a>>b;
    a*=n;
    cout<<min(a,b);
      
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
  return 0;
}



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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long n, long long m, long long K) {
        long long N = n * m;
        init(N + 123);

        long long P = nCr(N - 2, K - 2);
        long long res = 0;
        for (int i = 1; i <= n - 1; ++i) {
            res += i * ((n - i) * 1LL * m % MOD * m % MOD) % MOD;
            res %= MOD;
        }

        for (int i = 1; i <= m - 1; ++i) {
            res += i * ((m - i) * 1LL * n % MOD * n % MOD) % MOD;
            res %= MOD;
        }
        (res *= P) %= MOD;

        return res;
    }

private:
    const static long long MOD = 1000000007;

    vector<long long> pow2;
    vector<long long> F;
    vector<long long> IF;

    long long norm(long long a) {
        a %= MOD;
        if (a < 0) {
            a += MOD;
        }
        return a;
    }

    long long inverse(long long a) {
        long long b = MOD;
        long long u = 0, v = 1;
        a = norm(a);
        while (a != 0) {
            long long d = b / a;
            b -= d * a;
            u -= d * v;
            swap(a, b);
            swap(u, v);
        }
        return norm(u);
    }

    long long powM(long long x, long long e) {
        long long res = 1;
        while (e > 0) {
            if (e & 1) {
                res = res * x % MOD;
            }
            x = x * x % MOD;
            e >>= 1;
        }
        return res;
    }

    void init(int n) {
        F.clear();
        F.resize(n + 1, 1);
        IF = F;
        pow2.clear();
        pow2.resize(n + 1, 1);
        for (int i = 1; i <= n; ++i) {
            pow2[i] = pow2[i - 1] * 2 % MOD;
        }

        for (int i = 1; i <= n; ++i) {
            F[i] = F[i - 1] * i % MOD;
        }
        IF[n] = inverse(F[n]);
        for (int i = n - 1; i > 0; --i) {
            IF[i] = IF[i + 1] * (i + 1) % MOD;
        }
    }

    long long nCr(int n, int r) {
        if (r < 0 || r > n) {
            return 0;
        }
        long long res = F[n] * IF[r] % MOD * IF[n - r] % MOD;
        return res;
    }

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long n, m, k;
    cin >> n >> m >> k;
    Solution sol;
    cout << sol.solve(n, m, k) << "\n";

    return 0;
}

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

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

	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	vector<long long> ps;
	vector<bool> is_prime(101010, true);
	map<long long, long long> sq;
	for (long long i = 2; i < 101010; i++) {
		if (is_prime[i]) {
			ps.push_back(i);
			sq[i * i] = i;
			for (int j = i * 2; j < 101010; j += i) {
				is_prime[j] = false;
			}
		}
	}

	map<map<long long, int>, map<long long, int>> inv;
	map<map<long long, int>, int> cnt;
	for (int i = 0; i < n; i++) {
		map<long long, int> p, q;
		long long b = a[i];
		for (int j = 0; ps[j] <= 2500; j++) {
			int cnt = 0;
			while (a[i] % ps[j] == 0) a[i] /= ps[j], cnt++;
			cnt %= 3;
			if (cnt > 0) {
				p[ps[j]] = cnt;
				q[ps[j]] = 3 - cnt;
			}
		}
		if (a[i] != 1) {
			if (sq.count(a[i])) {
				p[sq[a[i]]] = 2;
				q[sq[a[i]]] = 1;
			} else {
				p[a[i]] = 1;
				q[a[i]] = 2;
			}
		}
		inv[q] = p;
		inv[p] = q;
		cnt[p]++;
	}

	long long ans = 0;
	for (auto &kv : inv) {
		auto &x = kv.first;
		auto &y = kv.second;
		if (x == y) {
			ans++;
		} else {
			if (x < y) {
				ans += max(cnt[x], cnt[y]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 167040
n, x = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
d_bef = 0

for i in range(1, n+1):
  d = d_bef + l[i-1]
    
  if d <= x:
    bound += 1
    
  d_bef = d

print(bound)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    
    ll cnt = 0;
    for(int i = 0; i * R <= N; i++){
        for(int j = 0; j * G + i * R <= N; j++){
            ll sum = N - (j * G + i * R);
            if(sum % B == 0) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}
int n;
string s;
vector<bool> ju(100100);

bool check(bool a, bool b, vector<bool> &da){
	da[0] = a, da[1] = b;
	rip(i,n,2){
		da[i] = (da[i-1]^da[i-2]^ju[i-1]);
	}
	return ((da[n-1]^da[n-2]^ju[n-1]^da[0])|(da[n-1]^da[0]^ju[0]^da[1]));
}

void out(vector<bool> &da){
	rip(i,n,0){
		if(da[i]) printf("W"); else printf("S");
	}
	cout << endl;
}

vector<vector<bool>> li = {{false, false}, {false, true}, {true, false}, {true, true}};

int main(){
	cin >> n >>s;
	rip(i,n,0) ju[i] = (s[i] == 'x');
	//vdeb(ju);
	vector<bool> da(n);
	rip(i,4,0){
		bool a = li[i][1], b = li[i][0];
		if(!check(a, b,da)){
			out(da);
			return 0;
		}
		//out(da);
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ord (comparing)

fst3 (a, _, _) = a
snd3 (_, b, _) = b
trd3 (_, _, c) = c

main :: IO ()
main = do
    [w, h, n] <- fmap read . words <$> getLine :: IO [Int]
    xyas <- replicateM n $ do
        [x, y, a] <- fmap read . words <$> getLine :: IO [Int]
        return (x, y, a)

    let x1 = case filter ((== 1) . trd3) xyas of
            [] -> 0
            xs -> fst3 $ maximumBy (comparing fst3) xs
    let x2 = case filter ((== 2) . trd3) xyas of
            [] -> w
            xs -> fst3 $ minimumBy (comparing fst3) xs
    let y1 = case filter ((== 3) . trd3) xyas of
            [] -> 0
            xs -> snd3 $ maximumBy (comparing snd3) xs
    let y2 = case filter ((== 4) . trd3) xyas of
            [] -> h
            xs -> snd3 $ minimumBy (comparing snd3) xs
    print $ max (x2 - x1) 0 * max (y2 - y1) 0

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    else if(n == 1){
        if(a == b)  cout << 1 << endl;
        else        cout << 0 << endl;
        return 0;
    }

    ll mi = (n-1)*a + b;
    ll ma = a + (n-1)*b;

    cout << ma - mi + 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;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  if (s[0] == t[0]) ans++;
  if (s[1] == t[1]) ans++;
  if (s[2] == t[2]) ans++;
  cout << ans << endl;
  return 0;
}

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

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

	int* A = new int[N];
	int total = 0;

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

	double cond = 1.0 * total  / (4 * M) ;
	int num = 0;

	for (int i = 0; i < N; i++)
	{
		if (A[i] >= cond)
		{
			num++;
		}
	}

	//cout << "test: " << num << endl;

	if (num >= M)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long M = 1000000007;
long long mod_pow(long long a,long long b)
{
	long long ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%M;
		a = a*a%M;
		b = b/2;
	}
	return ans;
}
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int an[100050];
		for(int i = 0;i < n;i++)
			scanf("%d",&an[i]);
		int q = 1;
		sort(an,an+n);
		int ant = 0;
		if(n%2 == 0)
		{
			for(int i = 0;i < n;i++)
			{
				if(an[i] != 2*(i/2+1) - 1)
				{
					q = 0;
					break;
				}
			}
		}
		else
		{
			for(int i = 0;i < n;i++)
			{
				if(an[i] != 2*((i+1)/2))
				{
					q = 0;
					break;
				}
			}
		}
		if(q == 0) printf("0\n");
		else printf("%lld\n",mod_pow(2,n/2));
	}
return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//入力を受け取るためのScanner型インスタンスscanner
		Scanner scanner = new Scanner(System.in);

		//価格を格納する変数
		int price = scanner.nextInt();
		//嫌いな数字の個数を格納する変数
		int numOfElements = scanner.nextInt();
		//嫌いな数字を格納する配列
		int[] dislikeNums = new int[numOfElements];

		//配列に格納
		for (int i = 0; i < dislikeNums.length; i++) {
			dislikeNums[i] = scanner.nextInt();
		}
		scanner.close(); //scannerに使用しているメモリを解放

		/*支払額の候補を1円ずつ増加させて、
		 条件を満たしているかどうか確認する*/
		boolean flag = false; //条件を満たしているかどうかを管理する変数
		String stringPay; //payをString型に変換したものを格納する変数
		ArrayList<Integer> payArray = new ArrayList<Integer>();// 支払予定額に使われている数字を格納するArrayList
		int pay = 0; //支払予定額を格納する変数

		for (pay = price ; pay < 100000 ; pay++) {

			//flagの初期値を設定（支払予定額が条件に合致すると仮定する)
			flag = false;

			//payを分解して、配列payArrayに1文字ずつ格納する
			stringPay = String.valueOf(pay);//payを分解する準備として、int型をString型に変換する

			for (int i = 0; i < stringPay.length(); i++) {
				//char型をInt型に変換することで、Integer型のArrayListに格納する
				payArray.add(Character.digit(stringPay.charAt(i), 10));
			}

			for (Integer dislikeNum : dislikeNums) {
				if(payArray.contains(dislikeNum)) {
					flag = true;
				}
			}
			payArray.clear(); //次のループに持ち越されないように、ArrayListの中身を空にする

			/*flagが更新されなかったら（支払予定額が条件に合致すれば）、
			ループを抜ける */
			if (flag == false) {
				System.out.println(pay);
				break;
			}
		}
	}

}

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

int main(){
    using namespace std;
    unsigned long Q;
    cin >> Q;
    constexpr auto M{205891132094649UL};
    const auto& calc = [](auto a, auto b, auto c, auto d){
        auto u{b}, l{b}, p{M};
        while(p /= 3)if((a / p + (4 - a / p % 3) % 3) * p <= c){
            if(b / p % 3 == 1){
                u = u / (3 * p) * 3 * p + 2 * p;
                l = l / (3 * p) * 3 * p + p - 1;
                break;
            }
        }
        return c - a + min(u - b + max(u, d) - min(u, d), b + d - 2 * l);
    };
    for(unsigned long _{0}, a, b, c, d; _ < Q; ++_){
        cin >> a >> b >> c >> d;
        if(--a > --c)swap(a, c), swap(b, d);
        if(--b > --d){
            b = M - b - 1;
            d = M - d - 1;
        }
        cout << max(calc(a, b, c, d), calc(b, a, d, c)) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import numpy as np

N = int(input())

A = []

for i in range(N):
    A.append(int(input()))

A.sort()

ans = 0
key = A[0]
cnt = 1

for i in range(1,N):
    if key == A[i]:
        if cnt == 0:
            cnt = 1
        else:
            cnt = 0
    else:
        key = A[i]
        ans += cnt
        cnt = 1

ans += cnt

print(ans)


Measured memory_bytes: 25080
fun main() {
  val a = readInt()
  val s = readString()
  println(if (a >= 3200) s else "red")
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 34408
#include<chrono>
#include<random>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using namespace chrono;

int n; // number of vertices
vector<vector<int>> adj; // adjacency list of graph
vector<bool> visited;
vector<int> ans;

void dfs(int v) {
	visited[v] = true;
	for (int u : adj[v]) {
		if (!visited[u])
			dfs(u);
	}
	ans.push_back(v);
}

void topological_sort() {
	visited.assign(n, false);
	ans.clear();
	for (int i = 0; i < n; ++i) {
		if (!visited[i])
			dfs(i);
	}
	reverse(ans.begin(), ans.end());
}

int main() {

	int m;

	cin >> n >> m;
	
	int x, y;

	vector<int> d;
	vector<int> p;

	adj.assign(n, vector<int>());
	// dp.assign(n + 1, vector<vector<int>>());

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		adj[x-1].push_back(y-1);
	}

	topological_sort();

	vector<int> dp(n);

	for (auto i : ans) {
		for (auto v : adj[i]) {
			dp[v] = max(dp[i] + 1, dp[v]);
		}
	}

	cout << *max_element(dp.begin(), dp.end()) << "\n";


	return 0;

}


Measured memory_bytes: 8696
n = int(input())

diceA = [[0 for i in range(6)] for j in range(n)]

diceB = [[0 for i in range(6)] for j in range(n)]

for i in range(n):
  diceA[i] = list(map(int, input().split()))
  diceB[i] = [diceA[i][0],diceA[i][1],diceA[i][2],diceA[i][4],diceA[i][3],diceA[i][5]]

diceC = [[1,2,3,5,4,2,3,5,6],[2,1,4,6,3,1,4,6,5],[3,1,2,6,5,1,2,6,4],[4,1,5,6,2,1,5,6,3],[5,1,3,6,4,1,3,6,2],[6,2,4,5,3,2,4,5,1]]

m = "judge"

for o in range(n-1):
  for l in range(1,n-o):
    for i in range(6):
      if diceB[o+l][0] == diceA[o][i]:
        for j in range(1,5):
          if diceB[o+l][1] == diceA[o][diceC[i][j]-1]:
            for k in range(1,4):
              if diceB[o+l][1+k] == diceA[o][diceC[i][j+k]-1]:
                m = "same"
              else:
                m = "diff"
                break
            if m == "same":
              if diceB[o+l][5] == diceA[o][diceC[i][8]-1]:
                m = "same"
                break
              else:
                m = "diff"
                break
      if m == "same":
        break
    if m == "same":
      break
  if m == "same":
    break

if m == "same":
  print("No")
else:
  print("Yes")


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

int main(){
    int a, b;
    cin >> a >> b;
    if (a>=10 || b>=10) cout << -1 << endl;
    else cout << a*b << endl;
}


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

typedef long long ll;

int n, m, DP[3005][3005];
char s[3005], t[3005], z[3005];

int main()
{
    scanf("%s %s", s, t);
    n = strlen(s);
    m = strlen(t);

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s[i-1] == t[j-1]) {
                DP[i][j] = DP[i-1][j-1] + 1;
            } else {
                DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            }
        }
    }

    int i = n, j = m, sz = 0;
    while(i > 0 && j > 0) {
        if(s[i-1] == t[j-1]) {
            z[sz++] = s[i-1];
            i--;
            j--;
        } else {
            if(DP[i-1][j] > DP[i][j-1]) {
                i--;
            } else {
                j--;
            }
        }
    }

    reverse(z, z+sz);
    printf("%s\n", z);

    return 0;
}


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
//#define modulo ll (1e9 + 7)
#define modulo ll (1e6 + 3)
const long double PI = 3.141592653589793238L;


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();
    int n, k;
    cin >> n >> k;

    int arr[n];
    for(int i = 0;i < n;i++)
        cin >> arr[i];

    sort(arr, arr + n);

    ll ans = LLONG_MAX;
    for(int i = 0;i <= n - k;i++){
        ll l = arr[i];
        ll r = arr[i + k - 1];

        if(l * r < 0)
            ans = min(ans, min(abs(l), abs(r)) * 2 + max(abs(l), abs(r)));
        else
            ans = min(ans, max(abs(l),abs(r)));
    }

    cout << ans;
}

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

using namespace std;

constexpr long long INF64 = 1e18;

using Weight = long long;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f) {
  if (e.weight != f.weight)
    return e.weight > f.weight;
  else if (e.src != f.src)
    return e.src < f.src;
  else
    return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
//経路復元可能
void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev) {
  const int V = g.size();
  priority_queue<Edge> q;
  dist[s] = 0;
  for (q.emplace(-2, s, 0); !q.empty();) {
    Edge e = q.top();
    q.pop();
    if (prev[e.dst] != -1)
      continue;
    prev[e.dst] = e.src;
    // if(prev[t]!=-1)return;
    for (auto ge : g[e.dst]) {
      if (dist[ge.dst] > e.weight + ge.weight) {
        dist[ge.dst] = e.weight + ge.weight;
        q.emplace(ge.src, ge.dst, e.weight + ge.weight);
      }
    }
  }
}

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  Graph g1(n), g2(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    Weight a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    g1[u].emplace_back(u, v, a);
    g1[v].emplace_back(v, u, a);
    g2[u].emplace_back(u, v, b);
    g2[v].emplace_back(v, u, b);
  }
  vector<Weight> dist1(n, INF64); //ここまでの距離が入る
  vector<int> prev1(n, -1);       //最短路の親が入る
  dijkstra(g1, s - 1, dist1, prev1);
  vector<Weight> dist2(n, INF64); //ここまでの距離が入る
  vector<int> prev2(n, -1);       //最短路の親が入る
  dijkstra(g2, t - 1, dist2, prev2);
  for (int i = 0; i < n; ++i) {
    dist1[i] += dist2[i];
  }
  Weight mi = 1e18;
  for (int i = n - 2; i >= 0; --i) {
    dist1[i] = min(dist1[i], dist1[i + 1]);
  }
  for (int i = 0; i < n; ++i) {
    cout << 1000000000000000 - dist1[i] << endl;
  }
}

Measured memory_bytes: 19068
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define ull unsigned long long

using namespace std;

inline ll in()
{
	ll Req = 0, wX = 0; char ch;
	while (!isdigit(ch)) {wX |= (ch == '-'); ch = getchar();}
	while (isdigit(ch)) {Req = (Req << 3) + (Req << 1) + (ch ^ 48); ch = getchar();}
	return wX ? -Req : Req;
}

inline void out(ll x)
{
	register short Pxn[20], Ry = 0;
	if (x == 0) putchar('0');
	if (x < 0) putchar('-'), x = -x;
	while (x != 0) Pxn[Ry] = x % 10, x /= 10, Ry++;
	for (int i = Ry - 1; i >= 0; i--) putchar(Pxn[i] + '0');
}

inline string strin()
{
	char ch = getchar(); string ret = "";
	while (ch == ' ' || ch == '\n') ch = getchar();
	while (ch != ' ' && ch != '\n') ret += ch, ch = getchar();
	return ret;
}

int main()
{

	string s = strin();
	int w = in(), len = s.length();
	for (int i = 0; i < len; i += w)
		putchar(s[i]);
	putchar('\n');

  return 0;

}



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

string n;

bool judge(string n){
    bool flag1=true,flag2=true,ret;

    for(int i=1; i<3; i++){
        flag1&=(n[i]==n[i-1]);
    }
    for(int i=2; i<4; i++){
        flag2&=(n[i]==n[i-1]);
    }
    ret=flag1|flag2;

    return ret;
}

int main(){

    cin>>n;

    if(judge(n)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define int long long
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 800020;
LL a[N];
int lc[N], rc[N];
long long sum[N], add[N];
#define lson(p) (p << 1)
#define rson(p) (p << 1 | 1)
inline void pushup(int p) {
	sum[p] = sum[lson(p)] + sum[rson(p)];
}
inline void pushdown(int p) {
	if (add[p]) {
		sum[lson(p)] += add[p] * (rc[lson(p)] - lc[lson(p)] + 1);
		sum[rson(p)] += add[p] * (rc[rson(p)] - lc[rson(p)] + 1);
		add[lson(p)] += add[p];
		add[rson(p)] += add[p];
		add[p] = 0;
	}
}
inline void build(int p, int l, int r) {
	lc[p] = l;
	rc[p] = r;
	if (l == r) {
		sum[p] = a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(lson(p), l, mid);
	build(rson(p), mid + 1, r);
	pushup(p);
}
inline long long query(int p, int l, int r) {
	if (l <= lc[p] && r >= rc[p]) return sum[p];
	pushdown(p);
	int mid = (lc[p] + rc[p]) >> 1;
	long long ans = 0;
	if (l <= mid) ans += query(lson(p), l, r);
	if (r > mid) ans += query(rson(p), l, r);
	return ans;
}
inline void modify(int p, int l, int r, int d) {
	if (l <= lc[p] && r >= rc[p]) {
		sum[p] += d * (rc[p] - lc[p] + 1);
		add[p] += d;
		return;
	}
	pushdown(p);
	int mid = (lc[p] + rc[p]) >> 1;
	if (l <= mid) modify(lson(p), l, r, d);
	if (r > mid) modify(rson(p), l, r, d);
	pushup(p);
}
struct Monster {
	int x, h;
	bool operator < (const Monster b) const {
		return x < b.x;
	}
}m[N];
LL x[N], p[N];
int H, n, d;
int need(int i) {
	return (x[i] + H - 1) / H;
}
int ans = 0;
void work(int i) {
	int &h = x[i];
	h -= query(1, i, i);
	if (h <= 0) {
		return;
	}
	if (h > 0) {
		int r = upper_bound(p + 1, p + n  + 1, m[i].x + 2 * d) - p - 1;
//		cerr << "HIT " << i << " " << r << " " << need(i) << endl;
		modify(1, i, r, H * need(i)); 
		ans += need(i);
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> d >> H;
	repn(i, n) cin >> m[i].x >> m[i].h;
	sort(m + 1, m + n + 1); repn(i, n) x[i] = m[i].h, p[i] = m[i].x;
	build(1, 1, n);
	repn(i, n) work(i);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 32512
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 11);

int n;
bitset<MAXN> A[MAXN];

void read()
{
	cin >> n;
	for(int i = 2; i <= n; i++)
	{
		string s;
		cin >> s;
		for(int j = 1; j < i; j++)
		{
			int x = s[j - 1] - '0';
			A[j][i] = x ^ 1;
			A[i][j] = x;
		}
	}
}

bitset<MAXN> lft[MAXN];
bitset<MAXN> rgh[MAXN];
bitset<MAXN> winners[MAXN], emp;

void solve()
{
	for(int i = 1; i <= n; i++)
		lft[i][i] = 1, rgh[i][i] = 1, winners[i][i] = 1;

	for(int len = 2; len <= n; len++)
	{
		for(int i = 1; i <= n; i++)
		{
			int r = i + len - 1;
			if(r > n) continue;
			if((A[i] & winners[i + 1]).count()) lft[r][i] = 1;
		}
	
		for(int i = 1; i <= n; i++)
		{
			int l = i - len + 1;
			if(l <= 0) continue;
			if((A[i] & winners[l]).count()) rgh[l][i] = 1;
		}

		for(int l = 1; l <= n; l++)
		{
			int r = l + len - 1;
			if(r > n) continue;
			winners[l] = rgh[l] & lft[r];
		}
	}

	cout << winners[1].count() << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 2432
//https://atcoder.jp/contests/agc038/tasks/agc038_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll H,W,A,B; cin>>H>>W>>A>>B;

    REP(y,H){
        REP(x,W){
            if (y>=B){
				if(x >= A) {
					cout << 0;
				} else {
					cout << 1;
				}
            } else {
				if(x < A) {
					cout << 0;
				} else {
					cout << 1;
				}
			}
		}
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, A, B, numA = 0, numB = 0;
  cin >> N >> A >> B;
  for(int i = 0; i < N; i++){
    cin >> A >> B;
    if(numA < A){
      numA = A;
      numB = B;
    }
  }
  cout << numA + numB << endl;
  return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  
  vector <int> A(N);
  
  cin >> A.at(0);
  int min = A.at(0);
  int max = A.at(0);
  
  for (int i=1;i<N;i++){
    cin >> A.at(i);
    if (A.at(i) < min ) min=A.at(i);
    else if (A.at(i) > max ) max = A.at(i);
    else continue;
  }
  
  cout << max - min <<endl;

}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
  }
  for(int i=0;i<N;i++){
    int C=0;
    for(int j=0;j<M;j++){
      if(A.at(j)==i+1){
        C++;
      }
      if(B.at(j)==i+1){
        C++;
      }
    }
    cout << C << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

int main(int argc, char const* argv[])
{
    std::string in_s, in_t;

    std::cin >> in_s >> in_t;
    std::sort(in_s.begin(), in_s.end(), std::less<char>());
    std::sort(in_t.begin(), in_t.end(), std::greater<char>());

    /* std::cout << in_t << std::endl; */

    auto s_len = in_s.length();
    auto t_len = in_t.length();
    auto min_len = std::min(s_len, t_len);
    for(int i=0; i<min_len; ++i)
    {
        if(in_s[i] == in_t[i])
        {
            continue;
        }
        if(in_s[i] < in_t[i])
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        else
        {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    if(s_len < t_len)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.next();

        if((s.charAt(0) == s.charAt(1)) || (s.charAt(1) == s.charAt(2)) || (s.charAt(2) == (s.charAt(3)))) {
            System.out.println("Bad");
        }
        else System.out.println("Good");    
    } 
}

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

const int N = 100000;

int n, a[N];
int m, x[N - 1], y[N - 1];

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  for (int i = 1; i < n - 1; i++) {
    if (a[i] < 0) {
      x[i - 1] = a[n - 1];
      y[i - 1] = a[i];
      a[n - 1] -= a[i];
    } else {
      x[i - 1] = a[0];
      y[i - 1] = a[i];
      a[0] -= a[i];
    }
  }
  x[n - 2] = a[n - 1];
  y[n - 2] = a[0];
  m = a[n - 1] - a[0];
  printf("%d\n", m);
  rep(i, n - 1) printf("%d %d\n", x[i], y[i]);
  return 0;
}

Measured memory_bytes: 4876
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  VI x(5);
  INPUT(x);
  REP(int, i, 5)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << endl;
      break;
    }
  }

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vP e(n-1);
  vii g(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[i] = make_pair(a,b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int cnt = 0;
  rep(i,n) cnt = max(cnt, sz(g[i]));

  queue<P> q; // pair = (v, cant_use_color)
  map<P,int> mp;
  vb seen(n);
  q.emplace(0,-1);
  while(sz(q)) {
    int v = q.front().fi;
    int cant = q.front().se;
    q.pop();
    seen[v] = true;  
    int col = 1;
    for(int nv : g[v]) {
      if(seen[nv]) continue;
      if(col == cant) col++;
      P edge = make_pair(min(v,nv), max(v,nv));
      mp[edge] = col;
      q.emplace(nv,col);
      col++;
    }
  }
  cout << cnt << endl;
  rep(i,n-1) {
    cout << mp[e[i]] << endl;
  }
}

Measured memory_bytes: 13056
# coding: utf-8
# Your code here!

n = int(input())
factors = []

p = 2
m = n
while p*p <= m:
    if m % p == 0:
        factors.append(p)
        m //= p
    else:
        p += 1
if m > 1:
    factors.append(m)

print(f'{n}:', *factors)


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

int main(int argc, const char * argv[]) {
    
    int S;
    cin >> S;
    
    cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << (S % 3600) % 60 <<  endl;
    return 0;
}

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

using namespace std;

int main()
{
    bitset <64> b;
	int n;
	cin>>n;
	vector < bitset <64> > v(n);
    for(int i=0;i<n;i++)
    {
        int p;
		cin>>p;
		while(p--)
		{
		    int j;
			cin>>j;
			v[i][j]=1;
		}
	}
	int q,a,x;
	cin>>q;
	while(q--)
	{
		cin>>a;
		if(a==0)
		{
		    cin>>x;
		    cout<<b[x]<<endl;
		}
		if(a==1)
        {
            cin>>x;
            b|=v[x];
        }
		if(a==2)
        {
            cin>>x;
            b&=~v[x];
        }
		if(a==3)
        {
            cin>>x;
            b^=v[x];
        }
		if(a==4)
        {
            cin>>x;
            cout<<((b&v[x])==v[x])<<endl;
        }
		if(a==5)
        {
            cin>>x;
            cout<<(b&v[x]).any()<<endl;
        }
		if(a==6)
        {
            cin>>x;
            cout<<(b&v[x]).none()<<endl;
        }
		if(a==7)
        {
            cin>>x;
            cout<<(b&v[x]).count()<<endl;
        }
		if(a==8)
        {
            cin>>x;
            cout<<(b&v[x]).to_ullong()<<endl;
        }
	}
	return 0;
}




Measured memory_bytes: 3084
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 998244353;
const int N = 1e5 + 10, M = 1e5 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int a[N];
int b[N];
vector<int> v;

int main()
{
    int x, y, A, B, C;
    cin >> x >> y >> A >> B >> C;
    for (int i = 1; i <= A; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= B; i++)
        scanf("%d", &b[i]);
    for (int i = 1; i <= C; i++)
    {
        int c;
        scanf("%d", &c);
        v.push_back(c);
    }
    sort(a + 1, a + A + 1);
    sort(b + 1, b + B + 1);
    for(int i = A - x + 1; i <= A; i++)
        v.push_back(a[i]);
    for(int i = B - y + 1; i <= B; i++)
        v.push_back(b[i]);
    sort(v.rbegin(), v.rend());
    ll res = 0;
    for(int i = 0; i < x + y; i++)
        res += v[i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<string> S;
    string Si;
    for(int i = 0; i < N; i++){
        cin >> Si;
        S.push_back(Si);
    }
    int count = 1;
    sort(S.begin(),S.end());
    for(int i = 1; i < N; i++){
        if(S[i] != S[i-1]){
            count++;
        }
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 11660
/**
 *    author:  ismail
 *    created: 20.01.2020  19:43:52
 **/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define w(a) std::cerr << #a << " : " << (a) << "\n";

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, ans = 1;
  cin >> n >> m;
  for (int i = 1, d; i < n; i++) {
    cin >> d;
    if (d <= m) {
      ans++;
      m = d;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    int D, N;
    std::cin >> D >> N;
    int base = 1;

    for(int i = 0; i < D; i++){
        base *= 100;
    }
    int out = 0;
    for(int i = 0; i < N; i++){
        out += base;
    }
    if(N == 100) out += base;
    std::cout << out << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
	return 0;
}


Measured memory_bytes: 256
t={}
for i=1,4 do
    t[i]=io.read("*n")
end
n=io.read("*n")

x=math.min(4*t[1],2*t[2],t[3])
if 2*x<t[4] then
    print(n*x)
else
    print((n//2)*t[4]+(n%2)*x)
end

Measured memory_bytes: 760
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        long N=sc.nextLong(),D=(int)Math.log10(N),a=0,M=N;
        for(int i=0;i<D;i++){
            if(M%10!=9){
                a--;
                break;
            }
            M/=10;
        }
        a+=N/(long)Math.pow(10,D);
        System.out.println(9*D+a);
    }
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
int need[5];
int cnt[26];
int main(void){
	int H,W;
	cin >> H >> W;
	string a[H];
	for(int i=0;i<H;i++)cin >> a[i];
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cnt[a[i][j]-'a']++;
	need[4] = (H/2)*(W/2);
	if(H%2)need[2] += W/2;
	if(W%2)need[2] += H/2;
	bool ok = 1;
	while(need[4]&&ok){
		ok = 0;
		for(int i=0;i<26;i++){
			if(cnt[i]>=4){
				cnt[i]-=4;
				need[4]--;
				ok = 1;
			}
		}
		if(!ok){
			cout << "No" << endl;
			return 0;
		}
	}
	ok = 1;
	while(need[2]&&ok){
		ok = 0;
		for(int i=0;i<26;i++){
			if(cnt[i]>=2){
				cnt[i]-=2;
				need[2]--;
				ok = 1;
			}
		}
		if(!ok){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

N = int(input())
S={}
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in S:
    S[s] += 1
  else:
    S[s] = 1

ans=0
for s in S.values():
  ans += s*(s-1)//2
  
print(ans)

Measured memory_bytes: 17808
N = int(input())
A = list(map(int, input().split())) # １行に別れてるとき

A1 = []
k = 0
for i in range(N):
    if i % 2 == 0:
        k += A[i]
    else:
        k -= A[i]
    A1.append(k)

ans = []
for i in range(N):
    if i == 0:
        ans.append(A1[-1])
        continue
    pre = A1[-1] - A1[i-1]
    fow = A1[i-1]
    if i % 2 == 0:
        ans.append(pre - fow)
    else:
        ans.append(fow - pre)

print(' '.join(map(str, ans)))

Measured memory_bytes: 22968
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), x = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < m; i++) {
            a[in.nextInt()] = 1;
        }
        int ans1 = 0,ans2 = 0;
        for (int i = x; i > 0; i--) {
            ans1 += a[i];
        }
        for (int i = x; i < n; i++) {
            ans2 += a[i];
        }
        System.out.println(Math.min(ans1, ans2));
    }
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 2100

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	vector<int> S, T;
	static int dp[MAX][MAX];
	static int sum[MAX][MAX];
	
	int con = 0;
	cin>>N>>M;
	
	S.resize(N);
	T.resize(M);
	
	for(int i = 0; i < N; i++){
		cin>>S[i];
	}
	
	for(int i = 0; i < M; i++){
		cin>>T[i];
	}

	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			if(S[i] == T[j]){
				dp[i+1][j+1] += sum[i][j] + 1;
				dp[i+1][j+1] %= MOD;
			}
			sum[i+1][j+1] = MOD + sum[i][j+1] + sum[i+1][j] - sum[i][j] + dp[i+1][j+1];
			sum[i+1][j+1] %= MOD;
		}
	}

	
	cout<<(sum[N][M]+1)%MOD<<endl;
	
	// cout<<con<<endl;
	
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W; cin >> H >> W;
    if (H==1||W==1){cout << 1 << '\n'; return 0;}
    ll ans=((H+1)/2)*((W+1)/2)+(H/2)*(W/2);
    cout << ans << '\n';
}

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

int N,M;
int C[700][700];
vector<vector<int> > E(700);
int vis[700];
int cnt[2];
int ok[700][700];

void dfs(int v,int c){
  if(vis[v]!=-1){
    if(vis[v]==c) return;
    cout<<-1<<endl;
    exit(0);
    return;
  }
  cnt[c]++;
  vis[v]=c;
  rep(i,E[v].size()) dfs(E[v][i],c^1);
}

int main(){
  cin>>N>>M;
  rep(i,M){
    int a,b; cin>>a>>b; a--,b--;
    C[a][b]=C[b][a]=1;
  }
  rep(i,N){
    C[i][i]=1;
    rep(j,N) if(C[i][j]==0) E[i].push_back(j);
  }
  ok[0][0]=1;
  int sum=0;
  fill(vis,vis+700,-1);
  rep(i,N) if(vis[i]==-1){
    cnt[0]=cnt[1]=0;
    dfs(i,0);
    rep(j,sum+1) if(ok[j][sum-j]){
      ok[j+cnt[0]][sum-j+cnt[1]]=1;
      ok[j+cnt[1]][sum-j+cnt[0]]=1;
    }
    sum+=cnt[0]+cnt[1];
  }
  int ans=INT_MAX/2;
  rep(i,N+1) if(ok[i][N-i]){
    ans=min(ans,i*(i-1)/2+(N-i)*(N-i-1)/2);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    ll l,r,res,mini=3000;
    cin>>l>>r;
    if (r-l>2030) {
        cout<<0<<endl;
    } else {
        for (ll i=l; i<r; i++) {
            for (ll j=i+1; j<=r; j++) {
                res=(i*j)%MOD;
                mini=min(res,mini);
            }
        }
    cout<<mini<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e11

int n,w,a[101][2];
ll dp[101][100005];

ll rec(int i,int val)
{
    if(val==0)
        return 0;
    if(i==n)
        return INF;
    if(dp[i][val]+1)
        return dp[i][val];

    ll pick = a[i][0]+rec(i+1,val-a[i][1]);
    ll leave = rec(i+1,val);

    return dp[i][val] = min(pick,leave);
}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin >> n >> w;
    for(int i=0;i<n;i++)
    {
        cin >> a[i][0] >> a[i][1];
    }
    for(int i=100000;i>0;i--)
    {
        if(rec(0,i)<=w)
            return cout << i,0;
    }
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>

int main()
{
  std::string alpabet = "a";
  std::cin >> alpabet;
  if(alpabet[0] >= 'A' && alpabet[0] <= 'Z')
  {
    alpabet = "A";
  }
  else
  {
    alpabet = "a";
  }
  std::cout << alpabet << std::endl;
  return 0;
}

Measured memory_bytes: 3588