akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long

using namespace std;
vector < char > v;
string s[100100];

int main()
{
    int n,A,B,C;
    cin >> n >> A >> B >> C;
    for(int i = 0;i<n;i++)  cin >> s[i];
    for(int i = 0;i<n;i++){
        if(s[i] == "AB"){
            if(!A && !B)  return cout << "No" , 0;
            else if(!A){
                A++;
                B--;
                v.push_back('A');
            }
            else if(!B){
                B++;
                A--;
                v.push_back('B');
            }
            else {
                if(i == n - 1)  v.push_back('A');
                else if(s[i + 1] == "BC"){
                    B++;
                    A--;
                    v.push_back('B');
                }
                else {
                    B--;
                    A++;
                    v.push_back('A');
                }
            }
        }
        else if(s[i] == "BC"){
            if(!C && !B)  return cout << "No" , 0;
            else if(!C){
                C++;
                B--;
                v.push_back('C');
            }
            else if(!B){
                B++;
                C--;
                v.push_back('B');
            }
            else {
                if(i == n - 1)  v.push_back('B');
                else if(s[i + 1] == "AC"){
                    C++;
                    B--;
                    v.push_back('C');
                }
                else {
                    C--;
                    B++;
                    v.push_back('B');
                }
            }
        }
        else if(s[i] == "AC"){
            if(!A && !C)  return cout << "No" , 0;
            else if(!A){
                A++;
                C--;
                v.push_back('A');
            }
            else if(!C){
                C++;
                A--;
                v.push_back('C');
            }
            else {
                if(i == n - 1)  v.push_back('A');
                else if(s[i + 1] == "BC"){
                    C++;
                    A--;
                    v.push_back('C');
                }
                else {
                    C--;
                    A++;
                    v.push_back('A');
                }
            }
        }
    }
    cout << "Yes" << '\n';
    for(auto j : v)  cout << j << '\n';
    return 0;
}


Measured memory_bytes: 6804
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

object Main extends App {
  val sc = new Scanner(System.in)
  val a = (sc.nextInt + 13) % 15
  val b = (sc.nextInt + 13) % 15

  val d = a - b

  val ans = if(d == 0) "Draw"
  else if(d > 0) "Alice"
  else "Bob"

  println(ans)
}

Measured memory_bytes: 22308
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> lucas(90,0);
    lucas[0] = 2;
    lucas[1] = 1;
    rep(i,85){
        lucas[i + 2] = lucas[i + 1] + lucas[i];
    }
    cout << lucas[N] << endl;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>

using namespace std;

#define ll long long

struct data
{
	int x, y, a;
};

int cost(const struct data &a, const struct data &b)
{
	return abs(a.x - b.x) + abs(a.y - b.y);
}

int main()
{
	int h, w, d;
	cin >> h >> w >> d;
	
	vector<vector<struct data>>	r(d);

	for(int i = 0; i < h;i++)
		for (int j = 0; j < w; j++)
		{
			int a;
			cin >> a;
			a--;
			r[a%d].push_back({ i,j,a });
		}

	vector<vector<long>>	dist(d);

	for (int i = 0; i < d; i++)
	{
		sort(r[i].begin(), r[i].end(), [](const struct data &l, const struct data &r) {return l.a < r.a; });
		dist[i].push_back(0);
		for (int j = 1; j < r[i].size(); j++)
			dist[i].push_back(dist[i][j - 1] + cost(r[i][j - 1], r[i][j]));
	}

	long q;
	cin >> q;

	for (long i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		printf("%ld\n", dist[l % d][r / d] - dist[l % d][l / d]);
	}

	return 0;
}


Measured memory_bytes: 10240
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n = sc.chars();
    if n.contains(&'7') {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2160
def gcd(x, y):
  while(x % y != 0 and y % x != 0):
    if(x > y):
      x = x % y
    else:
      y = y % x
  if(x > y):
    return y
  else:
    return x
  
def cnt(N, C, D):
  return (N // C) + (N // D) - (N // (C * D // gcd(C, D)))

A, B, C, D = map(int, input().split())
cnt_B_A = cnt(B, C, D) - cnt(A-1, C, D)
print(B-A+1-cnt_B_A)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, p; cin >> n >> p;
  string s; cin >> s;
  v1i v(n+1, 0), u(p-1, 1);
  rep(i, p-2){
    u[i+1] = u[i]*10;
    u[i+1] %= p;
  }
  rrep(i, n){
    v[i] = v[i+1] + u[(n-i-1)%(p-1)]*(s[i]-'0');
    v[i] %= p;
  }
  map<int, lint> m;
  rep(i, n+1) m[v[i]]++;
  lint a = 0;
  rep(i, p) a += m[i] * (m[i]-1) / 2;
  if(p == 2){
    a = 0;
    rep(i, n) if((s[i] - '0') % 2 == 0) a += i+1;
  }
  else if(p == 5){
    a = 0;
    rep(i, n) if((s[i] - '0') % 5 == 0) a += i+1;
  }
  cout << a << "\n";
  return 0;
}

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

int main(void){
    queue< pair<string, int> > que;
    int n, q;
    cin >> n >> q;
    for(int i=0; i<n; i++){
        string name;
        int time;
        cin >> name >> time; 
        que.push(make_pair(name, time));
    }
    //時刻
    int timer = 0;

    while (!(que.empty())){
        string tmp_name = que.front().first;
        int tmp_time = que.front().second;
        if(tmp_time <= q){
            timer += tmp_time;
            cout << tmp_name << " " << timer << endl;
            que.pop();
        }else{
            que.pop();
            timer += q;
            que.push(make_pair(tmp_name, tmp_time-q));
        }
    }
    
    return 0;
}


Measured memory_bytes: 6344
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string a,b,c,d;
	cin >> a >> b >> c;
	d.push_back(toupper(a[0]));
	d.push_back(toupper(b[0]));
	d.push_back(toupper(c[0]));
	cout << d << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        if (s.contains("AB") || s.contains("BA")) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 23636
#include <iostream>
using namespace std;
int main(void){
    int a,b,c ;
    cin >> a;
    cin >> b;
    cin >> c;
    if(a > b){
        int temp = a;
        a = b;
        b = temp;
    }
        
        if (b > c){
            int temp = b;
            b = c;
            c = temp;
                
        }
            if(a > b){
                int temp = a;
                a = b;
                b = temp;
            }
    cout << a << " " << b << " " << c << endl;
}   
         


Measured memory_bytes: 3108
N, T = map(int, input().split())
ans = 10000
is_back = False
for i in range(N):
  c, t = map(int, input().split())
  if t <= T and ans > c:
    ans = c
    is_back = True
if is_back == False:
  print("TLE")
else:
  print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int aw = a + w;
		int bw = b + w;
		if (aw < b)
			System.out.println(b - aw);
		else if (bw < a)
			System.out.println(a - bw);
		else
			System.out.println("0");
	}
}

Measured memory_bytes: 21844
import collections
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
kuro=0
siro=0
for h in range(H):
    for w in range(W):
        if s[h][w]=="#":
            kuro+=1
        else:
            siro+=1



visited=[[0 for i in range(W)] for h in range(H)]
visited[0][0]=1
stack=collections.deque([[0,0,1]])
flag=0
while stack and not flag:

    y,x,m=stack.popleft()
    lst=[]
    if y>0:lst.append([-1,0])
    if y<H-1:lst.append([1,0])
    if x>0:lst.append([0,-1])
    if x<W-1:lst.append([0,1])
    for y1,x1 in lst:
        Y=y+y1
        X=x+x1
        if Y==H-1 and X==W-1:
            flag=1
            m+=1
            break
        if not visited[Y][X] and s[Y][X]==".":
            stack.append([Y,X,m+1])
            visited[Y][X]=1

print((siro-(m)) if flag else -1)


Measured memory_bytes: 40688
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn factors(n: usize) -> Vec<usize> {
    let mut result = vec![];
    for d in 1.. {
        if d * d > n {
            break;
        }
        if n % d == 0 {
            result.push(d);
            result.push(n / d);
        }
    }
    result.sort();
    result.dedup();
    result
}

fn main() {
    input! {
        n: usize,
    }
    let mut result = HashSet::new();
    for &d in &factors(n - 1) {
        if d > 1 {
            result.insert(d);
        }
    }
    for &d in &factors(n) {
        if d == 1 {
            continue;
        }
        let mut m = n;
        while m % d == 0 {
            m /= d;
        }
        if m % d == 1 {
            result.insert(d);
        }
    }

    println!("{}", result.len());
}


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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_nDept(END), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod> &rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 5748
fun main(arr:Array<String>) {
    var num = readLine()!!.toInt()
    var current = 1
    var flag = mutableMapOf<Int,Int>()
    while (num>=0) {
        flag[num]?.let {
            println(current)
            return
        }
        flag[num] = current
        if(num%2==0) {
            num /=2
        } else {
            num = (num*3)+1
        }
        current++
    }
}


Measured memory_bytes: 31924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    str S;
    cin >> S;
    ll ss = 0;
    ll ans = S.size();
    REP(i, S.size()) {
        if(S[i] == 'S') ss++;
        if(ss > 0 && S[i] == 'T') {
            ss--;
            ans-=2;
        }
    }
    out(ans);
}

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


Measured memory_bytes: 720
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc101_c(){
    //入力
    int n,k;
    cin >> n >> k;
//    int iloc = -1;
//    REP(i,n){
//        int a;
//        cin >> a;
//        if(a==1){
//            iloc = i;
//            break;
//        }
//    }
//    int ans= 0 ;
//
//    //処理
//    int left,right;
//    left = iloc;
//    right = n-iloc-1;
//    ans += left/k;
//    if(left%k) ans++;
//    ans += right/k;
//    if(right%k) ans++;
    int ans = (n-1)/(k-1);
    if((n-1)%(k-1)) ans++;
    
    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>

#include <sstream>
#include <iostream>
#include <string>
using namespace std;

//#define DEBUG (1)

#ifdef DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif

template <class T>
class myStack {
public:
  myStack(int capacity);
  ~myStack();
  void push(T i);
  T pop();
  bool isEmpty();
  bool isFull();
  int size();

private:
  T *p_;
  int current_;
  int capacity_;
};

template <class T>
myStack<T>::myStack(int capacity) :
  capacity_(capacity)
{
  p_ = new T[capacity_];
  current_ = 0;
}

template <class T>
myStack<T>::~myStack()
{
  delete [] p_;
}

template <class T>
void myStack<T>::push(T c)
{
  if (isFull()) {
    cout << "Full!!" << endl;
    return;
  }
  p_[current_++] = c;
}

template <class T>
int myStack<T>::size()
{
  return current_;
}

template <class T>
T myStack<T>::pop()
{
  if (isEmpty()) {
    cout << "Empty!!" << endl;
    return -1;
  }
  return p_[--current_];
}

template <class T>
bool myStack<T>::isEmpty()
{
  return (current_ == 0);
}

template <class T>
bool myStack<T>::isFull()
{
  return (current_ == capacity_ - 1);
}

template <class T>
void proc_add(myStack<T> &s)
{
  int a = s.pop();
  int b = s.pop();
  s.push(a + b);
}

template <class T>
void proc_sub(myStack<T> &s)
{
  int a = s.pop();
  int b = s.pop();
  s.push(b - a);
}

template <class T>
void proc_mul(myStack<T> &s)
{
  int a = s.pop();
  int b = s.pop();
  s.push(a * b);
}

int main() {
  const int capacity = 100 + 99;
  myStack<int> st(capacity);

  string s;
#if 0
  while (cin >> s) {
    DPRINTF("%s\n", s.c_str());
    bool isOperator = (s == "+" || s == "-" || s == "*");
    if (isOperator) {
      continue;
    }
    st.push(stoi(s));
  }

  while (!st.isEmpty()) {
    cout << st.pop() << endl;
  }
#else
  while (cin >> s) {
    DPRINTF("%s\n", s.c_str());

    bool isOperator = (s == "+" || s == "-" || s == "*");
    bool isNumber = !isOperator;
    if (isNumber) {
      st.push(stoi(s));
      continue;
    }

    if (s == "+")      proc_add(st);
    else if (s == "-") proc_sub(st);
    else if (s == "*") proc_mul(st);
    else cout << "FAILED to parse : " << s << endl;
  }
#endif

  assert(st.size() == 1);
  cout << st.pop() << endl;
  assert(st.size() == 0);

  return 0;
}

Measured memory_bytes: 3168
<?php
fscanf(STDIN,'%d',$N);
$price=explode(" ",trim(fgets(STDIN)));
$cost=explode(" ",trim(fgets(STDIN)));
$sum=0;
for ($i=0; $i <$N ; $i++) {
  // code...
  if($price[$i]>=$cost[$i]){
    $sum=$sum+$price[$i]-$cost[$i];
  }
}
echo $sum;
echo "\n";



 ?>


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

using namespace std;

int main(){
  int n;
  std::cin >> n;
  vector<int> a(n);
  long long sum = 0;
  for(int idx = 0; idx < n; idx++){
    std::cin >> a[idx];
    sum += a[idx];
  }

  long long sum2 = 0;
  long long min = INT_MAX;
  for(int idx = 0; idx < n; idx++){
    sum2 += a[idx];
    sum -= a[idx];
    if(abs(sum - sum2) < min){
      min = abs(sum - sum2);
    }
  }
  std::cout << min << '\n';
  return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
S=input()+"*"

A=[0] if S[0]=="1" else [0,0]
cnt,num=0,S[0]
for i in range(n+1):
    if num==S[i]:
        cnt +=1
    else:
        A.append(cnt)
        cnt=1
        num=S[i]

for i in range(1,len(A)):
    A[i]=A[i]+A[i-1]
ans=0
for i in range(0,len(A),2):
    ans=max(ans,A[min(i+k*2+1,len(A)-1)]-A[i])
print(ans)

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

int main () {
  int box[3] = {};
  cin >> box[0] >> box[1] >> box[2];
  sort(box, box + 3);
  cout << 0 + box[1] - box[0] + box[2] - box[1] << endl;
}
  


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    float d,t,s,r;
    scanf("%f %f %f", &d, &t, &s);
    
    r = d/s;
    
    if (r <= t) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    
    return 0;
    
}

Measured memory_bytes: 1740
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll X,Y;cin>>X>>Y;
    ll cnt=1;
    while(Y>=X*2){
        X*=2;
        cnt++;
    }
    cout<<cnt<<"\n";
}

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

int main(){
  int ans = 0;
  string S, T;
  cin >> S >> T;

  for(int i = 0; i < 3; i++){
    if(S[i] == T[i]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
struct str {
	ll x, y;
	bool operator < (const str&A)const {
		return x < A.x;
	}
};
int X[4] = { 0,0,1,-1 };
int Y[4] = { 1,-1,0,0 };
ll n, m, k, a[30010],b[30100];
str arr[100100];
priority_queue<str> que;
int main() {
	scanf("%lld %lld", &n, &m);
	for (int i = 0;i < n; i++)scanf("%lld %lld", &arr[i].x, &arr[i].y);
	sort(arr, arr + n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (m > arr[i].y) {
			ans += arr[i].y*arr[i].x;
			m -= arr[i].y;
		}
		else {
			ans += m * arr[i].x;
			break;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    String[] str = (sc.nextLine()).split(" ");
	    if(str[0].equals("0")) break;
	    int res = 0, one = 0;

	    for(int i = 0; i < str.length; i++){
		int cd = Integer.parseInt(str[i]);
		if(cd > 10) cd = 10;
		if(cd == 1){
		    cd = 11;
		    one++;
		}
		res += cd;
		if(res > 21){
		    while(one > 0 && res > 21){
			one--;
			res-=10;
		    }
		    if(res > 21){
			res = 0;
			break;
		    }
		}
	    }
	    
	    System.out.println(Integer.toString(res));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
<?php
  fscanf(STDIN, "%d", $N);
  $W = explode(" ", trim(fgets(STDIN)));
  $total = array_sum($W);
  $tmp = 0;
  $ans = $total;

  for ($i = 0; $i < $N; $i++) {
    $tmp += $W[$i];
    $ans = min($ans, abs(($total - $tmp) - $tmp));
  }

  echo $ans;


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int a[2000];
int main()
{
    string x;
    cin>>x;
    for(int i=0;i<=200;i++)
        a[i]=0;
    for(int i=0;i<x.size();i++)
    {
        a[x[i]]++;
    }
    int ck=0;
    for(int i='a';i<='z';i++)
    {
        if(a[i]%2)
        {
            ck=1;
            break;
        }
    }
    if(ck)
    {
        printf("No\n");
    }
    else
        printf("Yes\n");
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

ll dp[100005];

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);

  Fill(dp, LL_INF);
  dp[0] = 0LL;

  rep(i, 0, 100000) {
    chmin(dp[i + 1], dp[i] + 1);
    ll base = 1;
    rep(j, 1, 7) {
      base *= 6;
      if (i + base > 100000) break;
      chmin(dp[i + base], dp[i] + 1);
    }
    base = 1;
    rep(j, 1, 6) {
      base *= 9;
      if (i + base > 100000) break;
      chmin(dp[i + base], dp[i] + 1);
    }
  }

  put(dp[N]);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

int main() {
    int a, b, c;

    cin >> a >> b;
    if ( a + b > a * b){
        c = a + b;
        if (a + b < a - b){
            c = a - b;
        }
    }else {
        c = a * b;
    }

   cout << c << endl; 
    return 0;
}


Measured memory_bytes: 256
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


table = [0]*26

letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


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

int main(){
	int n,a,h,ans=0;
	double t,x;
	double ans_temp=9999;
	
	cin>>n>>t>>a;
	for(int i=0;i<n;i++){
		cin>>h;
		
		if(abs(a-(t-0.006*h))<ans_temp){
			ans=i+1;
			ans_temp=abs(a-(t-0.006*h));
		}
	}

	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,p,a,b,c,d,e,f,s,m;
    string l;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::vector<tuple<double, string>> map;
            for (int i=0;i<n;i++) {
                cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
                double sum=0;
                double price=0;
                double ans;
                if (m==1) {
                    sum+=a+b+c+d+e;
                    price=f*s;
                    ans=(price-p)/sum;
                    map.emplace_back(ans,l);
                } else {
                    for (int j=1;j<=m;j++) {
                        if (j==1) {
                            sum+=a+b+c+d+e;
                            price+=f*s;
                        } else {
                            sum+=d+e;
                            price+=f*s;
                        }
                    }
                    ans=(price-p)/sum;
                    map.emplace_back(ans,l);
                }
            }
            
            for (int k=0;k<n-1;k++) {
                for (int l=k+1;l<n;l++) {
                    double& hoge_double=get<0>(map[k]);
                    double& piyo_double=get<0>(map[l]);
                    string& hoge_string=get<1>(map[k]);
                    string& piyo_string=get<1>(map[l]);
                    if (hoge_double<piyo_double) {
                        swap(hoge_double,piyo_double);
                        swap(hoge_string,piyo_string);
                    } else if (hoge_double==piyo_double) {
                        if (hoge_string>piyo_string) {
                            swap(hoge_double,piyo_double);
                            swap(hoge_string,piyo_string);
                        }
                    }
                }
            }
            for (auto x:map) {
                cout<<get<1>(x)<<endl;
            }
            cout<<"#"<<endl;
        }
    }
}


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

int main() {
  long long n;
  cin >> n;
  
  long long ans = 0;
  
  for(long long i=1; i<=n; i++){
    ans += (i*floor(n/i)*floor(1+n/i))/2;
  }
  
  cout << ans << endl;
  
	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
class Main{
	public static void main(String[] aegs){
    	Scanner sc = new Scanner(System.in);
    	int sum = sc.nextInt() + sc.nextInt() + sc.nextInt();
      	if(sum >= 22)
          	System.out.println("bust");
      	else
        	System.out.println("win");
      	sc.close();
    }
}

Measured memory_bytes: 22100
#include<stdio.h>

int main()
{
	int a,b,c,d=0;
	int k, max=0,keep=0;
	
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	
	if(a>=b && a>=c)
		max=a;
	else if(b>=a && b>=c)
		max=b;
	else if(c>=a && c>=b)
		max=c;
		
	keep=max;
	while(k>0){
		max*=2;
		k--;
	}
	
	if(keep==a)
		printf("%d\n",max+b+c);
	else if(keep==b)
		printf("%d\n",max+a+c);
	else if(keep==c)
		printf("%d\n",max+a+b);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli a[200002] = {};
lli ruiseki[200002] = {};

int main(void) {

	lli n, k;
	cin >> n >> k;

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

	for (int i = 0; i < n; i++) {
		ruiseki[i] += a[i];
		ruiseki[i + 1] += ruiseki[i];
		ruiseki[i] = (ruiseki[i] - i + k) % k;
		//cerr << ruiseki[i] << " ";
	}
	//cerr << endl;

	map<lli, lli> m;
	m[1]++;

	lli sum = 0;

	for (lli i = 0; i < min(k,n); i++) {
		if (i == k - 1) {
			m[1]--;
		}
		//ここで尺取りを使う
		m[ruiseki[i]]++;

		sum += m[ruiseki[i]] - 1;

		//cerr << sum << " ";
	}

	for (lli i = k; i < n; i++) {

		m[ruiseki[i - k]]--;
		m[ruiseki[i]]++;

		sum += m[ruiseki[i]] - 1;
		//cerr << sum << " ";
	}

	//cerr << endl;

	cout << sum << endl;



	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
using ll = long long;
typedef vector<int> vi;
//macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int mod = 1e9+7;
void solution(){
	long long n,d;
	cin >> n >> d;
	int count = 0;
	for(int i=0;i<n;i++){
		long long a,b;
		cin >> a >> b;
		if((a*a + b*b) <= d*d){
			count++;
		}
	}
	cout << count << endl;
	return;
}

// void solution(){ //read a whole line from the input, possibly containing spaces
// 	string s;
// 	getline(cin,s);
// }
int main(){
	
    fio; // fast input output
    int t;
    t = 1;
    // cin >> t;
    while(t--){
    	// cout << "Case #" << t  << ": ";
        solution();
    }
    return 0;
};

Measured memory_bytes: 3660
#include <stdio.h>

int main()
{
  int a, b;
  char op;

  while (1) {
    scanf("%d %c %d", &a, &op, &b);

    if (op == '+') {
      printf("%d\n", a + b);
    } else if (op == '-') {
      printf("%d\n", a - b);
    } else if (op == '*') {
      printf("%d\n", a * b);
    } else if (op == '/') {
      printf("%d\n", a / b);
    } else if (op == '?') {
      break;
    }
  }
   return 0;
}



Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int c=0,Cmax=0,ans=0,N,num;
	cin>>N;
	FOR(i,1,N+1){
		num=i;
		c=0;
		while(num>0){
			num=num/2;
			c++;
		}
		if(c>Cmax){
			Cmax=c;
			ans=i;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	n--;
	int temp;
	cin>>temp;
	int minn=temp;
	int maxn=-1000000000;
	while(n--){
		int c;
		cin>>c;
		maxn=max(maxn,c-minn);
		minn=min(minn,c);
	}
	cout<<maxn<<endl;
	return 0;
}


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

#define MAX 10000

int main(int, char**)
{
    int n, q;
    int s[MAX+1];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    cin >> q;

    int tmp;
    int count = 0;
    for (int i = 0; i < q; i++) {
        cin >> tmp;
        s[n] = tmp;
        int j = 0;
        while (s[j] != tmp) j++;
        if (j != n) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
string str2;

int main(void){
	cin >> str;
	cin >> str2;
	int now=0;
	int cnt=0;
	int ng=0;
	bool flag=true;
	for(int i=0;i<str.size();i++){
		if(now<str2.size() && str[i]==str2[now]){
			now++;
		}else{
			if(str[i]==str2[now-1]){
				flag=false;
			}
			if(ng<str2.size() && str[i]==str2[ng]){
				ng++;
			}
		}
	}
	if(ng==str2.size())flag=false;
	printf("%s\n",(now==str2.size() && flag)?"yes":"no");
	return 0;
}

Measured memory_bytes: 4204
#include <stdio.h>

int	main(void)
{
	int nb;
	int sum;
	sum = 0;
	scanf("%d", &nb);
	while (nb > 0)
	{
		if (nb >= 500)
		{
			nb -= 500;
			sum += 1000;
		}
		else if (nb >= 5)
		{
			nb -= 5;
			sum += 5;
		}
		else
			nb -= 1;
	}
	printf("%d", sum);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int s[3];
int main()
{
     for(int i=0;i<3;i++)
          scanf("%d",&s[i]);
     sort(s,s+3);
     if(s[0]==s[1])printf("%d\n",s[2]);
     if(s[1]==s[2])printf("%d\n",s[0]);
     return 0;
}


Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 505;

using namespace std;

int n, ans[N * N];
pair < int, int > a[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n;
	forn(i, n)	
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	//~sort
	sort(a + 1, a + n + 1);
	set < int > st;
	forn(i, n * n)	
		st.insert(i);
	forn(i, n)
	{
		ans[a[i].first] = a[i].second;
		st.erase(a[i].first);
		forn(j, a[i].second - 1)
		{
			int x = *st.begin();
			if (x > a[i].first)
			{
				cout << "No" << endl;
				return 0;
			}
			ans[x] = a[i].second;
			st.erase(x);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = a[i].second + 1; j <= n; j++)
		{
			int x = *st.begin();
			if (x < a[i].first)
            {
            	cout << "No" << endl;
            	return 0;
            }
            ans[x] = a[i].second;
            st.erase(x);
		}
	}
	cout << "Yes" << endl;
	forn(i, n * n)
		cout << ans[i] << ' ';
	return 0;
}



Measured memory_bytes: 13952
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int n;
	cin>>n;
	int ac=0,tle=0,wa=0,re=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")
			ac++;
		if(s=="WA")
		wa++;
		if(s=="TLE")
			tle++;
	if(s=="RE")
		re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// ya navid navid
const int N=2e5+100;
vector <int> g[N];
ll par[N];
ll vis[N];
ll ind[N];
int32_t main(){
    ll n,m;
    cin >> n >> m;
    for (int i=0;i<n+m-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        ind[v]++;
    }
    ll root=0;
    queue <int> q;
    for (int i=1;i<=n;i++){
        if (ind[i]==0){
            root=i;
        }
    }
    q.push(root);
    while(q.size()){
        ll v=q.front();
        q.pop();
        for (int i=0;i<g[v].size();i++){
            ll u=g[v][i];
            ind[u]--;
            if (ind[u]==0){
                q.push(u);
                par[u]=v;
            }
        }
    }
    for (int i=1;i<=n;i++){
        cout << par[i] << endl;
    }

}


Measured memory_bytes: 13312
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] a = new int[n];
        int ans = 0;

        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            x[i] = b;
            a[i] = b;
        }

        Arrays.sort(a);
        int c = n / 2;

        for (int i = 0; i < n; i++) {
                if (x[i] <= a[c - 1]) {
                    System.out.println(a[c]);
                } else {
                    System.out.println(a[c - 1]);
                }
            }

        sc.close();
    }    
}


Measured memory_bytes: 102032
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

const int INF = 100100100;

int main() {
    int n; cin >> n;
    string s[60];
    rep(i, 0, n) {
        cin >> s[i];
    }
    string ans;
    rep(c, 'a', 'z' + 1) {
        int small = INF;
        rep(i, 0, n) {
            int cnt = 0;
            rep(j, 0, s[i].size()) {
                if (s[i][j] == c) {
                    cnt++;
                }
            }
            small = min(small, cnt);
        }
        rep(i, 0, small) ans += c;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, X; cin >> N >> X;
  vi64 S(N);
  vector<tuple<i64, i64, i64>> t;
  i64 M = 0;
  i64 D = 0;
  i64 ok = 0, ng = -1;
  rep(i, N) {
    i64 b, l, u; cin >> b >> l >> u;
    t.push_back(make_tuple(b, l, u));
    S[i] = b * l + (X - b) * u;
    M += S[i];
    ok += b;
    D += -l * b;
  }
  vi32 ord(N);
  iota(all(ord), 0);
  sort(all(ord), [&](int i, int j) {
    return S[i] > S[j];
  });
  vi64 sums(N + 1);
  rep(i, N) sums[i + 1] = sums[i] + S[ord[i]]; 
  while (ok - ng > 1) {
    i64 k = (ok + ng) / 2;
    i64 ma = -1e18;
    i64 p = k / X, q = k - p * X;
    rep(i, N) {
      i64 MM;
      if (p > i) MM = sums[p + 1] - S[ord[i]];
      else MM = sums[p];
      i64 b, l, u;
      tie(b, l, u) = t[ord[i]];
      i64 T;
      if (q <= b) T = q * l;
      else T = b * l + (q - b) * u;
      amax(ma, MM + T);
    }
    if (ma + D >= 0) ok = k;
    else ng = k;
  }
  cout << ok << '\n';
}


Measured memory_bytes: 5748
N = int(input())
A = list(map(int,input().split()))
x = [None]*N
sm = 0
sign = 1
for i in range(N):
    sm += sign*A[i]
    sign *= -1
x[0] = sm // 2
for i in range(1,N):
    x[i] = A[i-1]-x[i-1]
print(*map(lambda a: a*2, x))

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans  = b+c-a;
    if(ans<0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, os

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

f = lambda:list(map(int,input().split()))

def get_qsa(file_name):
    audio, size = readfile(file_name)
    headers = {
        'Connection': 'keep-alive',
        'Content-Length': str(size)
    }

    
    parameter = {
                "request_id":int(time.time()*100),
                "th":1,
                "tht":"qf492_100fps",
                "the":1.000000,
                "thst":"neural"
                }
    res = requests.post(f"http://{config['ip']}:{config['port']}", timeout=120, data=audio, headers=headers, params = parameter)
    # print(res.url)

    res_json = res.json()
    # print(res_json.keys())


    if res_json['retmsg']!="success":
        raise Exception
    

    bin_str = res_json["th"][0]["feat"]
    bin_data = base64.b64decode(bin_str)

    bin2qsa_siren(bin_data, file_name)


def solve():
    n = f()[0]
    s = input()

    if len(s) <= n:
        print(s)
    else:
        print(s[:n] + "...")
       
    
solve()



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;

    ll l = lcm(n, m);
    ll a = l / n;
    ll b = l / m;

    V<int> v(n), w(m);
    v[0] = 1, w[0] = 1;
    for(ll i = 1; i < n; i++) v[i] = v[i - 1] + a;
    for(ll i = 1; i < m; i++) w[i] = w[i - 1] + b;

    for(ll i = 0; i < n; i++){
        auto ite = lower_bound(ALL(w), v[i]);
        if(v[i] == *ite){
            ll j = ite - w.begin();
            if(s[i] == t[j]) continue;
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << l << endl;

    return 0;
}


Measured memory_bytes: 4204
import java.util.*;
import java.io.*;

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      String s = sc.next();
      int w = sc.nextInt();
      String out = "";
      for (int i = 0; i < s.length(); i += w) {
        out = out + s.substring(i,i+1);
      }
      System.out.print(out);
    }
  }
}

Measured memory_bytes: 23892