akhauriyash/Code-Regression huggingface dataset:
/*
                                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/

#include <bits/stdc++.h>

#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
 
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
signed main()
{   jaldi
    char ch;
    cin>>ch;
    int x=ch;
    x++;
    ch=x;
    cout<<ch;
}

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

#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

bool prime[10000010];
inline void sieve(){
	prime[0]=prime[1]=0;
	for(int i=2;i<10000010;i++)
		prime[i]=1;
	for(int i=2;i<sqrt(10000010);i++){
		if(prime[i]==1){
			for(int j=i*i;j<10000010;j+=i)
				prime[j]=0;
		}
	}
}

inline bool isPrime(ll n){
    if (n <= 1)
        return false; 
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}

inline int toInt(string s){
	//return atoi(s.c_str());
	int x=(int)s[0]-48;
	return x;
}

inline int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}

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

inline bool isLeap(int yy){
	return ((yy%4 == 0 && yy%100 != 0) || yy%400 == 0);
}

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
	
    char c;
    cin >> c;

    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
        cout << "vowel\n";
    else
        cout << "consonant\n";
	
    //cerr << tick();

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
H, W = map(int, input().split(' '))
table = [[c for c in input()] for _ in range(H)]

def dfs(i, j):
    dists = [[-1 for _ in range(W)] for _ in range(H)]
    nexts = ((-1,0), (1,0), (0,-1), (0,1))

    buf = [(i, j)]
    dists[i][j] = 0
    while buf:
        i, j = buf.pop(0)

        for x, y in nexts:
            next_i = i + x
            next_j = j + y
            if 0 <= next_i < H and 0 <= next_j < W:
                if table[next_i][next_j] == '.' and dists[next_i][next_j] == -1:
                    dists[next_i][next_j] = dists[i][j] + 1
                    buf.append((next_i, next_j))


    ret = 0
    for i in range(H):
        for j in range(W):
            ret = max(ret, dists[i][j])

    return ret

# print(table)

ans = 0
for i in range(H):
    for j in range(W):
        if table[i][j] == '.':
            n = dfs(i, j)
            ans = max(ans, n)


print(ans)



Measured memory_bytes: 46700
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])
    t = list(input()[:-1])
    N = len(s)
    S = {}
    T = {}
    t_si = 0
    t_ti = 0
    n_s = []
    n_t = []
    for si, ti in zip(s, t):
        if not si in S:
            S[si] = t_si
            n_s.append(t_si)
            t_si += 1
        else:
            n_s.append(S[si])
        if not ti in T:
            T[ti] = t_ti
            n_t.append(t_ti)
            t_ti += 1
        else:
            n_t.append(T[ti])

    for si, ti in zip(n_s, n_t):
        if si != ti:
            print('No')
            exit()
    print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 83532
# -*- 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):
    if 1 not in N:
        return "NO"
    if 9 not in N:
        return "NO"
    if 7 not in N:
        return "NO"
    if 4 not in N:
        return "NO"
    return 'YES'


def main():
    N = read_int_n()
    print(slv(N))


if __name__ == '__main__':
    main()


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
template <class T> using Tree = tree<T, null_type, less<T>, 
	rb_tree_tag, tree_order_statistics_node_update>; 

ostream & operator << (ostream & os, const pii & x) { return os << '(' << x.first << ' ' << x.second << ')';}
const int maxn = 1e5 + 10;
int a[maxn], fa[maxn];
int ans = 2e9;
vector<pii> b; 
Tree<pii> t[maxn], all, ret;
bool vis[maxn];
int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]);} 
void join(Tree<pii> & x, Tree<pii> & y)
{
	if(x.size() >= y.size())
	{
		for(auto v : y)
			x.insert(v);
		y.clear();
	}
	else
	{
		for(auto v : x)
			y.insert(v);
		x.clear();
		swap(x, y);
	}
}
int main()
{
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		b.push_back(mp(a[i], i));
		fa[i] = i;
		t[i].insert(mp(a[i], i));
	}
	sort(b.begin(), b.end(), greater<pii>());
	for(auto item : b)
	{
		int i = item.second;
		vis[i] = 1;
		if(vis[i - 1])
		{
			int u = getfa(i), v = getfa(i - 1);
			fa[u] = getfa(v);
			join(t[v], t[u]);
		}
		if(vis[i + 1])
		{
			int u = getfa(i + 1), v = getfa(i);
			fa[u] = getfa(v);
			join(t[v], t[u]);
		}
		int x = getfa(i);
		if(t[x].size() >= k)
		{
			t[x].split(*t[x].find_by_order(t[x].size() - k), ret);
			swap(t[x], ret);
			join(all, ret);
		}
		if(all.size() >= q)
			ans = min(ans, all.find_by_order(q - 1)->first - all.begin()->first);
	}
	printf("%d\n", ans);
	return 0;
}
		
			
		

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

int64_t n, a, b, c, d;

__int128_t solve(__int128_t x, map<int64_t, int64_t> &memo){
    if(x == 0) return 0;
    if(x == 1 || x == -1) return d;
    if(memo.count(x)) return memo[x];
    if(x == 0) return memo[0] = 0;
    int c5[] = {0, 1, 2, 2, 1};

    return memo[x] = min({
        x*d,
        solve((x+2)/5, memo) + c + d*c5[x%5], solve((x+1)/3, memo) + b + d*(x%3!=0),
        solve(x/2, memo) + a + d*(x%2), solve((x-1)/2, memo) + a + d*((x+1)%2+1), solve((x+1)/2, memo) + a + d*((x+1)%2+1)
    });
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int t;
    cin >> t;
    while(t--){
        map<int64_t, int64_t> memo;
        cin >> n >> a >> b >> c >> d;
        cout << (int64_t)solve(n, memo) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		
		String ans = "";
		StringBuilder sb = new StringBuilder();
		
		sb.append("Christmas");
		while(25-D>0) {
			sb.append(" Eve");
			D++;
		}
		ans = sb.toString();
		System.out.println(ans);
	}
}


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

int	main() {
	string S;
	int K;
	cin >>S >>K;
	int i;
	for (i=0; i<S.size(); i++) {
		if (S.at(i)!='1') break;
	}
	if (K>i) cout <<S.at(i);
	else cout <<'1';
	cout <<endl;
	return 0;
}



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

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

    string s;
    cin >> s;

    int Count = 1;
    char last = s.at(0);
    for(int i=1; i<s.size(); i++){
        if(s.at(i) == last)
            continue;

        last = s.at(i);
        Count++;
    }

    cout << Count << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<double,double> pii;
const int N = 2e5+5;
const int M = 2e5+5;
const int Mod = 1e8;
#define pi acos(-1)
#define INF 1e14
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
	int a,b,c,k,ans = 0;
	cin >> a >> b >> c >> k;
	for(int i=1;i<=min(a,k);++i) ans += 1;
	k -= a;
	k -= b;
	for(int i=1;i<=min(c,k);++i) ans += -1;
	pr(ans);
	//system("pause");
	return 0;
}

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

int main() {
  int N, A, B, i, cnt = 0, sum;
  cin >> N >> A >> B;
  for(i=1;i<=N;i++) {
    sum = 0;
    int a = i;
    while(a > 0){
      sum += a % 10;
      a /= 10;
    }
    if(A <= sum && sum <= B) cnt += i;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
input()
S=input()

while True:
 x=''
 ans=''
 for i in S:
   if (x==''):
    x=i
    continue
   if x!=i:
    ans+=x
    x=i
 ans+=x
 if ans==S:
   break
 else:
   S=ans
print(len(ans))       

Measured memory_bytes: 9092
#include<stdio.h>

int main() 
{
	int A,B,C;
	scanf("%d %d",&A,&B);
	C=A+B;;
	if(C>=24)
	{
		C=C-24;
		printf("%d",C);
	}
	else if(C<24)
	{
		printf("%d",C);
	}
	return 0;
 } 


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
int m, n;
int maps[92][92];
int res;
void dfs(int x, int y, int r) {
	int dx[] = {-1,0,0,1};
	int dy[] = {0,-1,1,0};
	maps[x][y]=0;
	for (int i=0; i<4; i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if (maps[nx][ny]) {
			dfs(nx,ny,r+1);
		}
	}
	res=max(r,res);
	maps[x][y]=1;
}
int main() {
	while (scanf("%d%d",&m,&n)) {
		if (m==0&&n==0) break;
		for (int i=1; i<=n; i++) for (int j=1; j<=m; j++)
			scanf("%d",&maps[i][j]);
		res = 0;
		for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
			if (maps[i][j]) {
				dfs(i,j,0);
			}
		}
		printf("%d\n",res+1);
	}
}

Measured memory_bytes: 0
use proconio::input;
use std::collections::{HashMap, HashSet};

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    if is_pairwise(&a) {
        println!("pairwise coprime");
    } else if is_setwise(&a) {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}

fn is_pairwise(a: &[usize]) -> bool {
    /// O(n log(log(n))) # calculate vec, which vec[i] mean min(factorization(n))
    fn min_primes(size: usize) -> Vec<usize> {
        let mut sieve: Vec<_> = (0..=size).collect();
        for i in 2.. {
            if i * i > size {
                break;
            }
            for j in 2..=(size / i) {
                if sieve[i * j] == i * j {
                    sieve[i * j] = i;
                }
            }
        }
        sieve
    }

    /// O(log(n)) # calculate prime factorization of n, with min_primes
    fn factorization(n: usize, min_primes: &[usize]) -> HashMap<usize, usize> {
        if n <= 1 {
            return vec![(n, 1)].into_iter().collect();
        }
        let (mut divided, mut facts) = (n, HashMap::new());
        while divided > 1 {
            *facts.entry(min_primes[divided]).or_insert(0) += 1;
            divided /= min_primes[divided];
        }
        facts
    }

    let &max = a.iter().max().unwrap();
    let min_primes = min_primes(max);
    let mut p = HashSet::new();
    for &ai in a.iter() {
        for (k, _) in factorization(ai, &min_primes) {
            if 1 < k && p.contains(&k) {
                return false;
            }
            p.insert(k);
        }
    }
    true
}

fn is_setwise(a: &Vec<usize>) -> bool {
    use num::integer::gcd;
    use num::Integer;

    /// O(|v| log(min(v))) # calculate gcd recursively
    fn gcd_recursive<T: Integer + Copy>(v: &Vec<T>) -> T {
        if v.len() == 0 {
            T::zero()
        } else if v.len() == 1 {
            v[0]
        } else {
            let mid = (v.len() + 1) / 2;
            gcd_recursive(
                &(0..mid)
                    .map(|i| {
                        if 2 * i < v.len() - 1 {
                            gcd(v[2 * i], v[2 * i + 1])
                        } else {
                            v[2 * i]
                        }
                    })
                    .collect(),
            )
        }
    }

    gcd_recursive(&a) == 1
}


Measured memory_bytes: 25468
c=[]
for i in range(3):
  c.append(list(map(int,input().split())))
a21=[c[1][i]-c[0][i] for i in range(3)]
a32=[c[2][i]-c[1][i] for i in range(3)]
b21=[c[i][1]-c[i][0] for i in range(3)]
b32=[c[i][2]-c[i][1] for i in range(3)]
if max(a21)!=min(a21) or max(a32)!=min(a32) or max(b21)!=min(b21) or max(b32)!=min(b32):
  print("No")
else :
  flag=False
  for a1 in range(101):
    for b1 in range(101):
      a=[a1,a1+a21[0],a1+a21[0]+a32[0]]
      b=[b1,b1+b21[0],b1+b21[0]+b32[0]]
      flagij=True
      for i in range(3):
        for j in range(3):
          if c[i][j]!=a[i]+b[j]:
            flagij=False
      flag|=flagij
  if flag:
    print("Yes")  
  else:
    print("No")

Measured memory_bytes: 3064
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$p = (int)$input[0];
$q = (int)$input[1];
$r = (int)$input[2];

$max = max($p, $q, $r);

echo $p+$q+$r-$max;

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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int M = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}


const int MAX_N = 11;
int d[MAX_N][MAX_N];

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    int n;
    while(cin >> n, n) {
        rep(i,MAX_N) {
            fill(d[i], d[i] + MAX_N, INF);
            d[i][i] = 0;
        }

        rep(i,n) {
            int a, b, c;
            cin >> a >> b >> c;
            d[a][b] = d[b][a] = c;
        }

        rep(k, MAX_N) {
            rep(i, MAX_N) {
                rep(j, MAX_N) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

//        rep(i,5) {
//            rep(j,5) {
//                cerr << d[i][j]<< " ";
//            }
//            cerr << endl;
//        }

        pair<ll, int> res = mp(INF, 1);
        rep(i,MAX_N) {
            ll total = 0;
            rep(j,MAX_N)
                if(d[i][j] == INF)
                    break;
                else
                    total += d[i][j];
            if(total != 0 && total < res.first)
                res = mp(total, i);
        }

        cout << res.second << " " << res.first << endl;
    }


    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);
  if(X<600){
    OUT(8);
  }else if(X<800){
    OUT(7);
  }else if(X<1000){
    OUT(6);
  }else if(X<1200){
    OUT(5);
  }else if(X<1400){
    OUT(4);
  }else if(X<1600){
    OUT(3);
  }else if(X<1800){
    OUT(2);
  }else{
    OUT(1);
  }

  return 0;
}

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

#define trade(a,b) tmp=(a);(a)=(b);(b)=tmp;

long M;

int sort(long l[],int N){
        int i=1,j,k;
        long tmp;

        for(i=0;i<N;i++){
                for(j=i;j>0;j=(j-1)/2){
                        if(l[j]<l[(j-1)/2]){
                                trade(l[j],l[(j-1)/2]);
                        }else{
                                break;
                        }
                }
        }

        for(i=0,k=N-1;i<N;i++){
                trade(l[0],l[k]);
                k--;
                for(j=0;j*2+1<=k;){
                        if(j*2+2>k || l[j*2+1]<l[j*2+2]){
                                if(l[j]>l[j*2+1]){
                                        trade(l[j],l[j*2+1]);
                                        j=j*2+1;
                                }else{
                                        break;
                                }
                        }
                        else if(l[j]>l[j*2+2]){
                                trade(l[j],l[j*2+2]);
                                j=j*2+2;
                        }else{
                                break;
                        }
                }
        }

        return 0;

}

long search(long l[],int head,int tail,long ft){
        if(tail-head<0){
                while(l[tail]+ft>M)tail++;
                return l[tail]+ft;
        }

        int i=(tail+head)/2;


        if(l[i]+ft>M)
                return search(l,i+1,tail,ft);
        else
                return search(l,head,i-1,ft);
}


main(){
        int i,j,k;

        long N,N2;

        long l[1000+500500+1];
        long maxpt;

        while(1){
                scanf("%ld %ld",&N,&M);
                if(N==0)break;
                for(i=0;i<N;i++)
                        scanf("%ld",&l[i]);

                for(i=0,k=N;i<N;i++)
                        for(j=i;j<N;j++)
                                if(l[i]+l[j]<M)
                                        l[k++]=l[i]+l[j];
                l[k++]=0;
                N=k;

                sort(l,N);

                maxpt=0;
                for(i=0;i<N;i++){
                        j=search(l,i,N-1,l[i]);
                        if(maxpt<j)
                                maxpt=j;
                }

                printf("%ld\n",maxpt);

        }
        return 0;
}

Measured memory_bytes: 4516
#include <stdio.h>

int main()
{
	int n, k;
	char tmp;

	scanf("%d %d", &n, &k);

	scanf("%c", &tmp);

	for (int i = 1; i <= n; i++)
	{
		scanf("%c", &tmp);

		if (i == k)
			printf("%c", tmp + 32);
		else
			printf("%c", tmp);
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b; cin >> a >> b;
    
    int ans = 0;
    if(a >= b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }

    ans += max(a, b);
    cout << ans << endl;
}

Measured memory_bytes: 256
//Problem *
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
int n,w=100000,x;
ll dp[N];
int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=w;i++)dp[i]=x+1;
	for(int i=1;i<=n;i++){
		ll a;int b;scanf("%lld%d",&a,&b);
		for(int j=w;j>=b;j--)dp[j]=min(dp[j],dp[j-b]+a);
	}
	for(int i=w;~i;i--)if(dp[i]<=x){printf("%d",i);return 0;}
	return 0;
}

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

int main(void){
    int A, B, M;
    cin >> A >> B >> M;
    int a[110000], b[110000];
    int i = 0;
    for(i=0;i<A;i++){
        cin >> a[i];
    }
    for(i=0;i<B;i++){
        cin >> b[i];
    }
    int x[110000], y[110000], c[110000];
    for(i=0;i<M;i++){
        cin >> x[i] >> y[i] >> c[i];
    }
    int res = 210000;
    int cost;
    for(i=0;i<M;i++){
        cost = a[x[i]-1] + b[y[i]-1] - c[i];
        if(cost < res){
            res = cost;
        }
    }
    sort(a, a+A-1);
    sort(b, b+B-1);
    cost = a[0] + b[0];
    if(cost < res){
            res = cost;
        }
    cout << res << endl;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
// mp::cpp_int
 
 int hell=0;
const int MOD=1000000007;
const int MOD1=1000000007;
 
int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a%hell;
  int t=power(a,b/2);
  t*=t;
  t%=hell;
   if(b&1)
   {
       t*=a;
       t%=hell;
   }
   return t;
 
}
 
void EE(int a, int b, int& x, int& y)
{
    if(a%b == 0)
    {
        x=0;
        y=1;
        return;
    }
    EE(b,a%b,x,y);
    int temp = x;
    x = y;
    y = temp - y*(a/b);
}
 
 
int inverse(int a)
{
    int x=0,y=0;
    int m=hell;
    EE(a,m,x,y);
    if(x<0) x +=MOD*m;
    x%=m;
    return x;
}
 
 
int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){
    a=a*x;
    }
  return a;
}
 
 
int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}
int dig(int a)
{
  int sum=0;
  while(a!=0)
  {
    sum+=a%10;
    a/=10;
  }
  
} 


 
int solve()
{  

  map<char,int> m;
  rep(i,0,4)
  {
    char c;
    cin>>c;
    m[c]++;
  }
  int a[100]={0};
  for(auto x:m)a[x.SS]++;
    if(a[2]==2)
    {
      cout<<"Yes";
      return 0;
    }
    cout<<"No";

  return 0;
}
 
 
signed main()
{  int t=1;
 
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    
 
 

 
//pri();
 
  clock_t time_req;
 
    // Without ung pow function
                                                                                                                   
 
  //cin>>t;
 
    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
      //cout<<endl;
     }
 
         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
 
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int socket = 1;
  int count = 0;
  while(socket < b) {
    socket += (a-1);
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int a[25][25] = {0}, b[25] = {0};
    for(int i = 0; i < m; i ++)
        cin >> b[i];
    int num = 0;
    for(int i = 0; i < n; i ++)
    {
        int ans = 0;
        for(int j = 0; j < m; j ++)
        {
            cin >> a[i][j];
            ans += a[i][j] * b[j];
        }
        if(ans + c > 0) 
            num ++;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int D, check = 0, count = 0 ;
  int C[27] ;
  cin >> D ;
  int S[27][D+1] ;
  for(int i=1;i<27;i++) cin >> C[i] ;
  for(int i=1;i<(D+1);i++){
    for(int j=1;j<27;j++){
      cin >> S[j][i] ;
    }
  }
  for(int date=1;date<(D+1);date++){
    cout << (date % 26) + 1 << endl ;
  }
  return 0 ;
}  

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    string s;
    cin >> s;
    int az[26];
    for(int i = 0; i < 26; i++){
        az[i] = 0;
    }
    for(int i = 0; i < s.length(); i++){
        char tmp = s[i] - 'a';
        az[tmp]++;
    }
    for(int i = 0; i < 26; i++){
        if(az[i] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
                cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    for i in 0..1000000 {
        if (i as f64 * 1.08) as usize == n {
            p(i);
            return;
        }
    }
    p(":(");
}


Measured memory_bytes: 4352
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)


N = I()
CSF = []
for i in range(1, N):
    CSF.append(LI())

for i in range(N-1):
    # i駅から出発する場合
    current = i
    time = 0
    for csf in CSF[i:]:
        if time < csf[1]:
            # timeのほうが小さい場合、初発まで待つ
            time = csf[1] + csf[0]
        elif time % csf[2] == 0:
            time += csf[0]
        else:
            # timeが初発を超えていた場合、きりのいい次発までまつ
            div = time % csf[2]
            time -= div
            time += csf[2]
            time += csf[0]
        current += 1
    print(time)

print(0)




Measured memory_bytes: 5592
#include<bits/stdc++.h>
typedef long long i64;
const int N=100007;
int n,m,qp=0;
i64 qs[N],t[N],ans[N];
int main(){
	scanf("%d%d",&n,&m);
	qs[0]=n;
	for(int i=0;i<m;++i){
		i64 x;
		scanf("%lld",&x);
		if(x<=qs[0])qs[0]=x,qp=0;
		else{
			while(qs[qp]>=x)--qp;
			qs[++qp]=x;
		}
	}
	t[qp]=1;
	for(int i=qp;i;--i){
		i64 x=qs[i];
		while(x>=qs[0]){
			int p=std::upper_bound(qs,qs+i,x)-qs-1;
			t[p]+=x/qs[p]*t[i];
			x%=qs[p];
		}
		ans[x]+=t[i];
	}
	ans[qs[0]]+=t[0];
	for(int i=n;i;--i)ans[i-1]+=ans[i];
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}

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

using namespace std;
using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);

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

    for (auto i : a)
        cout << i << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#define _PI (3.141592653589793)
int main()
{
	std::string S, T;
	std::cin >> S >> T;
	T.resize(T.size() - 1);
	if (T == S) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3600
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
 
signed main() {
ll N,ans=0;
cin >> N;
for(int i=1;i<=N;i++){
if(i%5 !=0 && i%3 !=0){
    ans += i;
}
}
answer(ans);

}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	int m, h, t;
	while(cin>>str) {
		if(str=="-") break;
		cin>>m;
		h=0;
		for(int i=0; i<m; ++i) {
			cin>>t;
			h+=t;
		}
		h%=str.length();
		cout<<str.substr(h)<<str.substr(0, h)<<'\n';
	}
	return 0;
}



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

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		String numsArray[] = br.readLine().split(" ");
		long sum = 0;
		int max=-1000000;
		int min=1000000;
		int tmp=0;
		for(int i=0; i<num; i++){
			tmp = Integer.parseInt(numsArray[i]);
			if(tmp>max){
				max = tmp;
			}
			if(tmp<min){
				min = tmp;
			}
			sum = sum+tmp;
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 28244
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

def guu(s):
    return 1 if s[0:len(s)//2]==s[len(s)//2:] else 0
t=input().rstrip()
i=2
while i<len(t):
    #print(t[0:i])
    if guu(t[0:i])==1:
        mx=i
    i+=2
print(mx)
        

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

int main(){
  string S;
  cin >> S;
  int l=0,s=S.size(),j=2;
  if(S[0]!='A'){
    cout << "WA" << endl;
    return 0;
  }
  while(j!=s-1){
    if(S[j]=='C')l++;
    j++;
  }
  if(l!=1){
    cout << "WA" << endl;
    return 0;
  }
  l=0;
  for(int i=0;i<s;i++){
    if(S[i]<'a'||S[i]>'z')l++;
  }
  if(l==2)cout << "AC" << endl;
  if(l!=2)cout << "WA" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int cnt[100005];
int main()
{
    int n;
    scanf("%d",&n);
    long long int s=0;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        cnt[x]++;
        s+=x;
    }
    int q;
    scanf("%d",&q);
    
    for(int i=0;i<q;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        cnt[b]+=cnt[a];
        s=s+(b-a)*cnt[a];
        cnt[a]=0;
        printf("%lld\n",s);
    }
    return 0;
}



Measured memory_bytes: 4224
/* In the name of Allah */

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int flag1 = 0, flag2 = 0;
	while(a > 0 && c > 0){
		c -= b;
		if(c <= 0){
			cout << "Yes";
			return 0;
		}
		a -= d;	
		if(a <= 0){
			cout << "No";
			return 0;
		}
	}

	return 0;  
}

Measured memory_bytes: 3584
#include <iostream>
#include <queue>
long int dfs(std::queue<int> q, long int tmp, long int mem) {
  if(q.size()==1) {
    return q.front()+tmp+mem;
  }
  int f = q.front();
  q.pop();
  return dfs(q, (tmp+f)*10, mem) + dfs(q, 0, mem+f+tmp);
}
int main() {
  std::queue<int> q;
  char c;
  while(std::cin>>c)q.push(c-'0');
  std::cout << dfs(q, 0, 0) << "\n";
}
      
    
  

Measured memory_bytes: 256
import heapq

n = int(input())
a = list(map(int, input().split()))
hl = a[0: n]
hr = [-x for x in a[2*n: 3*n]]
heapq.heapify(hl)
heapq.heapify(hr)
sl = sum(hl)
sr = sum(hr)

bl = [sl]
br = [sr]
for i in range(1, n+1):
    heapq.heappush(hl, a[n-1+i])
    vl = heapq.heappop(hl)
    sl += a[n-1+i] - vl
    bl.append(sl)

    heapq.heappush(hr, -a[2*n-i])
    vr = heapq.heappop(hr)
    sr += -a[2*n-i] - vr
    br.append(sr)

max_score = -float('inf')
for i in range(n+1):
    max_score = max(max_score, bl[i]+br[n-i])


print(max_score)


Measured memory_bytes: 38420
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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 main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int K;

    cin >> K;

    if(K % 2 == 0){
        cout << ( K / 2 ) * ( K / 2) << endl;
    }else{
        cout << ((K+1) / 2) * ((K-1) / 2) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mk make_pair


int main()
{

  int a,b;
  cin>>a>>b;
  ll c[a];
  for(ll i=0;i<a;i++)
  cin>>c[i];
  sort(c,c+a);
  ll sum=0;
  for(ll i=0;i<b;i++)
  sum+=c[i];
  cout<<sum<<endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
#define vi vector<long long>

using namespace std;
typedef long long ll;
const ll mod=1e9;
const ll inf = 1e18+7;
const int maxn = 100;

long long cost[10],n;
map<long long,long long> mp;
long long dfs(long long x)
{
	if(x==0)
		return 0;
	if(mp.count(x))
		return mp[x];
	long long ans=1e18;
	long long temp[6]={x/2,x/2+1,x/3,x/3+1,x/5,x/5+1};
	long long t[6]={2,2,3,3,5,5};
	for(int i=0;i<6;i++)
		if(temp[i]<x)
			ans=min(ans,dfs(temp[i])+(long long)min((double)abs(temp[i]-x)*cost[0],abs(temp[i]*t[i]-x)*(double)cost[0]+cost[t[i]]));
	mp[x]=ans;
	return mp[x];
}
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		mp.clear();
		cin>>n>>cost[2]>>cost[3]>>cost[5]>>cost[0];
		cout<<dfs(n)<<endl;
	}
	return 0;
}

/**
5
6
7
1 2 2 4
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
**/


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)


using namespace std;


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

    ll n = s.size();


    ll d = 1;
    bool end = false;
    if(n%2 == 0){
        ll midl = n/2-1;
        ll midr = n/2;
        if(s[midl] != s[midr]){
            end = true;
            d = 0;
        }
        else{
            for(; !end && d < n/2+5; d++){
                if(0 <= midl-d){
                    if(s[midl] == s[midl-d]){}
                    else end = true;
                }
                if(midr+d < n){
                    if(s[midr] == s[midr+d]){}
                    else end = true;
                }
            }
            if(end) d--;
        }
        
        if(end) cout << (n/2) + d << endl;
        else    cout << n << endl;
    }
    else{
        ll mid = (n-1)/2;
        for(; !end && d < n/2+5; d++){
            if(0 <= mid-d){    
                if(s[mid] == s[mid-d]){}
                else end = true;
            }
            if(mid+d < n){
                if(s[mid] == s[mid+d]){}
                else end = true;
            }
        }

        if(end) d--;

        if(end) cout << ((n+1)/2) + d - 1 << endl;
        else    cout << n << endl;
    }

    

    return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, q: usize,
        tuv: [(usize, usize, usize); q]
    }

    let mut dsu = DSU::new(n);
    
    for (t, u, v) in tuv {
        match t {
            0 => {
                dsu.merge(u, v);
            }
            1 => {
                let res = dsu.same(u, v) as u32;
                println!("{}", res);
            }
            _ => unreachable!()
        }
    }
}
#[allow(dead_code)]
pub struct DSU {
    parent_or_size: Vec<isize>,
}

#[allow(dead_code)]
impl DSU {
    pub fn new(n: usize) -> Self {
        assert!(n <= std::isize::MAX as usize);
        Self {
            parent_or_size: vec![-1; n],
        }
    }

    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.leader(a);
        let mut y = self.leader(b);
        if x == y {
            return x;
        }
        if -self.parent_or_size[x] < -self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as isize;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.leader(a) == self.leader(b)
    }

    pub fn leader(&mut self, a: usize) -> usize {
        if self.parent_or_size[a] < 0 {
            a
        } else {
            self.parent_or_size[a] = self.leader(self.parent_or_size[a] as usize) as isize;
            self.parent_or_size[a] as usize
        }
    }

    pub fn size(&mut self, a: usize) -> usize {
        let leader = self.leader(a);
        -self.parent_or_size[leader] as usize
    }

    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0usize; self.parent_or_size.len()];
        let mut group_size = vec![0usize; self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.parent_or_size.len() {
            result[leader_buf[i]].push(i);
        }
        result.retain(|v| !v.is_empty());
        result
    }
}

Measured memory_bytes: 10128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi a(m);
    int64_t sum = 0;
    rep(i,m) cin >> a.at(i);
    rep(i,m) sum += a.at(i);
    if(sum>n){
        cout << -1 << endl;
    }else{
        cout << n-sum << endl;
    }
}

Measured memory_bytes: 3704
#include<iostream>

using namespace std;
const int N=100000;
int main(){
	int i,j,n,dp[N],a[N];
	cin>>n;
	for(i=0;i<n;++i) cin>>a[i];
	dp[1]=abs(a[0]-a[1]);
	dp[2]=abs(a[0]-a[2]);
	for(i=3;i<n;++i){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	co((A - C)*(B - D));

	Would you please return 0;
}

Measured memory_bytes: 256