akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <map>
using namespace std;

void chmin(long long &a, long long b) { if (a > b) a = b; }

long long Q, H, S, D, N;
int main() {
  while (cin >> Q >> H >> S >> D >> N) {
	long long res = 1LL<<60;
	chmin(S, Q*4);
	chmin(S, H*2);
	chmin(res, S*N);
	chmin(res, D*(N/2) + S*(N&1));
	cout << res << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int N;
	while(cin>>N){
		if(!N) break;
		int S=1;
		for(int i=2; i*i<=N; i++){
			if(!(N%i)){
				if(i*i==N) S += i;
				else S += i + N/i;
			}
		}
		if(N==1||N>S) cout << "deficient number\n";
		else if(N==S) cout << "perfect number\n";
		else cout << "abundant number\n";
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int answer = 0;

		while(true) {
			if(x > y) {
				if(x % y == 0) {
					answer = y;
					break;
				}
				x %= y;
			} else {
				if(y % x == 0) {
					answer = x;
					break;
				}
				y %= x;
			}
		}

		System.out.println(answer);
	}
}



Measured memory_bytes: 26212
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 5e5 + 10;
 
// sasdasfbasjkdbflkjasbdf
// dsaofasdkhfkasdgkf
// ahsfkjsgakfjgaksdjgf
// ladsfhlasjdgkjasdlgkjhasgf
// sadglkhsakdghaksgfkljasdgfkhrg

int n, k, cnt, arr[MAXN], bit[MAXN], newarr[MAXN];
int answer[MAXN];
pair<int, int> seg[4 * MAXN];
int lazy[4 * MAXN];
 
void bit_upt(int id, int val)
{
	for (; id < MAXN; id += id & (-id))
		bit[id] += val;
	return;
}
 
int bit_get(int id)
{
	int res = 0;
	for (; id; id &= id - 1)
		res += bit[id];
	return res;
}
 
pair<int, int> cmp(pair<int, int> l, pair<int, int> r)
{
	if (l.first < r.first)
		return l;
	return r;
}
 
void build(int l = 1, int r = n + 1, int id = 1)
{
	if ((r - 1) == l)
	{
		seg[id] = {newarr[l], l};
		return;
	}
	int mid = l + r >> 1;
	build(l, mid, id << 1);
	build(mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	return;
}
 
void assign(int g, int l = 1, int r = n + 1, int id = 1)
{
	if (l == (r - 1))
	{
		seg[id] = {1e9 - lazy[id], l};
		return;
	}
	int mid = l + r >> 1;
	if (g < mid)
		assign(g, l, mid, id << 1);
	else
		assign(g, mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	seg[id].first -= lazy[id];
	return;
}
 
void upt(int s, int e, int l = 1, int r = n + 1, int id = 1)
{
	if (l >= s && r <= e)
	{
		lazy[id]++;
		seg[id].first--;
		return;
	}
	if (l >= e || r <= s)
		return;
	int mid = l + r >> 1;
	upt(s, e, l, mid, id << 1);
	upt(s, e, mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	seg[id].first -= lazy[id];
	return;
}
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	k--;
	for (int i = 1; i <= k; i++)
	{
		bit_upt(arr[i], 1);
		cnt++;
	}
	for (int i = 1; i <= n; i++)
	{
		if ((i + k) <= n)
		{
			bit_upt(arr[i + k], 1);
			cnt++;
		}
		if ((i - k - 1) >= 1)
		{
			bit_upt(arr[i - k - 1], -1);
			cnt--;
		}
		newarr[i] = cnt - bit_get(arr[i]);
	}
	build();
	for (int i = n; i; i--)
	{
		int id = seg[1].second;
		answer[id] = i;
		assign(id);
		upt(max(1, id - k), min(n, id + k) + 1);
	}
	for (int i = 1; i <= n; i++)
		cout << answer[i] << '\n';
	return 0;
}

Measured memory_bytes: 28672
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

    int ans=0;
    for(;n;n/=k)
        ++ans;

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String siguInput = sc.next();
		StringBuilder sb = new StringBuilder();
		
		for (int i=0;i<siguInput.length();i++){
			
			String l = String.valueOf(siguInput.charAt(i));
			if(l.equals("0")
					|| l.equals("1")){
				sb.append(l);
			}
			else if(l.equals("B")
					&& sb.length()>0){
				sb.deleteCharAt(sb.length()-1);
			}
		}
		sc.close();
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 9428
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int A,B,C,D,E,F;
	char x,y;
	A = 10;
	B = 11;
	C = 12;
	D = 13;
	E = 14;
	F = 15;
	scanf("%c %c",&x,&y);
	if(x>y){printf(">\n");}
	else if(x<y){printf("<\n");}
		else {printf("=\n");}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

ll gcd(ll a, ll b) 
{ 
    if (a == 0)  return b; 
    return gcd(b % a, a); 
} 

int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);      
    #endif
    fastio;

    ll t; t=1;
    while(t--){
    	ll n; cin>>n;
        ll sum=0;
        for(int i=1;i<=n;i++){
            if(i%3!=0&&i%5!=0) sum+=i;
        }
        cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 3652
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N,M = list(map(int,input().split()))

    e_list = [[] for i in range(3*N)]

    def z(i,j):
        return i + j*N

    for i in range(M):
        u,v = list(map(int,input().split()))
        u,v = u-1,v-1
        e_list[z(u,0)].append(z(v,1)) 
        e_list[z(u,1)].append(z(v,2)) 
        e_list[z(u,2)].append(z(v,0))

    S,T = list(map(int,input().split()))
    S,T = S-1,T-1
    from collections import deque

    vi = z(S,0)  #change
    INF = float('inf')

    Q = deque([vi])

    checked_list = [False]*3*N
    checked_list[vi]=True

    min_path_list = [INF]*3*N #change
    min_path_list[vi] = 0

    while len(Q)>0:
        v = Q.pop()
        for v1 in e_list[v]:
            if not checked_list[v1]:
                checked_list[v1]=True
                Q.appendleft(v1)
                min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #change

    if min_path_list[z(T,0)]<10**9:
        print(min_path_list[z(T,0)]//3)
    else:
        print(-1)

if __name__ == '__main__':
    main()



Measured memory_bytes: 91940
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        int cntr = n;
        char ch = s[i];
        while(cntr--){
            ch++;
            if(ch > 'Z')
                ch = 'A';
        }
        cout << ch;
    }
    return 0;
}

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

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

    int n;
    cin >> n;

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

    for (int i = n; i > 0; i--) {
        cout << a[i - 1];
        if ((i - 1) != 0) {
            cout << ' ';
        } else {
            cout << '\n';
        }
    }
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

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

	if( n == m )	cout << "Yes" << endl;
	else			cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
template<class T> inline bool chmax(T& a, T b) {
     if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) {
     if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL<<60;

int main(){

    int  N;
    cin >> N;
    ll tower[100200];
    rep(i,N)cin >> tower[i];
    ll dp[100200];
    rep(i,100200)dp[i]=INF;
    dp[0]=0;

    for(int i =1;i<N;i++){
        chmin(dp[i],dp[i-1] + abs(tower[i]-tower[i-1]));
        if(i>1)chmin(dp[i],dp[i-2]+abs(tower[i]-tower[i-2]));
    }
    cout<<dp[N-1]<<endl;

    
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n,m; cin >> n >> m;
  vector<int> l(m), r(m);
  for(int i = 0; i < m; i++){
    int templ,tempr; cin >> templ >> tempr;
    l[i] = templ; r[i] = tempr;
  }

  sort(l.begin(), l.end(), greater<int>()); sort(r.begin(), r.end());

  if(r[0] - l[0]  >= 0){
    cout << r[0] - l[0] + 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    
    bool judge = false;
    int res = 0;
    int cnt = 0;
    
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            judge = true;
            cnt++;
            res = max(res, cnt);
        }
        else{
            judge = false;
            cnt = 0;
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
        if (vec[i] % 2 == 0) {
            if (vec[i] % 3 != 0 && vec[i] % 5 != 0) {
                cout << "DENIED\n";
                return;
            }
        }
    }
    cout << "APPROVED\n";
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    g = defaultdict(set)
    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    path = deque([1])
    path.append(list(g[1])[0])
    path_s = set(path)
    while not (g[path[0]] | g[path[-1]]).issubset(path_s):
        l = g[path[0]] - path_s
        if l:
            for v in l:
                path.appendleft(v)
                path_s.add(v)
                break
            continue
        r = g[path[-1]] - path_s
        if r:
            for v in r:
                path.append(v)
                path_s.add(v)
                break
            continue

    print(len(path))
    print(' '.join(map(lambda x: str(x), path)))


def main():
    # N = read_int()
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    (slv(N, M, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 66688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	long long a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	a = abs(b - a);
	v = v - w;
	if (a <= v * t) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	double x,h,s,t;
	double S;
	while(true){
		cin>>x>>h;
		if(x==0&&h==0) break;
		t=x*x*0.25+h*h;
		t=pow(t,0.5);
		s=0.5*x*t*4.0;
		S=s+x*x;
		fcout(6)<<S<<endl;
	}
}

Measured memory_bytes: 3284
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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<_>>()
    };

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;





fn main() {

    input! { 
       n: usize,
       m: usize,
       a: [i64;n],
    }

    let mut a = a;
    a.sort();


    use std::collections::BinaryHeap;
    let mut bh = BinaryHeap::new();
    for item in &a{
        bh.push(*item);
    }

    for i in 0..m{
        let mut x = bh.pop();
        let y  = x.unwrap()/2_i64;
        bh.push(y);

    }   

    
    let sum = bh.iter().fold(0, |x,y| x+y);
    println!("{}",sum);


}


Measured memory_bytes: 8444
#include <cstdio>

const int N = 100001, INF = 1e9;

int pricea[N], priceb[N];

inline void read() {}
template <typename Tp1, typename ...Tp2>
inline void read(Tp1 &num, Tp2 &...rest) {
    char c = getchar();
    while (c < '0' || c > '9') c = getchar();
    for (num = 0; c >= '0' && c <= '9'; c = getchar()) num = (num << 1) + (num << 3) + (c ^ '0');
    read(rest...);
}

int main() {
    int a, b, m, mina = INF, minb = INF, minn;
    read(a, b, m);
    for (int i = 1; i <= a; i++) {
        read(pricea[i]);
        if (pricea[i] < mina) mina = pricea[i];
    }
    for (int i = 1; i <= b; i++) {
        read(priceb[i]);
        if (priceb[i] < minb) minb = priceb[i];
    }
    minn = mina + minb;
    while (m--) {
        int x, y, less, tmp;
        read(x, y, less);
        tmp = pricea[x] + priceb[y] - less;
        if (tmp < minn) minn = tmp;
    }
    printf("%d\n", minn);
    return 0;
}


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

int n,a,b;

void solve(){
	cin>>n>>a>>b;
	
	for(int i=0;;++i){
		if(i&1)b+=a<b?-1:1;
		else a+=a<b?1:-1;
		if(a==b){
			if(i&1)puts("Alice");
			else puts("Borys");
			exit(0);
		}
	}
}

int main(){
	solve();
	
	return 0;
}

Measured memory_bytes: 256
N,M=gets.chomp.split.map(&:to_i)
H=gets.chomp.split.map(&:to_i)
goods=Array.new(N,true)

M.times{
    a,b=gets.chomp.split.map(&:to_i)
    if H[a-1] >= H[b-1]
        goods[b-1]=false
    end
    if H[a-1] <= H[b-1]
        goods[a-1]=false
    end
}

puts goods.count(true)

Measured memory_bytes: 23580
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    string a,b,c;
    int x,y,i;
    cin>>a>>b>>c;
    x=a.size();
    y=b.size();
    
    if(a[x-1]==b[0]&&b[y-1]==c[0])
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;


}



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

int W, a, b;

int main() {
    cin >> W >> a >> b;

    if (b > a + W) cout << b - (a + W) << endl;
    if (b <= a + W && b + W >= a) cout << "0" << endl;
    if (b + W < a) cout << a - (b + W) << endl;
    return 0;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		for(int i=0;i<h;i++) {
			String s = sc.next();
			System.out.println(s);
			System.out.println(s);
		}
	}

}

Measured memory_bytes: 23316
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 100;

int selectionSort(int A[], int N){
    int sw = 0, minj;

    rep(i, N - 1){
        minj = i;

        rep2(j, i, N){
            if(A[j] < A[minj]) minj = j;
        }

        swap(A[i], A[minj]);
        if(i != minj) sw++;
    }
    return sw;
}

void trace(int A[], int N){
    int i;
    rep(i, N){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main(){
    int A[MAX], N;

    cin >> N;
    rep(i, N) cin >> A[i];

    int sw = selectionSort(A, N);
    trace(A, N);

    cout << sw << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>
#include <cmath>

using namespace std;

void print_cnt(vector<int> &v) {
    for (auto&& a : v) {
        cout << a << " ";
    }
    // cout << endl;
}

void print_string(vector<string> &v) {
    for (auto&& a : v) {
        cout << a << endl;
    }
}

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

    s += 'R';
    vector<string> v;
    bool flg = false;
    string str;
    for (auto&& c : s) {
        if (flg) {
            if (c == 'R') {
                v.push_back(str);
                str = c;
                flg = false;
            } else {
                str += c;
            }
        } else {
            str += c;
            if (c == 'L') {
                flg = true;
            }
        }
    }

    // print_string(v);
    for (auto&& str2 : v) {
        // indexにはR...RL...LのRLのRのindexが入る
        int index = 0;
        for (int i = 0; i < str2.size(); i++) {
            if (str2[i] == 'L') {
                index = i-1;
                break;
            }
        }

        // cout << "index: " << index << endl;
        int mojisu = str2.size();
        vector<int> cnt(mojisu, 0);
        if (index%2 == 0) {
            if (mojisu%2 == 0) {
                cnt[index] = mojisu/2;
                cnt[index+1] = mojisu/2;
            } else {
                cnt[index] = mojisu/2 + 1;
                cnt[index+1] = mojisu/2;
            }
        } else {
            if (mojisu%2 == 0) {
                cnt[index] = mojisu/2;
                cnt[index+1] = mojisu/2;
            } else {
                cnt[index] = mojisu/2;
                cnt[index+1] = mojisu/2 + 1;
            }
        }
        print_cnt(cnt);
        // cout << endl;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

ll n;
vvi ans;
void  calc(vector<int> v, int max_num){
  if(v.size()==n) {
    ans.push_back(v);
    return;
  }
  for(int i=0;i<=max_num+1;i++){
    vector<int> x = v;
    x.push_back(i);
    calc(x, max(max_num, i));
  }
}
int main(int argc, char const *argv[]) {
  std::cin >> n;
  calc(vector<int>(), -1);
  vector<string> s;
  re(i, ans.size()){
    string tmp = "";
    re(j, n) tmp += ans[i][j] + 'a';
    s.push_back(tmp);
  }
  sort(all(s));
  re(i, s.size()) std::cout << s[i] << '\n';
  return 0;
}


Measured memory_bytes: 14256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    r,g,b = _in[0].split(' ')  # type:list(str)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'YES' if int(r+g+b)%4==0 else 'NO'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

ll GCD(ll x,ll y){
  if(x == y)return x;
  if(x < y)swap(x,y);
  ll r = x%y;
  if(r)return GCD(y,r);
  else return y;
}

ll LCM(ll x,ll y){
  return x/GCD(x,y)*y;
}
 
signed main(){
  int n;
  cin >> n;
  ll ans = 1;
  ll a;
  FOR(i,0,n){
    cin >> a;
    ans = LCM(ans,a);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3096
W, H, N = map(int, input().split())
ws, we, hs, he = 0, W, 0, H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        ws = max(ws, x)
    elif a == 2:
        we = min(we, x)
    elif a == 3:
        hs = max(hs, y)
    elif a == 4:
        he = min(he, y)
if we >= ws and he >= hs:
    res = (we - ws)*(he - hs)
else:
    res = 0
print(res)

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

int n, r, p, c, d[50], e[50];

int main() {
  while(cin >> n >> r && n && r) {
    for(int i = 0; i < n; i++)
      d[i] = n - i;
    for(int i = 0; i < r; i++) {
      cin >> p >> c;
      for(int j = 0; j < p - 1; j++)
        e[j] = d[j];
      for(int j = 0; j < c; j++)
        d[j] = d[j + p - 1];
      for(int j = 0; j < p - 1; j++)
        d[j + c] = e[j];
    }
    cout << d[0] << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>

using namespace std;

typedef struct _Rectangle
{
    int _H;
    int _W;
}Rectangle;

int main()
{
    vector<Rectangle> myRectangle;
    Rectangle rec;
    while(1)
    {
        cin>>rec._H>>rec._W;
        if(rec._H == 0 && rec._W == 0)
            break;
        myRectangle.push_back(rec);
    }

    for(int i = 0;i < myRectangle.size();i++)
    {
        for(int v = 0;v < myRectangle[i]._H;v++)
        {
            for(int h = 0;h < myRectangle[i]._W;h++)
                if((v>0&&v<myRectangle[i]._H-1)&&(h>0&&h<myRectangle[i]._W-1))
                    cout<<".";
            else
                cout<<"#";
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3176
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
from collections import Counter
c = Counter(S)
if abs(c['a']-c['b'])<=1 and abs(c['a']-c['c'])<=1 and abs(c['b']-c['c'])<=1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 77844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>s ;
  ll amin,zmax;
  amin=INF;
  zmax=-1;
  REP(i,s.length()){
    if(s[i]=='A' && amin>i) amin=i;
    if(s[i]=='Z' && zmax<i) zmax=i;
  }

  cout << zmax-amin+1 <<endl;
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	string a, b, c; cin >> a >> b>>c;
	//string s; cin >> s;
	if (a[a.size()-1]==b[0]&& b[b.size() - 1] == c[0])cout << "YES";
	else cout << "NO";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
int main() {
  uint64_t N;
  cin >> N;

  cout << N * N << endl;

  return 0;
}


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

int main() {
  int s,t;
  cin>>s>>t;
  if((s+t)%2==1){
    cout<<"IMPOSSIBLE"<<endl;
  }
  else{
    int m=(max(s,t)-min(s,t))/2;
    cout<<min(s,t)+m<<endl;
  }
}

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

using namespace std;

int n;
vector<int> len;
long long ans = 0;

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

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        len.push_back(t);
    }

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

    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            auto l = upper_bound(len.begin(), len.end(), len[j] - len[i]);
            int le = distance(len.begin(), l);
            auto r = lower_bound(len.begin(), len.end(), len[j] + len[i]) - 1;
            int ri = distance(len.begin(), r);
            ans += ri - le - (len[i] >= len[le] && len[i] <= len[ri]);
        }
    }

    cout << ans / 3;

	return 0;
}


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

int main()
{
    int a[3];
    int num[200]={0};
    for(int i=0; i<=2; i++)
    {
        cin>>a[i];

    }
     for(int i=0; i<=2; i++)
     {  int cnt=0;
         for(int j=0;j<=2;j++)
         {
             if(i==j)continue;
             if(a[i]!=a[j])
                cnt++;
         }
         if(cnt==2)
            printf("%d\n",a[i]);
     }


    return 0;
}


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

int main() {
  char a, b;
  
  cin >> a >> b;
  if (a == 'H') {
    if (b == 'H') {
      cout << 'H' << endl;
    } else {
      cout << 'D' << endl;
    }
  } else {
    if (b == 'H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }
}

Measured memory_bytes: 256
/*
    Vora Mahammadasim
*/

#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] != t[i]) ans++;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3764
N, M = map(int, input().split())
A = []
B = []
X = []
for i in range(N):
    p, q = map(int, input().split())
    A.append(p)
    B.append(q)
    X.append((p, q))

X.sort()

cnt = 0
cost = 0
for i in range(N):
    if cnt + X[i][1] < M:
        cnt += X[i][1]
        cost += X[i][1] * X[i][0]
    else:
        res = M - cnt
        cnt += X[i][1]
        cost += res * X[i][0]
        break

print(cost)

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


#define int long long
#define ll long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

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

const int mod = 1e9+7;
const ll inf = 2e18+5;

void solve(){

    int n;cin>>n;
  vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int sum=a[n-1];
    int cnt=n-2;
  for(int i=n-2;i>=0,cnt>0;i--){
    sum+=a[i];cnt--;
    if(cnt==0) break;
    sum+=a[i];cnt--;
  } 
    
  cout<<sum<<endl;

}















signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
            freopen("fin.txt", "r", stdin);
            freopen("fout.txt", "w", stdout);
    #endif   
    int cases=1;
    //cin>>cases;
    
    
    for(int iter=0; iter<cases; iter++){      
        solve();
    }
    return 0;
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

ll gcd(ll a,ll b){
  if(b<a) return gcd(b,a);
  if(b%a==0) return a;
  return gcd(b%a,a);
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll g=gcd(a,b);
  if(g==1){
    cout<<g<<endl;
    return 0;
  }
  
  ll c=1;
  for(ll i=2;i*i<g;i++){
    if(g%i==0) c++;
    while(g%i==0){
      g/=i;
    }
  }
  
  if(g!=1) c++;
  
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector<int> mountains;
	int n;
	while (cin >> n) {
		mountains.push_back(n);
	}
	sort(mountains.begin(), mountains.end(), greater<int>());
	
	cout << mountains[0] << endl;
	cout << mountains[1] << endl;
	cout << mountains[2] << endl;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    int check = 0;
    int i = 0;
    
    char w[11], input[1001];
    
    scanf("%s", w);
    for(i = 0; w[i] != '\0'; i++){
        w[i] = tolower(w[i]);
    }
    while(1){
        scanf("%s", input);
        if(strcmp(input, "END_OF_TEXT") == 0) {
            break;
        }
        for(i = 0; input[i] != '\0'; i++){
            input[i] = tolower(input[i]);
        }
        if(strcmp(input, w) == 0){
            check++;
        }
    } 
    
    printf("%d\n", check);
    
    return 0;
}


Measured memory_bytes: 2112
import math
import keyword

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

s,w = NextInts()

if (w >= s):
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 9200
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)

n, x, y = map(int, input().split())

ret = [0] * (n-1)
for s in range(1,n):
    for e in range(s+1,n+1):
        d = min(e-s, abs(s-x) + abs(e-y) +1)
        ret[d-1] += 1
for r in ret:
    print(r)

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

int main()
{
  int n, m;
  while (cin >> n >> m) {
    vector<int> c(2*n);
    for (int i = 0; i < 2*n; ++i)
      c[i] = i+1;

    for (int i = 0; i < m; ++i) {
      int k;
      cin >> k;

      vector<int> nc(2*n);
      if (k == 0) {
	for (int j = 0; j < n; ++j) {
	  nc[j*2] = c[j];
	  nc[j*2+1] = c[n+j];
	}
      } else {
	for (int j = 0; j < k; ++j)
	  nc[2*n-k+j] = c[j];
	for (int j = 0; j < 2*n-k; ++j)
	  nc[j] = c[k+j];
      }
      c = nc;
    }

    for (int i = 0; i < 2*n; ++i)
      cout << c[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  vector<uint64_t> A(N);
  N_TIMES(n, N) {
    cin >> A[n];
  }
  sort(A.begin(), A.end());

  uint64_t M = N / 2, S = 0;
  if (N % 2 == 0) {
    for (uint64_t i = M; i < N; ++i) {
      S += A[i] * 2;
    }
    S -= A[M];
    S += A[M - 1];
    for (uint64_t i = 0; i < M; ++i) {
      S -= A[i] * 2;
    }
  } else { // N % 2 == 1
    uint64_t P = 0;
    for (uint64_t i = M; i < N; ++i) {
      P += A[i] * 2;
    }
    P -= A[M] + A[M + 1];
    for (uint64_t i = 0; i < M; ++i) {
      P -= A[i] * 2;
    }

    uint64_t Q = 0;
    for (uint64_t i = M + 1; i < N; ++i) {
      Q += A[i] * 2;
    }
    Q += A[M - 1] + A[M];
    for (uint64_t i = 0; i < M + 1; ++i) {
      Q -= A[i] * 2;
    }

    S = max(P, Q);
  }
  cout << S << endl;
  
  return 0;
}

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

int main() {
  int A, B, C, K, m, n=0, ans=0;
  cin >> A >> B >> C >> K;
  
  if (A < B) {
    ans = A;
    m = B;
  } else {
    ans = B;
    m = A;
  }
  if (m < C) {
    ans = ans + m;
    m = C;
  } else ans = ans + C;
  
  do {
    m = m * 2;
    n++;
  } while (n < K);
  
  cout << m+ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {

  string S,T;
  cin >> S >> T;
  
  int x = 0;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
      x++;
    }
  }
    
    if (x == S.size()) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

Measured memory_bytes: 3620
n = int(input())
a_n = list(map(int, input().split(" ")))


def is_dividable(l):
    for i in l:
        if not i % 2 == 0:
            return False
    else:
        return True


def divide(l):
    return [i/2 for i in l]


count = 0
while is_dividable(a_n):
    a_n = divide(a_n)
    count += 1

print(count)

Measured memory_bytes: 3060
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("%s = %s\n", #x, to_string(x).data())
string to_string (char s) { return string(1, s); }
string to_string (string s) { return "\"" + s + "\""; }
template<typename T> string to_string (vector<T>);
template<typename U, typename V> string to_string (pair<U, V> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template<typename T> string to_string (vector<T> v) {
	string res = "["; for (int i = 0; i < (int)v.size() - 1; i++) res += to_string(v[i]) + ", ";
	if (!v.empty()) res += to_string(v.back());	res += "]"; return res; }

const int INF = (int)1e9;

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

	vi freq(26, INF);
	int n;
	char s[100];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		vi t(26, 0);
		for (int j = 0; s[j]; j++) t[s[j] - 'a']++;
		for (int j = 0; j < 26; j++) freq[j] = min(freq[j], t[j]);
	}

	string res = "";
	for (int i = 0; i < 26; i++) for (int k = 0; k < freq[i]; k++) res += ('a' + i);
	printf("%s\n", res.data());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmin(x,y) x = min(x,y)
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> dist(n, vector<int> (n, INF));
    rep(i, n) dist[i][i] = 0;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = dist[b][a] = c;
    }
    rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j], dist[i][k]+dist[k][j]);
    vector<vector<int>> dist2(n, vector<int>(n,INF));
    rep(i, n) rep(j, n) {
        if (dist[i][j] <= l) dist2[i][j] = 1;
    }
    rep(k,n)rep(i,n)rep(j,n) chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
    int Q;
    cin >> Q;
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        if (dist2[s][t] == INF) puts("-1");
        else cout << dist2[s][t] - 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }

  int ans = 0;
  for (auto kv : mp) {
    ans += kv.second % 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4864
package main

import "fmt"

func main() {
        var n, a int
        fmt.Scan(&n)

        p := map[int]int{}
        for i := 0; i < n; i++ {
                fmt.Scan(&a)

                _, ok := p[a]
                if ok {
                        delete(p, a)
                } else {
                        p[a] = a
                }
        }

        fmt.Printf("%d\n", len(p))
}


Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	private void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] BtoA = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			BtoA[i] = 0;
		}
		int[] A = new int[M + 1];
		int[] B = new int[M + 1];
		for (int i = 1; i <= M; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			if (BtoA[B[i]] < A[i]) {
				BtoA[B[i]] = A[i];
			}
		}
		int ans = 0;
		int maxRightCutId = 0;
		for (int i = 2; i <= N; i++) {
			if (maxRightCutId < BtoA[i]) {
				maxRightCutId = i - 1;
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 85236
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n,k;
     cin>>n>>k;
     vector<lld> v(n+1),dp(n+1,1e18);
     rep(i,1,n)
     {
         cin>>v[i];
     }
     dp[1]=0;
     rep(i,2,n)
     {
         rep(j,max(1LL,i-k),i-1)
         {
             dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
         }
     }
     cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/** ?????? */
	static final BigDecimal capital = BigDecimal.valueOf(100000);

	/** ?????? */
	static final BigDecimal interest = BigDecimal.valueOf(0.05);

	/** ??? */
	static final BigDecimal rate = BigDecimal.valueOf(1).add(interest);

	/**
	 * ????????°???????????°???????????????
	 * ????´???¨???Debt Hell(????????°???)
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String input = br.readLine();

		// ????????¶?????\???????????±????????????????????????????????????
		int weeks = Integer.valueOf(input);

		// ?¨??????????????????????????????????????´?
		BigDecimal result = capital;
		for (int i = 0; i < weeks; i++) {
			// ????????????????????????????????????1000???????????????????????????
			result = roundUpLowerThousand(rate.multiply(result).setScale(0, BigDecimal.ROUND_UP));
		}

		System.out.println(result);
	}

	/**
	 * ????§°?????°??????1000???????????????????????????????????´
	 *
	 * @param target ????§°??°???
	 * @return ????????????????????????
	 */
	private static BigDecimal roundUpLowerThousand(BigDecimal target) {
		// ?¨????????????¨??????????????°???1000???
		BigDecimal basisNumber = BigDecimal.valueOf(1000);
		BigDecimal result = target.divide(basisNumber).setScale(0, BigDecimal.ROUND_UP);

		return result.multiply(basisNumber);
	}
}

Measured memory_bytes: 18284
N = int(input())

s = []
for _ in range(N):
    s.append(int(input()))

dp = {}
dp[0] = {}
dp[0][0] = False
for i, si in enumerate(s, 1):
    dp[i] = {}
    for si_1 in dp[i - 1]:
        dp[i][si_1] = dp[i - 1][si_1]
        dp[i][si_1 + si] = ((si_1 + si) % 10 != 0)

ans = 0
for sum_s, is_not_bug in dp[N].items():
    if is_not_bug and ans < sum_s:
        ans = sum_s
#print(dp)
print(ans)

Measured memory_bytes: 33208
n=int(input())
ans=0
ea=0
sb=0
ba=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if(s[-1]=="A" and s[0]=="B"):
    ba+=1
  elif(s[-1]=="A"):
    ea+=1
  elif(s[0]=="B"):
    sb+=1
if(ea==0 and sb==0):
  if(ba>0):
    ans+=ba-1
elif(ea==0 or sb==0):
  ans+=ba
else:
  ans+=ba+min(ea,sb)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();

ll GCD(ll a, ll b) {
    if (a > b) swap(a, b);
    while (b != 0) {
        ll c = b;
        ll d = a % b;
        a    = c;
        b    = d;
    }
    return a;
}

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

    ll ans = 0;

    REP2(i, 1, K + 1) {
        REP2(j, 1, K + 1) {
            ll g1 = GCD(i, j);
            REP2(k, 1, K + 1) {
                ans += GCD(g1, k);
            }
        }
    }

    PR(ans);

    return 0;
}

Measured memory_bytes: 3612