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

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

    string s;
    cin >> s;

    vector<int> l(q);
    vector<int> r(q);
    for (int i = 0; i < q; i++)
    {
        int lin, rin;
        cin >> lin >> rin;
        lin--;
        rin--;
        l[i] = lin;
        r[i] = rin;
    }

    vector<int> c(n);
    int cnt = 0;
    char prev = '*';
    for (int i = 0; i < n; i++)
    {
        char current = s[i];
        if (prev == 'A' && current == 'C')
        {
            cnt++;
        }
        c[i] = cnt;
        prev = current;
    }

    for (int i = 0; i < q; i++)
    {
        int ans = c[r[i]] - c[l[i]];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextLong();
			for (long i = (long)Math.sqrt(n); i > 0; i--) {
				if (n % i == 0) {
					System.out.println(i + (n / i) - 2);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 23764
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long

const int mod = 1e9 + 7;
int fact[500001];
int ifact[500001];

int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

int inv(int n) { return power(n, mod - 2); }

int C(int n, int r) { return fact[n] * (ifact[n - r] * ifact[r] % mod) % mod; }

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

    fact[0] = 1;
    for (int i = 1; i < 500001; ++i)fact[i] = i * fact[i - 1] % mod;
    ifact[500000] = inv(fact[500000]);
    for (int i = 499999; i >= 0; --i) ifact[i] = (i + 1) * ifact[i + 1] % mod;

    int n, m;
    cin >> n >> m;
    int f = -1, ans = 0;
    for (int i = 0; i <= n; ++i) {
        f *= -1;
        ans = (ans + f * C(n, i) * fact[m - i] % mod) % mod;
        if (ans < 0)ans += mod;
    }
    ans = ans * fact[m] % mod;
    ans = ans * ifact[m - n] % mod * ifact[m - n] % mod;
    cout << ans << endl;
}

Measured memory_bytes: 11384
let a_s = Array.init 5 @@ fun _ -> Scanf.scanf " %d" (+) 0
let s, m = Array.fold_left (fun (s, m) a -> let w = (10 - a mod 10) mod 10 in s + a + w, max m w) (0, 0) a_s
let _ = Printf.printf "%d\n" @@ s - m

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

int main() {
  int K;
  cin >> K;
  int ans = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;

  int i = 0;
  while (i <= r) {
    if (i >= l) ans++;
    i += d;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	x := scanInts(5)
	for i := 0; i < 5; i++ {
		if x[i] == 0 {
			fmt.Println(i + 1)
			return
		}
	}
}


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

class Dice{
private:
  vector<int> data;

public: 
  Dice(): data(6,0){}
  Dice(vector<int> data): data(data){}

  void print_top(){
    cout << data[0] << endl;
  }  

  void print_all(){
    for(int d: data){
      cout << d << " ";
    }
    cout << endl;
  }

  void roll(char c){
    if(c == 'S'){
      swap(data[0], data[1]);
      swap(data[4], data[5]);
      swap(data[0], data[5]);
    }else if(c == 'N'){
      swap(data[0], data[1]);
      swap(data[4], data[5]);
      swap(data[1], data[4]);
    }else if(c == 'E'){
      swap(data[0], data[2]);
      swap(data[3], data[5]);
      swap(data[0], data[5]);
    }else if(c == 'W'){
      swap(data[0], data[2]);
      swap(data[3], data[5]);
      swap(data[2], data[3]);
    }
  }
};


int main(){
  vector<int> data(6);
  for(int i=0; i<6; i++){
    cin >> data[i];
  }
  Dice dice(data);

  string ops; cin >> ops;
  for(char op: ops){
    dice.roll(op);
  }

  dice.print_top();

  return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>

int min_p(int n); //nより小さい素数のうち最大のモノを返す
int max_p(int n); //nより大きい素数のうち最小のモノを返す

int main(void)
{
    int n;

    while (scanf("%d", &n) != EOF)
    {
        printf("%d %d\n", min_p(n), max_p(n));
    }
    return (0);
}
int min_p(int n)
{
    int i,j;
    int x;
    int flag;

    flag = 0;

    for (i = 2; i < n; i++){
        flag = 0;
        for (j = 2; j < i; j++){
            if (i % j == 0 && i != j){
                flag = 1;
                 break;
            }
        }
        if (flag == 0){
            x = i;
        }

    }
    return (x);

}
int max_p(int n)
{
    int i,j;
    int x;
    int flag;
    
    i = n + 1;
    while (1){
        flag = 0;
        for (j = 2; j < i; j++){
            if (i % j == 0 && i != j){
                flag = 1;
                 break;
            }
        }

        if (flag == 0){
            x = i;
            break;
        }
        i++;

    }
    return (x);
}


Measured memory_bytes: 1976
#include<stdio.h>
int a[100010],b[100010],c[100010];
int dp[4][100010];
int max(int a,int b){return a>b?a:b;}
int main(){
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d%d%d",&a[i],&b[i],&c[i]);
	dp[0][0]=a[0];dp[1][0]=b[0];dp[2][0]=c[0];
	for(i=1;i<n;i++){
		dp[0][i]=max(dp[1][i-1]+a[i],dp[2][i-1]+a[i]);
		dp[1][i]=max(dp[0][i-1]+b[i],dp[2][i-1]+b[i]);
		dp[2][i]=max(dp[0][i-1]+c[i],dp[1][i-1]+c[i]);
	}
	printf("%d",max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]));
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[100010],p=1,ans,x,mo=1000000007;
ll po(ll x,ll y){ll z=1;while (y){if (y%2==1)z=(x*z)%mo;x=(x*x)%mo;y/=2;}return z;}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)a[i]=(a[i-1]+po(i,mo-2))%mo;
	for (int i=1;i<=n;i++){p=p*i%mo;cin>>x;ans=(ans+x*(a[i]+a[n-i+1]-1))%mo;}
	cout<<ans*p%mo;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
struct one
{
	int cost, val[15];
} w[15];
int a[15], t[15];
int n, m, k;
inline bool check(void)
{
	rep(i, 0, m) if (t[i] < k) return 0;
	return 1;
}
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>k;
	t[0] = 11;
	t[1] = 12;
	t[2] = 13;
	rep(i, 0, n)
	{
		cin>>w[i].cost;
		rep(j, 0, m) cin>>w[i].val[j];
	}
	int ans = 1000000000;
	for( a[0] = 0; a[0] < 2; a[0]++)
	for( a[1] = 0; a[1] < 2; a[1]++)
	for( a[2] = 0; a[2] < 2; a[2]++)
	for( a[3] = 0; a[3] < 2; a[3]++)
	for( a[4] = 0; a[4] < 2; a[4]++)
	for( a[5] = 0; a[5] < 2; a[5]++)
	for( a[6] = 0; a[6] < 2; a[6]++)
	for( a[7] = 0; a[7] < 2; a[7]++)
	for( a[8] = 0; a[8] < 2; a[8]++)
	for( a[9] = 0; a[9] < 2; a[9]++)
	for( a[10] = 0; a[10] < 2; a[10]++)
	for( a[11] = 0; a[11] < 2; a[11]++)
	{
		memset(t, 0, sizeof(t));
		int cos = 0;
		rep(i, 0, n)
			if (a[i])
			{
				cos += w[i].cost;
				rep(j, 0, m) t[j] += w[i].val[j];
			}
		if (check()) ans = min(ans, cos);
	}
	if (ans == 1000000000) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3656
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [n, _] <- fmap (map read . words) getLine :: IO [Int]
    ass    <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
    print $ solve $ map tail ass    -- あらかじめ各行の先頭は取り除いておく

-- 全ての行に含まれる料理をintersectでフィルタしてカウント
solve :: [[Int]] -> Int
solve ass = length $ foldl1 intersect ass


Measured memory_bytes: 1148
use std::io::{stdout, BufWriter, Write};

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_x: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut ans = String::new();
    for x in in_x {
        ans += format!("{}\n", if x <= x1 { x2 } else { x1 }).as_str();
    }
    write!(out, "{}", ans).unwrap();
}

fn main() {
    use std::thread;
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}


Measured memory_bytes: 19704
N = int(input())
para = {}
for i in range(N):
    a = int(input())
    if not a in para.keys() :
        para[a] = 1
    else : para[a] += 1
ans = []
def judge(a) :
    for i in a.keys():
        if a[i] % 2 == 0 : pass
        else : ans.append(1)
    return sum(ans)

print("{}".format(judge(para)))



Measured memory_bytes: 15072
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define fore(a, v, n) for(ll a=v; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
//cout<<flush;

using namespace std;

int main() {
	IOS;


    string bw;
    cin >> bw;

    ll total = 0;
    ll i = 0;
    for(; bw[i] == 'W' && i < bw.size(); i++);

    ll contador = 0;
    for(; i < bw.size(); i++) {
        if (bw[i] == 'B') {
            contador++;
        } else {
            total += contador;
        }
    }

    cout << total << endl;


	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    vector<int> b(n);
    for(i = 0; i < n; i++){
        b.at(a.at(i)-1) = i+1; 
    }
    for(int x : b){
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int l;
    l = s.length();
    for(int i = 0; i<l; i++){
        int t = (s[i] - 'A');
        t+=n;
        t%=26;
        putchar(t+'A');
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll D;

int main(){
  cin>>D;
  if(D==25)cout<<"Christmas"<<endl;
  else if(D==24)cout<<"Christmas Eve"<<endl;
  else if(D==23)cout<<"Christmas Eve Eve"<<endl;
  else if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
int a,b,c;
string s,ss,sss;
cin>>a>>b;
if(a<=8&&b<=8)
cout<<"Yay!"<<endl;
else
cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	d=0;
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(a>c){
		d=a;
		a=c;
		c=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
N = gets.to_i
A = Array.new(N).map{
  gets.chomp.split(" ").map(&:to_i)
}

mn = A.map{|a, b| a}.sort
mx = A.map{|a, b| b}.sort

if N.even? then
  puts mx[N/2]+mx[N/2-1] - mn[N/2]-mn[N/2-1] + 1
else
  puts mx[(N-1)/2] - mn[(N-1)/2] + 1
end


Measured memory_bytes: 37868
s=input()
while 1:
    n = len(s)
    if n==0:
        print("YES")
        exit()
    elif 1<=n<=4:
        print("NO")
        exit()
    else:
        if s[n-5:n]=="dream" or s[n-5:n]=="erase":
            s=s[:n-5]
        elif s[n-6:n]=="eraser":
            s=s[:n-6]
        elif s[n-7:n]=="dreamer":
            s=s[:n-7]
        else:
            print("NO")
            exit()

Measured memory_bytes: 74240
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long int

using namespace std;

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if(i%k == 0){
            puts("OK");
            return 0;
        }
    }
    puts("NG");
    return 0;
}

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

using namespace std;
const int N = 100010;
int _w;

int n, a[N], b[N];
map<int,int> mp;

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for( int i = 1; i <= n; ++i )
		cin >> a[i], b[i] = a[i];
	sort(b+1, b+n+1);
	for( int i = 1; i <= n; ++i )
		mp[b[i]] = i & 1;
	int ans = 0;
	for( int i = 1; i <= n; ++i )
		ans += (i & 1) != mp[a[i]];
	printf( "%d\n", ans / 2 );
	return 0;
}


Measured memory_bytes: 5760
import sys
input = sys.stdin.readline
 
H, W = [int(x) for x in input().split()]
s = []
W_count = 0
for _ in range(H):
    tmp = list(input().rstrip())
    s.append(tmp)
    W_count += tmp.count('.')

from collections import deque
D = [[-1] * W for _ in range(H)]

def bfs():
    queue = deque([(0, 0, 0, 0)])
    D[0][0] = 0
    while queue:
        u = queue.popleft()
        x = u[0]
        y = u[1]
        D[x][y] = D[u[2]][u[3]] + 1
        for i in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]:
            if 0 <= i[0] < H and 0 <= i[1] < W and D[i[0]][i[1]] < 0 and s[i[0]][i[1]] == ".":
                queue.append((i[0], i[1], x, y))
                s[i[0]][i[1]] = "#"
    return D

D = bfs()
if D[-1][-1] == -1:
    print(-1)
    sys.exit()
print(W_count - D[-1][-1])




Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;

int main() {
	
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++){
		cout << a[i] ;
if(i<b.size())cout<< b[i];
}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int a, b;

int main(int argc, char *argv[]){
    cin >> a >> b;
    if(a >=  13) cout << b << endl;
    else if(a >= 6 && a <= 12) cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    
    ll ans = 0;
    using pl4 = pair<ll, ll>;
    priority_queue<pl4> q;
    REP(i, n) {
        if (b[i] != a[i])
            q.push(pl4(b[i] - a[i], i));
    }
    while (q.size()) {
        pl4 v = q.top(); q.pop();
        ll i = v.second;
        ll opw = b[(i+1)%n] + b[(i-1+n)%n];
        ll num = v.first / opw;
        if (!num) {
            cout << -1 << endl;
            return 0;
        }
        ans += num;
        b[i] -= num * opw;
        if (b[i] != a[i]) {
            q.push(pl4(b[i] - a[i], i));
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 9584
a = gets.chomp.to_i
hsh = Hash.new{|k,v| k[v] = 0}
a.times do |j|
  b = gets.chomp.split("")
  tmp = Hash.new{|k,v| k[v] = 0}
  b.each do |item|
    tmp[item] += 1
  end
  [*'a'..'z'].each do |i|
    if j == 0
    hsh[i]=tmp[i]
    else
    hsh[i] = tmp[i] if hsh[i] > tmp[i] 
    end
  end
end

str = ""

[*'a'..'z'].each do |i|
  hsh[i].times do
    str << i
  end
end

puts str


Measured memory_bytes: 3964
#include <stdio.h>
#include <string.h>

int main(){

	char A[105], B[105], C[105];
	
	scanf("%s %s %s", A, B, C);
	if((A[strlen(A)-1] == B[0]) && (B[strlen(B)-1] == C[0]))
		printf("YES\n");
	else
		printf("NO\n");
		
	return 0;

}


Measured memory_bytes: 128
package main

import "fmt"

// 参考：http://drken1215.hatenablog.com/entry/2019/07/07/233700
func answer(L, R int) int {
	if R-L > 2019 {
		return 0
	}

	r := 2018
	for i := L; i <= R-1; i++ {
		for j := L + 1; j <= R; j++ {
			a := i * j % 2019
			if a < r {
				r = a
			}
		}
	}
	return r
}

func solve(L, R int) int {
	r := 3000
	for i := L; i <= R-1; i++ {
		for j := i + 1; j <= R; j++ {
			a := i * j % 2019
			if a < r {
				r = a
			}
		}
	}
	return r
}

func main() {
	var L, R int
	fmt.Scan(&L)
	fmt.Scan(&R)
	//fmt.Println(solve(L, R))
	fmt.Println(answer(L, R))
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

ll f[105][10];
ll p[105][11];
void solve(){
  int n;
  cin>>n;
  ll ans=-INF;
  rep(i,n){
    rep(j,10)cin>>f[i][j];
  }
  rep(i,n)rep(j,11)cin>>p[i][j];
  for(int bit=0;bit<(1<<10);++bit){
    ll sum=0;
    if(bit==0)continue;
    rep(i,n){
      ll cnt=0;
      rep(j,10){
        if(bit&(f[i][j]<<j))++cnt;
      }
      sum+=p[i][cnt];
    }
    chmax(ans,sum);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    ll n, k;

    cin >> n >> k;

    ll ans = 0;

    vector<ll> sum(k + 1);

    for (ll i = k; i >= 1; i--)
    {
        sum[i] = power(k / i, n);
        sum[i] %= MOD;

        for (ll j = 2 * i; j <= k; j += i)
        {
            sum[i] += MOD;
            sum[i] -= sum[j];
            sum[i] %= MOD;
        }
    }

    for (int i = 1; i <= k; i++)
    {
        ans += (i * sum[i]) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3948
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int height, width, black_height, black_width, area;
    height = Integer.parseInt(sc.next());
    width = Integer.parseInt(sc.next());
    black_height = Integer.parseInt(sc.next());
    black_width = Integer.parseInt(sc.next());
    area = (height - black_height) * (width - black_width);
    System.out.println(area);
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    int a, b, c;
    int i, judge = 0;
    
    cin >> a >> b >> c;
    
    for(i = 1; i < b; i++) {
        if((a * i) % b == c) {
            judge = 1;
            break;
        }
    }
  
    
    if(judge == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		int ans = 0;
		for(char x: s.toCharArray()) {
			if(x == '1') {
				ans++;
			}
		}
		
		System.out.println(ans);
	}

}


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

int main(int argc, const char * argv[]) {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d;
    e=a+b;
    f=c+d;
    if(e>f)cout<<"Left"<<endl;
    else if(e==f)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define ins insert
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define per(i,j,k) for(ll i=j;i>=k;--i)
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define ff first
#define ss second
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pll;
 
const int N = 2e5 + 5;
const int M = 1e5 + 1;
const int inf = INT_MAX;
const int mod = 1e9 + 7;

int32_t main() {
    io;
    // in; out;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}
 


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s,)


def solve(s):

    a = int(s[:2])
    b = int(s[2:])

    def mm(x):
        return 1 <= x and x <= 12

    def yy(x):
        return 0 <= x and x <= 99

    result = "NA"
    if mm(a) and mm(b):
        result = "AMBIGUOUS"
    elif mm(a) and yy(b):
        result = "MMYY"
    elif yy(a) and mm(b):
        result = "YYMM"

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int a, b, t;
    cin >> a >> b >> t;
    int ans = (t/a) * b;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;
		for (int i = 0; i < n - 2; i++) {
			char first = s.charAt(i);
			char second = s.charAt(i + 1);
			char third = s.charAt(i + 2);
			if (first == 'A' && second == 'B' && third == 'C') {
				count++;
			}
		}
		print(count);
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 23764
import Foundation

var r = Int(readLine()!)!
var i = 0
var j = 0
for _ in 0 ..< r {
    let arr=readLine()!.split{$0==" "}.map{Int(String($0))!}
        let n=arr[0]
        let a=arr[1]
    if a == n {
        i = i + 1
        if i > 2 {
           j = 1
        }
    }else{
        i = 0
    }
}

if j == 1 {
    print("Yes")
}else{
    print("No")
}

Measured memory_bytes: 13004
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
    int n;
    cin>>n;
    int a[n];
    f(i,0,n)cin>>a[i];
    int dp[n];
    ms(dp,0);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    f(i,2,n){
    	dp[i]=min(dp[i-1] +abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
 	return 0;
}


Measured memory_bytes: 1024
import heapq
N = int(input())
A = list(map(int,input().split()))

f = A[:N]
heapq.heapify(f)
S = sum(f)
fs = [S]
for i in range(N):
    a = A[N+i]
    S += a
    heapq.heappush(f,a)
    a = heapq.heappop(f)
    S -= a
    fs.append(S)

l = [-a for a in A[2*N:]]
heapq.heapify(l)
S = sum(l)
ls = [S]
for i in range(N):
    a = -A[2*N-i-1]
    S += a
    heapq.heappush(l,a)
    a = heapq.heappop(l)
    S -= a
    ls.append(S)

ans = -10**15
for i in range(N+1):
    ans = max(ans,fs[i]+ls[N-i])
print(ans)

Measured memory_bytes: 38416
// 解き直し.
// http://agc005.contest.atcoder.jp/data/agc/005/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int A[111];

int main(){
    
    // 1. 入力情報.
    int N, a, K = 0;
    scanf("%d", &N);
    rep(i, N){
        scanf("%d", &a);
        A[a]++;
        K = max(K, a); // 直径を取得.
    }
    
    // 2. パスの構築(※解説参照).
    bool f = (K & 1); // 偶奇フラグ.
    bool ok = true;   // 条件を満たす木が構築できるか？
    repr(i, K, K / 2 + 1){
        if(A[i] >= 2) A[i] -= 2;
        else          ok = false;
    }
    // 偶数の場合は, K / 2 も 見る.
    if(!f){
        if(A[K / 2]) A[K / 2]--;
        else         ok = false;
    }
    
    // 3. 最大距離をチェックしながら, 残りの辺を繋げる.
    priority_queue<int> pq;
    rep(i, N) rep(j, A[i]) pq.push(i);
    while(ok && !pq.empty()){
        // 最大距離を取得.
        int k = pq.top();
        pq.pop();
        
        // 偶奇に分けて比較.
        if(f && (k <= (K + 1) / 2)) ok = false;
        if(!f && (k <= K / 2))      ok = false;
    }
    
    // 4. 出力.
    printf("%s\n", ok ? "Possible" : "Impossible");
    return 0;
    
}

Measured memory_bytes: 3692
#include<iostream>
//#include<vector>
#include<string>
using namespace std;

int main() {
  int N;
  //vector<string> S;
  string r;
  cin >> N;
  int AC=0, WA=0, TLE=0, RE=0;
  for(int i=0; i<N; i++) {
    cin >> r;
    if(r == "AC") {
      AC++;
    }else if(r == "WA"){
      WA++;
    }else if(r == "TLE") {
      TLE++;
    }else if(r == "RE") {
      RE++;
    }
    //S.push_back(r);
    //cout << r << endl;
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
#include <iomanip>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N;
double dp[301][301][301]; //1個残ってる皿の枚数、2個、3個

double solve(int one, int two, int three){
	if(one == 0 && two == 0 && three == 0) return 0;
	if(dp[one][two][three] != -1) return dp[one][two][three];
	return dp[one][two][three] = (double)N/(one+two+three)
		+ (one!=0 ? (double)one/(one+two+three) * solve(one-1, two, three) : 0)
		+ (two!=0 ? (double)two/(one+two+three) * solve(one+1, two-1, three) : 0)
		+ (three!=0 ? (double)three/(one+two+three) * solve(one, two+1, three-1) : 0);
}

int main(){
	ios::sync_with_stdio(false);
	
	cin >> N;
	int one = 0;
	int two = 0;
	int three = 0;
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		if(tmp == 1) one++;
		if(tmp == 2) two++;
		if(tmp == 3) three++;
	}
	for(int i=0; i<=N; i++){
		for(int j=0; j<=N; j++){
			for(int k=0; k<=N; k++){
				dp[i][j][k] = -1;
			}
		}
	}
	cout << setprecision(17) << solve(one, two, three) << endl;
	//cout << solve(1,0,0) << " " << solve(0,1,0) << " " << solve(2,0,0) << endl;

	return 0;
}

Measured memory_bytes: 213376
def main():
  r,g,b,n=map(int,input().split())
  cnt=0
  for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

const int mod = 1000000007;
const int N = 300007;

int bp(int x, int y) {
	if (y==0) return 1;
	if (y==1) return x%mod;

	if (y%2) return ((ll) x * bp(x, y-1)) % mod;
	int t = bp(x, y/2);

	return ((ll) t * t) % mod;

}

int rv[N];

int n;

int ans = 0;
void solve3(int l, int r, int Q, vector<tuple<int, int, int> > &kek, int tut) {

	Q = ((ll) Q * rv[tut]) % mod;
	int mid = (l+r)/2;

	int a = 0, b = 0, c = 0, d = 0, e=0, f=0;
	for (auto x : kek) {
		if (get<0>(x) < mid) {
			if (get<2>(x) == 1) {
				e++;
				a += get<1>(x);
				if (a >= mod) a -= mod;
			}
			else {
				f++;
				b += get<1>(x);
				if (b >= mod) b -= mod;
			}
		}

		else {
			if (get<2>(x) == 1) {
				e++;
				c += get<1>(x);
				if (c >= mod) c -= mod;
			}
			else {
				f++;
				d += get<1>(x);
				if (d >= mod) d -= mod;
			}
		}
	}

	if (e==0 || f==0) return;
	int T = ((ll) Q * a) % mod;
	T =((ll) T * d) % mod;

	ans += T;
	if (ans >= mod) ans -= mod;

	T = ((ll) Q * b) % mod;
	T =((ll) T * c) % mod;

	ans += T;
	if (ans >= mod) ans -= mod;

	vector<tuple<int, int, int> > fv, sv;
	for (auto x : kek) {
		if (get<0>(x) < mid) fv.pb(x);
		else sv.pb(x);
	}

	Q = ((ll) Q * rv[tut]) % mod;

	solve3(l, mid, Q, fv, 2*tut);
	solve3(mid, r, Q, sv, 2*tut+1);

	



}

void solve2(vector<int> &a, vector<int> &b, int M, int step, vector<int> &perm) {

	vector<int> w1, w2;

	int u = 0;

	for (auto x : a) {

		x += n;

		int now = 1;
		int y = x;

		while (true) {
			now = ((ll) now * y) % mod;
			if (y == M) break;
			y = y/2;
		}

		y = perm[step + u] + n;

		while (true) {
			now = ((ll) now * y) % mod;
			if (y == 1) break;
			y = y/2;
		}		

		u++;
		w1.pb(now);

	}

	for (auto x : b) {

		x += n;

		int now = 1;
		int y = x;

		while (true) {
			now = ((ll) now * y) % mod;
			if (y == M) break;
			y = y/2;
		}

		y = perm[step + u] + n;

		while (true) {
			now = ((ll) now * y) % mod;
			if (y == 1) break;
			y = y/2;
		}		

		u++;
		w2.pb(now);

	}

	M = rv[M];

	vector<tuple<int, int, int> > kek;
	for (int i = 0; i < a.size(); ++i) {
		kek.pb(make_tuple(perm[step + i], w1[i], 1));
		kek.pb(make_tuple(perm[step + i + a.size()], w2[i], 2));
	}

	sort(all(kek));

	solve3(0, n, M, kek, 1);


}

void solve(int l, int r, vector<int> &v, int tut) {

	if (r - l == 1) return;
	vector<int> a, b;
	int mid = (l+r)/2;

	for (int i = l; i < mid; ++i) a.pb(i);
	for (int i = mid; i < r; ++i) b.pb(i);

	solve2(a, b, tut, l, v);

	solve(l, mid, v, 2*tut);
	solve(mid, r, v, 2*tut+1);

}

int main(){
#ifdef LOCAL
	freopen("D_input.txt", "r", stdin);
	//freopen("D_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for (int i = 1; i < N; ++i) {
		rv[i] = bp(i, mod-2);
	}

	cin >> n;

	n = (1<<(n-1));

	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		v[i]--;
	}

	solve(0, n, v, 1);

	cout << ans;

}


Measured memory_bytes: 10696
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        pq.push(x);
    }

    for (int i = 0; i < m; ++i) {
        int x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }

    long long ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <map>
using namespace std;
int main()
{
  string s;
  cin >> s;
  map<char,int> m;
  for(int i=0; i<s.length(); i++){
    m[s[i]]++;
  }
  int paircount = 0;
  long long div = 1;
  bool bOdd = false;
  for(map<char,int>::iterator p = m.begin(); p != m.end(); p++){
    if((*p).second % 2 == 1){
      if(!bOdd){
        bOdd = true;
      }else{
        cout << 0 << endl;
        return 0;
      }
    }
    int pair = (*p).second / 2;
    paircount += pair;
    while(pair > 1){
      div *= pair;
      pair--;
    }
  }
  long long ret = 1;
  while(paircount > 1){
    ret *= paircount;
    paircount--;
  }
  cout << ret / div << endl;
  return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = list(map(int,input().split()))
print(*a)
for i in range(1,n):
    for j in range(i):
        p = i-j
        if a[p] < a[p-1]:
             a[p], a[p-1] = a[p-1], a[p]
    print (*a)


Measured memory_bytes: 5976
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 1000000007;

int p[maxn];
int a[maxn];

void gcd(ll a,ll b, ll& d,ll& x,ll& y){  //      已经测试 FZU 1402
  if(!b) {d=a;x=1;y=0;}
  else   {	gcd(b,a%b,d,y,x);	y-=a/b*x;}
}

ll inv(ll a,ll n)  { //无逆元返回-1
  ll d,x,y;	gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    a[i] = x;
    for(int j=2;j*j<=x;j++){
      int cnt = 0;
      while(x%j==0){
        cnt++;
        x/=j;
      }
      if(cnt)p[j]=max(p[j],cnt);
    }
    if(x>1)p[x] = max(p[x], 1);
  }
  ll bei = 1;
  for(int i=2;i<maxn;i++){
    for(int j=0;j<p[i];j++)bei = bei * i %mod;
  }
  ll ret = 0;
  for(int i=0;i<n;i++){
    ret = (ret + bei * inv(a[i], mod)%mod)%mod;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vi v(n);
    unordered_map<int,int> cntodd;
    unordered_map<int,int> cnteve;;
    int le=0,lo=0;
    rep(i,n){
        cin>>v[i];
        if(i%2){
            cntodd[v[i]]++;
        }
        else
        {
            cnteve[v[i]]++;
        }
    };
    using cntkey=pair<int,int>;
    int res=0;
    priority_queue<cntkey> qe,qo;
    for(auto i:cntodd)qo.emplace(i.second,i.first);
    for(auto i:cnteve)qe.emplace(i.second,i.first);
    int ov=qo.top().first,ev=qe.top().first,ok=qo.top().second,ek=qe.top().second;
    if(ok!=ek){
        res=n-(ov+ev);
    }
    else{
        if(ov!=ev){
            if(ov>ev){
                qe.pop();
                if(!qe.empty())ev=qe.top().first;
                else ev=0;
            }
            else{
                qo.pop();
                if(!qo.empty())ov=qo.top().first;
                else ov=0;
            }
        }
        else{
            qe.pop();qo.pop();
            if(ev==n/2){
               cout<<n/2<<endl;
               return 0;
            }

            if(qe.top().first>=qo.top().first){
                ev=qe.top().first;
            }
            else {
                ov=qo.top().first;
            }
        }
        res=n-(ov+ev);
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 5908
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};
 
int main(){
	lint a,b;
	cin>>a>>b;
	if(a+b>=10)cout<<"error"<<endl;
	else cout<<a+b<<endl;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
E - Get Everything
https://atcoder.jp/contests/abc142/tasks/abc142_e

"""
import sys


def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1]


def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int h, a, ans;
	cin >> h >> a;
	ans = (h + a - 1) / a;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888