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

int main(void){
    int anttena_pos[5],d,k;

    for(int i = 0;i<5;i++) cin >> anttena_pos[i];
    cin >> k;

    // anttena_pos[0] = 15;
    // anttena_pos[1] = 18;
    // anttena_pos[2] = 26;
    // anttena_pos[3] = 35;
    // anttena_pos[4] = 36;

    // k = 18;

    

    for(int i = 0;i < 5;i++)
    {
        for(int j = 0;j < i;j++)
        {
            d = anttena_pos[i] - anttena_pos[j];
            
            if(d > k)
            {
                cout << ":(" << endl;
                return 0;
            }

        }
    }

    cout << "Yay!" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int abs(int a)
{
    if(a<0) return -a;
    return a;
}
int min(int a, int b)
{
    if(a>b) return b;
    return a;
}
int main()
{
    int a[4], sum=99999;
    scanf("%d%d%d",a+1,a+2,a+3);
    int i, j, k;
    for(i=1;i<=3;i++)
        for(j=1;j<=3;j++)
        for(k=1;k<=3;k++)
    {
        if(i==j||j==k||i==k) continue;
        sum=min(sum,abs(a[j]-a[i])+abs(a[k]-a[j]));
    }

    printf("%d\n",sum);
}


Measured memory_bytes: 128
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	k := getInt()

	m := make(map[string]int)
	n := len(s)
	for i := 0; i < n; i++ {
		for j := i + 1; j <= min(i+5, n); j++ {
			m[s[i:j]]++
		}
	}
	// out(m)
	a := make([]string, 0)
	for v := range m {
		a = append(a, v)
	}
	sort.Strings(a)
	// out(a)
	out(a[k-1])
}


Measured memory_bytes: 3712
#include<stdio.h>

int dp[50];

int fib(int n)
{
	if(n == 0 || n == 1) return dp[n] = 1;
	if( dp[n] != -1) return dp[n];
	return dp[n] = fib(n-1)+fib(n-2);
}

int main()
{
	int n , i;
	for( i = 0; i < 50; i++)
	{
		dp[i] = -1;
	}
	scanf("%d",&n);
	printf("%d\n",fib(n));
	return 0;
}




Measured memory_bytes: 2068
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll unsigned long long
#define int long long
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

int32_t main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int dp[4];
	int n;
	cin >> n;
	vi arr(n);
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[0] - arr[1]);
	for(int i =  2; i <  n; i++){
		dp[i%3] = min(dp[(i - 2)%3] + abs(arr[i - 2] - arr[i]), dp[(i - 1)%3] + abs(arr[i - 1] - arr[i]));
	}
	cout << dp[(n - 1)%3] << endl;

	return 0;
}

Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

angleDiffDeca :: Int -> Int -> Int
angleDiffDeca h m = abs (((5 * (60 * h + m)) `mod` 3600) - ((60 * m) `mod` 3600))

main = do
  [a, b, h, m] <- getIntList
  let angleDiff = angleDiffDeca h m
  let angle = (fromIntegral angleDiff) * pi / (1800::Double)
  print $ sqrt ((fromIntegral a - fromIntegral b * cos angle) ^ 2 + (fromIntegral b * sin angle) ^ 2)


Measured memory_bytes: 4360
a,b,c,x,y = map(int,input().split())

price1 = a*x+b*y

if x <= y:
    price2 = c*x*2 + (y-x)*b
else:
    price2 = c*y*2 + (x-y)*a

price3 = max(x,y)*2*c

print(min(price1,price2,price3))



Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B, C, D = MAP()

print(max(A*B, C*D))

Measured memory_bytes: 3884
#include<stdio.h>
int main(void){
	int i,j,h,w;
	for(;;){
		scanf("%d %d",&h,&w);
		for(i=0;i<h;i++){
			
			for(j=0;j<w;j++){
				
				if(j==0 || j==w-1 || i==0 || i==h-1) printf("#");
					else printf(".");
			
			}
			printf("\n");
		}
		if(h==0&&w==0){
			break;
		}
	else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		HashSet<String> A=new HashSet<>();
		int n=in.nextInt();
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			char odr=in.next().charAt(0);
			String str=in.next();
			
			if(odr=='i') {
				A.add(str);
			}
			else if(odr=='f')out.println((A.contains(str))?"yes" : "no");
		}
		out.flush();
	}

}



Measured memory_bytes: 217064
// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef set<int> si;
typedef priority_queue<int> pqi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define loop(i, a) for (int i = 0; i < (a); i++)
#define loop1(i, a) for (int i = 1; i <= (a); i++)
#define loopr(i, a, b) for (int i = (a); i <= (b); i++)
#define dloop(i, a) for (int i = (a) - 1; i >= 0; i--)
#define dloopr(i, b, a) for (int i = (b); i >= (a); i--)
#define tr(it, container) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define vpresent(container, element) (find(container.being(), container.end() ,element) != container.end())
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << (a) << "\n"
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) ((int)x.size())
#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
const int MOD = 1000000007;
const double PI = acos(-1);

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	ios::sync_with_stdio(false);cin.tie(NULL);

	int n; cin >> n;
	int a[n+1][n+1];
	loop1(i, n) loop1(j, n) cin >> a[i][j];
	bool b[n+1][n+1]; mem(b, true);
	bool pos = true;
	ll sum = 0;
	loop1(k, n)
		loop1(i, n)
			loop1(j, n) {
				if ((i == k) || (j == k) || (i == j)) continue;
				if (a[i][j] > a[i][k] + a[k][j]) pos = false;
				if (a[i][j] == a[i][k] + a[k][j]) b[i][j] = false;
			}
	loop1(i, n) loop1(j, n) if (b[i][j]) sum+=a[i][j];
	if (!pos) show(-1);
	else show(sum/2);

	return 0;
}


Measured memory_bytes: 768
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    ll a,b,n;
    cin>>a>>b>>n;
    ll x = min(b-1,n);
    ll res = floor((a*x)/b) - a*floor(x/b);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 3660
#include<stdio.h>

int main(){
	int w,i;
	char S[1000];
	
	scanf("%s",S);
	scanf("%d",&w);
	for(i=0;S[i]!='\0';i++){
		if(i%w==0){
			printf("%c",S[i]);
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    vector<vector<pii>> Z(N, vector<pii>());
    rep(i, 0, N){
        cin >> A[i];
        rep(j, 0, A[i]){
            pii tmp; cin >> tmp.first >> tmp.second;
            tmp.first--;
            Z[i].push_back(tmp);
        }
    }
    int ans = 0;

    rep(i, 0, 1 << N){
        int cnt = 0;
        bool flag = 1;
        vector<int> T(N, -1); 
        rep(j, 0, N){
            if(i & (1 << j)) T[j] = 1;
            else T[j] = 0;
        }
        rep(j, 0, N){
            if(i & (1 << j)){
                cnt++;
                for(auto e: Z[j]){
                    if(T[e.first] != e.second){
                        flag = 0;
                        break;
                    }
                }
            }
            if(flag == 0) break;
        }
        if(flag == 0) continue;
        //cout << i << " " << cnt << endl;

        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import copy

def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    PX = []
    for i in range(M):
        P, X = map(int, input().split())
        tmp = copy.copy(T)
        tmp[P-1] = X
        print(sum(tmp))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9280
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,wari,en,x;
	scanf("%d",&n);
	x=n/15;
	en=n*800-x*200;
	printf("%d\n",en);
	
	return 0;
}

Measured memory_bytes: 128
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
a=[]
for i in range(h):
    sub=input().rstrip()
    a.append(sub)
check=True
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            for k in range(h):
                for l in range(w):
                    if (i>k and j<l) or (i<k and j>l):
                        if a[k][l]=='#':
                            check=False
if check:
    print('Possible')
else:
    print('Impossible')



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

int cmmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  int i,n;
  long long int sum;
  int b[10000];
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++) scanf("%d",b+i);
    qsort(b,n,sizeof(int),cmmp);
    for(sum=0,i=0;i<n-1;i++) sum+=(b[i]*(n-i-1));
    printf("%lld\n",sum);
  }while(1);
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 1e6 + 5;

int n,a[21],b[21],c[21],sum = 0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP1(i, n){
		cin>>a[i];
	}
	REP1(i, n){
		cin>>b[i];
	}
	REP1(i, n-1){
		cin>>c[i];
	}
	REP1(i, n){
		sum += b[a[i]];
		if(i > 1 && a[i] == a[i-1] + 1)
			sum += c[a[i-1]];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut dp = vec![0; n + 1];
    for i in 0..n {
        for j in 0..(n - i) {
            let x = a[j] - dp[j + 1];
            let y = a[j + i] - dp[j];
            dp[j] = std::cmp::max(x, y);
        }
    }
    let ans = dp[0];
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{ int x,y,a;
	while(1){
	scanf("%d %d",&x,&y );
	if(x>y){printf("%d %d\n",y,x);}
	else if(x<y){printf("%d %d\n",x,y);}
	else if(x==y){if(x==0){break;}else{printf("%d %d\n",x,y);}
	};}
	return 0;
}


Measured memory_bytes: 2040
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class HGrid1 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            long mod = (int) 1e9 + 7;
            char[][] g = new char[n][m];
            long[][] dp = new long[n][m];
            for (int i = 0; i < n; i++) {
                String s = in.next();
                for (int j = 0; j < m; j++)
                    g[i][j] = s.charAt(j);
            }

            dp[0][0] = 1;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (g[i][j] == '#' || j == 0 && i == 0) continue;
                    if (j == 0) dp[i][j] = dp[i - 1][j];
                    else if (i == 0) dp[i][j] = dp[i][j - 1];
                    else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
                }
            }

            out.println(dp[n - 1][m - 1]);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }
}



Measured memory_bytes: 40340
#include<bits/stdc++.h>
#define mx 307
using namespace std;

double dp[mx][mx][mx];
bool vis[mx][mx][mx];
double n;

double rec( int x, int y, int z )
{
    if( !(x+y+z) )
        return 0;

    if( vis[x][y][z] )
        return dp[x][y][z];

    double ret= 1;

    if(x)
        ret+= (x/n)*rec( x-1, y, z );
    if(y)
        ret+= (y/n)*rec( x+1, y-1, z );
    if(z)
        ret+= (z/n)*rec( x, y+1, z-1 );

    ret*= n/(x+y+z);

    vis[x][y][z]= 1;

    return dp[x][y][z]= ret;
}

int main()
{
    cin>>n;

    int x= 0, y= 0, z= 0;

    for( int i=0;i<n;i++ )
    {
        int p;
        cin>>p;

        if(p==1)
            x++;
        if(p==2)
            y++;
        if(p==3)
            z++;
    }

    cout<<setprecision(12)<<fixed<< rec( x, y, z ) <<endl;
}


Measured memory_bytes: 250240
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use num::integer::gcd;

#[fastout]
fn main() {
    input! {
        k:usize
    }
    let mut ans = 0_usize;
    for i in 1..=k {
        for j in 1..=k {
            for k in 1..=k {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
    string s;
    cin>>s;

    for(int i=0;i<s.size();i++){
        if(s[i]=='?'&&i==0){
            if(s[1]=='?'){
                s[i]='P';
                s[i+1]='D';
            } 
            else s[i]='D';
        }
        else if(s[i]=='?'&&i==s.size()-1){
                s[i]='D';
        }
        else if(s[i]=='?'){
            if(s[i-1]=='P') s[i]='D';
            else if(s[i+1]=='D') s[i]='P';
            else if(s[i+1]=='?'){
                s[i]='P';
                s[i+1]='D';
            }
            else s[i]='D';
        }
    }
    cout<<s;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int k;
    cin >> k;
    vll a;
    rep1(i, 9) a.push_back(i);
    while (1) {
        if (k <= int(a.size())) {
            cout << a[k-1] << endl;
            return 0;
        }
        else k -= a.size();
        vll old;
        swap(a, old);
        for (ll x : old) {
            for (int i=-1; i<=1; ++i) {
                int d = x % 10 + i;
                if (d < 0 || d > 9) continue;
                ll y = x * 10 + d;
                a.push_back(y);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=6000;
int n,A,B,cnt,x,y,m,sum,id[N],p[N],q[N];
char s[N];
string S,P,T; 
void work(int l,int r){
	A=B=0;
	FOR(i,l,r) s[i]=='a'?id[p[++A]=i]=A:id[q[++B]=i]=B;
	if(p[1]==l){
		for(cnt=1,x=1,y=2;y<=A;y++)
			if(q[x]<p[y]) x=y,cnt++;
		P="";
		FOR(i,0,cnt) S=max(S,P+T),P=P+"ab";
		T=S;
	}
	if(q[1]==l){
		cnt=(r-l+1)>>1;
		FOR(i,0,cnt){
			P="";
			FOR(j,l,r)if(id[j]>i) P=P+s[j];
			S=max(S,P+T);
		}
		T=S;
	}
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%s",&n,s+1);m=n<<1;
	ROF(i,m,1){
		sum+=s[i]=='a'?-1:1;
		if(!sum) work(i,m),m=i-1;
	}
	cout<<S<<'\n';
}

Measured memory_bytes: 512
import sys
import math
import bisect
import heapq
from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod = 10 ** 9 + 7
    S = list(input())
    l = len(S)
    dp = [[0] * 13 for _ in range(l + 1)]

    dp[0][0] = 1
    for j in range(1, l + 1):
        jp = j - 1
        if S[jp] == "?":
            for k in range(13):
                kk = k * 10
                for q in range(10):
                    new_k = (kk + q) % 13
                    dp[j][new_k] += dp[jp][k]
            for k in range(13):
                dp[j][k] %= mod
        else:
            n = int(S[jp])
            for k in range(13):
                new_k = (k * 10 + n) % 13
                dp[j][new_k] += dp[jp][k]
                dp[j][new_k] %= mod
    print(dp[l][5])


if __name__ == "__main__":
    main()


Measured memory_bytes: 98828
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

	int N,M;
	map<int,bool> S;
	int A[10]={6,2,5,5,4,5,6,3,7,6};
	vecs(ANS)
int main() {
	

	cin>>N>>M;
	vec(C)
	fx(M){
		vecp(C)
	}
      sorts(C)
	vector<int> dp[20000];
	fy(N+1){
		fx(M){
			if(y-A[C.at(x)]<0){continue;}
          if(dp[y-A[C.at(x)]].size()==0&&y-A[C.at(x)]!=0){continue;}
			if(dp[y-A[C.at(x)]].size()+1>dp[y].size()){
              
				dp[y].clear();
				pb(dp[y],C.at(x))
				fz(dp[y-A[C.at(x)]].size()){
				    pb(dp[y],dp[y-A[C.at(x)]].at(z))
				}
			}else if(dp[y-A[C.at(x)]].size()+1==dp[y].size()){
				sorts(dp[y])
				vector<int> TEMP;
              TEMP.clear();
				pb(TEMP,C.at(x))
				fz(dp[y-A[C.at(x)]].size()){
					pb(TEMP,dp[y-A[C.at(x)]].at(z))
				}
				sorts(TEMP);
				bool flag=true;
				for(int i=TEMP.size()-1;i>=0;i--){
					if(dp[y].at(i)<TEMP.at(i)){
						flag=false;
						break;
					}
				}
				if(!flag){
                  dp[y].clear();
					for(int i=0;i<TEMP.size();i++){
                     // doublece(y,TEMP.at(i))
					pb(dp[y],TEMP.at(i))
					}
				}
			}
		}
	}
	
	sorts(dp[N])
	reverses(dp[N])
	fx(dp[N].size()){
		//doublece(N,dp[N].at(x))
		cout<<dp[N].at(x);
	}
	cout<<endl;
    
}

Measured memory_bytes: 123392
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        a += sc.next();
        double b = Double.parseDouble(a);
        if(Math.pow(b,0.5) % 1 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

const int maxn = 305;
int N; 
double dp[maxn][maxn][maxn];
int c[4];

double f(int c1, int c2, int c3) {
    //if (c1 < 0 || c2 < 0 || c3 < 0) return 0;
    if (c1 == 0 && c2 == 0 && c3 == 0) return 0;
    double& res = dp[c1][c2][c3];
    if (res != -1) return res;
    res = 1;
    if (c1 > 0) res += 1.0*c1/N*f(c1-1,c2,c3);      
    if (c2 > 0) res += 1.0*c2/N*f(c1+1,c2-1,c3);
    if (c3 > 0) res += 1.0*c3/N*f(c1,c2+1,c3-1);
    if (c1 + c2 + c3 < N) res = (res * N) / (1.0 * c1 + c2 + c3);
    //cout << c1 << ' ' << c2 << ' ' << c3 << ": " << res << '\n';
    return res; 
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N;
    for (int i = 0; i < N; i++) {
        int ai; cin >> ai;
        c[ai]++;
    }
    for (int i = 0; i < maxn; i++) {
        for (int j = 0; j < maxn; j++) {
            for (int k = 0; k < maxn; k++) {
                dp[i][j][k] = -1;
            }
        }
    }
    double ans = f(c[1],c[2],c[3]);
    cout << fixed << setprecision(12) << ans << '\n';


    return 0;
}



Measured memory_bytes: 222080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s;
  cin >> s;
  ll p = 0, q = 0;
  for(int i = 0; i < s.size(); ++i)
  {if(s[i]-'0'==1) ++p ;
  else  ++q;
  }
  cout << min(p, q) * 2;
}



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

#define N 102
#define MAXK 100005

int n, K, a[N], f[MAXK];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> K;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    f[0] = 0;
    for (int i = 0; i <= K; ++i) {
        if (f[i]) continue;
        for (int j = 1; j <= n && i + a[j] <= K; ++j)
            f[i + a[j]] = 1;
    }
    puts(f[K] ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct edge { int from, to, cost; };
vector<edge> v;
int main(){
	int n; cin >> n;
	int m;
	rep(i, 20) {
		if (n&(1 << i)) {
			m = i;
		}
	}
	//頂点m+1個
	rep(i, m) {
		v.push_back({ i,i + 1,1 << (m - 1 - i) });
		v.push_back({ i,i + 1,0 });
	}
	int now = 1 << m;
	per(i, 20) {
		if (n&(1 << i)) {
			if (m == i)continue;
			v.push_back({ 0,m - i,now });
			now += (1 << i);
		}
	}
	int len = v.size();
	cout << m + 1 << " " << len << endl;
	rep(j, len) {
		int x = v[j].from + 1; int y = v[j].to + 1; int c = v[j].cost;
		cout << x << " " << y << " " << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;

namespace a
{
    class c
    {
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();

            int cntrow = int.Parse(Console.ReadLine());
            for (int cnt = 1; cnt <= cntrow; cnt++)
            {
                al.Add(int.Parse(Console.ReadLine()));
            }
            al.Sort();
            int sum = 0;
            for (int i = 0; i < (al.Count - 1); i++)
            {
                sum += int.Parse(al[i].ToString());
            }
            sum += int.Parse(al[al.Count - 1].ToString()) / 2;
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
 
int main ()
{
  prep();
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i=0; i<n; i++){
      cout <<s[i] << t[i];
  }
  return 0; 
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll r,g,b,k,ans = 0;
	cin >> r >> g >> b>> k;
	while(g <= r){
		g *= 2;
		ans++;
	}
	while(b <= g){
		ans++;
		b *= 2;
	}
	if(ans <=k){
		cout << "Yes" << nl;
	}
	else cout << "No" << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
    	//cout <<"Case #"<<i<<':'<<nl;
        doit();
    }
}


Measured memory_bytes: 3660
import sys
import bisect
import collections

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()
A.sort()


def solve():
    ac = collections.Counter(A)
    num_pairs = 0
    for i in range(N - 1, 0, -1):
        x = A[i]
        if ac[x] <= 0:
            continue
        p = 1
        while p <= x:
            p <<= 1
        j = bisect.bisect_left(A, p - x, 0, i)
        if j >= i:
            continue
        y = A[j]
        if x + y != p:
            continue
        ac[x] -= 1
        if ac[y] <= 0:
            continue
        ac[y] -= 1
        num_pairs += 1
    return num_pairs


print(solve())


Measured memory_bytes: 35836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string b;
	cin >> b;
	if (b == "A") {
		cout << "T" << endl;
	}
	if (b == "C") {
		cout << "G" << endl;
	}
	if (b == "G") {
		cout << "C" << endl;
	}
	if (b == "T") {
		cout << "A" << endl;
	}	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int> W(N);
  for(int t=0;t<N;t++){
    cin >>W.at(t);
  }
  
 //以上入力
  vector<int> S(N);
  S.at(0)=W.at(0);
  for(int t=1;t<N;t++){
    S.at(t)=S.at(t-1)+W.at(t);
  }
  int ans = 100000;
  for(int t=0;t<N;t++){
    int tmp1,tmp2;
    tmp1=S.at(N-1)-S.at(t);
    if(tmp1>S.at(t)){
      tmp2 =tmp1-S.at(t);
    }else{
      tmp2 =S.at(t)-tmp1;
    }
    if(tmp2<ans){
      ans=tmp2;
    }
  }
  cout <<ans<<endl;
      
}
    

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

using namespace std;

#define F first
#define S second
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 18;
const int mod = 1e9+7;
const int MASK = 1e6+10;

int n, m;
int a[maxn][maxn];
ll dp[MASK], F[MASK];

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

    cin>> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin>> a[i][j];

    for(int mask = 0; mask < (1<<n); mask++)
    {
        for(int i = 0; i < n; i++)
            for(int j = i+1; j < n; j++)
                if((1<<i)&mask && (1<<j)&mask)
                    F[mask] += a[i][j];
        dp[mask] = F[mask];
        for(int sm = mask; sm; sm = (sm-1)&mask)
            dp[mask] = max(dp[mask], dp[mask^sm] + F[sm]);
    }

    int mask = (1<<n)-1;
    cout<< dp[mask];
}





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

int students[10001][750] = {};
int numlogin[10001] = {};
int sum[10001][800]={};

int main(){

  while(1){
    int N,M,r;
    cin >> N >> M;
    if(!N and !M) break;
    cin >> r;

    memset(students,0,sizeof(students));
    memset(numlogin,0,sizeof(numlogin));
    memset(sum,0,sizeof(sum));

    // ?¨????
    for(int i=0; i<r; i++){ // 1000
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      t -= 540;
      if(s == 0) { // ?????°??¢??????
	numlogin[m]--;
	if(numlogin[m] == 0){
	  for(int i=t-1; students[m][i] != 1 and t>=0; i--){ // 1000
	    students[m][i] = 1;
	  }
	}
      }
      else{ // ?????°??????
	numlogin[m]++;
	if(numlogin[m] == 1)
	  students[m][t] = 1;
      }
    }

    // ?´???????
    for(int i=1; i<=M; i++){ // 100000
      for(int j=1; j<=720; j++){ // 1000
	sum[i][j] = sum[i][j-1] + students[i][j]; 
      }
    }

    // ??????
    int  q;
    cin >> q;
    for(int i=0; i<q; i++){
      int ts,te,id;
      cin >> ts >> te >> id;
      ts -= 540;
      te -= 540;
      cout << sum[id][te-1] - sum[id][ts] + students[id][ts] << endl;
    }
  }
}

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

int main() {
    int A,B,K;
    cin >>A>>B>>K;
    int mx =max(A,B);
    vector<int> data(mx);
    for (int i=1;i<=mx;i++){
        if(A%i ==0 && B%i==0)data.at(i-1) =i;
        else data.at(i-1)=0;
    }
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    cout << data.at(K-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i, n ,a;
	char b;
	cin>>n>>a;
	for(i=0;i < n;i++){
		cin>>b;
		if (i==a-1){
			cout<<char(b-'A'+'a');
			continue;
			
		}
		cout<<b;
			
		
	}
	
	
	
	
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if(a * b) % 2 == 0 {"Even"} else { "Odd"};
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;


int main() {
    ll N;
    int ans = 0;
    cin >> N;
    ll MAXN = N;
    for (ll i = 2; i * i <= MAXN && i <= N; i++) {
        int cnt = 0;
        while (N % i == 0) {
            N /= i;
            cnt++;
        }
        for (int j = 1; cnt - j >= 0; j++) {
            cnt -= j;
            ans++;
        }
    }
    if (N > 1)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int N=1e5+5;
char S[N],T[N];
int n,ans=1e9,cnt1,cnt2,A[N],B[N],tmpA[N],tmpB[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(n),scanf("%s%s",S+1,T+1);
	cnt1=(bool)(S[1]=='1'),cnt2=(bool)(T[1]=='1');
	for(int i=1;i<n;++i)
		(S[i]!=S[i+1])?tmpA[++cnt1]=i:0,(T[i]!=T[i+1])?tmpB[++cnt2]=i:0;
	(S[n]=='1')?tmpA[++cnt1]=n:0,(T[n]=='1')?tmpB[++cnt2]=n:0;
	int lim=cnt1+cnt2+cnt2;
	for(int i=cnt2+1;i<=lim;++i) A[i]=(i<=cnt1+cnt2)?tmpA[i-cnt2]:n;
	for(int i=0;i<=cnt1+cnt2;i+=2) {
		int res=0;
		for(int j=1;j<=lim;++j) B[j]=j<=i?0:(j<=i+cnt2?tmpB[j-i]:n);
		for(int j=1;j<=lim;++j) res+=abs(A[j]-B[j]);
		ans=min(ans,res);
	}
	return printf("%d\n",ans),0;
}

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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int l,r;
    cin>>l>>r;
    if(r-l>=2018){
        cout<<0<<endl;
        return 0;
    }
    l=l%2019;
    r=r%2019;
    if(l>r) r+=2019;
    int a,mi=2018;
    for(int i=l; i<=r; i++){
        for(int j=l; j<i; j++){
            a=i*j;
            a=a%2019;
            mi=min(mi,a);
            a=0;
        }
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define INF 1000000009
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof 
#define pii pair<ll,ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i,a) for(auto i:a)
#define st string
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); 
void solve(){
  double d,t,s;
  cin>>d>>t>>s;
  double ans=d/s;
  if(ans<=t){
    cout<<"Yes"<<endl;
    return;
  }
  else{
  cout<<"No"<<endl;
  return;
}
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    fast
    solve();
    return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor()
{
    cout<<"NO";
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
 //   freopen("input.txt","r",stdin);

    ///FastIO;
    int t;
    t = 1;
    while(t--)
    {
        int n;
        lli k;
        scn(n);
        scnll(k);
        lli a[n];
        vector<int>cnt(70,0);

        for(int i=0; i<n; i++)
        {
            scnll(a[i]);
            lli num = a[i];

            for(int pos = 0 ; num ; num /= 2, pos++)
            {
                cnt[pos] += (num%2);
            }
        }
        lli ans = 0 , now = 0;
       // cout<<cnt[0]<<endl;
        for(int pos=60; pos>=0; pos--){

            lli o = n-cnt[pos] , l = cnt[pos];

            if(o>l){
                now |= (1LL<<pos);
                if(now<=k) ans += (1LL<<pos)*o;
                else{
                    now ^= (1LL<<pos);
                    ans += l*(1LL<<pos);
                }
            }
            else{
                ans += (1LL<<pos)*l;
            }
        }
        cout<<ans;
       // cout<<endl;
    }
    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 1024
N, Y = map(int, input().split())
Y //= 1000
ans = [-1,-1,-1]
for c in range(Y%5,N+1,5):
	x = (Y-c)//5
	a = x - (N-c)
	b = 2*(N-c) - x
	if a < 0:
		continue
	if b < 0:
		continue
	ans = [a,b,c]
	break

print(*ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
int main()
{   
	int n; cin>>n; vector<int>a(n); vector<int>f(100003,0);
	long long int res=0;
	for(int i=0;i<=n-1;i++) { cin>>a[i]; f[a[i]]++;  res+=a[i]; } 
	int q; cin>>q;
	while(q--)
	{
		int b,c; cin>>b>>c;
		res+=f[b]*(c-b);
		f[c]+=f[b]; f[b]=0;
		cout<<res<<"\n";
	}
	return 0;
}


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

void dfs(vector<vector<int> > &G, vector<bool> &seen, vector<int> &d, vector<int> &f, int v, int &t) {
    seen[v] = true;
    d[v] = ++t;
    for (int i = 0; i < G[v].size(); i++) {
        if (seen[G[v][i]]) continue;
        dfs(G, seen, d, f, G[v][i], t);
    }
    f[v] = ++t;
}

void print(int n, vector<int> &d, vector<int> &f) {
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int> > G(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }

    vector<bool> seen(n, false);
    vector<int> d(n), f(n);
    int t = 0;
    for (int i = 0; i < n; i++) {
        if (seen[i]) continue;
        dfs(G, seen, d, f, i, t);
    }
    print(n, d, f);

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define INF 10001
int ans=0;
int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--)
	{
		int n,awal,ans;
		cin>>n>>awal;
		if(n%2==1)
			ans=(n-1)*127+awal;
		else
			ans=(n-1)*127+(127^awal);
		cout<<ans<<endl;
	}
}

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

int main() {
   string s; cin >> s;
   vector <int> v(26,0);
   rep(i,s.size()){
   		v[s[i]-'a']++;
   }
   int num=27;
   rep(i,v.size()){
   	if(v[i]==0){
   		num = i;
   		break;
   	}
   }
   if(num==27) cout << "None" << endl;
   else cout << char(num+'a') << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

int main( void )
{
	int n;
	std::cin >> n;

	std::string s = std::to_string( n );
	int x = 0;
	for( int i = 0; i < s.size(); i++ ) {
		x += s[ i ] - '0';
	}

	std::cout << ( n % x == 0 ? "Yes" : "No" ) << std::endl;
	return 0;
}



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int ans = 0;
    for(int i = 0; i * i <= N; i++) ans = i*i;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#include <random>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
cin >> n;
long double a, b;
int ans = 0;
long double nownear = 99121213;
cin >> a >> b;
vector<long double>H(n);
rep0(i, n - 1)cin >> H[i];
rep0(j, n - 1){
	if (nownear  > abs(b - (a - (H[j] * 0.006)))) {
		nownear = abs(b - (a - (H[j] * 0.006)));
		ans = j + 1;
	}
	
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
 char b;
  cin >> b;
  
  switch(b){
    case 'A':cout << 'T' << endl;break;
    case 'T':cout << 'A' << endl;break;
    case 'C':cout << 'G' << endl;break;
    case 'G':cout << 'C' << endl;break;

  }
 return 0; 
}

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

using namespace std;

ll n , h[111111] , dp[111111];

int main() {
	for (int i = 0; i < 111111; i++) dp[i] = 8e18;
	scanf("%lld" , &n);
	for (int i = 1; i <= n; i++) scanf("%lld" , &h[i]);
	dp[2] = abs(h[2]-h[1]);	
	dp[3] = min(dp[2]+abs(h[3]-h[2]) , abs(h[3]-h[1]));
	for (int i = 4; i <= n; i++) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]));
	
	printf("%lld" , dp[n]);
	
	return 0;
}

Measured memory_bytes: 5468