akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int n, m, ans;
vector<int> s[10];
bool p[10];

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    while (k--) {
      int idx;
      cin >> idx;
      idx--;
      s[i].push_back(idx);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int idx: s[i]) {
        if (1 & (bit >> idx)) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) flag = false;
    }
    if (flag) {
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll fact(ll n){
    if(n == 1){
        return 1;
    }

    else{
        return n*fact(n-1);
    }
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    double x[n], y[n];
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    double dist[n][n] = {};
    rep(i, n){
        rep(j, n){
            if(i == j) continue;

            double dx = x[i] - x[j];
            double dy = y[i] - y[j];
            dist[i][j] = sqrt(dx*dx + dy*dy);
        }
    }

    ll perm[n];
    rep(i, n){
        perm[i] = i;
    }

    double sumdist = 0.0;
    do{
        reps(i, 1, n){
            sumdist += dist[perm[i-1]][perm[i]];
        }
    }while(next_permutation(perm, perm+n));

    double ans = sumdist / (double)fact(n);

    cout << setprecision(15);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n],sum[n],dif[n],pair_count[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    sum[i] = i+1+a[i];
    dif[i] = i+1-a[i];
    pair_count[i] = 0;
  }
  qsort(sum, n, sizeof(long), cmpnum);
  qsort(dif, n, sizeof(long), cmpnum);
  long cur = 0;
  long pairs = 0;
  for (long i = 0; i < n; i++) {
    if (i != 0 && sum[i] == sum[i-1]) {
      pair_count[i] = pair_count[i-1];
    } else {
      while (cur < n-1 && dif[cur] < sum[i]) {
        cur++;
      }
      if (dif[cur] > sum[i]) {
        continue;
      }
      while (dif[cur] == sum[i]) {
        pair_count[i]++;
        if (cur < n-1) {
          cur++;
        } else {
          break;
        }
      }
    }
  }
  for (long i = 0; i < n; i++) {
    pairs += pair_count[i];
  }
  printf("%ld\n", pairs);

  return 0;
}

Measured memory_bytes: 9452
package main

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

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_C&lang=jp>
 */

func init() {

}

func main() {
	v, _ := SplitIntStdin(" ")
	sort.Ints(v)
	fmt.Println(v[0],v[1],v[2])
}

// ????????????1?????????
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// ??´??°???1?????????
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// ?????????????????????????????????????????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// ??????????????§??????????????????????????????????????????
func SplitStrStdin(delim string) (stringReturned []string) {
	// ???????????§1?????????
	stringInput := StrStdin()

	// ????????§??????
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// ??????????????§??????????????´??°????????????????????????
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// ??????????????????????????????
	stringSplited := SplitStrStdin(" ")

	// ??´??°?????????????????????
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

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

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

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll dp[45][405][405];

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

    ll N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<ll> a(N), b(N), c(N);
    REP(i, N) cin >> a[i] >> b[i] >> c[i];

    const ll INF = (1ll<<60);
    REP(i, 45)REP(j, 405)REP(k, 405) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    REP(i, N){
        REP(j, 405){
            REP(k, 405){
                if(dp[i][j][k] == INF) continue;
                chmin(dp[i+1][j][k], dp[i][j][k]);
                if(j+a[i]<405 and k+b[i]<405) chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
            }
        }
    }

    ll res = INF;
    ll k = 1;
    while(1){
        if(k*Ma < 405 and k*Mb < 405){
            chmin(res, dp[N][k*Ma][k*Mb]);
            k++;
        }else{
            break;
        }
    }

    cout << (res==INF ? -1 : res) << endl;

    return 0;
}

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

using namespace std;

long long f(long long n)
{
    if(n % 4 == 0)
        return n;
    if(n % 4 == 1)
        return 1;
    if(n % 4 == 2)
        return n + 1;
    return 0;
}

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

    long long a, b;
    cin >> a >> b;

    cout << (f(a - 1) ^ f(b));

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

char s[100020];

int main() {
  while (scanf("%s", s) != EOF) {
    int n = strlen(s);

    if ((s[0] == s[n - 1]) ^ (n % 2 == 0)) puts("Second");
    else puts("First");
  }
}


Measured memory_bytes: 384
/*
      author : nishi5451
      created: 11.08.2020 23:13:06
*/

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


int main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(a<=b/k*k) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3640
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
k = inp[0]
ans = 1
n.times do
  if(ans+k < ans*2)
    ans+=k
  else
    ans*= 2
  end
end
p ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  
  cout << (n * m % 2 ? "Odd" : "Even");

  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tofile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); 
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define fi first
#define se second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

const ll N=3010;
ll dp[N][N];

int main()
{
	string a,b;
	cin >> a >> b;
	ll m=(ll)a.size(),n=(ll)b.size();
	
	for(ll i=1;i<=m;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	if(dp[m][n]==0){ cout << "" << endl; return 0;}
	
	string lcs="";
	ll i=m,j=n;
	while(i>0 && j>0)
	{
		if(dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else if(dp[i][j]==dp[i][j-1])
		{
			j--;
		}
		else
		{
			lcs.pb(a[i-1]);
			i--;
			j--;
		}
	}
	for(i=lcs.size()-1;i>=0;i--){ cout << lcs[i]; }
	cout << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	long long h;
	cin >> h;
	long long hie = 1;
	while(h != 1){
	//debug
	// cout << "h:" << h << ",hie:" << hie << endl;
		h = h / 2;
		hie++;
	}
	
	//debug
	// cout << hie << endl;
	
	long long ans = 0;
	for(long long i = 0; i < hie; i++) {
		ans += pow(2,i);
	}
	
	cout << ans << endl;
	
	
	
	
	return 0;
}


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

using namespace std;

int cnt;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    
    for (int i = 1; i < n - 1; ++i)
    {
        int iden = 0;
        unordered_set<char> l, r;
        
        for (int j = 0; j < i; ++j)
            l.insert(s[j]);
        for (int k = i; k < n; ++k)
            r.insert(s[k]);
        
        for (auto t = l.begin(); t != l.end(); ++t)
            if (r.find(*t) != r.end())
                ++iden;
            
        cnt = max(iden, cnt);
    }
    
    cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void merge(int A[], int B[], int left, int mid, int right) {
    int i = left;
    int j = mid;
    int k = 0;
    int l;
    while (i < mid && j < right) {
        if (A[i] < A[j]) {
            B[k++] = A[i++];
        } else {
            B[k++] = A[j++];
        }
    }
    if (i == mid) { /* i����A��B�Ɉړ����s�������̂ŁAj�������Ԃ�B�ɓ���Ă��� */
        while (j < right) {
            B[k++] = A[j++];
        }
    } else {
        while (i < mid) { /* j����A��B�Ɉړ����s�������̂ŁAi�������Ԃ�B�ɓ���Ă��� */
            B[k++] = A[i++];
        }
    }
    for (l = 0; l < k; l++) {
        A[left + l] = B[l];
    }
}
void merge_sort(int A[], int B[], int left, int right) {
    int mid;
    if (left == right || left == right - 1) { return; }
    mid = (left + right) / 2;
    merge_sort(A, B, left, mid);
    merge_sort(A, B, mid, right);
    merge(A, B, left, mid, right);
}

int main(){
	
	int n;
	cin >> n;
	
	int d[n], d_sort[n];
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	
	merge_sort(d, d_sort, 0, n);
	cout << (d_sort[n / 2] - d_sort[(n / 2) - 1]) << endl;
	
	return 0;

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int N; 
    cin >> N;
    vector<vector <int>> xy(N, vector<int>(2));


    vector<int> P(N);
    REP(i,N){
        cin >> xy[i][0] >> xy[i][1];
        P[i] = i;
    }

    double sum = 0.0;
    int count = 0;
    do{
        FOR(i,0,N-1){
            sum += sqrt(pow((xy[P[i]][0] - xy[P[i+1]][0]),2) + pow((xy[P[i]][1] - xy[P[i+1]][1]),2));
        }
        count ++;
    }while (next_permutation(ALL(P)));

    cout << fixed << setprecision(10) << sum/count << endl;


    return 0;
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))

a1 = a * b
a2 = a * b * 2
a3 = a * b * 3

if (a1 % 2 == 1) or (a2 % 2 == 1) or (a3 % 2 == 1):
    print("Yes")

else:
    print("No")


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

int main(){
  int H,W; cin >> H >> W;
  char s[H+10][W+10];
  for(int i = 1; i < H+1; i++){
      for(int j = 1; j < W+1; j++){
          cin >> s[i][j];
      }
  }
  
  bool Draw = true;
  for(int i = 1; i < H + 1; i++){
      for(int j = 1; j < W + 1; j++){
          if(s[i][j] == '#'){
              if(s[i+1][j] != '#' && s[i-1][j] != '#' && s[i][j+1] != '#' && s[i][j-1] != '#') Draw = false;
          }
      }
  }
  if(Draw) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
fn main() {
    let n = read();
    let works: Vec<(i32,i32)> = {
        let mut works: Vec<(i32,i32)> = (0..n).map(|_| read_pair()).collect();
        works.sort_by(|&(_, x), &(_, y)| x.cmp(&y));
        works
    };

    let mut t = 0;
    for (a,b) in works {
        t += a;
        if t > b { println!("No"); return; }
    }
    println!("Yes");
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}
fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_pair<T: std::str::FromStr + Copy>() -> (T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1])
}
fn read_triple<T: std::str::FromStr + Copy>() -> (T,T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1], v[2])
}

const MOD: u64 = 1_000_000_007;

#[derive(Copy, Clone, PartialEq, Eq)]
struct F(u64);

impl F {
    pub fn new(n: i32) -> Self { F((MOD as i32 + n)as u64%MOD) }
    pub fn pow(self, mut exp: u32) -> Self {
        let mut base = self.0;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 { acc *= base; acc %= MOD; }
            exp /= 2; base *= base; base %= MOD;
        }
        if exp == 1 { acc *= base;acc %= MOD; }
        F(acc)
    }
}
impl std::fmt::Display for F {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
use std::ops::*;
impl Mul for F {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {F((self.0 * rhs.0)%MOD)}
}
impl MulAssign for F {
    fn mul_assign(&mut self, rhs: Self) {*self = F((self.0 * rhs.0)%MOD)}
}
impl Add for F {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {F((self.0 + rhs.0)%MOD)}
}
impl AddAssign for F {
    fn add_assign(&mut self, rhs: Self) {*self = F((self.0 + rhs.0)%MOD)}
}
impl Neg for F {
    type Output = Self;
    fn neg(self) -> Self {if self.0==0 {F(0)} else {F(MOD - self.0)}}
}
impl Sub for F {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {F((MOD + self.0 - rhs.0)%MOD)}
}
impl SubAssign for F {
    fn sub_assign(&mut self, rhs: Self) {*self = F((MOD + self.0 - rhs.0)%MOD)}
}
impl Div for F {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {F(self.0 * rhs.pow(MOD as u32-2).0 %MOD)}
}
impl DivAssign for F {
    fn div_assign(&mut self, rhs: Self) { *self = F(self.0 * rhs.pow(MOD as u32 - 2).0 % MOD) }
}
impl std::iter::Sum<F> for F {
    fn sum<I: Iterator<Item=F>>(iter: I) -> F { iter.fold(F(0), |a,b| a + b) }
}
impl<'a> std::iter::Sum<&'a F> for F {
    fn sum<I: Iterator<Item=&'a F>>(iter: I) -> F { iter.fold(F(0), |a, b| a + *b) }
}
impl std::iter::Product for F {
    fn product<I: Iterator<Item=F>>(iter: I) -> F { iter.fold(F(1), |a, b| a * b) }
}
impl<'a> std::iter::Product<&'a F> for F {
    fn product<I: Iterator<Item=&'a F>>(iter: I) -> F { iter.fold(F(1), |a, b| a * *b) }
}

Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int  l=-2,r=-2;

  rep(i,s.length()-1)
  {
    if(s[i]==s[i+1]){l=i;r=i+1;break;}
  }
  rep(i,s.length()-2)
  {
    if(s[i]==s[i+2]){l=i;r=i+2;break;}
  }
  cout<<l+1<<" "<<r+1<<endl;
  return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define MAXN 2020
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}


int32_t main(){
	fastio;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    for(int i=0;i<a;i++)cin>>p[i];
    for(int i=0;i<b;i++)cin>>q[i];
    for(int i=0;i<c;i++)cin>>r[i];

    sort(all(p),greater<int>());
    sort(all(q),greater<int>());    
    sort(all(r),greater<int>());

    int res = 0;
    multiset<int> S;
    for(int i=0;i<x;i++){
        res+=p[i];
        S.insert(p[i]);
    }
    for(int i=0;i<y;i++){
        res+=q[i];
        S.insert(q[i]);
    }
    for(int i=0;i<c;i++){
        int x = r[i];
        if(S.size()==0)break;
        if(*S.begin() < x){
            res-=*S.begin();
            res+=x;
            S.erase(S.begin());
        }
    }
    cout<<res<<endl;

	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int A[101010];

signed main()
{
    cin >> N;
    REP(i,N) cin >> A[i];

    int ans = 1;
    int pre = A[0];
    int sta = 0;    //０：未定　１：増加　－１：減少
    for (int i=1; i<N; i++) {
        if (sta == 0) {
            if (pre == A[i]) {
                sta = 0;
            } else if (pre < A[i]) {
                sta = 1;
            } else {
                sta = -1;
            }
        } else if (sta == 1) {
            if (pre > A[i]) {
                ans++;
                sta = 0;
            }
        } else if (sta == -1) {
            if (pre < A[i]) {
                ans++;
                sta = 0;
            }
        }

        pre = A[i];
    }

    cout << ans << endl;
}


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

using namespace std;

const int N = 100010;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a ,b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int last[26];
int c[26];
int s[365][26];
int a[365];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<26;i++){
    	cin >> c[i];
    }
    for(int i=0;i<d;i++){
    	for(int j=0;j<26;j++){
    		cin >> s[i][j];
    	}
    }
    for(int i=0;i<d;i++){
    	int mx=0;
    	int id=0;
    	for(int j=0;j<26;j++){
    		if(mx<(i+1-last[j])*c[j]+s[i][j]){
    			mx=(i+1-last[j])*c[j]+s[i][j];
    			id=j;
    		}
    	}
    	a[i]=id+1;
    	last[id]=i+1;
    }
    for(int i=0;i<26;i++){
    	last[i]=0;
    }
    int res=0;
    for(int i=0;i<d;i++){
    	res+=s[i][a[i]-1];
    	last[a[i]-1]=i+1;
    	for(int j=0;j<26;j++){
    		res-=c[j]*(i+1-last[j]);
    	}
    }
    for(int i=0;i<1e6;i++){
    	int day,qq;
    	day=myRand(d)+1;
    	qq=myRand(26)+1;
    	int resres=res;
    	int qqq=a[day-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres+=c[qq-1]*(i+1-last[qq-1]);
            resres+=c[qqq-1]*(i+1-last[qqq-1]);
        }
        a[day-1]=qq;
        resres-=s[day-1][qqq-1];
        resres+=s[day-1][qq-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres-=c[qq-1]*(i+1-last[qq-1]);
            resres-=c[qqq-1]*(i+1-last[qqq-1]);
		}
		if(resres>=res){

		}
		else{
			a[day-1]=qqq;
		}
    }
    for(int i=0;i<d;i++){
    	printf("%d\n",a[i]);
    }
}



Measured memory_bytes: 3792
#include<cstdio>
#include<cstring>

int main(){
   char s[201],t[101],p[101];
   scanf("%s %s",s,p);

   strcpy(t,s);
   strcat(s,t);

   if(strstr(s,p) == NULL){
	printf("No\n");
	}else{
	printf("Yes\n");
	}
   return 0;
}

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

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);//0??????h-1?????§???????????£????????????????????¨??????  
    	  String right = cards.substring(h, cards.length());//h?????????????????§???????????£????????????????????¨?????? 	
          cards = right + left;//?????¨????????\?????????????????????????????£??????????????????????????¨??????

      }
      System.out.println(cards);

   }



  }
}

Measured memory_bytes: 24336
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}


#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (h, n) = input!(u64, u64);
    let a = invec!(u64);

    if h <= a.iter().sum() {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    solve();
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASeptember9 solver = new ASeptember9();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASeptember9 {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            out.println(n / 10 == 9 || n % 10 == 9 ? YES : NO);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int all = 0;
  vector<int> as(N);
  F0R(i, N) {
    cin >> as[i];
    all ^= as[i];
  }

  F0R(i, N) {
    cout << (as[i] ^ all) << ' ';
  }
}
#endif


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll X, A, B;
  cin >> X >> A >> B;
  X -= A;
  X %= B;
  COUT(X);
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n, w;
  cin >> n >> w;

  vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
  rep(i, 1, n + 1) {
    ll x, v;
    cin >> x >> v;
    rep(j, 1, w + 1) {
      if (j < x)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - x] + v);
    }
  }
  cout << dp[n][w] << endl;
}


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

typedef complex<double>Point;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point p;
    double r;
    Circle(const Point &p=Point(),double r=0.0):p(p),r(r){}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point>Polygon;

const double PI=acos(-1);
const double EPS=1e-8;
const double INF=1e16;
const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_BACK=2;
const int ONLINE_FRONT=-2;
const int ON_SEGMENT=0;

inline double square(double a){return a*a;}
inline double norm(const Point &a){return square(a.real())+square(a.imag());}
inline double dot(const Point &a,const Point &b){return (conj(a)*b).real();}
inline double cross(const Point &a,const Point &b){return (conj(a)*b).imag();}
inline double toDeg(double t){return t/PI*180.0;}
inline double toRad(double t){return t/180.0*t;}
#define equals(a,b) (fabs((a)-(b))<EPS)

void getPoint(Point &p){
    double x,y;
    scanf("%lf%lf",&x,&y);
    p=Point(x,y);
}

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return isOrthogonal(s1.p1-s1.p2,s2.p1-s2.p2);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return isParallel(s1.p1-s1.p2,s2.p1-s2.p2);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflection(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS)return CLOCKWISE;
    if(dot(a,b)<-EPS)return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    return ON_SEGMENT;
}

int main(){
    Point a,b;
    getPoint(a);
    getPoint(b);

    int q;
    scanf("%d",&q);
    while(q--){
        Point c;
        getPoint(c);
        int x=ccw(a,b,c);
        if(x==1)puts("COUNTER_CLOCKWISE");
        else if(x==-1)puts("CLOCKWISE");
        else if(x==2)puts("ONLINE_BACK");
        else if(x==-2)puts("ONLINE_FRONT");
        else puts("ON_SEGMENT");
    }
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n;
   cin >> n;
   int odd = 0, even = 0;
   int sum = 0;
   rep (i, n) {
      int x;
      cin >> x;
      sum += x;
      if (x&1) {
         odd++;
      }else {
         even++;
      }
   }

   if (sum&1) {
      puts("NO");
   } else {
      puts("YES");
   }

   // if (even==n) {
   //    puts("YES");
   // } else {
   //    if (odd&1) {
   //       puts("NO");
   //    } else {
   //       puts("YES");
   //    }
   // }

   return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    for(int i=1;;i++){
        n -= i;
        //cout << n << endl;
        if(n <= 0){
            //cout << n << endl;
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  int y, m, d;
  char s[20];
  char *g;
  
  while (1) {
    fgets(s, sizeof(s), stdin);
    if (s[0] == '#') break;
    s[strlen(s) - 1] = '\0';
    g = strtok(s, " ");
    
    g = strtok(NULL, " ");
    y = atoi(g);
    g = strtok(NULL, " ");
    m = atoi(g);
    g = strtok(NULL, " ");
    d = atoi(g);

    if (y <= 30) {
      printf("HEISEI %d %d %d\n", y, m, d);
    } else if (y >=32) {
      printf("? %d %d %d\n", y - 30, m, d);
    } else {
      if (m >= 5) {
        printf("? 1 %d %d\n", m, d);
      } else {
        printf("HEISEI %d %d %d\n", y, m, d);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2092
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define inf 1000000

using namespace std;


int main()
{

    HabdModeActive
    LL n,m;
    cin>>n>>m;
    if(llabs(n-m)>1)
        return cout<<0,0;
    LL s1=1,s2=1,mod=1e9+7;

    for(int i=1 ; i<=n ; i++)
    {
        s1*=i;
        s1%=mod;

    }
    for(int i=1 ; i<=m ; i++)
    {

        s2*=i;
        s2%=mod;
    }

    if(n!=m)
        cout<<(s1*s2)%mod;
    else
        cout<<(2*s1*s2)%mod;



    return 0;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dp[1<<20];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  VI sz(M);
  VI xs(N);
  REP(i,N){
	cin >> xs[i];
	--xs[i];
	sz[xs[i]]++;
  }
  VVI cnt(N+1, VI(M,0));
  REP(i,N){
	REP(j,M)
	  cnt[i+1][j] = cnt[i][j] + (xs[i] == j);
  }

  fill(dp, dp+(1<<20), 1e9);

  REP(j,M){
	dp[1<<j] = sz[j] - cnt[sz[j]][j];
  }

  for(int b=1;b<(1<<M);++b){
	int s = 0;
	REP(j,M) if(b>>j&1) s += sz[j];
	REP(j,M){
	  if((b>>j&1) == 1) continue;
	  mini(dp[b|(1<<j)], dp[b] + sz[j] - (cnt[s+sz[j]][j] - cnt[s][j]));
	}
  }
  cout << dp[(1<<M)-1] << endl;
  
  return 0;
}

Measured memory_bytes: 18984
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<math.h>
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define ll long long
using namespace std;
int main()
{
    int k;
    scanf("%d",&k);
    printf("%d",(k>>1)*(k-(k>>1)));
}


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

typedef long long ll;

int main() {
    int N, K;
    int x;
    vector<int> p;
    vector<double>kitai;

    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        cin >> x;
        p.push_back(x);
        kitai.push_back((p[i]+1)/2.0);
    }

    double sum = 0;
    double maxV = 0;

    for (int i = 0; i < K; i++) {
        sum += kitai[i];
    }

    maxV = sum;

    for (int i = K; i < N; i++) {
        sum -= kitai[i-K];
        sum += kitai[i];
        maxV = max({maxV, sum});
    }

    printf("%.7f\n", maxV);
}


Measured memory_bytes: 3052
def solve():
    n, k = map(int, input().split())
    sunuke = [0]*n
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in range(d):
            if sunuke[a[j]-1] == 0:
                sunuke[a[j]-1] = 1
    print(sunuke.count(0))
    return 0

if __name__ == "__main__":
    solve()

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

public class Main {

	public static void main(String[] args)
			throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		int n;
		while (   (  n = Integer.parseInt( br.readLine() )  ) != 0   ) {
			int[] a = new int[n];
			for (int i=0; i < n; i++) {
				a[i] = Integer.parseInt(br.readLine());
			}
			System.out.println( MaxSumS(a) );
		}
	}

	public static long MaxSumS(int[] a) {
		long max = a[0];
		long maxfromend = a[0]; //  ... + a[i-3] + a[i-2] + a[i-1] ????????§?????§??¨????????????
		for (int i=1; i < a.length; i++) {
			maxfromend = Math.max(maxfromend + a[i], a[i]);
			max = Math.max(max, maxfromend);
		}
		return max;
	}
}

Measured memory_bytes: 25340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
ll int n,i,j;
double dp[3005][3005],p[3005];
double solve(int idx, int h )
{
  if(idx==n)
  {
    double on =1;double ze=0;
    if(h>n/2) return on;
    else return ze;
    
  }


  if(dp[idx][h]!=(double)-1)
    return dp[idx][h];
  double ans=0;
  
    ans+=p[idx]*solve(idx+1,h+1);
    //cout<<ans<<endl;
    ans+=(double)(1-p[idx])*solve(idx+1,h);
    //cout<<ans<<endl;
  
  dp[idx][h]=ans;
  return ans;
}
 
int main()
{
  fastio();
ll int T;
T=1;
while(T--)
{

cin>>n;

for(i=0;i<n;i++)
{
  for(j=0;j<n;j++)
    dp[i][j]=(double)-1;
}

for(j=0;j<n;j++)
  cin>>p[j];

cout << fixed << setprecision(10) ;
double answer= solve(0,0);
cout<<answer<<endl;
}






    return 0;
}

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

typedef long long LL;

string s;

LL fe(LL x, LL y){
	if(y == 0) return 1LL;
	LL ret = fe(x,y/2);
	ret = ret*ret;
	if(y&1) ret = ret*x;
	return ret;
}

LL f(int x, LL y){
//	cout << x << " " << y << endl;
	LL tmp = y*10LL+s[x]-'0';
	int pan = 0;
	LL lala = y;
	while(lala > 0){
		lala/=10;
		pan++;
	}
	int kiri = x-pan;
	int kur = 2;
	if(kiri == 0) kur--;
	if(x>=s.size()){
		kur--;
//		cout << "KONTRIBUTE " << y << " TIMES " << fe(2LL,s.size()-pan-1) << endl;
		return y*fe(2LL,s.size()-pan-kur);
	}
//	cout << "KONTRIBUTE " << y << " TIMES " << fe(2LL,s.size()-pan-kur) << endl;
	return (y*fe(2LL,s.size()-pan-kur));
}

int main(){
	cin >> s;
	LL ans = 0LL;
	for(int i=0;i<s.size();i++){
		LL tmp = 0LL;
		for(int j=i;j<s.size();j++){
			tmp*=10LL;
			tmp+=s[j]-'0';
			ans+=f(j+1,tmp);
		}
	}
	cout << ans << endl;
//	cout << f(1,s[0]-'0') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{";
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r;
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/
double calc(double a, double b, double c) {
	return a * a + b * b + c * c;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> x(n), y(n), z(n,0);
  double X = 0, Y = 0, Z = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] ;
    X += x[i];
    Y += y[i];
    Z += z[i];
  }
  X /= n, Y /= n, Z /= n;
	double delta = 0.1;
  const int MAGIC = 1e5 + 42;
	for (int iter = 0; iter < MAGIC; ++iter) {
    int u = -1;
    double far = -1 / 0.0;
    for (int i = 0; i < n; ++i) {
      if (uax(far, calc(X - x[i], Y - y[i], Z - z[i]))) u = i;
    }
    X += (x[u] - X) * delta;
    Y += (y[u] - Y) * delta;
    Z += (z[u] - Z) * delta;
    delta *= 0.9987;
	}
  cout.precision(18);
   long double mx=0;
   for(int i=0;i<n;i++){
        long double dist = calc(X-x[i] , Y-y[i],0);
        dist=sqrt(dist);
        mx=max(mx , dist);
   }
   cout<<fixed<<mx;
}


Measured memory_bytes: 256