akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr double EPS = 1e-9;

struct point {
	double x, y;
	explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
	point(const point &p):x(p.x), y(p.y) {}

	point operator+(const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y);
	}

	point operator*(double s) const {
		return point(x * s, y * s);
	}
};

double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

double abs(const point &p) {
	return sqrt(norm(p));
}

double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

istream &operator>>(istream &is, point &p) {
	return is >> p.x >> p.y;
}

// ax^2 + bx + c = 0
vector<double> solve_quadratic_equation(double a, double b, double c) {
	if(abs(a) <= EPS) {
		if(abs(b) <= EPS) {
			if(abs(c) <= EPS) return {0};
			return {};
		}
		return {-c / b};
	}

	const double d = b * b - 4 * a * c;
	if(d < -EPS) return {};

	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

double collision_time(const point &a, const point &va, const point &b, const point &vb, double r) {
	const point d_p = a - b;
	const point d_v = va - vb;
	const double l = norm(d_v);
	const double m = 2 * dot(d_p, d_v);
	const double n = norm(d_p) - r * r;

	double res = INT_MAX;
	for(const auto &e : solve_quadratic_equation(l, m, n)) {
		if(e > EPS && res - EPS > e) {
			res = e;
		}
	}

	return res;
}

double calc(point p, point v, point g) {
	if(g.x == -1) {
		swap(g.x, g.y);
		swap(p.x, p.y);
		swap(v.x, v.y);
	}

	if(abs(v.x) < EPS) return INT_MAX;

	const double res = (g.x - p.x) / v.x;
	return res > EPS ? res : INT_MAX;
}

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

	for(int n; cin >> n && n;) {
		int w, h, r;
		point v;
		cin >> w >> h >> r >> v;

		vector<point> balls(n);
		for(auto &e : balls) cin >> e;

		const array<point, 4> table{{point(r, -1), point(-1, r), point(w - r, -1), point(-1, h - r)}};
		double rest_time = 10000 / abs(v);

		while(true) {
			double min_time = rest_time;
			int idx = -1;

			for(const auto &g : table) {
				const double t = calc(balls.front(), v, g);
				if(min_time - EPS > t) {
					min_time = t;
					idx = 0;
				}
			}

			for(int i = 1; i < n; ++i) {
				const double t = collision_time(balls.front(), v, balls[i], point(0, 0), r + r);
				if(min_time - EPS > t) {
					min_time = t;
					idx = i + 1;
				}
			}

			if(idx) {
				cout << idx << endl;
				break;
			}

			rest_time -= min_time;
			balls.front() = balls.front() + v * min_time;

			for(int i = 0; i < 4; ++i) {
				if((i & 1)) {
					if(abs(balls.front().y - table[i].y) < EPS) v.y = -v.y;

				}
				else {
					if(abs(balls.front().x - table[i].x) < EPS) v.x = -v.x;
				}
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1248
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
res = 0
for x,y in zip(a,b):
    if x > y:
        res += x-y
    elif x < y:
        res -= (y-x)//2
# print(res)
print('No' if res > 0 else 'Yes')

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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int n;
    cin >> n;
    int f = 0;
    for (int i = 1; i <= n; i++)
    {
        f = 0;
        if (i % 3 == 0)
            f = 1;
        else
        {
            int x = i;
            while (true)
            {
                if (x % 10 == 3)
                {
                    f = 1;
                    break;
                }
                else
                {
                    x /= 10;
                    if (x == 0)
                        break;
                }
            }
        }
        if (f == 1)
            cout << " " << i;
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();	//賞味期限+x+1日でお腹を壊す
		int a = sc.nextInt();	//賞味期限のa日前に買った
		int b = sc.nextInt();	//買ってからb日後に食べた
		
		if(b - a <= 0){
			//賞味期限内に食べた
			System.out.println("delicious");
		}else if(b - a <= x){
			//お腹は壊さない
			System.out.println("safe");
		}else{
			System.out.println("dangerous");
		}	
	}
}

Measured memory_bytes: 23252
use std::str::FromStr;
use std::string::String;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn dfs(length : u32, cur_len : u32, s : String, num_str : u8) {
    if length == cur_len {
        println!("{}", s);
        return;
    }

    for i in 0..num_str+1 {
        let c : char = ('a' as u8 + i) as char;
        let mut ts = s.to_string();
        ts.push(c);
        dfs(length, cur_len+1, ts, if i == num_str {num_str+1} else {num_str});
    }
    return;
}

fn main() {
    let n : u32 = get_one();
    dfs(n,1,"a".to_string(),1);
}


Measured memory_bytes: 5500
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >



void solve(){
    ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
    char c;
    cin>>c;
    if(c >= 'A' && c <= 'Z'){
        cout<<"A\n";
    }
    else{
        cout<<"a\n";
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    /* ll t;
    cin>>t;
    while(t--){ */
        solve();
    /* } */

}


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

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());

        // 主処理
        int[] abc = new int[] { a, b, c };
        Arrays.sort(abc);

        int result = abc[0] + abc[1] + (abc[2] * 10);

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    
    while(true){
        int n, x;
        cin >> n >>x;

        if(n == 0 && x == 0) break;
        int res = 0;    
    
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k == x) res++;
                }
            }
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(b - a == c - b) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
}

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

using namespace std;

long long int GetDigit(long long int num){
    return log10(num)+1;
}
int  main() {
    ios::sync_with_stdio(false);
    long long int N;
    cin >> N;

    if (N == 1) {
        cout << "1" << endl;
        return 0;
    }

    // 2 から ルートa
    long long int iLimit = (long long int) sqrt(N), mxI=0;
    for (long long int i = 2; i <= iLimit; i++) {
        if (N % i == 0){
            mxI = i;
        }
    }
    long long int a=1,b=N;
    if(mxI!=0){
        a = N/mxI;
        b = mxI;
    }
    cout << max(GetDigit(a),GetDigit(b)) << endl;

    return 0;
}


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


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

	vector<string> v[15];
	v[1].push_back("a");
	for(int i=2;i<=10;i++){
		for(int j=0;j<v[i-1].size();j++){
			string s=v[i-1][j];
			bool f[30]={};
			ll cnt=0;
			for(int k=0;k<s.size();k++){
				ll x=s[k]-'a';
				f[x]=1;
			}
			for(int k=0;k<26;k++)if(f[k])cnt++;
			for(int k=0;k<=cnt;k++){
				char c='a'+k;
				string yan=s+c;
				v[i].push_back(yan);
			}
		}
	}
	sort(v[n].begin(),v[n].end());
	for(int i=0;i<v[n].size();i++)cout<<v[n][i]<<endl;
	return 0;
}


Measured memory_bytes: 11380
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B, C, D; cin >> A >> B >> C >> D;

    string ans;
    if (A+B == C+D) {
        ans = "Balanced";
    } else if (A+B < C+D) {
        ans = "Right";
    } else {
        ans = "Left";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			int v = sc.nextInt();
			int j = 0;
			while (v * j < d) {
				count++;
				j++;
			}
		}
		System.out.println(count + x);
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int n = scan.nextInt();

        int l = 0, r = w, t = h, b = 0;
        for (int i = 0; i < n; i++) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            int a = scan.nextInt();

            if (a == 1) {
                if (x > l) l = x;
            }
            if (a == 2) {
                if (x < r) r = x;
            }
            if (a == 3) {
                if (y > b) b = y;
            }
            if (a == 4) {
                if (y < t) t = y;
            }
        }

        if (l > r || b > t) {
            System.out.println(0);
        } else {
            System.out.println((r - l) * (t - b));
        }
    }
}


Measured memory_bytes: 21972
object Main {

  def main(args: Array[String]): Unit = {
    def find(l: List[Char]): Int = {
      def min(a: Int, b: Int): Int =
        if (a < b) a else b
      @annotation.tailrec
      def go(l: List[Char], lBlack: Int, rWhite: Int, minN: Int): Int =
        l match {
          case Nil => minN
          case '#' :: t => go(t, lBlack + 1, rWhite,     min(minN, lBlack + rWhite + 1))
          case '.' :: t => go(t, lBlack,     rWhite - 1, min(minN, lBlack + rWhite - 1))
        }
      val rWhite = l.count(_ == '.')
      go(l, 0, rWhite, rWhite)
    }
    scala.io.StdIn.readLine()
    println(find(scala.io.StdIn.readLine().toList))
  }

}

Measured memory_bytes: 34836
# 入力割り当て
N = int(input())

# 可否判定
ans = 'Yes'
for i in range(N):
	t, x, y = map(int, input().split())
	if t < x + y or t%2 != (x+y)%2:
		ans = 'No'

# 結果の表示
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

ll n, a, b, c, d;
map<ll, ll> dp;

ll dfs(ll n) {
    if (n == 0) return 0;
    if (n == 1) return d;
    if (dp.count(n) > 0) return dp[n];
    dp[n] = 1e18;
    if (n < (1e18 / d)) dp[n] = d * n;
    dp[n] = min(dp[n], d * (n % 2) + a + dfs(n / 2));
    dp[n] = min(dp[n], d * (n % 3) + b + dfs(n / 3));
    dp[n] = min(dp[n], d * (n % 5) + c + dfs(n / 5));
    dp[n] = min(dp[n], d * (2 - n % 2) + a + dfs((n + 1) / 2));
    dp[n] = min(dp[n], d * (3 - n % 3) + b + dfs((n + 2) / 3));
    dp[n] = min(dp[n], d * (5 - n % 5) + c + dfs((n + 4) / 5));
    return dp[n];
}

void solve() {
    cin >> n >> a >> b >> c >> d;
    dp.clear();
    cout << dfs(n) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll t;
    cin >> t;
    rep(i, t) solve();
    return 0;
}


Measured memory_bytes: 4440
n=int(input())
s=list(input())

E=s.count('E')
W=s.count('W')

if s[0]=='E':
  ans=E-1
else:
  ans=E
  
ans1=[]
ans1.append(ans)
  
for x in range(1,n):
  if s[x]=='E':
    if s[x-1]=='E':
      ans-=1
      
  else:
    if s[x-1]=='W':
      ans+=1
  ans1.append(ans)
  
print(min(ans1))

Measured memory_bytes: 23380
function main(input) {
  const input_array = input.split(' ');

  const N = input_array[0];
  const A = input_array[1];
  const B = input_array[2];
  
  var answer = 0;
  const reducer = (accumulator, currentValue) => accumulator + currentValue;

  for (i=1; i<=N; i++){
    sum = i.toString().split("").map( x => parseInt(x, 10)).reduce(reducer)
    if(A <= sum && sum <= B){
      answer+=i;
    }
  }
  
  console.log(answer);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 10332
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] Vs = new int[N];
        int[] Cs = new int[N];
        int X_Y = 0;
        
        for (int i=0; i<N; i++) {
            Vs[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            Cs[i] = sc.nextInt();
        }

        for (int i=0; i<N; i++) {
            if (Vs[i] > Cs[i]) {
                X_Y += Vs[i] - Cs[i];
            }
        }

        System.out.println(X_Y);
    }
}


Measured memory_bytes: 21716
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int X[200002] = {0};
int Y[200002] = {0};

int main()
{
	int N = 0, D = 0;
	scanf("%d %d", &N, &D);

	int i = 0, ans = 0;
	for (i = 0; i < N; i++) {
		scanf("%d %d", &X[i], &Y[i]);
	}

	for (i = 0; i < N; i++) {
		double x = X[i];
		double y = Y[i];

		if ((double)D >= sqrt((x*x) + (y*y))) {
			ans++;
		}
	}

	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,r,wk,gcd,x,y;
	long long lcm;
	while(scanf("%d %d",&a,&b)!=EOF){
		x=a;
		y=b;
		//printf("x=%d,y=%d\n",x,y);
		while(1){
			if(a<b){
				wk=a;
				a=b;
				b=wk;
			}
			r=a%b;
			if(r==0){
				break;
			}
			//printf("a=%d b=%d r=%d\n",a,b,r);
			a=b;
			b=r;
		}
		gcd=b;
		lcm=(long long)x*y/gcd;
		printf("%d %lld\n",gcd,lcm);
	}
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) if(a<b)a=b
#define LL long long
const int N=18;

int n;
LL a[N][N];
LL cost[1<<N],dp[1<<N];

int main()
{
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
		scanf("%lld",&a[i][j]);
	for(int mask=1;mask<(1<<n);mask++)
	for(int i=0;i<n;i++) if(mask>>i&1)
	for(int j=i;j<n;j++) if(mask>>j&1)
		cost[mask]+=a[i][j];
	for(int mask=0;mask<(1<<n);mask++)
	for(int mask2=mask;mask2;mask2=(mask2-1)&mask)
		chmax(dp[mask],cost[mask2]+dp[mask-mask2]);
	printf("%lld\n",dp[(1<<n)-1]);
	
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
l d[30000000];

int main()
{
    int i,n,a1,a2,b1,b2,c1,c2;
    cin>>n;
    cin>>a1>>b1>>c1>>a2>>b2>>c2;
    for(i=0;i<=n;i++)d[i]=i;
    for(i=0;i<n;i++)
    {
        d[i+a1]=max(d[i+a1],d[i]+a2);
        d[i+b1]=max(d[i+b1],d[i]+b2);
        d[i+c1]=max(d[i+c1],d[i]+c2);
    }n=d[n];
    for(i=0;i<=n;i++)d[i]=i;
    for(i=0;i<n;i++)
    {
        d[i+a2]=max(d[i+a2],d[i]+a1);
        d[i+b2]=max(d[i+b2],d[i]+b1);
        d[i+c2]=max(d[i+c2],d[i]+c1);
    }
    cout<<d[n];
    return 0;
}


Measured memory_bytes: 196864
n=int(input())
A=0
B=0
C=0
D=0
for i in range(n):
  m=input()
  if m =="AC":
     A +=1
  elif m=="WA":
    B+=1
  elif m=="TLE":
    C +=1
  elif m=="RE":
    D +=1

print("AC x ",A)
print("WA x ",B)
print("TLE x ",C)
print("RE x ",D)
  


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

using namespace std;

int main() {
	int a,x,cu=0;
	cin>>a;
	while(a--)
	{
	cin>>x;
	while(x%2==0)
	{
	x/=2;
	cu++;
	}
	}
	cout<<cu;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, Z, W;
  scanf("%d", &N);
  scanf("%d", &Z);
  scanf("%d", &W);
  std::vector<int > a(N);
  for (int i=0; i<N; i++){
    scanf("%d", &a[i]);
  }
  if (N==1){
    printf("%d\n", abs(W-a[N-1]));
  } else {
    printf("%d\n", std::max(abs(W-a[N-1]), abs(a[N-2]-a[N-1])));
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a[5];
    int k;
    for(int i=0;i<5;i++)
        cin>>a[i];
    cin>>k;
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++)
        {
            int num=a[i]-a[j];
            if(num<0)num=-num;
            if(num>k)
            {
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
    return 0;
}


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

public class Main {
	private static int s;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0 0")) {
			String[] dataset = str.split(" ");
			int n = Integer.parseInt(dataset[0]);
			s = Integer.parseInt(dataset[1]);
			int cnt = 0;
			int[] a = new int[n];
			for (int i = 0; i < 10; i++) {
				a[0] = i;
				cnt += Search(s, i, 1, n, a);
			}
			System.out.println(cnt);
			str = br.readLine();

		}
	}

	private static int Search(int n0, int t0, int d0, int dmax, int[] a) {
		int num = 0;
		if (d0 < dmax) {
			for (int i = Math.min(n0 - t0, t0); i >= 0; i--) {
				if (i == t0)
					continue;
				a[d0] = i;
				num += Search(n0 - t0, i, d0 + 1, dmax, a);
			}
		} else if (d0 == dmax) {
			int total = 0;
			for (int k : a)
				total += k;
			if (total == s) {
				num += 1;
			}
		}
		return num;
	}
}

Measured memory_bytes: 24648
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ct2 = 0;
  int ct4 = 0;
  REP(i,N){
    int a;
    cin >> a;
    if(a % 4 == 0) ct4+=2;
    else if(a % 2 == 0) ct2++;
  }
  if(ct2 >= 2){
    ct4 += ct2 - 1;
  }
  if(ct4 >= N - 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define ten52 200005

int num[ten52];
int vint[ten52];

int main(void)
{
    int m,n,i,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        vint[i]=num[i]=m;
    }
    sort(vint,vint+n);
    l=vint[n/2-1];
    r=vint[n/2];
    for(i=0;i<n;i++)
    {
        if(num[i]>=r) cout<<l<<endl;
        else cout<<r<<endl;
    }
    return 0;
}



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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans;
    if (h2 < h1 || (h1 == h2 && m2 < m1)) {
        h2 += 24;
    }
    ans = max(0, 60*h2+m2 - (60*h1+m1) - k);

    cout << ans << endl;
}


Measured memory_bytes: 3636
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static int R;
     static int C;
     static int[] S;
     static int[] G;
     static int[,] map;
     
     static void Main(string[] args) {
     //入力を受け取る
     var NM  = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
     var N = NM[0];
     var M = NM[1];
     
     var FromOne = new int[N+1];
     var ToN     = new int[N+1];
     
     for(int i = 0;i < M;i++){
         var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
         var A = AB[0];
         var B = AB[1];
         
         if(A == 1){
             FromOne[B] = 1;
         }
         if(B == N){
             ToN[A] = 1;
         }
     }
     
     
     var flag = false;
     for(int i = 0;i < N ; i++){
         if(FromOne[i]*ToN[i] ==1){
             flag = true;
         }
     }
     
     
   
     
     if(flag){
         Console.WriteLine("POSSIBLE");
     }else{
         Console.WriteLine("IMPOSSIBLE");
     }
        
     }
     
     
}
     
     
     
     
     


Measured memory_bytes: 18656
import sys

N, X = map(int, (input().split()))
L = list(map(int, input().split()))
point = 0
count = 1

for x in range(0, N):
    point+=L[x]
    if(point<=X):
        count+=1
    if(point>=X):
        print(count)
        sys.exit()

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>
 
#define MaxN 100
#define INF 2140000000
 
using namespace std;
 
int N,X,fr=0,cool=0;
bool v[MaxN];
 
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>X;
		if(X<400)
		{
			if(!v[1])
				fr++,v[1]=true;
		}
		else if(X<800)
		{
			if(!v[2])
				fr++,v[2]=true;
		}
		else if(X<1200)
		{
			if(!v[3])
				fr++,v[3]=true;
		}
		else if(X<1600)
		{
			if(!v[4])
				fr++,v[4]=true;
		}
		else if(X<2000)
		{
			if(!v[5])
				fr++,v[5]=true;
		}
		else if(X<2400)
		{
			if(!v[6])
				fr++,v[6]=true;
		}
		else if(X<2800)
		{
			if(!v[7])
				fr++,v[7]=true;
		}
		else if(X<3200)
		{
			if(!v[8])
				fr++,v[8]=true;
		}
		else cool++;
	}
	cout<<max(1,fr)<<" "<<fr+cool<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = Integer.parseInt(sc.next());
        int m1 = Integer.parseInt(sc.next());
        int h2 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        System.out.println(Math.max((h2 * 60 + m2) - (h1 * 60 + m1) - k, 0));
    }
}


Measured memory_bytes: 35652
#!/usr/bin/env python3

def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = lcm(a)
    b = [c // ai for ai in a]
    print(sum(b) % (10 ** 9 + 7))

def lcm(li):
    res = 1
    for x in li:
        res *= (x // gcd(res, x))
    return res

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x
if __name__ == "__main__":
    main()


Measured memory_bytes: 262644
/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>

#define N 100000
#define INF 0x3f3f3f3f

int min(int a, int b) {
	return a < b ? a : b;
}

int time(int x, int l, int r) {
	return r - l + min(abs(x - l), abs(x - r));
}

int main() {
	static int xx[N];
	int n, k, i, ans;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &xx[i]);
	ans = INF;
	for (i = 0; i <= n - k; i++) {
		int x = time(0, xx[i], xx[i + k - 1]);

		if (ans > x)
			ans = x;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
S = input().split(' ')
s1 = int(S[0])
s2 = int(S[1])
k = int(S[2])
sum = s2 - s1 + 1

if sum < k:
    for i in range(s1, s2 + 1):
        print(i)
elif sum / 2  < k:
    for i in range(s1, s2 + 1):
        print(i)
else:
    for i in range(s1, s1 + k ):
        print(i)
    for i in range(s2 - k + 1, s2 + 1):
        print(i)


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        xu: [(f64, String); n]
    }
    const BTC_RATE: f64 = 380000.0f64;
    let sum = xu.into_iter().map(|(x, u)| {
        if u == "BTC" {
            x * BTC_RATE
        } else {
            x
        }
    }).fold(0f64, |sum, x| sum + x);
    println!("{}", sum);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		str=str.replaceAll("apple", "あっぷる");
		str=str.replaceAll("peach", "apple");
		str=str.replaceAll("あっぷる", "peach");
		System.out.println(str);
	}
}

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

int main() {
  int n; cin >> n;
  int ans = 0;
  while(n) {
    ans += n % 10;
    n/=10;
  }
  if (ans == 1) {
    cout << 10 << endl;
  }
  else {
    cout << ans << endl;
  }
}


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

int main()
{
  int n ;
  
  cin >> n ;
  
  if(n%1000%111==0 || n/10%111==0)
  {
    cout << "Yes" << endl ;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())

sunuke = [0 for i in range(n)]

for i in range(k):
    t = int(input())
    tl = map(int, input().split())
    for j in tl:
        sunuke[j-1] += 1

ans = 0
for i in sunuke:
    if i == 0:
        ans += 1

print(ans)

Measured memory_bytes: 67432
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi=acos(-1.0);
int main(){
    double c;
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double cal=fabs(h*30+m/2-m*6);
    double val=pi/180;
    double ret=cos(cal*val);
    double ans=sqrt(a*a+b*b-2*a*b*ret);
    printf("%.20f\n",ans);
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

	int L[1] = {0};
	int a[49] = {0};
    int partition(int l, int r) {
        int i = l - 1;
        int j = r;
        int temp;
     
        int pivot = a[r];
     
        while (1) {
            i++;
            while (a[i] < pivot) {
                i++;
            }
            j--;
            while (i < j && pivot < a[j]) {
                j--;
            }
         
            if (i >= j) {
                break;
            }
     
            temp = a[i];
            a[i] = a[j];
            a[j] = temp;
        }
        temp = a[i];
        a[i] = a[r];
        a[r] = temp;
        return i;
    }
     
    void quickSort(int l, int r) {
        int v;
        if (l >= r) {
            return;
        }
        v = partition(l, r);
        quickSort(l, v - 1);
        quickSort(v + 1, r);
    }

int main(void){
	scanf("%d", &L[0]);
	scanf("%d", &L[1]);
	for (int n = 0;n < L[0];n++){ 
		scanf("%d", &a[n]);
	}
    quickSort(0, L[0]-1);
	int num = L[0] - L[1];
	int snake = 0;
	for(num+1; num < L[0]; num++){
		snake = snake + a[num];
	}
	printf("%d\n", snake);
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <string>

class Baseball{
    private:
        std::queue<int> runner;
        int out_count;
        int score;
        
    public:
        void initRunner(){
            while(runner.empty() != true){
                runner.pop();
            }
            for(int i = 0; i < 3; ++i){
                runner.push(0);
            }
        }
        
        Baseball(){
            out_count = 0;
            score = 0;
            initRunner();
        }
        
        ~Baseball(){}
        
        void hit(){
            if(runner.front() == 1) ++score;
            runner.pop();
            runner.push(1);
        }
        
        void homerun(){
            do{
                if(runner.front() == 1) ++score;
                runner.pop();
            } while (runner.empty() != true);
            ++score;
            initRunner();
        }
        
        int getScore(){
            std::string str;
            while(out_count != 3){
                std::cin >> str;
                if(str == "HIT") hit();
                if(str == "HOMERUN") homerun();
                if(str == "OUT") ++out_count;
            }
            return score;
        }
};

int main(void){
    int N;
    std::cin >> N;
    for(int i = 0; i < N; ++i){
        Baseball baseball;
        std::cout << baseball.getScore() << std::endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main(){
    int N,K; cin>>N>>K;
    vector<pair<int,int>> sushi(N);
    int t,d;
    for (int i = 0; i < N; ++i) {
        cin>>t>>d;
        sushi[i]={d,t};
    }

    sort(sushi.rbegin(),sushi.rend());

    vector<int> cnt(N+10,0);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> delsushi;
    ll v=0ll; ll total=0ll;
    for (int i = 0; i < K; ++i) {
        if(cnt[sushi[i].second]==0){
            v++;
        }
        cnt[sushi[i].second]++;
        total+=(ll)sushi[i].first;
        delsushi.push(sushi[i]);
    }

    ll ans=v*v+total;

    priority_queue<pair<int,int>> rest;
    for (int i = K; i < N; ++i) {
        rest.push(sushi[i]);
    }

    while(!rest.empty()&&v<K&&!delsushi.empty()){
        pair<int,int> del=delsushi.top();
        delsushi.pop();
        if(cnt[del.second]==1) continue;
        cnt[del.second]--;
        total-=(ll)del.first;
        pair<int,int> add;
        bool f=false;
        do{
            if(rest.empty()) {
                f=true;
                break;
            }
            add=rest.top();
            rest.pop();
        }while(cnt[add.second]>0&&!rest.empty());
        if(f||cnt[add.second]>0) break;
        cnt[add.second]++;
        total+=(ll)add.first;
        v++;
        ans=max(ans,v*v+total);

    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2808
using namespace std;

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdlib>

int n, m;
vector<int> d, c;
int dp[1000][1001];

int dfs(int day, int where){
	if (where == n){
		return 0;
	}
	if (day == m){
		return 1 << 29;
	}
	if (~dp[day][where]){
		return dp[day][where];
	}
	int res = min(dfs(day + 1, where), dfs(day + 1, where + 1) + d[where] * c[day]);
	return dp[day][where] = res;
}

int main(){
	scanf("%d %d", &n, &m);
	d.resize(n);
	c.resize(m);
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d", &d[i]);
	}
	for (size_t i = 0; i < m; i++)
	{
		scanf("%d", &c[i]);
	}
	memset(dp, -1, sizeof(dp));
	printf("%d\n", dfs(0, 0));
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

int main() {
    int c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> c[i][j];
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 1; j < 3; j++) {
            if (c[i + 1][j] - c[i][j] != c[i + 1][0] - c[i][0]) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    for (int j = 0; j < 2; j++) {
        for (int i = 1; i < 3; i++) {
            if (c[i][j + 1] - c[i][j] != c[0][j + 1] - c[0][j]) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[111111];
vi adj[111111];

void dfs(int u, int p)
{
	int xr=0;
	for(int v:adj[u])
	{
		if(v==p) continue;
		dfs(v,u);
		xr^=(dp[v]+1);
	}
	dp[u]=xr;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	dfs(0,-1);
	cout<<(dp[0]>0?"Alice":"Bob")<<'\n';
}


Measured memory_bytes: 14208
s = input()

l = 0
current = 'R'
ans = [0 for x in s]
for i,c in enumerate(s):
    if c == current:
        l += 1
    elif l > 0:
        for j in range(l):
            ans[i - 1] += j % 2 == 0
            ans[i] += j % 2 == 1
        l = 0

l = 0
current = 'L'
for i,c in enumerate(reversed(s)):
    if c == current:
        l += 1
    elif l > 0:
        for j in range(l):
            ans[-i] += j % 2 == 0
            ans[-(i + 1)] += j % 2 == 1
        l = 0

print(' '.join(str(x) for x in ans))


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  int ans=0;
  for(int i=1;i*i<N;i++){
    if(N%i==0){
      if(N/i-1>i)
      ans+=N/i-1;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue> 
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;
const int N = 100010;
int p[N];
int q[N];
int r[N];
int x,y,a,b,c;
int cnt_p, cnt_q, cnt_r;
priority_queue<PII> pq;

int main() {
    cin >> x >> y >> a >> b >> c;
    for(int i = 0; i < a; i ++) {
        cin >> p[i];
        pq.push({p[i], 1});
    }
    for(int i = 0; i < b; i ++) {
        cin >> q[i];
        pq.push({q[i], 2});
    }
    for(int i = 0; i < c; i ++) {
        cin >> r[i];
        pq.push({r[i], 0});
    }
    ll sum = 0;
    while(cnt_p + cnt_q + cnt_r < x + y) {
        PII curr = pq.top();
        pq.pop();
        int color = curr.second;
        int num = curr.first;
        if(color == 1 && cnt_p < x) {
            sum += num;
            cnt_p ++;
        } else if(color == 2 && cnt_q < y) {
            sum += num;
            cnt_q ++;
        } else if(color == 0) {
            sum += num;
            cnt_r ++;
        } else if(color == 1) {
            continue;
        } else if(color == 2) {
            continue;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 7536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif
const int MAXN=202020;
ll n,k;
vector<ll>lens(MAXN);
bool possible(ll val){
  ll tot=0;
  for(int i=0;i<n;i++){
    if(lens[i]%val==0){
      tot+=(lens[i]/val)-1;
    }else{
      tot+=((lens[i]/val));
    }
  }
  return (tot<=k);
}
int main(){
  fastIO();
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>lens[i];
  }
  ll l=0,h=(1e9)+5;
  while(l<h){
    ll mid=(l+h)/2;
    if(mid==0){
      l=1;
      break;
    }
    if(possible(mid)){
      h=mid;
    }else{
      l=mid+1;
    }
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 4660
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
 
string s;
int main(){
	cin >> s;
	int a=s.size();
	char s0 =s[0];
	char sn =s[a-1];
	cout<<s0<<a-2<<sn<<endl;
	
}

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int n;
string s, t;

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

    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3556
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, a[MAXN], ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++) {
		if (i == n)
			if (a[i] == i)
				ans++;
			else
				;
		else
			if (a[i] == i)
				swap(a[i], a[i + 1]), ans++;
			else
				;
	}
	cout << ans << endl;
	return 0;
}


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

#define pb push_back
#define mk make_pair
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(S) (S).begin(), (S).end()
#define debug(a) cerr << #a << " = " << a << endl;
#define debug2(a,b) cerr << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugM(M, l, c ) rep( i, 0, l ){ rep( j, 0, c ){ cerr << M[i][j] << " "; } cerr << endl; }
#define debugP(p) cerr << #p << " = " << p.x << " --- " << #p << " = " << p.y << endl;
#define MAXN 100005

using namespace std;

typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;

int n;
int a[MAXN], b[MAXN], c[MAXN];
int pd[MAXN][4];

int solve(int i, int l) {
	if(i == n) return 0;
	
	int &ans = pd[i][l];
	if(ans != -1) return ans;
	
	if(l != 0) ans = max(ans, solve(i+1, 0) + a[i]);
	if(l != 1) ans = max(ans, solve(i+1, 1) + b[i]);
	if(l != 2) ans = max(ans, solve(i+1, 2) + c[i]);
	
	return ans;
}

int main(void) {
	memset(pd, -1, sizeof(pd));
	
	scanf("%i", &n);	
	rep(i, 0, n)
		scanf("%i %i %i", &a[i], &b[i], &c[i]);
	
	printf("%i\n", solve(0, 3));	
		
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  if(a > b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		a.push_back(x);
	}

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

	int alice = 0, bob = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) alice += a[N - 1 - i];
		else bob += a[N - 1 - i];
	}

	int dif = alice - bob;
	cout << dif << endl;
	return 0;
}


Measured memory_bytes: 256