akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/

bool judge(vector<vector<int>> &_G,vector<ll> &_h, int p){

    for(auto x : _G[p]){
        if(_h[p] <= _h[x]) return false;
    }

    return true;
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, m; cin >> n >> m;
    vector<ll> h(n+1);
    For(i, 1, n+1) cin >> h[i];
    vector<vector<int>> G(n+1);
    rep(i, m){
        int a, b; cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }

    ll ans = 0;
    For(i, 1, n+1){
        if(judge(G, h, i)) ans++;
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 9184
// ＡＢＣのＡ過去問を解くだけだよ
// フォント    x:小文字(ｘ)    X:大文字(Ｘ)

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int train = min(a, b);
    int bus = min(c, d);

    cout << train + bus;

    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
p = sorted(list(map(int, input().split())))
if N == 0:
    print(X)
    exit()
for i in range(N):
    if X <= p[i]:
        for j in range(X+1):
            if not X-j in p[:i+1]:
                print(X-j)
                exit()
            elif j != 0 and not X+j in p[i+1:]:
                print(X+j)
                exit()
        print(0)
        exit()

Measured memory_bytes: 61960
from collections import defaultdict

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

ddict = defaultdict(int)
for i in d:
    ddict[i] += 1

for j in t:
    if ddict[j] >= 1:
        ddict[j]-=1
    else:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 41700
import math
def solve(n):
	A=list(map(int,n))
	A.reverse()
	cnt=0
	for i in A:
		if i==0:
			cnt+=1
		else:
			break
	return cnt

while True:
	n=int(input())
	if n==0:
		break
	ans=solve(str(math.factorial(n)))
	print(ans)

Measured memory_bytes: 8404
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      B += A / 2;
      A /= 2;
    } else {
      A += B / 2;
      B /= 2;
    }
  }
  cout << A << ' ' << B << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,ll> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

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

    vector<P> ab(n);
    
    rep(i,n){
        cin >> ab[i].first >> ab[i].second;
    }
    ssort(ab);
    rep(i,n-1)ab[i+1].second+=ab[i].second;
    int i=0;
    while(ab[i].second<k){
        ++i;
    }
    cout << ab[i].first << endl;
}

Measured memory_bytes: 4760
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
B=zeros(Int,N)
for i=N:-1:1
	now=A[i]
	for j=i:i:N
		now+=B[j]
	end
	B[i]=now%2
end
println(sum(B))
for i=1:N
	if B[i]==1
		println(i)
	end
end


Measured memory_bytes: 165524
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int n;
    int b;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        if(n%i==0)
        {
            b=n/i;
            if(b>=1&&b<=9)
            {
                printf("Yes\n");
                return 0;
            }

        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro alice = new Magatro();
        alice.Scan();
        alice.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;
    private const char Separator = ' ';
    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }
    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }
    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private long x;
    public void Scan()
    {
        Scanner sc = new Scanner();
        x = sc.NextLong();
    }

    public void Solve()
    {
        long amari = x % 11;
        long ans = (x / 11) * 2;
        if (amari > 0 && amari < 7)
        {
            ans++;
        }
        else if(amari>=7)
        {
            ans += 2;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2772
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
print(n if n&1 == 0 else n*2)
















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

int main(){
    string s;
    cin >> s;

    int k;
    cin >> k;

    int n = s.length();

    map<string, int> m;
    for(int i = 0; i < n ; i++){
        for(int j = i; j < n; j++){
            if(i + k <= j){
                break;
            }
            string l;
            l = s.substr(i, j - i + 1);

            auto itr = m.find(l);
            if(itr == m.end()){
                m[l] = 1;
            }
        }
    }

    auto itr = m.begin();
    for(int i = 1; i < k; i++){
        itr++;
    }

    cout << itr->first << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


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

    unordered_map<i64, vector<i64>> job;
    i64 a, b;
    REP(i, N) {
        cin >> a >> b;
        job[a].pb(b);
    }

    priority_queue<i64> candid;

    i64 ans = 0;
    REPS(i, M) {
        if (job[i].size() > 0) {
            for (auto it = job[i].begin(); it != job[i].end(); it++) {
              candid.push(*it);
            }
        }

        if (candid.empty()) continue;
        ans += candid.top(); candid.pop();
    }
    cout << ans << endl;

    return 0;
}

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

vector<int> dp;
vector<vector<int>> adj;
int dfs(int node){
    if(adj[node].size() == 0) return 0;
    int& ans = dp[node];
    if(ans != -1) return ans;
    for(int x : adj[node]) ans= max(ans, dfs(x)+1);
    return ans;
}

int main(){

    int n, m;
    cin >> n >> m;
    adj.resize(n+1);
    for(int i = 1; i <= m ; ++i){
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    dp.assign(n+1, -1);
    int ans = 0;
    for(int i = 1; i <= n ; ++i) ans = max(ans, dfs(i));
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 7424
n,m=map(int,input().split())
g = [[] for _ in range(n)] # 隣接リスト
from collections import deque
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].append(b)
    g[b-1].append(a)
#print(g)
def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
x=[0]*n
s=1
m=0
for i in range(1,n+1):
    if x[i-1]==0:
        x[i-1]=s
        c=1
        q=deque([i])
        while q:
            v = q.popleft()
            for j in g[v-1]:
                if x[j-1]==0:
                    q.append(j)
                    x[j-1]=s
                    c+=1
        s+=1
        m=max(m,c)
print(m)

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

typedef long long ll;
const ll M = 998244353;

int main(){
	static ll H,W;
	static char s[302][302];
	scanf("%lld%lld",&H,&W);
	for(int i = 1 ; i <= H ; i ++){
		scanf("\n");
		for(int j = 1 ; j <= W ; j ++){
			scanf("%c",&s[i][j]);
		}
	}
	
	static ll a[605][605] = {};
	static ll b[605][605] = {};
	static ll c[605][605] = {};
	for(int i = 1 ; i <= H ; i ++){
		for(int j = 1 ; j <= W ; j ++){
			if(s[i][j] == '#')a[i+j][i-j+302] = 1;
			b[i+j][i-j+302] = a[i+j][i-j+302];
			c[i+j][i-j+302] = a[i+j][i-j+302];
		}
	}
	for(int i = 2 ; i <= 600 ; i ++){
		for(int j = 1 ; j <= 602 ; j ++){
			b[i][j] += b[i][j-1];
		}
	}
	
	//cout << a[2][302] << endl;
	//cout << b[2][302] << endl;
	//cout << b[2][299] << endl;
	
	ll ret = 0;
	for(int i = 2 ; i <= 600 ; i ++){
		for(int j = 2 ; j <= 602 ; j += 2){
			if((i+j)&1)j ++;
			if(a[i][j] == 0)continue;
			for(int k = j+2 ; k <= 602 ; k += 2){
				if(a[i][k] == 0)continue;
				if(i-k+j >= 0)ret += b[i-(k-j)][k]-b[i-(k-j)][j-1];
				if(i+k-j < 605)ret += b[i+(k-j)][k]-b[i+(k-j)][j-1];
			}
		}
	}
	//cout << ret << endl;
	
	for(int j = 2 ; j <= 602 ; j ++){
		for(int i = 2 ; i <= 600 ; i ++){
			c[i][j] += c[i-1][j];
		}
	}
	for(int j = 2 ; j <= 602 ; j ++){
		for(int i = 2 ; i <= 600 ; i += 2){
			if((i+j)&1)i ++;
			if(a[i][j] == 0)continue;
			for(int k = i+2 ; k <= 600 ; k += 2){
				if(a[k][j] == 0)continue;
				if(j-k+i >= 0)ret += c[k-1][j-(k-i)]-c[i+1][j-(k-i)];
				if(j+k-i < 605)ret += c[k-1][j+(k-i)]-c[i+1][j+(k-i)];
			}
		}
	}
	cout << ret << endl;
}
	

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

bool cmp(string &s1,string &s2,int n,int ind)
{
    bool f=true;
    for(int i=0;i<n;i++)
    {
        if(s2[i]!=s1[(i+ind)%n]) {f=false;break;}
    }
    return f;
}

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size();
    bool res=false;
    for(int i=0;i<n;i++)
    {
        res=res||cmp(s1,s2,n,i);
        if(res) break;
    }
    if(res) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
typedef vector<vector<int>> Graph;

const double PI = 3.14159265358979323846;
const int mod = 1000000007;


int main(int argc, char *args[]) {
	int n, m; cin >> n >> m;
	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var lMap = {};
	var rMap = {};
	var output = 0;
	for(var i = 0; i < N; i++){
		if(lMap[list[i] + i] == null){
			lMap[list[i] + i] = 1;
		}else{
			lMap[list[i] + i]++;
		}
		if(rMap[i - list[i]] == null){
			rMap[i - list[i]] = 1;
		}else{
			rMap[i - list[i]]++;
		}
	}
	
	var keys = Object.keys(lMap);
	for(var i = 0; i < keys.length; i++){
		if(rMap[keys[i]] != null){
			output += lMap[keys[i]] * rMap[keys[i]];
		}
	}
	myout(output);
}


Measured memory_bytes: 103652
import scala.io.Source

object Main {
  def main(args: Array[String]) = {
    val lines = Source.stdin.getLines.toStream
    val input = lines.drop(1).head.split(' ').map(_.toLong)

    val memo = Array.fill(input.length + 1, input.length + 1, 2)(-1L)
    (1 to input.length).foreach { n =>
      memo(n-1)(n)(0) = input(n-1)
      memo(n-1)(n)(1) = 0
    }

    val res = dp(input, 0, input.length, memo)
    println(res(1))
  }

  def dp(input: Array[Long], left: Int, right: Int, memo: Array[Array[Array[Long]]]): Array[Long] = {
    if (memo(left)(right)(0) != -1L) return memo(left)(right)

    var minCost = Long.MaxValue
    var minTotal = Long.MaxValue
    ((left + 1) to (right - 1)).foreach { split =>
      val leftRes = dp(input, left, split, memo)
      val rightRes = dp(input, split, right, memo)
      val cost = leftRes(0) + rightRes(0)
      val total = leftRes(1) + rightRes(1) + leftRes(0) + rightRes(0)
      if (total < minTotal) {
        minCost =  cost
        minTotal = total
      }
    }
    memo(left)(right)(0) = minCost
    memo(left)(right)(1) = minTotal
    memo(left)(right)
  }
}


Measured memory_bytes: 41676
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int Mod;
int n,m;
int C[310][310];
int f[310][310],F[310][310];
int main()
{
	cin>>n>>m>>Mod;
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	}
	for(int i=0;i<=m;i++)
		f[0][i]=1;
	for(int i=1;i<=n;i++)
	{
		F[i-1][0]=f[i-1][0];
		for(int j=1;j<=m;j++)
			F[i-1][j]=(F[i-1][j-1]+f[i-1][j])%Mod;
		for(int j=1;j<=m;j++)
			for(int k=1;k<=i;k++)
				f[i][j]=(f[i][j]+(long long)C[i-1][k-1]*F[k-1][j-1]%Mod*f[i-k][j])%Mod;
	}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll modinv(ll n)    { ll ans=powm(n,mod-2); return ans; }
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

int main()
{
	fast
	ll n,k;
	cin>>n>>k;
	ll a[n];
	forn(i,0,n)
		cin>>a[i];

	vector<ll>v;
	forn(i,0,n)
	v.pb(a[i]);

	sort(all(v));
	ll ans=0;
	forn(i,0,n)
	{
		ll idx = ub(all(v),a[i]-1)-v.begin();
		//cout<<idx<<endl;
		ll x;
		if(k%2)
		{
			x=(k-1)/2;
			ans=add(ans,mult(mult(k,x),idx));
		}
		else
		{
			x=k/2;
			ans=add(ans,mult(mult(x,k-1),idx));
		}

		//ans=add(ans,mult(mult(k,k-1)/2,idx));
	}
	ll cnt=0;
	forn(i,0,n)
	{
		forn(j,0,n)
		{
			if(i<j && a[i]>a[j])
				cnt++;
		}
	}

	cnt=mult(cnt,k);
	//cout<<cnt<<endl;
	ans=add(ans,cnt);
		
	cout<<ans;
	return 0;
}

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

int main(){
    unsigned int n, k, y, x;
    cin >> n >> k >> x >> y;
    if(n<k){
        cout << n*x << endl;
    }else{
        cout << k*x+(n-k)*y << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,a,b,c,d;
string s;

void error(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  cin >> n >> a >> b >> c >> d;
  cin >> s;
  if(c < d){
    ll x = a;
    while(x < c){
      if(s[x] == '#'){
        if(s[x+1] == '#') error();
        x += 2;
      }else{
        x += 1;
      }
    }
    x = b;
    while(x < d){
      if(s[x] == '#'){
        if(s[x+1] == '#') error();
        x += 2;
      }else{
        x += 1;
      }

    }
    cout << "Yes" << endl;
  }else{
    ll x = a;
    bool flag = false;
    while(x < c){
      if(s[x] == '#'){
        if(s[x+1] == '#') error();
        x += 2;
      }else{
        x += 1;
      }
    }
    x = b;
    while(x < d){
      if(s[x-2] == '.' && s[x] == '.') flag = true;
      if(s[x] == '#'){
        if(s[x+1] == '#') error();
        x += 2;
      }else{
        x += 1;
      }

    }
    if(s[x-2] == '.' && s[x] == '.') flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

const ll MOD = 1e9+7;
const int MAX = 1001001;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}
signed main(){
    COMinit();
    int n; cin >> n;
    int p; cin >> p;
    int num[2]={0,0};
    rep(i,n){
        int a; cin >> a;
        a%=2;
        num[a]++;
    }
    if(p==0){
        ll ans=(1ull<<num[0]);
        ll res=1;
        for(int i=2;i<=num[1];i+=2){
            res+=COM(num[1],i);
        }
        ans*=res;
        cout << ans << endl;
    }else{
        ll ans=(1ull<<num[0]);
        ll res=0;
        for(int i=1;i<=num[1];i+=2){
            res+=COM(num[1],i);
        }
        ans*=res;
        cout << ans << endl;
    }
}




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

int main(){
	int n,ans = 0;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i]--;
	}
	for(int i = 0;i < n;i++) if(i == a[a[i]]) ans++;
	cout << ans / 2 << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	vector<vector<ll>> dp(n+2,vector<ll>(2, -1LL<<60));
	dp[0][0]=0;
	rep(i, n) {
		dp[i+1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
		dp[i+1][1] = max(dp[i][1] + a[i], dp[i][0] - a[i]);
	}
	
	cout << dp[n][0] <<"\n";
	
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define Mashu cout << "UUZ ate it." << endl
#define RE register int
#define ll long long
using namespace std;

inline int read(){
	char ch=getchar();
	int x=0,cf=1;
	while(ch<'0'||ch>'9') {
		if(ch=='-') cf=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	if (cf < 0) return -x;
	else return x;
}

int G[55];
template<class T> inline void write(T x){
	int g=0;
	do{G[++g]=x%10;x/=10;}while(x);
	for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}

long long dp[200010];
long long qzh[200010];
int l[200010], r[200010];

int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++){
		cin >> l[i] >> r[i];
	}
	dp[1] = 1;
	qzh[1] = 1;
	for (int i = 2; i <= n; i++){
		for (int j = 1; j <= k; j++){
			if (l[j] >= i) continue;
			int R = i - l[j];
			int L = max(1, i - r[j]);
			dp[i] += qzh[R] - qzh[L - 1] % 998244353;
			dp[i] %= 998244353;
		}
		qzh[i] = qzh[i - 1] + dp[i] % 998244353;
	}
	cout << dp[n] << endl; 
	return 0;
	Mashu;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 , ma ;
    cin >> num1 >> num2 ;
    ma = max (num1 , num2 ) ;

    cout << (16 / ma > 1 ? "Yay!" : ":(") ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  string s;
  cin >> s;
  ll n = s.length();
  vector < ll > a(n);
  vector < pair < char, ll > > v;
  for(int i = 0; i < n; i++){
    if(v.size() == 0){
      v.push_back({s[i], 1});
    }else if(v.back().first == s[i]){
      v.back().second++;
    }else{
      v.push_back({s[i], 1});
    }
  }

  int ind = 0;
  for(int i = 0; i < v.size(); i += 2){
    ind += v[i].second - 1;
    a[ind] = (v[i].second + 1) / 2 + (v[i + 1].second) / 2;
    a[ind + 1] = v[i].second + v[i + 1].second - a[ind];
    ind += v[i + 1].second + 1;
  }

  for(auto i : a) cout << i << " ";
  cout << '\n';
}


Measured memory_bytes: 3268
#include <stdio.h>

int main(void)
{
	int year, month, date, detail;
	
	while (scanf("%d%d%d", &year, &month, &date) != EOF){
		detail = year * 10000 + month * 100 + date;
		if (detail < 18680908){
			printf("pre-meiji\n");
		}
		else if (detail < 19120730){
			printf("meiji %d %d %d\n", year - 1867, month, date);
		}
		else if (detail < 19261225){
			printf("taisho %d %d %d\n", year - 1911, month, date);
		}
		else if (detail < 19890108){
			printf("showa %d %d %d\n", year - 1925, month, date);
		}
		else {
			printf("heisei %d %d %d\n", year - 1988, month, date);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl a(5);
	cin>>a;
	puta(min(a[0]*a[4],a[1]+a[3]*max(0,a[4]-a[2])));
	return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;
import java.util.Arrays;

class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int aa;
		int bb;

		if (a > 0) {
			aa = 1;
		} else if (a == 0) {
			aa = 0;
		} else {
			aa = -1;
		}
		if (b > 0) {
			bb = 1;
		} else if (b == 0) {
			bb = 0;
		} else {
			bb = -1;
		}
		if (aa == 1 && bb == 1) {
			System.out.println("Positive");
		} else if (aa == -1 && bb == 1) {
			System.out.println("Zero");
		} else if (aa == 0 || bb == 0) {
			System.out.println("Zero");
		} else if (aa == -1 || bb == -1) {
			if(Math.abs(b-a) % 2 == 0){
				System.out.println("Negative");
			}else{
				System.out.println("Positive");
			}
		}
		in.close();

	}

}

Measured memory_bytes: 9936
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2000050;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

ll num[maxn];
int n;
ll solve()
{

    ll temp = 0;
    if(num[1]!=0)
    {
        return -1;
    }

    for(int i=2; i<=n; i++)
    {
        if(num[i] >= i || num[i]-num[i-1]>1)
            return -1;

        if(num[i]>num[i-1])
        {
            if(num[i]-num[i-1]==1)
                temp++;
            else return -1;
        }
        else
        {
            temp+=num[i];
        }
    }
    return temp;

}
int main()
{

    scanf("%d",&n);

    num[0]=0;
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&num[i]);

    }

    cout<< solve()<<endl;

    return 0;
}




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

int main() {
  int N;
  cin >> N;
  int M = N;
  int dig = 0;
  int count = 0;
  for(int i = 0;i < 10;i++) {
    dig = N % 10;
    count = count + dig;
    N = N / 10;

  }
  if(M % count == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N){
        cin >> A.at(i);
    }

    vector<ll> right(N);
    REP(i, N){
        right.at(i) = i + 1;
    }
    REP(i, M){
        ll l, r;
        cin >> l >> r;
        l--; r--;
        right.at(l) = max(right.at(l), r + 1);
    }
    for(ll i = 1; i < N; ++i){
        right.at(i) = max(right.at(i - 1), right.at(i));
    }

    vector<array<ll, 2>> dp(N);
    for(ll i = N - 1; i >= 0; --i){
        if(i == N - 1){
            dp.at(i).at(0) = 0;
        }else{
            dp.at(i).at(0) = max(
                dp.at(i + 1).at(0),
                dp.at(i + 1).at(1)
            );
        }
        const ll r = right.at(i);
        if(r >= N){
            dp.at(i).at(1) = A.at(i);
        }else{
            dp.at(i).at(1) = A.at(i) + max(
                dp.at(r).at(0),
                dp.at(r).at(1)
            );
        }
    }

    cout << max(dp.at(0).at(0), dp.at(0).at(1)) << endl;
    return 0;
}



Measured memory_bytes: 8848
package main
import (
  "fmt"
  "math"
)

func main() {
  var (
    x float64
    a float64
    b float64
  )
  fmt.Scan(&x)
  fmt.Scan(&a)
  fmt.Scan(&b)

  if math.Abs(x - a) > math.Abs(x - b) {
    fmt.Println("B")
  } else {
    fmt.Println("A")
  }
}


Measured memory_bytes: 512
fn main() {
    let (h, w): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut map = vec![];
    for i in 0..h {
        let s: Vec<char> = read::<String>().chars().collect();
        map.push(s);
    }
    let mut memo = vec![vec![0; w]; h];
    for i in 0..h {
        if map[i][0] == '.' {
            memo[i][0] = 1;
        } else {
            break;
        }
    }
    for i in 0..w {
        if map[0][i] == '.' {
            memo[0][i] = 1;
        } else {
            break;
        }
    }
    for i in 1..h {
        for j in 1..w {
            if map[i][j] == '.' {
                memo[i][j] = (memo[i - 1][j] + memo[i][j - 1]) % MOD;
            }
        }
    }
    // for i in 0..h {
    //     println!("{:?}", memo[i]);
    // }
    println!("{}", memo[h - 1][w - 1]);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main(){
    int n;
    cin >> n;
    bool ok = false;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ok |= (i*j == n);
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-6;
struct node{
	double x,y;
}g[N];
ll a[N],b[N],c[N],ans;
priority_queue<ll>q;
bool cmp(ll a,ll b)
{
	return a>b;
}
vector<ll>v;
int main()
{
	int x,y,na,nb,nc;
	scanf("%d%d%d%d%d",&x,&y,&na,&nb,&nc);
	for(int i=0;i<na;i++)scanf("%lld",&a[i]);
	for(int i=0;i<nb;i++)scanf("%lld",&b[i]);
	for(int i=0;i<nc;i++)
	{
		ll x;
		scanf("%lld",&x);
		q.push(x);
	}
	sort(a,a+na,cmp);
	sort(b,b+nb,cmp);
	for(int i=0;i<x;i++)
	{
		ans+=a[i];
		v.push_back(a[i]);
	}
	for(int i=0;i<y;i++)
	{
		ans+=b[i];
		v.push_back(b[i]);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(q.empty())break;
		ll t=q.top();q.pop();
		if(t>v[i])ans=ans-v[i]+t;
		else break;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4724
#include<iostream>
#include<map>
using namespace std;
main()
{
    //fast
    int tc=1,i,j,k;
    map<string,int>mp;
    cin>>tc;
    while(tc--)
    {
       string s;
       cin>>s;
       mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
     cout<<"WA x "<<mp["WA"]<<endl;
      cout<<"TLE x "<<mp["TLE"]<<endl;
       cout<<"RE x "<<mp["RE"]<<endl;

}




Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

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

const int mod = 1000000007;
vector<int> G[5005];
int f[5005][5005], g[5005], tmp[5005], n, sz[5005];

void dfs(int u, int fa)
{
	f[u][sz[u] = 1] = 1;
	for (auto v : G[u])
	{
		if (v != fa)
		{
			dfs(v, u);
			for (int i = 1; i <= sz[u] + sz[v]; i++) tmp[i] = 0;
			for (int i = 1; i <= sz[u]; i++)
			{
				for (int j = 0; j <= sz[v]; j++)
				{
					tmp[i + j] = (tmp[i + j] + 1ll * f[u][i] * f[v][j] % mod) % mod;
				}
			}
			for (int i = 1; i <= sz[u] + sz[v]; i++) f[u][i] = tmp[i];
			sz[u] = sz[u] + sz[v];
		}
	}
	for (int i = 2; i <= sz[u]; i = i + 2) f[u][0] = (f[u][0] + mod - 1ll * f[u][i] * g[i] % mod) % mod;
}

int main()
{
	g[0] = 1, n = gi();
	for (int i = 2; i <= n; i = i + 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
	for (int i = 1; i < n; i++)
	{
		int x = gi(), y = gi();
		G[x].push_back(y), G[y].push_back(x);
	}
	dfs(1, 0);
	printf("%d\n", mod - f[1][0]);
	return 0;
}


Measured memory_bytes: 97408
package main

import "fmt"

func main() {
	var o, e string

	fmt.Scanln(&o)
	fmt.Scanln(&e)
	//fmt.Println(o, e)
	for i := 0; i < len(o) || i < len(e); i++ {
		if i < len(o) {
			fmt.Print(string([]byte{o[i]}))
		}
		if i < len(e) {
			fmt.Print(string([]byte{e[i]}))
		}
	}
	fmt.Println()
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int highest(int x) {
  while (x >= 10) x /= 10;
  return x;
}

ll cnt[10][10];

int main() {
  CIN(int, N);
  for (int i = 1; i <= N; ++i) {
    ++cnt[i % 10][highest(i)];
  }
  ll ans = 0;
  REP(i, 10) REP(j, 10) ans += cnt[i][j] * cnt[j][i];
  COUT(ans);
}


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

using namespace std;

#define ll long long

signed main() {
	ll a, b;
	a = 1; b = 0;
	int n; cin >> n;
	while (n--) {
		int q, x;
		cin >> q >> x;
		if (q == 1) {
			a *= x; b *= x;
		}
		else if (q == 2)
			b += x;
		else
			b -= x;
	}

	cout << (-b) << " " << a << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#define MAXN 305
using namespace std;

int n, a[MAXN][MAXN];
bool del[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            cin >> a[i][j];

    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i == k)
                continue;

            for (int j = 1; j <= n; ++j) {
                if (j == k)
                    continue;

                if (a[i][k] + a[k][j] < a[i][j]) {
                    cout << "-1\n";
                    return 0;
                }
                if (a[i][k] + a[k][j] == a[i][j]) {
                    del[i][j] = 1;
                }
            }
        }
    }

    long long sol = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (!del[i][j])
                sol += a[i][j];

    cout << sol << "\n";

    return 0;
}

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

int main() {
  int N, D, X;
  int A[100];
  cin >> N;
  cin >> D >> X;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int A_eat[100];
  for (int i = 0; i < N; i++) {
    A_eat[i] = 1 + ((D - 1) / A[i]);
  }
  int tot = X;
  for (int i = 0; i < N; i++) {
    tot += A_eat[i];
  }
  cout << tot << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
  }
  int ans = 0, cnt = 0, now = 1;
  REP(i, N){
    if(a[i] == now){
      ans += cnt;
      cnt = 0;
      now++;
    }else{
      cnt++;
    }
  }
  ans += cnt;
  if(cnt == N){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}

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

//関数
//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin>>s.at(i);
    }
    //計算
    long ans=0;
    long l=0,r=0,lr=0;//hasi
    for(int i=0;i<N;i++){
        bool waiting =false;
        for(int j=0;j<s.at(i).size();j++){
            if(s.at(i).at(j)=='B' && waiting) ans++;
            waiting =(s.at(i).at(j)=='A');
        }
        if(s.at(i).at(0)=='B' && s.at(i).at(s.at(i).size()-1)=='A'){
            lr++;
        }else if(s.at(i).at(0)=='B'){
            l++;
        }else if(s.at(i).at(s.at(i).size()-1)=='A'){
            r++;
        }
    }
   // cout<<ans<<" "<<l<<" "<<r<<" "<<lr<<endl;
    
    if(lr>0){
        ans+=lr-1;
        if(l>0){
            ans++;
            l--;
        }
        if(r>0){
            ans++;
            r--;
        }
        ans+=min(r,l);
    }else{
        ans+=min(r,l);
    }

    
    
    

    //出力
    cout<<ans<<endl;//" "<<l<<" "<<r<<endl;
}

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

int main() {
  int N;
  cin>>N;
  int y;
  cin>>y;
  int z=y%2;
  
  int k=0;
  
  while(z==0){
    y/=2;
    z=y%2;
    k++;
  }
  
  for(int i=1;i<N;i++){
    int j=0;
    int A;
    cin>>A;
    int x=A%2;
    
    while(x==0){
      A/=2;
      x=A%2;
      j++;
    }
    
    if(j<k){
      k=j;
    }
  }
  
  cout<<k<<endl;
}


Measured memory_bytes: 256