akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(31)]
for ai in a:
  i = 0
  while ai > 0:
    if ai%2 == 1:
      x[i] += 1
    ai = ai//2
    i += 1
for i in range(31):
  x[i] = x[i]%2
for ai in a:
  s = 0
  for i in range(31):
    if ai%2 == 1:
      if x[i] == 0:
        s += 2**i
    else:
      if x[i] == 1:
        s += 2**i
    ai = ai//2
  print(s)

Measured memory_bytes: 94044
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	int n,W;
	cin>>n>>W;
	vector<long long> v(n), w(n);
	for(int i=0;i<n;i++) {
		cin>>w[i]>>v[i];
	}
	vector<vector<long long>> dp(n+1,vector<long long> (W+1));
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=W;j++) {
			if(j<w[i-1]) {
				dp[i][j] = dp[i-1][j];    //exclude
			} else {
				dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j-w[i-1]]);
			}
		}
	}
	cout<<dp[n][W];
	
}


Measured memory_bytes: 83012
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        _n: usize,
        s: chars,
        k: usize,
    }
    let c = s[k - 1];
    let ans = s
        .iter()
        .map(|x| if *x == c { *x } else { '*' })
        .collect::<String>();
    println!("{}", ans);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,A;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>A;
	if(X<A) cout<<0<<endl;
	else cout<<10<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 892
n = gets.to_i
arr = gets.split.map(&:to_i)
res_arr = []
1.upto(n) do |t|
  lt_arr = []
  gt_arr = []
  arr.each_with_index do |e, i|
    if i <= t
      lt_arr << e
    else i > t
      gt_arr << e
    end
  end
  res_arr << (lt_arr.inject(:+) - gt_arr.inject(:+)).abs unless lt_arr.empty? || gt_arr.empty?
end
puts res_arr.min

Measured memory_bytes: 3836
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n;
  cin >> n;
  bool prime[100005] = {false};
  lol ans[100005] = {};
  prime[1] = true;
  for(int i = 2;i * i <= 100000;i ++){
    if(!prime[i]){
      for(int j = i * 2;j <= 100000;j += i){
	prime[j] = true;
      }
    }
  }
  reps(i, 100000){
    if(!prime[i] && !prime[(i + 1) / 2]){
      ans[i] ++;
    }
    ans[i] += ans[i - 1];
  }
  int l, r;
  rep(i, n){
    cin >> l >> r;
    cout << ans[r] - ans[l - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
N, X, M = map(int, input().split())

mod_check_list = [False for _ in range(M)]
mod_list = [(X ** 2) % M]
counter = 1
mod_sum = (X ** 2) % M
last_mod = 0
for i in range(M):
    now_mod = (mod_list[-1] ** 2) % M
    if mod_check_list[now_mod]:
        last_mod = now_mod
        break
    mod_check_list[now_mod] = True
    mod_list.append(now_mod)
    counter += 1
    mod_sum += now_mod

loop_start_idx = 0
for i in range(counter):
    if last_mod == mod_list[i]:
        loop_start_idx = i
        break

loop_list = mod_list[loop_start_idx:]
loop_num = counter - loop_start_idx
ans = 0
if mod_list[-1] == 0:
    ans = X + sum(mod_list[:min(counter, N - 1)])
else:
    if (N - 1) <= counter:
        ans = X + sum(mod_list[:N - 1])
    else:
        ans += X + mod_sum
        N -= (counter + 1)
        ans += sum(loop_list) * (N // loop_num) + sum(loop_list[:N % loop_num])
print(ans)

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (-A+B <= 0) cout << "delicious" << endl;
  else if (0<-A+B && -A+B<=X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static ArrayList<Integer> list;

    public static void main(String args[]) throws FileNotFoundException {
        list = new ArrayList<Integer>();
        Scanner stdIn = new Scanner(System.in);
        while (stdIn.hasNext()) {
            list.add(stdIn.nextInt());
        }
        algorith(list.get(0), 1);
    }

    private static void algorith(Integer N, int index) {
        int min = 1000;
        int max = 0;
        int Sum = 0;
        if (list.size() < (N + index + 1)) {
            return;
        }
        for (int i = index; i < (N + index); i++) {
            if (list.get(i) < min) {
                min = list.get(i);
            }
            if (list.get(i) > max) {
                max = list.get(i);
            }
            Sum += list.get(i);
        }
        int result = (Sum - max - min) / (N - 2);
        System.out.println(result);
        algorith(list.get(N + index), N + index + 1);
    }
}



Measured memory_bytes: 29876
#include <bits/stdc++.h>
using namespace std;
const int M = 6;
struct hs {
	int v[M];
	hs(){
		memset(v, 0, sizeof(v));
	}
};
hs mods;
int mds[] = {
	961'748'927,
	961'820'429,
	1'000'000'007,
	1'000'000'009,
	1'003'162'753,
	1'023'893'771
};
hs create(int x){
	hs r;
	for(int i = 0; i < M; i++){
		r.v[i] = x % mods.v[i];
		if(r.v[i] < 0) r.v[i] += mods.v[i];
	}
	return r;
}
hs operator + (hs a, hs b){
	hs r;
	for(int i = 0; i < M; i++){
		r.v[i] = a.v[i] + b.v[i];
		if(r.v[i] >= mods.v[i]) r.v[i] -= mods.v[i];
	}
	return r;
}
hs operator - (hs a, hs b){
	hs r;
	for(int i = 0; i < M; i++){
		r.v[i] = a.v[i] - b.v[i];
		if(r.v[i] < 0) r.v[i] += mods.v[i];
	}
	return r;
}
hs operator * (hs a, hs b){
	hs r;
	for(int i = 0; i < M; i++){
		r.v[i] = 1ll * a.v[i] * b.v[i] % mods.v[i];
	}
	return r;
}
bool operator < (hs a, hs b){
	for(int i = 0; i < M; i++) if(a.v[i] != b.v[i]) return a.v[i] < b.v[i];
	return false;
}
int pwr(int a, int b, int mod){
	int r = 1;
	for(; b; b>>=1, a = 1ll * a * a % mod) if(b&1) r = 1ll * r * a % mod;
	return r;
}
bool is_prime(int x){
	for(int i = 2; i * i <= x; i++) if(x % i == 0) return false;
	return true;
}
const int maxn = 300300;
using Poly = pair<hs, hs>;
hs eval(Poly f, hs x){
	return f.first + (f.second * x);
}
Poly poly[maxn];
int main(){
	srand(time(NULL));
	memcpy(mods.v, mds, sizeof(int) * M);
	hs x, mx, minus = create(-1), plus = create(1);
	int xx;
	do {
		xx = 900'999'999 + 50;
		xx += rand() % 1000;
	} while(!is_prime(xx));
	x = create(xx);
	for(int i = 0; i < M; i++){
		mx.v[i] = pwr(x.v[i], mods.v[i] - 2, mods.v[i]);	
		assert((1ll * mx.v[i] * x.v[i] % mods.v[i]) == 1);
	}
	int n; cin >> n;
	string s; cin >> s;
	poly[n] = {create(0), create(1)};
	for(int i = n - 1; i >= 0; i--){
		poly[i] = poly[i + 1];
		if(s[i] == '+'){
			poly[i].first = poly[i].first - poly[i].second;
		} else if(s[i] == '-'){
			poly[i].first = poly[i].first + poly[i].second;
		} else {
			hs mul = x;
			if(s[i] == '<')
				mul = mx;
			poly[i].second = poly[i].second * mul;
		}
	}
	Poly norm = poly[n];
	for(int i = 0; i < n; i++){
		if(s[i] == '+'){
			norm.first = norm.first + norm.second;
		} else if(s[i] == '-'){
			norm.first = norm.first - norm.second;
		} else if(s[i] == '<'){
			norm.second = norm.second * x;
		} else {
			norm.second = norm.second * mx;
		}
	}
	hs tot = norm.first;
	map<hs, int> cnt;
	cnt[poly[n].first]++;
	long long ans = 0;
	for(int i = n - 1; i >= 0; i--){
		ans += cnt[eval(poly[i], tot)];
		cnt[poly[i].first]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53636
using System;
using System.Collections.Generic;

namespace ARC061C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var bitLength = S.Length - 1;
            var answer = 0L;
            for (var bit = 0; bit < (1 << bitLength); bit++)
            {
                var buf = new List<char>();
                for (var i = 0; i < S.Length; i++)
                {
                    buf.Add(S[i]);
                    if ((bit & (1 << i)) != 0)
                    {
                        answer += long.Parse(buf.ToArray());
                        buf = new List<char>();
                    }
                }
                if (buf.Count > 0)
                {
                    answer += long.Parse(buf.ToArray());
                }
            }
            Console.WriteLine(answer);
        }
    }
}


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

int main(){
  string str1;
  cin >> str1;
  
  int  n = stoi(str1);
  int  L = n / 100;
  int  R = n % 100;
   

 if(1<=L&&L<=12){
    if(1<=R&&R<=12)printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }else{
    if(1<=R&&R<=12)printf("YYMM\n");
    else printf("NA\n");
  }
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct{
    long price;
    int num;
}shop;

//昇順
int asc(const void* a, const void* b){
    shop p = *(shop*)a;
    shop q = *(shop*)b;

    if(p.price<q.price) return -1;
    else if(p.price>q.price) return 1;
    return 0;
}

int main(void){
    int N,M;
    scanf("%d%d",&N,&M);

    //S[0]~S[N-1]に格納する
    shop* S;
    NEW(S,N);
    for(int i=0;i<N;i++){
        scanf("%ld%d",&S[i].price, &S[i].num);
    }
    qsort(S,N,sizeof(shop),asc);

    long ans=0;
    int i=0;
    while(M>0){
        if(M>=S[i].num){
            ans+=S[i].price*S[i].num;
            M-=S[i].num;
        }
        else{
            ans+=S[i].price*M;
            M=0;
        }
        i++;
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 3324
n, k, q = map(int, input().split())
p = []
for i in range(n):
    p.append(0)
for i in range(q):
    a = int(input())
    p[a - 1] += 1

for i in range(n):
    if q - p[i] >= k:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 4684
import sys
import math
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            ans += A[i] * A[j]
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < 4; i++){
    if(n%10 == 2) ans++;
    n /= 10;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
number=[int(i) for i in input().split()]
number.sort()
a,b,c=number

#aを何回操作すればｃかc-1にできるか
anum=(c-a)//2
amari=(c-a)%2

bnum=(c-b)//2
bamari=(c-b)%2
c=amari+bamari

if c==0:
    plus=0
elif c==1:
    plus=2
else:
    plus=1
print(anum+bnum+plus)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{ 
	int n,c,x,y,p[100],i;
	y=0;
	scanf("%d %d",&n,&c);
	for(i=0;i<c;i++){
	scanf("%d",&p[i]);
	y=y+p[i];
	}
	x=y/(n+1);
	if(y%(n+1)!=0){
	printf("%d\n",x+1);
	}
	else{
	printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

long double n,m,d,ans=0;

int main(){
  cin >> n >> m >> d;
  if(d==0){
    ans=(m-1)/n;
  }
  else{
    ans=2*(m-1)*(n-d)/pow(n,2);
  }
  cout << fixed << setprecision(10) << ans << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
char name[9][16];
int main() {
	int n, m, I;
	char name[16];
	for(I = 0; I < 9; ++ I) {
		scanf("%s %d %d", name, &n, &m);
		printf("%s %d %d\n", name, n + m, 200 * n + 300 * m);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		long a = Long.parseLong(scanner.nextLine());


		if(isPrime(a)) {

			System.out.println(a);
			return;

		}

		if(a % 2 == 0) {

			a++;

		}




		for(;;) {

			if(isPrime(a)) {

				System.out.println(a);
				return;
			}

			a += 2;

		}
	}
	private static boolean isPrime(long num) {
		if(num < 2)  return false;
		if(num == 2) return true ;
		if(num % 2 == 0) return false;

		for(int i = 3; i < Math.sqrt(num); i++) {
			//素数？素数じゃない？
			if(num % i == 0) {return false;}

		}

		return true;
	}
}

Measured memory_bytes: 35700
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll x, y;
    cin >> x >> y;

    ll res = INF;

    for (int i = -1; i <= 1; i++)
    {
        for (int j = -1; j <= 1; j++)
        {
            if (i * j == 0)
                continue;

            ll t = (y * j - x * i);

            if (i < 0)
                t++;
            if (j < 0)
                t++;

            if (t > 0)
            {
                res = min(res, t);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int q = read.to!int;

	auto xh = new RedBlackTree!(long, "a>b", true);
	auto yh = new RedBlackTree!(long, "a<b", true);
	long z;
	bool hasZ;
	long xsum, ysum;
	long bsum;
	
	foreach(_; 0 .. q){
		
		print!1("0 xh:", xh[], " xsum:", xsum, " z:", (hasZ? z: 999), " yh:", yh[], " ysum:", ysum, " bsum:", bsum);
		int t = read.to!int;
		if(t == 1){
			long a = read.to!long;
			long b = read.to!long;
			print!1("xh.length:", xh.length, " yh.length:", yh.length, " hasZ:", hasZ);
			print!1("1 xh:", xh[], " xsum:", xsum, " z:", (hasZ? z: 999), " yh:", yh[], " ysum:", ysum, " bsum:", bsum);
			if(hasZ){
				if(a < z){
					print!1("X odd");
					xh.insert(a), xsum += a;
					yh.insert(z), ysum += z;
					hasZ = 0;
				}
				else{
					print!1("Y odd");
					xh.insert(z), xsum += z;
					yh.insert(a), ysum += a;
					hasZ = 0;
				}
			}
			else{
				print!1("a:", a, " x:", xh.front, " y:", yh.front);
				if(! xh.empty && a < xh.front){
					print!1("X even");
					xh.insert(a), xsum += a;
					z = xh.front;
					xh.removeFront, xsum -= z;
					hasZ = 1;
				}
				else if(! yh.empty && a > yh.front){
					print!1("Y even");
					yh.insert(a), ysum += a;
					z = yh.front;
					yh.removeFront, ysum -= z;
					hasZ = 1;
				}
				else{
					print!1("Z even");
					z = a;
					hasZ = 1;
				}
			}
			bsum += b;
			print!1("2 xh:", xh[], " xsum:", xsum, " z:", (hasZ? z: 999), " yh:", yh[], " ysum:", ysum, " bsum:", bsum);
		}
		else{
			if(hasZ) writeln(z, " ", ysum - xsum + bsum);
			else writeln(xh.front, " ", ysum - xsum + bsum);
		}
		
		print!1("3 xh:", xh[], " xsum:", xsum, " z:", (hasZ? z: 999), " yh:", yh[], " ysum:", ysum, " bsum:", bsum);
	}
	
}



Measured memory_bytes: 23420
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n , k ; cin >> n >> k ; 
min_self( k , n );
vector<ll>arr(n);
for(ll i = 0 ; i<n ; i++)cin >> arr[i] ; 
sort(all(arr) , greater<ll>());
 ll ans = 0 ; 
for(ll  i = k ; i<n ; i++){
	ans += arr[i];
}
cout << ans ;

	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define data data1
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
            int n;
            cin>>n;
            int a[n];
            rep(i,0,n)cin>>a[i];         
            int tot=0;
            rep(i,0,n)tot^=a[i];
            int ans=0;
            rep(i,0,n)
            {
                  ans=(tot^a[i]);
                  cout<<ans<<" ";
            }
            cout<<endl;
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

typedef struct dice_tag{
	int num[8];
} dice_t;


void north(dice_t *dice)
{
	int tmp = dice->num[1];
	dice->num[1] = dice->num[2];
	dice->num[2] = dice->num[6];
	dice->num[6] = dice->num[5];
	dice->num[5] = tmp;
}

void south(dice_t *dice)
{
	int tmp = dice->num[1];
	dice->num[1] = dice->num[5];
	dice->num[5] = dice->num[6];
	dice->num[6] = dice->num[2];
	dice->num[2] = tmp;
}

void west(dice_t *dice)
{
	int tmp = dice->num[1];
	dice->num[1] = dice->num[3];
	dice->num[3] = dice->num[6];
	dice->num[6] = dice->num[4];
	dice->num[4] = tmp;
	
}

void east(dice_t *dice)
{
	int tmp = dice->num[1];
	dice->num[1] = dice->num[4];
	dice->num[4] = dice->num[6];
	dice->num[6] = dice->num[3];
	dice->num[3] = tmp;

}

void turnRight(dice_t *dice)
{
	int tmp = dice->num[2];
	dice->num[2] = dice->num[4];
	dice->num[4] = dice->num[5];
	dice->num[5] = dice->num[3];
	dice->num[3] = tmp;
}

int equivDice(dice_t *dice1, dice_t *dice2)
{
	if(dice1->num[1] == dice2->num[1] && dice1->num[2] == dice2->num[2] && dice1->num[3] == dice2->num[3]
	&& dice1->num[4] == dice2->num[4] && dice1->num[5] == dice2->num[5] && dice1->num[6] == dice2->num[6])
	{
		return 1;
	}
	else return 0;
}

int check_equiv_dice(dice_t *dice1, dice_t *dice2)	
{	int i;
	for(i = 0; i < 4; i++)
	{
		if(equivDice(dice1, dice2))
		{
			
			return 1;
		}

		turnRight(dice1);
	}

	
	return 0;

}



int main(void)
{
	int j, flag = 0;
	dice_t dice1, dice2;

	for(int i = 1; i <= 6; i++) scanf("%d", &dice1.num[i]);
	for(int i = 1; i <= 6; i++) scanf("%d", &dice2.num[i]);
	
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}
	north(&dice1);
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}
	north(&dice1);
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}
	north(&dice1);
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}
	east(&dice1);
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}
	east(&dice1);
	east(&dice1);
	if(flag = check_equiv_dice(&dice1, &dice2))
	{
		printf("Yes\n");
		return 0;
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];

    ll sum = accumulate(as.begin(), as.end(), 0ll, [](ll a, ll b) { return a ^ b; });

    for (ll l : as) cout << (sum ^ l) << endl;

}


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, k;
    string s;

    cin >> n >> k >> s;

    int res = 0;
    int d = 0;

    for (int i = 0; i < n - 1; i++)
    {
        d += s[i] != s[i + 1];
        res += s[i] == s[i + 1];
    }

    res += min(d, k * 2);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
  public class Program
  {
    public static void Main(string[] args)
    {
      long N = long.Parse(Console.ReadLine());
      long s = 0;
      for(long i=1;i<=N;++i)
      for(long j=1;j<=N;++j)
      for(long k=1;k<=N;++k)
      {
        s+=Gcd(Gcd(i,j),k);
      }
      Console.WriteLine(s);
    }
    public static long Gcd(long m, long n)
    {
        long temp;
        while (m % n != 0)
        {
            temp = n;
            n = m % n;
            m = temp;
        }
        return n;
    }  
  }
}

Measured memory_bytes: 27536
#include <cstdio>
#include <algorithm>

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

const int maxn=500000;
const int mod=998244353;
const int inv=499122177;

int n,m,ans,fac[maxn*2+10],ifac[maxn*2+10];

int main()
{
  n=read();
  m=read();
  fac[0]=ifac[0]=ifac[1]=1;
  for(int i=1; i<=std::max(n,m)*2; ++i)
    {
      fac[i]=1ll*fac[i-1]*i%mod;
    }
  for(int i=2; i<=std::max(n,m)*2; ++i)
    {
      ifac[i]=1ll*(mod-mod/i)*ifac[mod%i]%mod;
    }
  for(int i=1; i<=std::max(n,m)*2; ++i)
    {
      ifac[i]=1ll*ifac[i-1]*ifac[i]%mod;
    }
  ans=std::max(n,m);
  for(int i=1; i<=std::min(n,m); ++i)
    {
      ans=(ans+1ll*fac[n+m-2*i]*fac[2*i]%mod*fac[n]%mod*fac[m]%mod*ifac[n+m]%mod*ifac[n-i]%mod*ifac[m-i]%mod*ifac[i]%mod*ifac[i]%mod*inv)%mod;
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 7936
# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=200010,INF=0x3f3f3f3f;
int a[N];
int cnt[N];
int n;
int ans;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	n=read();
	for(rr int i=1;i<=n;++i){
		a[i]=read();
		++cnt[a[i]];
	}
	for(rr int i=1;i<=n;++i){
		if(cnt[i]>=2){
			ans+=(1+(cnt[i]-1))*(cnt[i]-1)/2;
		}
	}
	for(rr int i=1;i<=n;++i){
		if(cnt[a[i]]<2){
			printf("%lld\n",ans);
		}else{
			int prd=(1+(cnt[a[i]]-2))*(cnt[a[i]]-2)/2,ped=(1+(cnt[a[i]]-1))*(cnt[a[i]]-1)/2;
			ans-=ped,ans+=prd;
			printf("%lld\n",ans);
			ans+=ped,ans-=prd;
		}
	}
	return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
           int m,f,r;
           m=sc.nextInt();
           f=sc.nextInt();
           r=sc.nextInt();
           if(m==-1&&f==-1&&r==-1)break;
            if(m==-1||f==-1)System.out.println("F");
            else if(m+f>=80)System.out.println("A");
            else if(m+f>=65)System.out.println("B");
            else if(m+f>=50)System.out.println("C");
            else if(m+f<30)System.out.println("F");
            else if(r>=50)System.out.println("C");
            else System.out.println("D");
    }
}
}



Measured memory_bytes: 26416
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, r;
        cin >> n >> r;
        if(n == 0)
            break;
        vector<int> p(r), c(r);
        for(int i=0; i<r; ++i)
            cin >> p[i] >> c[i];

        int ret = 1;
        for(int i=r-1; i>=0; --i){
            if(ret <= c[i])
                ret += p[i] - 1;
            else if(ret <= c[i] + p[i] - 1)
                ret -= c[i];
        }
        cout << (n - ret + 1) << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main(){
	bool a[30];
	int b[28];
	for(int i=0;i<30;i++){
		a[i]=false;
	}
	for(int i=0;i<28;i++){
		std::cin>>b[i];
		a[b[i]-1]=true;
	}
	for(int i=0;i<30;i++){
		if(a[i]==false){
			std::cout<<i+1<<std::endl;
		}
	}
}

Measured memory_bytes: 3092
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = l[0], k = l[1];
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dp = Enumerable.Repeat(int.MaxValue, n).ToArray();
            dp[0] = 0;
            for (var i = 1; i < n; i++)
            {
                for (var j = 1; j <= Math.Min(i, k); j ++)
                {
                    dp[i] = Math.Min(dp[i], dp[i-j] + Math.Abs(h[i]-h[i-j]));
                }
            }
            
            Console.WriteLine(dp[n-1]);
        }
    }
}


Measured memory_bytes: 21216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()/2) {
		int cnt = 0;
		rep(j, i) {
			if (s[j] == s[i + j]) {
				cnt++;
			}
		}
		if (cnt == i) {
			ans = i*2;
		}
	}
	cout << ans;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
#include<deque>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


int N, M;
vector<VI> G;
int color[100010];

bool dfs(int u, int c) {
	color[u] = c;
	REP(i, G[u].size()) {
		int v = G[u][i];
		if (color[v] == c)return false;
		if (color[v] == 0 && !dfs(v, -c)) {
			return false;
		}
	}
	return true;
}




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

	cin >> N >> M;
	G.resize(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int B = 0, W = 0;
	if (dfs(0, 1)) {
		REP(i, N) {
			if (color[i] == 1) {
				B++;
			}
			else if(color[i]==-1){
				W++;
			}
		}
		cout << B * W - M << endl;
	}
	else {
		cout << ((N*(N - 1)) / 2) - M << endl;
	}
	
	return 0;
}



Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
long long N,a,b,c,d;
map<long long, long long> dp;
long long get_dp(long long x)
{
  if(dp.count(x)) return dp[x];
  long long res = min(3e18, (double)x*a);
  if(x%2) res = min(res, min(get_dp(x/2),get_dp(x/2+1)) + a + b);
  else res = min(res, get_dp(x/2) + b);
  if(x%3 == 0) res = min(res,get_dp(x/3)+c);
  else if(x%3 == 1) res = min(res,get_dp(x/3)+c+a);
  else if(x%3 == 2) res = min(res,get_dp(x/3+1)+c+a);
  if(x%5 == 0) res = min(res,get_dp(x/5)+d);
  else if(x%5 == 1) res = min(res,get_dp(x/5)+d+a);
  else if(x%5 == 2) res = min(res,get_dp(x/5)+d+a+a);
  else if(x%5 == 3) res = min(res,get_dp(x/5+1)+d+a+a);
  else if(x%5 == 4) res = min(res,get_dp(x/5+1)+d+a);
  dp[x] = res;
  return res;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long T;
  cin >> T;
  while(T--)
  {
    dp.clear();
    cin >> N >> b >> c >> d >> a;
    dp[0] = 0;
    dp[1] = a;
    cout << get_dp(N) << endl;
  }
  return 0;
}


Measured memory_bytes: 4348
#include <algorithm>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;
int n, m;
vector<vector<int>> p;

int main() {
  cin >> n >> m;
  p.resize(n);
  for (int i = 0; i < m; i++) {
    int t, f;
    cin >> t >> f;
    t--;
    f--;
    p[t].push_back(f);
    p[f].push_back(t);
  }
  vector<int> ans(3 * n);
  set<int> as;
  int offset = n * 3 / 2, size = 2;
  ans[offset] = 0;
  ans[offset + 1] = p[0][0];
  as.insert(0);
  as.insert(p[0][0]);
  while (true) {
    set<int> bs, es;
    for (int i = 0; i < p[ans[offset]].size(); i++) {
      if (as.find(p[ans[offset]][i]) == as.end())
        bs.insert(p[ans[offset]][i]);
    }
    for (int i = 0; i < p[ans[offset + size - 1]].size(); i++) {
      if (as.find(p[ans[offset + size - 1]][i]) == as.end())
        es.insert(p[ans[offset + size - 1]][i]);
    }
    if (bs.size() + es.size() == 0) {
      cout << size << endl;
      cout << ans[offset] + 1;
      for (int i = 1; i < size; i++)
        cout << " " << ans[offset + i] + 1;
      cout << endl;
      break;
    } else {
      if (bs.size() > 0) {
        offset--;
        size++;
        ans[offset] = (*bs.begin());
        as.insert(*bs.begin());
      } else {
        size++;
        ans[offset + size - 1] = (*es.begin());
        as.insert(*es.begin());
      }
    }
  }

  return 0;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename X, typename Y> ostream &operator<< (ostream &fout, const pair<X, Y> &p)
{ fout << '{' << p.first << ", " << p.second << "} "; return fout; }

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 2e3 + 5;

int main()
{
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    sort(a.begin(), a.end());
    ll sa = 0, sb = 0;
    ll al = 1;
    for (ll i = n - 1; i >= 0; i--) {
        if (al) { sa += a[i]; }
        else { sb += a[i]; }
        al = !al;
    }
    cout << llabs(sa - sb) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
using namespace std;
int main(){
    int n;
    cin>>n;
    unordered_map<string,int>bmp,rmp;
    for(int i=0;i<n;i++)
    {
        string element;
        cin>>element;
        if(bmp.find(element)==bmp.end()){
            bmp[element]=1;
        }
        else
        {
            bmp[element]++;
        }
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        string element;
        cin>>element;
        if(rmp.find(element)==rmp.end()){
            rmp[element]=1;
        }
        else
        {
            rmp[element]++;
        }
    }
    int finalresult=0;
    for(auto it=bmp.begin();it!=bmp.end();it++)
    {
        int result=0;
        if(rmp.find(it->first)==rmp.end()){
            result+=it->second;
        }
        else
        {
            int red=rmp.find(it->first)->second;
            result+=max(0,it->second-red);
        }
        if(finalresult<result)
        {
            finalresult=result;
        }
    }
    cout<<finalresult;
}

Measured memory_bytes: 3592
def ext_row(i, matrix):
    return matrix[i]


def ext_col(j, matrix):
    return [row[j] for row in matrix]


def inner_prod(va, vb):
    return sum([a * b for a, b in zip(va, vb)])


n, m, l = map(int, input().split())

A = [[0] * m for _ in range(n)]
B = [[0] * l for _ in range(m)]

for i in range(n):
    A[i] = [int(c) for c in input().split()]
for i in range(m):
    B[i] = [int(c) for c in input().split()]

ans = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        ans[i][j] = inner_prod(ext_row(i, A), ext_col(j, B))
for row in ans:
    print(' '.join([str(i) for i in row]))



Measured memory_bytes: 6836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  vector<vector<char>>f(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>f.at(i).at(j);
    }
  }
  for(int i=0;i<h;i++){
    bool a=true;
    for(int j=0;j<w;j++){
      if(f.at(i).at(j)=='#'){
        a=false;
        break;
      }
    }
    if(a){
      for(int j=0;j<w;j++){
        f.at(i).at(j)='*';
      }
    }
  }
  for(int i=0;i<w;i++){
    bool a=true;
    for(int j=0;j<h;j++){
      if(f.at(j).at(i)=='#'){
        a=false;
        break;
      }
    }
    if(a){
      for(int j=0;j<h;j++){
        f.at(j).at(i)='*';
      }
    }
  }
  for(int i=0;i<h;i++){
    bool ex=false;
    for(int j=0;j<w;j++){
      if(f.at(i).at(j)=='*')continue;
      cout <<f.at(i).at(j);
      ex=true;
    }
    if(ex)cout <<endl;
  }
  cout <<endl;
}

Measured memory_bytes: 3580
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int MAX = 1 << 30;

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

    int n, m;
    cin >> n >> m;

    vector<int> cost(m), vec(m);
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> cost[i] >> b;
        for (int j = 0; j < b; j++) {
            cin >> c;
            c--;
            vec[i] += 1 << c;
        }
    }

    // i番目の鍵までのなかで、箱の組み合わせjを開けるのに必要な最小コスト
    vector <vector<int>> dp(m + 1, vector<int>(1 << n, MAX));
    dp[0][0] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < (1 << n); j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);

            int use = j | vec[i - 1];
            dp[i][use] = min(dp[i][use], dp[i - 1][j] + cost[i - 1]);
        }
    }

    if (dp[m][(1 << n) - 1] == MAX) {
        cout << -1 << '\n';
    } else {
        cout << dp[m][(1 << n) - 1] << '\n';
    }

    return 0;
}

Measured memory_bytes: 16384
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>p(n);
  rep(i,n) cin >> p.at(i);
  sort(p.begin(),p.end());
  int sum = 0;
  rep(i,k) sum += p.at(i);
  cout << sum << endl;
}

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

v = [2]
for i in range(3,n+1):
    sosu = True
    for j in v:
        if i%j == 0:
            sosu = False
    if sosu:
        v.append(i)


ans = 1
for j in v:
    count = 0
    for i in range(1,n+1):
        while i%j == 0:
            count += 1
            i= i//j
    ans = (ans * (count+1))%(10**9+7)
print(ans)

Measured memory_bytes: 39792
N=int(input())
H=list(map(int,input().split()))

C=[H[0]]
for i in range(1,N):
    if H[i-1]!=H[i]:
        C.append(H[i])
        
for i in range(len(C)-1):
    if C[i]>C[i+1]:
        C[i]-=1

F=True
for i in range(len(C)-1):
    F&=(C[i]<=C[i+1])

if F:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 90660
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC optimize("O3")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000*1000+5;
const ll N2      = 2000*1000*10;
const ld PI  = 3.141592653589793;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tree_set;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    int a[n],b[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    b[0]=a[0];
    for(int i = 1 ; i<n ; i++)
    {
        b[i] = min(b[i-1],a[i]);
    }
    int count(0);
    for (int i = 0; i < n; ++i)
    {
        if(a[i]<=b[i])
            count++;
    }
    cout<<count;
}

Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e6+3; //AREGLAAAAAAAAR!!!!
char a[223456];
int cant[234567];
map<char,int>mapa;

int main(){
	scanf("%s",a);
	int tam=strlen(a);
	FORR(i,tam-1,-1){
		cant[i]=mapa[a[i]];
		mapa[a[i]]++;
	}
	ll ans=0;
	FOR(i,0,tam) ans+=(tam-i-1-cant[i]);
	printf("%lld",ans+1);
}


Measured memory_bytes: 1280