akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
long long arr[45], x[1005], y[1005];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, y + i);
		if ((x[i] + y[i] & 1) ^ (x[0] + y[0] & 1)) {
			puts("-1");
			return 0;
		}
	}
	int m = 40;
	arr[m - 1] = arr[m - 2] = arr[m - 3] = arr[m - 4] = 1;
	for (int i = m - 5; i >= 0; i--)
		arr[i] = arr[i + 1] << 1;
	if (x[0] + y[0] & 1)
		m--;
	printf("%d\n", m);
	for (int i = 0; i < m; i++)
		printf("%lld%c", arr[i], " \n"[i + 1 == m]);
	auto abs = [&] (auto x) { return x < 0 ? -x : x; };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (abs(x[i]) <= abs(y[i])) {
				putchar(y[i] <= 0 ? 'D' : 'U');
				y[i] += arr[j] * (y[i] <= 0 ? 1 : -1);
			} else {
				putchar(x[i] <= 0 ? 'L' : 'R');
				x[i] += arr[j] * (x[i] <= 0 ? 1 : -1);
			}
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
     int x,a,b;
     cin>>x>>a>>b;
      if(a<b&&b-a<=x)
           cout<<"safe"<<endl;
      else if(a>=b)
           cout<<"delicious"<<endl;
      else if(a<b&&b-a>=x)
            cout<<"dangerous"<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
typedef long long I;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

int mo[10];

int main()
{
	REP(i, 10){
		cin >> mo[i];
	}
	sort(mo, mo + 10);

	cout << mo[9] << endl;
	cout << mo[8] << endl;
	cout << mo[7] << endl;

	return 0;
}

Measured memory_bytes: 1172
#include<iostream>

using namespace std;

int main(){
	int N, ans, count;
	while(1){
		cin >> N;
		if(!N) break;
		count=0;
		for(int i=1;i<N;++i){
			ans=0;
			for(int j=i;j<N;++j){
				ans+=j;
				if(ans == N) count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;
const int m=1e5+60;
long long pom[m];
long long odp[m];

int main(){
  ios_base::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  vector<long long> v;
  v.push_back(n);
  for(int i=0;i<q;i++) {
    long long in;
    cin>>in;
    while(v.back()>=in && !v.empty())v.pop_back();
    v.push_back(in);
  }
 // cout<<"co jest" << v.size()-1<<endl;
  int siz=v.size()-1;
  pom[siz]=1;
  int p;
  for(int i=siz;i>0;i--) {
    long long k=v[i];
    while(k>v[0]){
      p=lower_bound(v.begin(),v.begin()+i,k)-v.begin()-1;
      pom[p]+=pom[i]*(k/v[p]);
      k=k%v[p];
    }
    odp[k-1]+=pom[i];
  }
  odp[v[0]-1]+=pom[0];
  for(int i=n-1;i>=0;i--) {
    odp[i]+=odp[i+1];
  }
  for(int i=0;i<n;i++) {
    cout<<odp[i]<<endl;
  }
}


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int x[N], y[N], a[N];
  rep(i, N) {
    cin >> x[i] >> y[i] >> a[i];
  }

  int up = H, bottom = 0, left = 0, right = W;
  bool flag = true;

  rep(i, N) {
    switch (a[i]) {
      case 1:
        left = max(left, x[i]);
        break;
      case 2:
        right = min(right, x[i]);
        break;
      case 3:
        bottom = max(bottom, y[i]);
        break;
      case 4:
        up = min(up, y[i]);
        break;
      default:
        break;
    }

    if (left >= right || bottom >= up) {
      flag = false;
      break;
    }
  }

  cout << ( flag ? (right-left)*(up-bottom) : 0 ) << endl;
}


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

int main() {
  int N; cin >> N;
  bool ex = false;
  for (int i = 0; i < N / 4 + 1; i++) {
    for (int j = 0; j < N / 7 + 1; j++) {
      if (4 * i + 7 * j == N) {
        ex = true;
      }
    }
  }
  if (ex == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#かつてAC

import math

def culc(t):
    return math.degrees(math.atan(t))

a,b,x=map(int,input().split())
V=a**2*b

if x>=V/2:
    T=2*((b/a)-(x/(a**3)))
    print(culc(T))
else:
    T=(a*(b**2))/(2*x)
    print(culc(T))



Measured memory_bytes: 9248
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1010

const ll INF = 1e17 + 7;
const int MOD = 1e9 + 7;

int main() {

	int w, h;
	cin >> w >> h;
	vector<int> a(w), b(h);
	int sum_a = 0, sum_b = 0;

	for (int i = 0; i < w; i++)
	{
		cin >> a[i];
		sum_a += a[i];
	}

	for (int i = 0; i < h; i++)
	{
		cin >> b[i];
		sum_b += b[i];
	}

	if (sum_a != sum_b)
	{
		cout << "0" << endl;
		return 0;
	}

	sort(a.begin(), a.end(), greater<int>());


	for (int i = 0; i < w; i++)
	{
		sort(b.begin(), b.end(), greater<int>());
		for (int j = 0; j < a[i]; j++)
		{
			if (b[j] > 0)
			{
				b[j]--;
			}
			else
			{
				cout << "0" << endl;
				return 0;
			}
		}
	}
	cout << "1" << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  vector<ll> arr(N);
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  int i = 0;
  while (i < N) {
    while (i < N-1 && arr[i] == arr[i+1]) {
      i++;
    }
    if (i < N-1 && arr[i] < arr[i+1]) {
      while (i < N-1 && arr[i] <= arr[i+1]) {
        i++;
      }
    }
    else if (i < N-1 && arr[i] > arr[i+1]) {
      while (i < N-1 && arr[i] >= arr[i+1]) {
        i++;
      }
    }
    ans++;
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
const long long MOD = 1000000007;
int main(){
  long long N;
  long long K;
  cin >> N >> K;

  long long ans = 0;
  for(long long i = K; i <= N + 1; i++){
    long long min_sum = i * (i - 1) / 2;
    long long max_sum = (2 * N - i + 1) * i / 2;
    //cout << i << " " << min_sum << " " << max_sum << endl;
    ans = (ans + (max_sum - min_sum + 1)) % MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int max( int a, int b )
{
    return a > b ? a : b;
}

struct Tree
{
    int p, s, deg, dep, h;
    vector<int> c;
    string k;
};

int getHeight( Tree* t, Tree a )
{
    if( a.c[0] == -1 && a.c[1] == -1 )
        return 0;
    else if( a.c[0] == -1 )
        return getHeight( t, t[a.c[1]] ) + 1;
    else if( a.c[1] == -1 )
        return getHeight( t, t[a.c[0]] ) + 1;
    else
        return max( getHeight( t, t[a.c[1]] ) + 1, getHeight( t, t[a.c[0]] ) + 1 );
}

int main()
{
    Tree t[25];
    int n, a, b, c;

    cin >> n;

    for( int i = 0; i < 25; i++ )
        t[i].p = -1;

    for( int i = 0; i < n; i++ )
    {
        cin >> a >> b >> c;
        t[b].p = a;
        t[c].p = a;
        t[a].c.push_back(b);
        t[a].c.push_back(c);
    }

    for( int i = 0; i < n; i++ )
    {
        //兄弟
        if( t[i].p != -1 )
            t[i].s = ( i == t[t[i].p].c[0] ) ? t[t[i].p].c[1] : t[t[i].p].c[0];

        //ノードタイプ
        if( t[i].p == -1 )
        {
            t[i].k = "root";
            t[i].s = -1;
        }
        else if( t[i].c[0] + t[i].c[1] == -2 )
            t[i].k = "leaf";
        else
            t[i].k = "internal node";

        //子の数
        t[i].deg = ( t[i].c[0] == -1 ? 0 : 1 ) + ( t[i].c[1] == -1 ? 0 : 1 );

        //深さ
        int cnt = 0, parent = t[i].p;
        while( parent != -1 )
        {
            parent = t[parent].p;
            cnt++;
        }
        t[i].dep = cnt;

        //高さ
        t[i].h = getHeight( t, t[i] );

    }

    for( int i = 0; i < n; i++ )
    {
        cout << "node " << i << ": parent = " << t[i].p << ", sibling = " << t[i].s << ", degree = " << t[i].deg;
        cout << ", depth = " << t[i].dep << ", height = " << t[i].h << ", " << t[i].k << endl;
    }

    return 0;
}


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

int main()
{
    long long int h, w, n, cnt = 0;
    cin >> h >> w >> n;
    vector<long long int> a(n);
    for(long long int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    
    vector<vector<long long int>> ans(h);
    for(long long int i = 0;i < h;i++){
        vector<long long int> ansd(w);
        ans[i] = ansd;
        if(i % 2 == 0){
            for(long long int j = 0;j < w;j++){
                ans[i][j] = cnt + 1;
                a[cnt]--;
                if(a[cnt] == 0){
                    cnt++;
                }
            }
        }
        else{
            for(long long int j = w - 1;j >= 0;j--){
                ans[i][j] = cnt + 1;
                a[cnt]--;
                if(a[cnt] == 0){
                    cnt++;
                }
            }
        }
    }

    for(long long int i = 0;i < h;i++){
        for(long long int j = 0;j < w;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

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

signed main(){
  string s; cin >> s;
  lint K; cin >> K;
  lint counter = 0;
  for(lint i = 0; i < s.size(); i++){
    if(s[i] == 'a') continue;
    lint need = lint('z' - s[i]) + 1;
    if(counter + need <= K){
      s[i] = 'a'; counter += need;
    }
  }
  s[s.size() - 1] = char(s[s.size() - 1] + ((K - counter) % 26));
  cout << s << endl;
}

Measured memory_bytes: 512
#include<cstdio>
static const int MAX = 100;
#define SENTINEL  2000000000
int nonpaired = -1;
int paired = 1;

struct Point
{
    int x;
    int y;
    int state;
};

Point Red[MAX];
Point Blue[MAX];

void BlueMerge(int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    Point L[MAX/2 + 2], R[MAX/2 + 2];

    for (int i = 0; i < n1; i++) 
    {
        L[i] = Blue[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = Blue[mid + i];
    }
    L[n1].x = R[n2].x = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        if (L[i].x <= R[j].x)
        {
            Blue[k] = L[i];
            i++;
        }
        else
        {
            Blue[k] = R[j];
            j++;
        }
    }
}

void MergeSortBP(int n, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        MergeSortBP(n, left, mid);
        MergeSortBP(n, mid, right);
        BlueMerge(n, left, mid, right);
    }
}

void RedMerge(int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    Point L[MAX/2 + 2], R[MAX/2 + 2];

    for (int i = 0; i < n1; i++) 
    {
        L[i] = Red[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = Red[mid + i];
    }
    L[n1].y = R[n2].y = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        if (L[i].y <= R[j].y)
        {
            Red[k] = L[i];
            i++;
        }
        else
        {
            Red[k] = R[j];
            j++;
        }
    }
}

void MergeSortRP(int n, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        MergeSortRP(n, left, mid);
        MergeSortRP(n, mid, right);
        RedMerge(n, left, mid, right);
    }
}


int main()
{
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d%d", &Red[i].x, &Red[i].y);
        Red[i].state = nonpaired;
    }
    for (int i = 0; i < N; i++)
    {
        scanf("%d%d", &Blue[i].x, &Blue[i].y);
        Blue[i].state = paired;
    }

    MergeSortRP(N, 0, N);
    MergeSortBP(N, 0, N);

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = N - 1; j >= 0; j--)
        {
            if (Red[j].state == nonpaired && Red[j].x < Blue[i].x && Red[j].y < Blue[i].y)
            {
                Red[j].state = paired;
                count++;
                break;
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=b[a[0]-1]

for i in range(1,n):
  ans+=b[a[i]-1]
  if a[i]==a[i-1]+1:
    ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 61540
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int n, m;
vector<pii> s(10010);

int main(){
	cin >> n >> m;
	while(n){
		rep(i, n){
			int d, p; cin >> d >> p;
			s[i] = pii(d, p);
		}
		sort(s.begin(), s.begin()+n, [](const pii &a, const pii &b){return a.se > b.se;});
		rep(i, n){
            if(m == 0) break;
			else if(s[i].fi <= m){
				m -= s[i].fi;
				s[i] = pii(0, s[i].se);
			}
			else{
				s[i] = pii(s[i].fi-m, s[i].se);
				m = 0;
			}
		}
		int ans = 0;
		rep(i, n) ans += s[i].fi * s[i].se;
		cout << ans << endl;
		cin >> n >> m;
	}
}



Measured memory_bytes: 3072
n, k = gets.chomp.split().map(&:to_i)
s = gets.chomp.split(//)

ans = 0
els = 0
(n-1).times do |i|
  if s[i] == s[i+1]
    ans += 1
  else
    els += 1
  end
end

puts ans + [els, k * 2].min


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

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a,b = map(int, input().split())
    x=
    A.append(a)
    B.append(b)'''

n=int(input())
h=list(map(int,input().split()))
cnt=0
while sum(h)>0:
    pv=0
    pone=0
    for i in range(n):
        if h[i]!=0 and pv==0:# 最初に1確定
            pone+=1
        pv=h[i]
    cnt+=pone
    h=[i-1 if i>0 else 0 for i in h]
    #print(h,cnt)
print(cnt)
        




Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const ll INF = (1ll << 60) - 1;

int n,E,T;
int head,tail;
int Q[MAXN];

ll MIN;
ll x[MAXN];
ll f[MAXN];
ll g1[MAXN];
ll g2[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> E >> T;
	for (int i = 1;i <= n;i++)
		cin >> x[i];
	MIN = INF;
	head = tail = 1;
	g1[0] = -2 * x[1];
	g2[0] = T;
	for (int i = 1,j = -1;i <= n;i++)
	{
		while (j + 1 < i && 2 * (x[i] - x[j + 2]) >= T)
			MIN = min(MIN,g1[++j]);
		while (head <= tail && Q[head] <= j)
			head++;
		f[i] = MIN + 3 * x[i];
		if (head <= tail)
			f[i] = min(f[i],g2[Q[head]] + x[i]);
		g1[i] = f[i] - x[i] - 2 * x[i + 1];
		g2[i] = f[i] - x[i] + T;
		while (head <= tail && g2[Q[tail]] >= g2[i])
			tail--;
		Q[++tail] = i;
	}
	cout << f[n] + E - x[n] << endl;
	return 0;
}

Measured memory_bytes: 3840
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int cnt[] = new int[26];
        for (int i = 0; i < h; i++) {
            String a = sc.next();
            for (int j = 0; j < w; j++) {
                cnt[a.charAt(j) - 'a']++;
            }
        }

        cnt = Arrays.stream(cnt).filter(n -> n != 0).toArray();

        System.out.println(check(h, w, cnt) ? "Yes" : "No");
    }

    private boolean check(int h, int w, int cnt[]) {
        if (Arrays.stream(cnt).filter(n -> n % 2 == 1).count() > 1) {
            return false;
        }

        long center = h % 2 * w + w % 2 * h - (h % 2 * w % 2);
        long cnt2 = Arrays.stream(cnt).filter(n -> n % 4 >= 2).count();
        if (center / 2 < cnt2) {
            return false;
        }

        return true;
    }

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


Measured memory_bytes: 29140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

type Group struct {
	Depth int
	Value string
}

type Job struct {
	No     int
	S      int
	E      int
	Worker string
}

type Res struct {
	No int
}

func Abs(a int64, b int64) int64 {
	res := a - b
	if a-b < 0 {
		res = -res
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	var res int64 = 0
	for i := 1; i <= n; i++ {
		if i%3 != 0 && i%5 != 0 {
			res += int64(i)
		}
	}
	fmt.Fprintln(out, fmt.Sprint(res))
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  ll n,m;
  cin >> n >> m;
  map<ll,ll> mp;
  mp[0]++;
  ll s = 0;
  rep(i,n){
    ll a;
    cin >> a;
    s += a;
    mp[s%m] ++;
  }
  ll ans = 0;
  for(auto p : mp){
    ll now = p.second;
    ans += now*(now-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7412
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    while(n){
        int OUTPOINT=0,count=0,HITPOINT=0;
        while(OUTPOINT != 3){
            string s;
            cin >> s;
            if(s=="HIT"){
                if(HITPOINT == 3)     count++;
                else                HITPOINT++;
            }
            else if(s=="OUT")       OUTPOINT++;
            else{
                count+=++HITPOINT;
                HITPOINT=0;
            }
        }
        cout << count << endl;
        n--;
    }
}


Measured memory_bytes: 3040
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int bra = 0;
    int ket = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '(')
            bra++;
        else if (bra > 0)
            bra--;
    }
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == ')')
            ket++;
        else if (ket > 0)
            ket--;
    }
    for (int i = 0; i < ket; ++i) {
        s = "(" + s;
    }
    for (int i = 0; i < bra; ++i) {
        s = s + ")";
    }
    cout << s << "\n";
    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 y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    for (int i=0; i<n; ++i) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i=0; i<k; ++i) sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3600
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)
print(sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X+Y]))

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

#define endl '\n'
#define pb push_back
typedef vector<int> vi;

int ing[100005], dp[100005];
int n, m;
vi prec[100005], adj[100005];
vi top;

int f(int v){
  //cout << v << endl;
  if(prec[v].size()==0) return 0;
  if(dp[v]!=-1) return dp[v];
  for(auto u: prec[v]){
    dp[v]=max(dp[v], f(u)+1);
  }
  return dp[v];
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> m;

  int a, b;
  for(int i=1; i<=m; i++){
    cin >> a >> b;
    prec[b].pb(a);
    adj[a].pb(b);
    ing[b]++;
  }

  queue <int> q;
  for(int i=1; i<=n; i++) if(ing[i]==0) q.push(i), top.pb(i);

  while(!q.empty()){
   int u=q.front(); q.pop();
   for(auto v: adj[u]){
     if(--ing[v]) continue;
     q.push(v), top.pb(v);
   }
  }

  /*
  for(auto v: top) cout << v << " ";
  cout << endl;
  */
  memset(dp, -1, sizeof(dp));
  int ans=-1;
  for(int i=n; i>=1; i--){
    ans=max(ans, f(i));
  }
  cout << ans << endl;
}

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

vector<int> to[250000];
vector<int> ans;

void dfs(int v, int p = -1)
{
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main(void)
{
    int n, q;
    cin >> n >> q;

    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(n);
    rep(i, q)
    {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) { cout << ans[i] << endl; }
}


Measured memory_bytes: 24704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}

i64 g(i64 r, i64 c) {
    return comb(r + c + 2, r + 1) - 1;
}

int main() {
    i64 r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    c1--;
    i64 ans = g(r2, c2) - g(r1, c2) - g(r2, c1) + g(r1, c1);
    ans += 2 * mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

r, g, b, n = map(int, read().split())
cnt = 0
for i in range(n + 1):
    for j in range(n + 1):
        check = n - (r * i + g * j)
        if check >= 0:
            if check % b == 0:
                cnt += 1
        else:
            break
print(cnt)


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, m; cin>>n>>m;
  vector<ii> a;
  vi f(n+1), mm(n+1);
  rep(i,0,m) {
    int p; string s; cin>>p>>s;
    if(mm[p] == 0 && s == "WA") {
      f[p]++;
    }
    else if(mm[p] == 1) continue;
    else if(s == "AC") {
      mm[p] = 1;
    }
  }
  lli ans1, ans;
  ans1 = ans = 0;
  rep(i,1,n+1) {
    if(mm[i]) {
      ans += f[i];
      ans1++;
    }
  }
  cout<<ans1<<" "<<ans<<endl;
}



Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> S;
    S[5] = ' ';
    S[13] = ' ';
    cout << S << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

A,B,C = (int(x) for x in input().rstrip('\n').split())
K = int(input().rstrip('\n'))
les = K
for i in range(K):
  if A>=B:
    B = B*2
    les -= 1
  else:
    break
les2 = les
for _ in range(les):
  if B>=C:
    C = C*2
    les2 -= 1
  else:
    break
if B>A and C>B:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9200
#!/usr/bin/env python3
import sys


def solve(S: str):
    if S =="ABC":
        print("ARC")
    else:
        print("ABC")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
#define fori(i,n) for(int i=0; i<n; i++)
#define itn int 
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <ll>
#define be(a) (a).begin(), (a).end()
#define size(a) (int)a.size()
#define get(a) cin >> a
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int ac=0,tle=0,wa=0,re=0;
	while (n--) 
	{
		string s;
		cin >>s;
		if (s=="AC") ac++;
		else if (s=="TLE") tle++;
		else if (s=="WA") wa++;
		else re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
	return 0;
}


Measured memory_bytes: 3652
n, k = map(int, input().split())
mod = 10 ** 9 + 7
dp = [0] * (k + 1)
ans = 0
for i in range(k, 0, -1):
    num = k // i
    dp[i] += pow(num, n, mod)

    for j in range(1, num):
        dp[i] -= dp[(j + 1) * i]
    ans += i * dp[i]
    ans %= mod
print(ans)


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

int main()
{
  long int N;
  cin>>N;
  long int a=(int)sqrt(N);
  long int b;
  while(a>=1)
  {
    if(N%a==0)
    {
      b=N/a;
      break;
    }
    a--;
  }
  cout<<a+b-2<<endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a;cin>>a;
  ld b;cin>>b;
  cout<<(ll)floor(a*b)<<endl;
  return 0;
}

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

string s,t;
int a;


int main(){
    cin>>s>>t;
    a=t.length();
    t.erase(a-1,1);
    if(s==t){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int N, M;
vector <int> G[100005];
 
bool visited[100005][3];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
//        G[b].push_back(a);
    }
 
    int S, T;
    cin >> S >> T;
 
    queue <pair<int, int>> q;
    q.push({S, 0});
 
    while(!q.empty()) {
        int v = q.front().first;
        int dis = q.front().second;
        q.pop();
        if(visited[v][dis % 3])
            continue;
        visited[v][dis % 3] = true;
        if(v == T && dis % 3 == 0) {
            cout << dis / 3 << endl;
            return 0;
        }
 
        for(auto u: G[v]) if(!visited[u][(dis + 1) % 3]) {
            q.push({u, dis + 1});
        }
    }
    cout << -1;
}
#include <bits/stdc++.h>

Measured memory_bytes: 6016
#![allow(non_snake_case)]

use std::io;
use std::collections::HashMap;
use std::collections::HashSet;
use std::cmp::max;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line.clear();
    io::stdin().read_line(&mut line).unwrap();

    let mut left = HashMap::new();
    let mut right = HashMap::new();
    let mut set = HashSet::new();
    let mut ret = 0;

    for c in line.chars() {
        *right.entry(c).or_insert(0) += 1;
    }

    for c in line.chars() {
        let remove_flag = {
            let x = right.get_mut(&c).unwrap();
            *x -= 1;
            *x == 0
        };
        if remove_flag {
            right.remove(&c);
            set.remove(&c);
        } else {
            set.insert(c);
        }
        *left.entry(c).or_insert(0) += 1;
        ret = max(ret, set.len());
    }

    println!("{}", ret);
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int s[10]={0};
 
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        for(int i=0;i<10;i++)
            scanf("%d",&s[i]);
        int a=0,b=0;
        bool flag=0;
        for(int i=0;i<10;i++)
        {
            if(s[i]<a&&s[i]<b)
            {
                flag=1;
                break;
            }
            else if(s[i]<a&&s[i]>b)b=s[i];
            else if(s[i]>a&&s[i]<b)a=s[i];
            else
            {
                a=a>b?s[i]:a;
                b=a<b?s[i]:b;
                if(a==b)a=s[i];
            }
        }
        if(flag)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
const int MOD = 1000000007;
using namespace std;
void solve(void)
{
    int n;
    cin >> n;
    cout << 2 * n / __gcd(2, n) << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>

int main(void)
{
	using namespace std;
	int data[3];
	for(int i=0; i<5; i++){
		cin >> data[i];
	}

	int W = data[0], H = data[1], x = data[2], y = data[3], r = data[4];
	if((0 <= x-r && x+r <= W) && (0 <= y-r && y+r <= H))	cout << "Yes" << endl;
	else 																									cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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 T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

double culc(int xi, int xj, int yi, int yj){
    int bs = (xi - xj) * (xi - xj) + (yi - yj) * (yi - yj);
    double distance = sqrt(bs);
    return distance;
}

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    int cnt = 0;
    int max = 0;
    rep(i, n - 1){
        if (h[i] >= h[i + 1]) cnt++;
        else cnt = 0;
        chmax(max, cnt);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
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;
typedef pair<int, int> P;

int main() {
    string s; cin >> s;
    int a = (int)(s[0]-'0')*10 + (int)(s[1]-'0');
    int b = (int)(s[2]-'0')*10 + (int)(s[3]-'0');
    bool f1 = false, f2 = false;
    if (1<=a && a<=12) f1 = true;
    if (1<=b && b<=12) f2 = true;
    if (f1 && f2) cout << "AMBIGUOUS" << endl;
    else if (f1) cout << "MMYY" << endl;
    else if (f2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int a, b, c, d, e;
    scanf("%d", &a);
    b = a / 100;
    c = a - b * 100;
    d = c / 10;
    e = c - d * 10;
    if (b == 7 || d == 7 || e == 7) {
        printf("Yes");
    }
    else {
        printf("No");
    }
}

Measured memory_bytes: 1696
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    ll ans = 0;
    vector<bool> ch(n);
    rep(i, n) {
        if(i>=k && t[i] == t[i-k]) {
            if(!ch[i-k]) {
                ch[i] = true;
                continue;
            }
        }
        switch(t[i]) {
            case 'r': 
                ans += p;
                break;
            case 's':
                ans += r;
                break;
            case 'p':
                ans += s;
        }
    }

    cout << ans << endl;
}

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

int main() {
    int s;
    cin >> s;
    set<int> st;
    st.insert(s);
    int ans = 1;
    while (true) {
        ans++;
        s % 2 == 0 ? (s /= 2) : (s = 3 * s + 1);
        if (st.count(s)) {
            cout << ans << endl;
            break;
        } else st.insert(s);
    }
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int n; cin >> n;
    vector<ll> A(n), B(n), C(n);
    REP(i,n) cin >> A[i]; REP(i,n) cin >> B[i]; REP(i,n) cin >> C[i];
    SORT(A); SORT(B); SORT(C);

    ll ans = 0;
    REP(i,n){
        ll l=-1, r=n, c=(l+r)/2;
        while(r-l > 1){
            if(B[i] > A[c]) l = c;
            else r = c;
            c = (l+r)/2;
        }
        ll n1 = r;
        l=-1; r=n; c=(l+r)/2;
        while(r-l > 1){
            if(B[i] >= C[c]) l = c;
            else r = c;
            c = (l+r)/2;
        }
        ll n2 = n-r;
        ans += n1*n2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
import Control.Monad

main = do
  [n, m] <- map read . words <$> getLine
  xs <- replicateM m (map read . words <$> getLine)
  let x = concat xs
  print $ func x 1 n

func :: [Int] -> Int -> Int -> Int
func [] a b = if (a <= b)
              then b - a + 1
              else 0
func (x:y:xs) a b = func xs na nb
  where
    na =
      if a > x
        then a
        else x
    nb =
      if b < y
        then b
        else y


Measured memory_bytes: 73084
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		String c=sc.next();
		
		System.out.println("A"+b.charAt(0)+"C");	
	}
	
}

Measured memory_bytes: 21968
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
     	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	int e = sc.nextInt();
        int order[] = {a,b,c,d,e};
      	Integer time[] = new Integer[order.length];
      	int total = 0;
      
      	//時間の1の位求める
      	for(int i = 0; i < order.length; ++i){
        	time[i] = order[i]%10;
          	order[i] = order[i]-time[i];
        }
      	
      	//時間を足す
      	for(int i = 0; i < time.length; ++i){
          int amari=0;
          	if(time[i]!=0){
          		amari = 10-time[i];
            }
          	total = total+order[i]+time[i]+amari;
        }
      	//最後の時間に余りを引く
      	Arrays.sort(time);
      
      	if(time[0]!=0){
      		total = total - (10-time[0]);
          	 //調理時間出力
      		System.out.println(total);
         }else if(time[1]!=0){
          	total = total - (10-time[1]);
          	System.out.println(total);
         }else if(time[2]!=0){
          	total = total - (10-time[2]);
          	System.out.println(total);
         }else if(time[3]!=0){
          	total = total - (10-time[3]);
          	System.out.println(total);
         }else if(time[4]!=0){
          	total = total - (10-time[4]);
          	System.out.println(total);
         }else if(time[4]==0){
          	System.out.println(total);
        }
      
    }
}

Measured memory_bytes: 35820
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
s=list(input())
ans=0
for i in range(1,n):
    s1=set(s[:i])
    s2=set(s[i:])
    s1=s1.intersection(s2)
    ans=max(ans,len(s1))
print(ans)

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

fact={}
i = 2
while n != 1:
    if n % i == 0:
        n = n/i
        if i in fact:
            fact[i] += 1
        else:
            fact[i] = 1
    else:
        i += 1
    if i > (n**(1/2)+1):
        if n in fact:
            fact[n] += 1
        else:
            fact[n] = 1
        break

if fact == {}:
    print(0)
else:
    ans = 0
    for v in fact.values():
        #print(v)
        for i in range(1,v+1):
            if v - i >= 0:
                ans +=1
                v = v-i
    print(ans)

Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,m;
	cin >> n >> m;
	vector <ll> factors;
	factors.push_back(1);
	factors.push_back(m);
	for(ll i = 2 ; i*i <= m ; i++)
	{
		if(m % i == 0)
		{
			if(i != m/i)
			{
				factors.push_back(m/i);
			}
			factors.push_back(i);
		}
	}
	sort(factors.begin(),factors.end());
	ll ans;
	for(auto i = 0 ; i < factors.size() ; i++)
	{
	//	cout << factors[i] << endl;
		if(n*factors[i] <= m)
			ans = factors[i];
	}
	cout << ans;
}

Measured memory_bytes: 256
while True:
    N = int(input())
    if N == 0:
        exit()
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        dp = [0 for i in range(0, N+1)]
        dp[0] = 1
        dp[1] = dp[0]
        dp[2] = dp[0]+dp[1]
        for i in range(3, N+1):
            dp[i] = dp[i-3]+dp[i-2]+dp[i-1]
        ans = dp[N]//3650
        if dp[N] % 3650 == 0:
            print(ans)
        else:
            print(ans+1)



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

ll MOD = 1e9 + 7;

ll calc(ll x) {
  if (x == 0) return 1;
  if (x == 1) return 2;
  ll ans = calc(x / 2);
  ans = (ans * ans) % MOD;
  if (x % 2 == 1) ans = (ans * 2) % MOD;
  return ans;
}

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

  ll N; cin >> N;
  vector<ll> C(N); for (ll i = 0; i < N; i++) cin >> C[i];
  sort(C.begin(), C.end());

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll M = N - i;
    ll temp = ((N - i - 1) * calc(2 * N - 2)) % MOD;
    temp = (temp + calc(2 * N - 1)) % MOD;
    temp = (temp * C[i]) % MOD;
    ans = (ans + temp) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
k = gets.to_i
ary = (1..9).to_a
a = 0

k.times do 
	a = ary.shift
	b = a % 10
	ary << 10 * a + b - 1 if b != 0
	ary << 10 * a + b
	ary << 10 * a + b + 1 if b != 9
end

puts a


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s; cin >> s;
  LL n = s.size();
  map<char, int> mp;
  rep(i, n) mp[s[i]] ++;

  LL sum = 0;
  for (auto x : mp) {
    LL t = x.second;
    sum += t * (t - 1) / 2;
  }

  LL ans = n * (n - 1) / 2 - sum + 1;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    string S;

    cin >> S;

    int a_cnt = 0, b_cnt = 0;

    for (const auto c : S) {
        if (c == 'A') a_cnt++;
        if (c == 'B') b_cnt++;
    }

    if (a_cnt == S.length() || b_cnt == S.length()) cout << "No";
    else cout << "Yes";


    return 0;
}



Measured memory_bytes: 256