akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

struct Node {
  ll value;
  Node *left = nullptr,
       *right = nullptr,
       *parent = nullptr;

  Node(ll value = -1): value(value) {}
};

class BST {
  Node *root = nullptr;

  string tos_pre(Node *nd) {
    string s = "";

    s += " " + to_string(nd->value);
    if (nd->left) s += tos_pre(nd->left);
    if (nd->right) s += tos_pre(nd->right);

    return s;
  }

  string tos_in(Node *nd) {
    string s = "";

    if (nd->left) s += tos_in(nd->left);
    s += " " + to_string(nd->value);
    if (nd->right) s += tos_in(nd->right);

    return s;
  }
  
  Node *find_partial(ll value, Node *nd) {
    if (!nd) return nullptr;
    if (nd->value == value) return nd;
    
    return nd->value > value
      ? find_partial(value, nd->left)
      : find_partial(value, nd->right);
  }

public:
  void insert(ll value) {
    Node *x = root, *y = nullptr, *z = new Node(value);
    
    while (x) {
      y = x;
      x = z->value < x->value ? x->left : x->right;
    }
    z->parent = y;

    if (!y) root = z;
    else if (z->value < y->value) y->left = z;
    else y->right = z;
  }

  Node *find(ll value) {
    return find_partial(value, root); 
  }

  void del(ll value) {

  }
  
  string print_pre() {
    return tos_pre(root);
  }

  string print_in() {
    return tos_in(root);
  }
};

int main() {
  int n;
  cin >> n;
  
  auto bst = BST();
  rep(i, n) {
    string cmd;
    cin >> cmd;
    
    if (cmd == "print") {
      cout << bst.print_in() << endl;
      cout << bst.print_pre() << endl;
    } else {
      ll opr;
      cin >> opr;

      if (cmd == "insert") bst.insert(opr);
      else if (cmd == "find") 
        cout << (bst.find(opr) ? "yes" : "no") << endl;
    }
  }
}



Measured memory_bytes: 30448
N = int(input())
H = [list(map(int, input().split()))]

ans = 0
while H:
    h = H.pop(0)
    if not h: continue

    min_h = min(h)
    ans += min_h
    
    s = 0
    
    for i in range(len(h)):
        h[i] -= min_h
        
        if h[i]: continue
        H.append(h[s:i])
        s = i+1
    if s != N: H.append(h[s:i+1])

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp32 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();

            char t1 = s[0];
            char t2 = s[1];
            char t3 = s[2];
            char t4 = s[3];
            
            if (t1 == t2 || t2 == t3 || t3 == t4) {
                Console.WriteLine("Bad");
            } else {
                Console.WriteLine("Good");
            }
            
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
    int N, K;
    cin >> N >> K;
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(h[i] >= K){
            cnt++;
        }
    }
    cout << cnt;
}

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

int main(){
	int h,w; cin>>h>>w;
	vector<vector<char>> v(h,vector<char>(w));
	rep(i,h){
		string s; cin>>s;
		rep(j,w){
			v[i][j]=s[j];
		}
	}
	vector<vector<string>> a(h,vector<string>(w,"#"));
	rep(i,h){
		rep(j,w){
			int cnt=0;
			for(int k=-1; k<=1; k++){
				for(int l=-1; l<=1; l++){
					if(i+k<0||j+l<0||i+k>=h||j+l>=w) continue;
					else if(k==0&&l==0) continue;
					else if(v[i+k][j+l]=='#') cnt++;
				}
			}
          if(v[i][j]=='#') continue;
		else a[i][j]=to_string(cnt);
		}
	}
  rep(i,h){
    rep(j,w){
      cout<<a[i][j];
    }
    cout<<endl;
  }

}

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

int main(){
    string S,T;
    cin >>S>>T;
    int count=T.size();
    for(int i=0;i<S.size()-T.size()+1;i++){
        int aaa=0;
        for(int j=0;j<T.size();j++){
          if(S.at(i+j)!=T.at(j)){
              aaa++;
          }
        }
        count=min(aaa,count);
    }
    cout <<count <<endl;
}

Measured memory_bytes: 3604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ESequenceSum {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, X, M;
        cin >> N >> X >> M;

        if (N == 1) {
            cout << X << endl;
            return;
        }

        int num = 1;
        int sum = X;
        int cur = X;
        vector<int> v(M + 1);
        v[0] = X;
        set<int> s;
        s.insert(X);
        REP(i, M) {
            cur = (cur * cur) % M;
            v[i + 1] = cur;
            if (s.count(cur)) break;
            sum += cur;
            num++;
            if (num == N) {
                cout << sum << endl;
                return;
            }
        }
        int len = 0;
        int prev = 0;
        int t = -1;
        sum = 0;
        REP(i, M) {
            if (len > 0) {
                if (v[i] == cur) {
                    break;
                }
                sum += v[i];
                len++;
            } else {
                if (v[i] == cur) {
                    len = 1;
                    sum += v[i];
                    t = i;
                } else {
                    prev += v[i];
                }
            }
        }
        int k = (N - t) / len;
        int res = k * sum + prev;
        FOR(i, t + len * k, N-1) {
            res += cur;
            cur = (cur * cur) % M;
        }
        cout << res << endl;


    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ESequenceSum solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3988
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

size_t di[]={size_t(-1), size_t(-1), 0, 0, 1, 1};
size_t dj[]={size_t(-1), 0, size_t(-1), 1, 0, 1};

int score(const std::vector<std::vector<int>> &S, int C) {
  size_t N = S.size();

  union_find uf(N*(N+1)/2);
  for (size_t i=0; i<N; ++i) {
    for (size_t j=0; j<=i; ++j) {
      for (size_t k=0; k<6; ++k) {
        size_t ni = i+di[k];
        size_t nj = j+dj[k];
        if (!(ni < N && nj <= ni)) continue;
        if (S[i][j] != S[ni][nj]) continue;

        size_t f0 = i*(i+1)/2+j;
        size_t f1 = ni*(ni+1)/2+nj;
        uf.unite(f0, f1);
      }
    }
  }

  std::set<size_t> safe;
  for (size_t i=0; i<N; ++i) {
    for (size_t j=0; j<=i; ++j) {
      if (S[i][j] != 0) continue;
      for (size_t k=0; k<6; ++k) {
        size_t ni = i+di[k];
        size_t nj = j+dj[k];
        if (!(ni < N && nj <= ni)) continue;

        size_t f1 = ni*(ni+1)/2+nj;
        safe.insert(uf.find(f1));
      }
    }
  }

  int res = 0;
  for (size_t i=0; i<N; ++i) {
    for (size_t j=0; j<=i; ++j) {
      if (S[i][j] == 0) continue;
      size_t f0 = i*(i+1)/2+j;
      if (safe.count(uf.find(f0))) continue;
      (S[i][j] == C)? --res:++res;
    }
  }
  return res;
}

int testcase_ends() {
  size_t N;
  int C;
  scanf("%zu %d", &N, &C);
  if (N == 0 && C == 0) return 1;

  std::vector<std::vector<int>> S(N);
  for (size_t i=0; i<N; ++i) {
    S[i].resize(i+1);
    for (size_t j=0; j<=i; ++j)
      scanf("%d", &S[i][j]);
  }

  int res = -100;
  for (size_t i=0; i<N; ++i) {
    for (size_t j=0; j<=i; ++j) {
      if (S[i][j] != 0) continue;
      S[i][j] = C;
      res = std::max(res, score(S, C));
      S[i][j] = 0;
    }
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2688
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

struct Connection {
	vector<int>friends;
	vector<int>block;
	vector<int>friendable;
	Connection() {};
};

int main() {

	string S;
	cin >> S;

	int n = S.size();
	for (int i = 0; i < (n / 2); i++) {
		if (S[i] != S[(n - 1) - i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	int mx = n / 2;
	for (int i = 0; i < mx; ++i) {
		if (S[i] != S[(n - 1) - i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	int mn = (n + 3) / 2 - 1;
	for (int i = mn; i < n; ++i) {
		if (S[i] != S[(n - 1) - (i - mn)]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int k,n;
	cin>>k>>n;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];	
	}
	int st=a[0];
	int maxdis=0;
	FOR(i,1,n){
		maxdis=max(maxdis,a[i]-a[i-1]);
	}
	maxdis=max(maxdis,st+k-a[n-1]);
	cout<<k-maxdis<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 1024
#include <stdio.h>

int a, times, ind[105];

void solve(int l, int r)
{
	times++;
	if (a == ind [(l + r) / 2]){
		return;
	}
	if (l > r){
		times--;
		return;
	}
	
	if (ind[(l + r) / 2]  > a){
		solve (l, (l + r) / 2 - 1);
	}
	else {
		solve ((l + r) / 2 + 1, r);
	}
	
}

int main(void)
{
	
	int n;
	int i;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &ind[i]);
		}
		
		scanf("%d", &a);
		solve(0, n - 1);
		
		printf("%d\n", times);
		times = 0;
	}
	return (0);
}

Measured memory_bytes: 600
s = input()
t = input()

n = len(s)
m = len(t)

for i in range(n-m, -1, -1):
  x = s[i:i+m]
  for j in range(m+1):
    if j == m:
      print((s[:i]+t+s[i+m:]).replace("?","a"))
      exit()
    if x[j] == "?": continue
    elif x[j] != t[j]: break
    
print("UNRESTORABLE")


Measured memory_bytes: 9056
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, k = inpl()
p = sorted(inpl())
print(sum(p[:k]))


Measured memory_bytes: 68444
program answer
  implicit none

  integer :: N, K, sum, i
  integer, allocatable :: p(:)

  read(*,*) N, K
  allocate(p(N))
  read(*,*) p

  call bsort(p)

  do i = 1, K
     sum = sum + p(i)
  end do
  
  write(*,*) sum

  deallocate(p)
  stop
contains
  !bsort
  subroutine bsort(array)
    implicit none
    integer, intent(inout) :: array(:)
    integer :: i, j, n

    n=size(array)
    do i = 1, n
       do j = 1, n-1
          call swapif(array(j),array(j+1))
       end do
    end do
  end subroutine bsort

  subroutine swapif(a,b)
    implicit none
    integer, intent(inout) :: a, b
    integer ::c
    if(a>b) then
       c=a
       a=b
       b=c
    end if
    end subroutine swapif
    
 end program answer

  

Measured memory_bytes: 2804
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll h,w;cin>>h>>w;

  if(h==1 || w==1){cout<<1; return 0;}

  if(h%2==1 && w%2==1){
    cout<<(h/2+1)+(w-1)*h/2;
  }else{
    cout<<h*w/2;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

ld dist(ll x,ll y){
	ld res = sqrt(x*x + y*y);
	return res;
}
	
ll N,x,y,D;
void test_case(){
	cin >> N >> D;
	int cnt = 0;
	for(int i = 0;i<N;++i){
		cin >> x >> y;
		if(dist(x,y) - (ld)D <= 1e-6) ++cnt;
	}
	cout << cnt << endl; 
}





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, ans=0;
    string a, b, c;
    cin >> n;
    cin >> a >> b >> c;
    for (int i = 0; i < n; ++i) {
        if (a[i]!=b[i]) {
            if (b[i]==c[i]) ans++;
            else {
                if (a[i]==c[i]) ans++;
                else ans += 2;
            }
        }
        else {
            if (b[i]==c[i]) continue;
            else ans++;
        }

    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    ddcc2020qualc()
}

private enum class Direction { R, L }

fun ddcc2020qualc() {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    val board = (1..h).map { readLine()!! }

    val berrys = mutableListOf<Pair<Int, Int>>()

    board.forEachIndexed { indexY, s ->
        s.forEachIndexed { indexX, c ->
            if (c == '#') berrys.add(Pair(indexY, indexX))
        }
    }

    val answer = Array(h) { IntArray(w) { 0 } }

    berrys.forEachIndexed { index, pair ->
        answer[pair.first][pair.second] = index + 1
    }

    fun dfs(y: Int, x: Int, value: Int, direction: Direction) {
        when (direction) {
            Direction.R -> {
                if (x + 1 <= w - 1 && (answer[y][x + 1] == 0 || answer[y][x + 1] == value)) {
                    answer[y][x + 1] = value
                    dfs(y, x + 1, value, Direction.R)
                }
            }
            Direction.L -> {
                if (x - 1 >= 0 && (answer[y][x - 1] == 0 || answer[y][x - 1] == value)) {
                    answer[y][x - 1] = value
                    dfs(y, x - 1, value, Direction.L)
                }
            }
        }
    }

    berrys.forEachIndexed { index, pair ->
        val (y, x) = pair
        dfs(y, x, index + 1, Direction.R)
    }
    berrys.forEachIndexed { index, pair ->
        val (y, x) = pair
        dfs(y, x, index + 1, Direction.L)
    }

    var berryFound = false
    for (yi in 0 until h) {
        val row = answer[yi]
        if (row.none { it != 0 }) continue

        if (!berryFound) {
            (0 until yi).forEach { answer[it] = row.copyOf() }
            berryFound = true
        }

        var down = yi
        while (down + 1 < h && answer[down + 1].none { it != 0 }) down++
        if (down < h) {
            (yi..down).forEach { answer[it] = row.copyOf() }
        }
    }

    val ans = answer.joinToString(System.lineSeparator()) { it.joinToString(" ") }

    println(ans)
}


Measured memory_bytes: 45888
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


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(b<a)a=b;}

int main(){
  int N;cin>>N;
  VI x(N);
  REP(i,N){
    cin>>x[i];
  }
  int max=0;
  int tmp=1000001;
  for(int i=1;i<=100;i++){
    REP(j,N){
      max=max+pow(x[j]-i,2);
    }
    if(tmp>max){
      tmp=max;
    }
    max=0;
  }
  cout<<tmp<<endl;

}

Measured memory_bytes: 888
/* kadai3_4
   Saikyo_Kazune
*/
#include <stdio.h>


int main(void){
   //int型　N,判定用にjudgeを宣言
   int N,judge=0;
   scanf("%d",&N);
   for(int i=1;i<=9;i++){
       for(int j=1;j<=9;j++){
           if(N==i*j){
               judge=1;
           }
       }
   }
   if(judge){
        printf("Yes\n");
   }
   else{
       printf("No\n");
   }
 

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
#define all(a)           a.begin(), a.end()
 
 
int main()
{
     ios_base::sync_with_stdio(0); 
     cin.tie(0); cout.tie(0);  
     long long n, num=0; 
     cin >> n;
     string arr[n];
     map<string, int> mp;
    
    for(int i=0; i<n; i++)    
    {        
        cin >> arr[i];
        sort(all(arr[i]));
        mp[arr[i]]++;
    }
 
 
    for(auto it : mp)
    {
        pair<string, long long > p = it;
        num += p.second*(p.second-1)/2;
    }
    cout << num;
 
    return 0;
}

Measured memory_bytes: 16640
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<bitset>
#define heap priority_queue<int,vector<int>,greater<int> >
#define _heap priority_queue<int,vector<int>,less<int> >
#define _for(a,b,c) for((a)=(b);(a)<=(c);++(a))
#define __for(a,b,c) for((a)=b;(a)>=(c);--(a))
#define _init(a,b) memset((a),(b),sizeof (a))
#define LL long long
#define mod 1e9+7
#define INF 0x3f3f3f3f
using namespace std;

namespace FastIO {
	template<typename tp> inline void read(tp &x) {
		x=0; register char c=getchar(); register bool f=0;
		for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
		for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
		if(f) x=-x;
	}
	template<typename tp> inline void write(tp x) {
		if (x==0) return (void) (putchar('0'));
		if (x<0) putchar('-'),x=-x;
		int pr[20]; register int cnt=0;
		for (;x;x/=10) pr[++cnt]=x%10;
		while (cnt) putchar(pr[cnt--]+'0');
	}
	template<typename tp> inline void writeln(tp x) {
		write(x);
		putchar('\n');
	}
}
using namespace FastIO;

//------------Coding Area------------
struct node{
	int d,a;
};
bool cmp(node a,node b){
	return a.d<b.d;
}
int d[200010],ans[200010];
node e[200010];
int n;
int main(){
	read(n);
	int cache=(n+1)/2;
	for(int i=1;i<=n;++i) read(d[i]);
	for(int i=1;i<=n;++i) e[i].d=d[i],e[i].a=i;
	sort(e+1,e+n+1,cmp);
	int mid1=e[cache].d,mid2=e[cache+1].d;
	for(int i=1;i<=n;++i) 
		if(i>cache) ans[e[i].a]=mid1; else ans[e[i].a]=mid2;
	for(int i=1;i<=n;++i) writeln(ans[i]);
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void){
	int a=0,b[5],t,c[5];
	for(t=0;t<4;t++){
		scanf("%d",&a);
		scanf("%d",&b[a]);
	c[1]=6000;
	c[2]=4000;
	c[3]=3000;
	c[4]=2000;
	
	printf("%d\n",c[a]*b[a]);

	}

return 0;
}

Measured memory_bytes: 600
package main

import "fmt"

func main() {

	var (
		num, score_Hana, score_Taro int
		str_Hana, str_Taro          string
	)

	fmt.Scanln(&num)

	for i := 0; i < num; i++ {
		fmt.Scanln(&str_Taro, &str_Hana)

		var j int
		for j = 0; j < len(str_Taro) && j < len(str_Hana); j++ {
			if str_Taro[j] > str_Hana[j] {
				score_Taro += 3
				break
			}
			if str_Taro[j] < str_Hana[j] {
				score_Hana += 3
				break
			}
		}

		if j == len(str_Taro) || j == len(str_Hana) {
			if len(str_Taro) == len(str_Hana) {
				score_Taro++
				score_Hana++
			} else if len(str_Taro) > len(str_Hana) {
				score_Taro += 3
			} else {
				score_Hana += 3
			}
		}

	}
	fmt.Println(score_Taro, score_Hana)
}



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

ll mod = 1e9 + 7;

ll factorial(ll n){
    if(n == 0) return 1;
    return ((n % mod)* (factorial(n-1) % mod));
}

int main(void)
{
    ll N, M;
    cin >> N >> M;



    if(abs(N - M) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll nfac = factorial(N);
    ll mfac = factorial(M);

    ll result = ((nfac % mod) * (mfac % mod))%mod;

    if(abs(N - M) == 0){
        cout << (result * 2)%mod << endl;
    } else {
        cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 6628
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  int n;
  ll dp[100002][3]={};
  cin >> n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i]>> c[i];
  }
  for(int i=0;i<n;i++){
    dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i];
    dp[i+1][1]=max(dp[i][0],dp[i][2])+b[i];
    dp[i+1][2]=max(dp[i][1],dp[i][0])+c[i];
  }
  cout << max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

map<int, int> res;
void prime_factors(int n) {
  for(int i = 2; i*i <= n; ++i) {
    while(n % i == 0) {
      res[i]++; // 素数i^{res[i]}
      n /= i;
    }
  }
  if(n!=1) res[n]++;
}

void Main(){

  int N;
  cin >> N;

  reps(i,2,N+1){
    prime_factors(i);
  }

  ll ans=1;

  for(auto i : res) {
    ans=ans*(i.second+1) %MOD;
  }

  cout << ans <<"\n";
}


//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mid (l+r)/2
#define ri node+node+1
#define le node+node
#define ll long long
using namespace std;
const ll inf = 2e5+9;
ll n,d,k,tree[inf],ans,b[inf];
pair<ll,ll> a[inf];

void update(ll idx,ll val){

    while(idx <= n){
        tree[idx] += val;
        idx += idx&-idx;
    }
}

ll query(ll idx){

    ll ret = 0;
    while(idx > 0)
        ret += tree[idx], idx -= idx&-idx;
    return ret;
}

int main(){

    cin>>n>>d>>k;
    for(ll i=1;i<=n;i++)
        cin>>a[i].first>>a[i].second;;

    sort(a+1,a+1+n);
    for(ll i=1;i<=n;i++)
        b[i] = a[i].first;

    b[n+1] = 1e18+9;
    for(ll i=1;i<=n;i++){
        ll tmp = query(i) + a[i].second;
        if(tmp <= 0)
            continue;
        ll times = tmp/k + ( (tmp%k) > 0);

       ll id = upper_bound(b+1,b+2+n,a[i].first + d+d ) - b;
        id--;
        ans += times;
        update(i ,-times * k);
        update(id+1,times*k);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;


const int MAXN = 120000;

class BITree {
 public:
 	void build() {
 		SET(bit, 0);
	}

	void update(int idx, int val) {
		while (idx < TREE_SIZE) {
			bit[idx] += val;
			idx += idx & -idx;
		}
	}

	int query(int idx) {
		int ret = 0;
		while (idx) {
			ret += bit[idx];
			idx -= idx & -idx;
		}
		return ret;
	}

 private:
 	static const int TREE_SIZE = 1 << 17;
 	int bit[TREE_SIZE];
};


int A[MAXN], B[MAXN], C[MAXN];
int N;

LL cnt;

vector<int> X, Y, k;
vector<pair<double, int> > inter;
vector<pair<double, int> > steep;
int pos[MAXN];


BITree bit;


double solve(vector<int> X, vector<int> Y, vector<int> k) {
	double s = -100000000001.0, e = 100000000001.0, mid;
	double ret = s;
	steep.clear();
	FOR (i, N)
		steep.pb(make_pair(-1.0 * X[i] / Y[i], i));
	sort(all(steep));
	FOR (i, N)
		pos[steep[i].second] = i + 1;
	inter.clear();
	FOR (i, N)
		inter.pb(make_pair(-1, -1));
	FOR (iter, 75) {
		mid = (s + e) / 2.0;
		LL sum = 0;
		
		FOR (i, N)
			inter[i] = make_pair((k[i] - X[i] * mid) / Y[i], i);
		sort(all(inter));
		bit.build();
		FOR (i, N) {
			sum += bit.query(pos[inter[i].second]);
			bit.update(pos[inter[i].second], + 1);
		}
		if (sum >= (cnt + 1LL) / 2) {
			ret = mid;
			e = mid;
		}
		else
			s = mid;
	}
	return ret;
}

int main() {
	scanf("%d", &N);
	FOR (i, N)
		scanf("%d %d %d", &A[i], &B[i], &C[i]);
	cnt = 1LL * N * (N - 1LL) / 2LL;
	
	X.clear();
	Y.clear();
	k.clear();
	FOR (i, N) {
		X.pb(A[i]);
		Y.pb(B[i]);
		k.pb(C[i]);
	}
	
	printf("%.10lf ", solve(X, Y, k));
	printf("%.10lf\n", solve(Y, X, k));
	return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
ll x,y;
void input()
{
	x=read<ll>(),y=read<ll>();
}
void work()
{
	if(abs(x-y)>1)puts("Alice");
	else puts("Brown");
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


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

using namespace std;
typedef long long ll;




int main()
{
    int N,K;
    cin >> N >> K;
    if(K > (N-1)*(N-2)/2){
        cout << -1 << endl;
        return 0;
    }
    
    vector<pair<int,int>> ans;
    int k = 0;
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if(j == N-1){
                ans.push_back({i,j});
                continue;
            }
            if(k < K) k++;
            else ans.push_back({i,j});
        }
    }
    
    cout << ans.size() << endl;
    rep(i,int(ans.size())) cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    
    
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
signed main(){
	ic(n) ic(k)
	c(sankaku(n-1)+sankaku(k-1))
}	


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

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
#define int long long

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

    string t;
    cin >> t;
    for (auto &i:t) {
        if (i == '?')i = 'D';
    }
    cout << t << endl;
}


Measured memory_bytes: 3776
import java.util.*;

public class Main {

	char[][] board;
	int N;
	int dx[] = {0,0,1,1,1,-1,-1,-1};
	int dy[] = {1,-1,1,0,-1,1,0,-1};
	int maxDepth;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt();
			if(N==0) return ;
			board = new char[N][];
			for(int i=0; i<N; i++){
				board[i] = in.next().toCharArray();
			}
			System.out.println(solve());
		}
	}

	boolean dfs(int depth){
		if(depth > maxDepth) return false;
		int x = 0, y = 0;
		boolean foundVirus = false;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(board[i][j] == '#'){
					foundVirus = true;
				}
				else if(board[i][j] == '@'){
					y = i; x = j;
				}
			}
		}
		if(!foundVirus){
			return true;
		}
		char[][] tmp = new char[N][];
		for(int i=0; i<N; i++){
			tmp[i] = board[i].clone();
		}
		for(int k=0; k<8; k++){
			int nx = x + dx[k], ny = y + dy[k];
			if(0<=nx && nx<N && 0<=ny && ny<N && tmp[ny][nx]!='#'){
				tmp[y][x] = '.';
				tmp[ny][nx] = '@';
				for(int i=0; i<N; i++){
					for(int j=0; j<N; j++){
						int cnt = 0;
						for(int kk=0; kk<8; kk++){
							int nny = i + dy[kk], nnx = j + dx[kk];
							if(0<=nny && nny<N && 0<=nnx && nnx<N && tmp[nny][nnx]!='.')
								cnt++;
						}
						if(tmp[i][j] == '.'){
							board[i][j] = (cnt==3?'#':'.');
						}
						else if(tmp[i][j] == '#'){
							board[i][j] = ((cnt==2 || cnt==3)?'#':'.');
						}
						else{
							board[i][j] = '@';
						}
					}
				}
				if(dfs(depth+1)) return true;
				tmp[ny][nx] = '.';
				tmp[y][x] = '@';
			}
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				board[i][j] = tmp[i][j];
			}
		}
		return false;
	}

	int solve(){
		for(maxDepth=0; maxDepth<=11; maxDepth++){
			if(dfs(0)) return maxDepth;
		}
		return -1;
	}

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

Measured memory_bytes: 13000
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N;
  std::cin >> N;
  if (N==3) {
    printf("2 5 63\n");
  } else if (N==4) {
    printf("2 5 20 63\n");
  } else if (N==6) {
    printf("2 5 63 4 10 126\n");
  } else {
    int num2 = std::min(10000, N-2-N%2);
    int num3 = N-num2;
    std::vector<int > ans;
    int from3 = std::min((num3/2)*2, 5000);
    int from6 = num3-from3;
    //printf("num3=%d (from3=%d, from6=%d, num2=%d\n", num3, from3, from6, num2);
    for (int i=1; i<=from3; i++) {
      ans.push_back(i*6-3);
    }
    for (int i=1; i<=from6; i++) {
      ans.push_back(i*6);
    }
    for (int i=1; i<=num2/2; i++) {
      ans.push_back(6*i-4);
      ans.push_back(6*i-2);
    }
    long long sum = 0;
    for (int i=0; i<ans.size(); i++) {
      if (ans[i]>30000) {
        while(true){}
      }
      printf("%d%c",ans[i],(i==ans.size()-1)?'\n':' ');
      sum+=ans[i];
    }
    //std::cout << sum << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3380
import java.util.Scanner;
 
public class Main {
    static Scanner stdin = new Scanner(System.in);
    public static void main(String args[]) {
        int sumMoney = 0;
        int count = 0;
        double sumStock = 0;
        while(stdin.hasNext()) {
            count++;
            Scanner s = new Scanner(stdin.next().replaceAll(",", " "));
            int a = s.nextInt(), b = s.nextInt();
            sumMoney += a * b;
            sumStock += b;
        }
        System.out.println(sumMoney);
        System.out.println((int)((sumStock / count) + 0.5));
    }
}

Measured memory_bytes: 26228
#include<stdio.h>
int main(){
	char s[4];
	scanf("%s",s);
	
	if(s[0] == s[1] && s[1] != s[2] && s[0] != s[2]){
	printf("Yes\n");
	}
	else if(s[0] !=s[1] && s[1] != s[2] && s[0] == s[2]){
	  
	printf("Yes\n");
	}
	else if(s[0] !=s[1] && s[1] == s[2] && s[0] !=s[2]){
	
    printf("Yes\n");
	}
      else{
    printf("No\n");}

return 0;  

}

Measured memory_bytes: 1624
#include <cstdio>
#include <cmath>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    int s, w;
    scanf("%d %d", &s, &w);
    if (s <= w)
    {
        puts("unsafe");
    }
    else
    {
        puts("safe");
    }
}

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

int main() {
	ll n;
	vector<ll>a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		a.push_back(z);
		b.push_back(z);
	}
	sort(b.begin(),b.end());
	ll medi=b[(n)/2];
	for(int i=0;i<n;i++){
		if(a[i]<medi){
			cout << medi<<endl;
		}
		else{
			cout << b[n/2-1]<<endl;
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const ll mod = 1'000'000'007;

auto main (void) -> int {
  int n;
  cin >> n;

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

  ll tmp_0 = 0;
  ll tmp_1 = 0;

  for (auto i = 0; i < n; i++) {
    auto c = static_cast<ll> (a[i]);
    tmp_0  = tmp_0 + c;
    tmp_1  = tmp_1 + c * c;
    if (tmp_0 > mod) tmp_0 %= mod;
    if (tmp_1 > mod) tmp_1 %= mod;
  }
  tmp_0 = (tmp_0 * tmp_0) % mod;

  auto b = tmp_0 < tmp_1 ? tmp_0 - tmp_1 + mod : tmp_0 - tmp_1;

  cout << (b + (b % 2) * mod) / 2 << endl;

  return 0;
}


Measured memory_bytes: 4052
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)62500 + 7)
#define N ((int)250 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
//typedef tree < pair < int, int >,  null_type,  less < pair < int, int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).



int main()
{
    fastio;
    int x;
    cin>>x;
    x -= 400;
    x /= 200;
    cout<<8-x<<endl;
    return 0;
}


Measured memory_bytes: 3644
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  const A = input[0];
  const B = input[1];
  const C = input[2];
  let sum = A + B + C;
  let max = Math.max(A, B, C);
  let M = 3 * max;

  let ret = 0;
  if(M%2 === sum%2){
    ret = (M-sum)/2;
  } else {
    ret = (M+3-sum)/2;
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	long long A[200000];

	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%lld", &A[i]);
		A[i] -= i+1;
	}

	sort(A,A+N);

/*
	long long minus = 0;
	long long plus = 0;
	for(int i=0;i<N;i++){
		if(A[i]<0) minus += (-1)*A[i];
		else plus += A[i];
	}
*/

	int mid;
	if(N%2==0) mid = N/2;
	else mid = (N-1)/2;
	long long m = A[mid];
	for(int i=0;i<N;i++){
		A[i] -= m;
	}

	long long ans = 0;
	for(int i=0;i<N;i++){
		ans += abs(A[i]);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
def between(l,c,r):
    return l<=c and c<=r

N,A,B,C,D=[int(i) for i in input().split()]
ul = [A + D*i for i in range(N)]
dl = [A + C*i for i in range(N)]
ur = [B + D*i for i in range(N)][::-1]
dr = [B + C*i for i in range(N)][::-1]
res = False
for i in range(N):
    if between(dl[i], ur[i], ul[i]) or between(dl[i], dr[i], ul[i]):
        res=True
print("YES" if res else "NO")


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

activies = []
for i in range(N):
    activies.append(list(map(int, input().split())))

n_activivies = len(activies[0])

dp = [[0 for _ in range(n_activivies)] for _ in range(N)]
for i in range(n_activivies):
    dp[0][i] = activies[0][i]

for day in range(1, N):
    for prev_activity in range(n_activivies):
        for cur_activity in range(n_activivies):
            if cur_activity != prev_activity:
                dp[day][cur_activity] = max(
                    dp[day][cur_activity], dp[day-1][prev_activity] + activies[day][cur_activity]
                )

print(max(dp[N-1]))

Measured memory_bytes: 102836
import java.util.Scanner;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		Vector<String> results = new Vector<String>();
		Scanner in = new Scanner(System.in);
		String string = in.nextLine();
		char[] chars = string.toCharArray();
		int l = string.length();
		int k = (int) Math.pow(2, l - 1);
		for (int i = 0; i < k; ++i) {
			String result = "" + chars[0];
			String b = Integer.toBinaryString(i);
			int bl = b.length();
			int pp = l - 1;
			int minus = pp - bl;
			String oo = "";
			for (int q = 0; q < minus; ++q) {
				oo += "0";
			}
			b = oo + b;
			for (int j = 0; j < l - 1; ++j) {
				char t = b.charAt(j);
				if (t == '0') {
					result += chars[j + 1];
				} else {
					result += '+';
					result += chars[j + 1];
				}
			}
			//System.out.println(result);
			results.add(result);

		}
		int ss = results.size();
		long rr = 0;
		for (int w = 0; w < ss; ++w) {
			 rr += cal(results.get(w));
		}
		System.out.println(rr);

	}
	
	public static void main2(String[] args) {
		cal("17+2");
	}
	
	

	public static long cal(String s) {
		//System.out.println(s);
		long r = 0;
		if (!s.contains("+")) {
			return Long.parseLong(s);
			
		}
		String[] m = s.split("\\+");
		int size = m.length;
		for (int i = 0; i < size; ++i) {
			//System.out.println(m[i]);
			long k = Long.parseLong(m[i]);
			r += k;

		}
		return r;
	}
}


Measured memory_bytes: 11852
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>() -> T
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    T::from_str(buffer.trim_right()).unwrap()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

#[allow(unused_macros)]
macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

use std::collections::HashMap;

#[derive(Debug, Clone, Copy, PartialEq)]
struct City {
    id: usize,
    born_year: usize,
}

fn main() {
    parse_line![prefecture_count: usize, city_count: usize];

    let mut cities_on_prefectures = vec![vec![]; prefecture_count];

    for i in 1..city_count + 1 {
        parse_line![belonging_prefecture: usize, born_year: usize];

        let city = City {
            id: i,
            born_year: born_year,
        };

        let prefecture_index = belonging_prefecture - 1;

        cities_on_prefectures[prefecture_index].push(city);
    }

    let mut idstrings = vec![String::new(); city_count];

    for i in 1..prefecture_count + 1 {
        let prefecture_index = i - 1;
        let cities = &mut cities_on_prefectures[prefecture_index];
        cities.sort_by_key(|c| c.born_year);

        let id_left = to_id_string(i);
        for (index, city) in cities.into_iter().enumerate() {
            let id_right = to_id_string(index + 1);
            let idstring = format!("{}{}", id_left, id_right);

            let city_index = city.id - 1;
            idstrings[city_index] = idstring;
        }
    }

    for idstring in idstrings.into_iter() {
        println!("{}", idstring);
    }
}

fn to_id_string(x: usize) -> String {
    let right = x.to_string();
    let zero_count = 6 - right.len();

    let mut s = String::new();

    for _ in 0..zero_count {
        s.push('0');
    }
    s.push_str(&right);

    s
}


Measured memory_bytes: 19964