akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 64
#define CHK 16

typedef struct {
  char mark;
  int num;
} card_t;

void BubbleSort(card_t* C, int N);
void SelectionSort(card_t* C, int N);
int verifyStab(card_t* C, card_t* Ccopy, int N);

int main(void){
  int N, i;
  char tmp[4];
  card_t C[SIZE], Ccopy[SIZE];
  
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%s", tmp);
    C[i].mark = tmp[0];
    C[i].num = atoi(&tmp[1]);
  }
  for (i = 0; i < N; i++)
    Ccopy[i] = C[i];

  BubbleSort(C, N);
  for (i = 0; i < N; i++) {
    printf("%c%d", C[i].mark, C[i].num);
    if (i < N - 1)
      printf(" ");
  }
  printf("\n");

  // verify a bubble stability
  if (verifyStab(C, Ccopy, N))
    printf("Stable\n");
  else
    printf("Not stable\n");

  // set back a array unsorted
  for (i = 0; i < N; i++)
    C[i] = Ccopy[i];
  
  SelectionSort(C, N);
  for (i = 0; i < N; i++) {
    printf("%c%d", C[i].mark, C[i].num);
    if (i < N - 1)
      printf(" ");
  }
  printf("\n");

  // verify a selection stability
  if (verifyStab(C, Ccopy, N))
    printf("Stable\n");
  else
    printf("Not stable\n");

  return 0;
}

void BubbleSort(card_t* C, int N){
  int i, j;
  card_t tmp;
  for (i = 0; i < N; i++) {
    for (j = N - 1; i < j; j--) {
      if (C[j].num < C[j - 1].num) {
	// swap mark
	tmp.mark = C[j].mark;
	C[j].mark = C[j - 1].mark;
	C[j - 1].mark = tmp.mark;
	// swap num
	tmp.num = C[j].num;
	C[j].num = C[j - 1].num;
	C[j - 1].num = tmp.num;
      }
    }
  }
}

void SelectionSort(card_t* C, int N){
  int i, j, minj;
  card_t tmp;
  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (C[j].num < C[minj].num)
	minj = j;
    }
    // swap mark
    tmp.mark = C[i].mark;
    C[i].mark = C[minj].mark;
    C[minj].mark = tmp.mark;
    // swap num
    tmp.num = C[i].num;
    C[i].num = C[minj].num;
    C[minj].num = tmp.num;
  }
}

int verifyStab(card_t* C, card_t* Ccopy, int N){
  int stbFlg = 1, skipFlg, i, j, k = 0, checkNum[CHK] = {0};
  char markOri[SIZE] = {0}, markSort[SIZE] = {0};
  
  for (i = 0; i < N - 1; i++) {
    // confirm whether a number is checked
    skipFlg = 0;
    for (j = 0; j < k; j++) {
      if (Ccopy[i].num == checkNum[j]) {
	skipFlg = 1;
	break;
      }
    }

    if (!skipFlg) {
      // create a original mark array
      strncat(markOri, &Ccopy[i].mark, 1);
      for (j = i + 1; j < N; j++) {
	if (Ccopy[j].num == Ccopy[i].num)
	  strncat(markOri, &Ccopy[j].mark, 1);
      }
      // create a sorted mark array
      for (j = 0; j < N; j++) {
	if (C[j].num == Ccopy[i].num)
	  strncat(markSort, &C[j].mark, 1);
      }

      // comapare Original with Sorted
      if (strcmp(markOri, markSort) != 0) {
	stbFlg = 0;
	break;
      }

      // add a checked number to array
      checkNum[k] = Ccopy[i].num;
      k++;
    
      // initializing mark array
      memset(markOri, 0, sizeof(markOri));
      memset(markSort, 0, sizeof(markSort));
    }
  }
  return stbFlg;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, A;
  cin >> N >> A;
  vll x(N+1, 0);
  for(int i = 1; i <= N; i++){
    cin >> x.at(i);
    x.at(i) -= A;
  }
  vvll dp(N+1, vll(6000, 0)); //i枚目までで平均Aとの過不足がdのとき、dp.at(i).at(d+N*A)に格納
  dp.at(0).at(0+N*A) = 1;
  dp.at(1).at(0+N*A) = 1;
  dp.at(1).at(x.at(1)+N*A) += 1;
  for(int i = 1; i < N; i++){
    for(int j = -1*N*A; j <= N*A ; j++){
      dp.at(i+1).at(j + N*A) += dp.at(i).at(j + N*A);
      if((j-x.at(i+1)) >= -1*N*A && (j-x.at(i+1)) <= N*A) dp.at(i+1).at(j + N*A) += dp.at(i).at(j-x.at(i+1) + N*A);
      dp.at(i+1).at(j + N*A);
    }
  }
  cout << dp.at(N).at(0 + N*A) - 1 << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
int main()
{
  string a,x;
  char b;
  cin >> a;
  b=a.back();
  int num = (int) b;
  if(num==115)
  {
       x=a.append("es",2);
  }
  else {
      x=a.append("s",1);
  }
  cout << x;
}


Measured memory_bytes: 3144
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let buttons: Vec<usize> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();

    let mut cnt = 0;
    let mut target_button_index = 1;
    while target_button_index != 2 && cnt < 100000 {
        target_button_index = buttons[target_button_index - 1];
        cnt += 1;
    }
    if cnt == 100000 {
        println!("-1");
    } else {
        println!("{}", cnt);
    }
}

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

int main()
{
    long long N, A;
    cin >> N >> A;

    vector<long long> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
        x[i] -= A;
    }

    // dp[i][j]:# of patterns
    // i: items
    // j: sum
    vector<vector<long long>> dp(N + 1, vector<long long>(3000, 0));
    enum
    {
        ZERO = 1500
    };
    dp[0][ZERO] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3000; j++)
        {
            if (dp[i][j] > 0)
            {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j + x[i]] += dp[i][j];
            }
        }
    }
    cout << dp[N][ZERO] - 1 << endl;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
        System.out.print(Math.min(a, b) + Math.min(c, d));
    }
}


Measured memory_bytes: 35476
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=1,y=0,z=0,k,n,m,h,ans = 0,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9 + 1;
  string s, t, u;
  bool ok=true;
  cin >> n;
  VL a(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    if(chmin(Min,a[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int N = 1e5 + 5;
typedef vector<int> vi;
vi adj[N];
int in_degree[N] = {0};
int dist[N];
int visited[N] = {0};
int m,n;

void dfs(int u)
{
	visited[u] = 1;
	for (int i = 0; i < adj[u].size(); ++i)
	{
		int  v = adj[u][i];
		dist[v] = max(dist[v], dist[u]+1);
		in_degree[v]--;
		if(in_degree[v] == 0)
			dfs(v);
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		in_degree[v]++;
	}

	for (int i = 1; i <= n; ++i)
	{
		if(!visited[i] && in_degree[i] == 0)
			dfs(i);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans = max(ans, dist[i]);
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 11520
#include <stdio.h>
int main(){
  int i,j,k,n,a[3],tmp;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<2;i++){
    for(j=2;j>i;j--){
      if(a[j] < a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    if(i != 2){
      printf("%d ",a[i]);
    }
    else{
      printf("%d\n",a[i]);
    }
  }
  return(0);
}

Measured memory_bytes: 596
# AGC011B - Colorful Creatures
from itertools import accumulate


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    cs = [0] + list(accumulate(A))  # cs: cumulative sum
    ng = [i for i, (a, c) in enumerate(zip(A, cs)) if c * 2 < a]
    ans = N - max(ng)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14432
s=input()
if s[-7]+s[-6]+s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='keyence':
    print("YES")
    exit()
elif s[0]=='k':
    if s[-6]+s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='eyence':
        print("YES")
        exit()
    elif s[1]=='e':
        if s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='yence':
            print("YES")
            exit()
        elif s[2]=='y':
            if s[-4]+s[-3]+s[-2]+s[-1]=='ence':
                print("YES")
                exit()
            elif s[3]=='e':
                if s[-3]+s[-2]+s[-1]=='nce':
                    print("YES")
                    exit()
                elif s[4]=='n':
                    if s[-2]+s[-1]=='ce':
                        print("YES")
                        exit()
                    elif s[5]=='c':
                        if s[-1]=='e':
                            print("YES")
                            exit()
print("NO")

Measured memory_bytes: 9136
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
cnt = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        idx = bisect.bisect_left(L, L[i] + L[j], j + 1)
        cnt += max(0, idx - (j + 1))

print(cnt)


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  int a, b, c, d;
  cin >>a>>b>>c>>d;
  if(abs(a-c)<=d)cout << "Yes"<<endl;
  else if(abs(a-b)<=d&&abs(b-c)<=d)cout <<"Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    char c; cin >> c;
    bool ok = false;
    string alp = "aiueo";
    FOR(i, 0, 5)ok |= alp[i] == c;
    if (ok)cout << "vowel\n";
    else cout << "consonant\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int a[10][10], H, W, cnt;
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { char p; cin >> p; if (p == '#')cnt++; } }
	if (cnt == H + W - 1) { cout << "Possible" << endl; }
	else { cout << "Impossible" << endl; }
	return 0;
}

Measured memory_bytes: 256
n = int(input())
list = list(map(int, input().strip().split()))
list.append(10001)
list.append(10002)
count = 0
i = 0
while i < n:
    if list[i] == list[i + 1] and list[i + 1] and list[i + 2]:
        count += 1
        i += 2
        continue
    elif list[i] == list[i + 1]:
        count += 1
    i += 1
print(count)


Measured memory_bytes: 3316
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int N;

int main() {
	cin >> N;
	for (long long int i = 0; i < 100000; i++) {
		if (i*(i + 1) / 2 >= N) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//



int32_t main()
{
    //io;
    double x;
    cin>>x;
    x/= 3;
    printf("%.9f", x*x*x);
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  if(n>=10000&&n!=100000){
    cout<<n-9999+909<<endl;
  }else if(n>=1000&&n<10000){
    cout<<909<<endl;
  }else if(n>=100&&n<=999){
    cout<<n-99+9<<endl;
  }else if(n>=10&&n<100){
    cout<<9<<endl;
  }else if(n>=1&&n<10){
    cout<<n<<endl;
  }else if(n==100000){
    cout<<90909<<endl;
  }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    int k,t;
    cin >> k >> t;
    vector<int> v(t);
    rep(i, t) cin >> v[i];
    
    auto it = max_element(v.begin(), v.end());
    int max_ = *it;
    int max_i = (int)distance(v.begin(), it);
    
    rep(i, t){
        if(i != max_i) max_ -= v[i];
    }
    
    cout << max(0, max_-1) << el;
}


Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def f(n, ts, vs):
    sumOfT = sum(ts)

    t = 0
    k = 0
    k1s = [k]

    for i in range(n-1):
        t += ts[i]
        k = min(k, vs[i] - t)
        k1s.append(k)

    t = sumOfT
    k = t
    k2s = [k]

    for i in range(n-1, 0, -1):
        t -= ts[i]
        k = min(k, vs[i] + t)
        k2s.insert(0, k)

    t0 = 0
    d = 0

    for t, v, k1, k2  in zip(ts, vs, k1s, k2s):
        # t0 制限速度がv である開始時刻
        # t1 加速を終わらせる時刻
        # t2 減速を始める時刻
        # t3 制限速度がv である終了時刻

        t3 = t0 + t

        t1 = v - k1
        t2 = k2 - v
        
        if t1 > t2:
            t1 = (k2 - k1)/2
            t2 = t1

        if t0 < t1:
            t12 = min(t1, t3)
            d +=  k1*(t12-t0) + (t12**2 -t0**2)/2

        dt = min(t2, t3) - max(t0, t1)
        if dt > 0:
            d += v*dt

        if t2 < t3:
            t22 = max(t2, t0)
            d +=  k2*(t3-t22) - (t3**2 - t22**2)/2

        t0 = t3
        
    return d


def test():
    assert(f(1, [100], [30]) == 2100)
    assert(f(2, [60,50], [34,38]) == 2632)
    assert(f(3, [12, 14, 2], [6, 2, 7]) == 76)
    assert(f(1, [9], [10]) == 20.25)
    assert(f(10,[64, 55, 27, 35, 76, 119, 7, 18, 49, 100],[29, 19, 31, 39, 27, 48, 41, 87, 55, 70]) == 20291)


def main():
    n = int(input())
    ts = list(map(int, input().split()))
    vs = list(map(int, input().split()))

    print('{0:.4f}'.format(f(n, ts, vs)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3320
N, M = map(int, input().split())
a = [[0*2]]*N
ans = 0
for i in range(N):
    a[i] = list(map(int, input().split()))

a.sort()
i = 0

while M > 0:
    if M - a[i][1] >= 0:
        ans += a[i][0] * a[i][1]
        M -= a[i][1]
    else:
        ans += a[i][0] * M
        M = 0
    i += 1


print(ans)

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

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

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

	if(a +  b < 24) cout << a + b << "\n";
	else cout << a + b - 24 << "\n";

	return 0;
}

Measured memory_bytes: 256
module mod_priority_queue
  implicit none
  type t_priority_queue
    private
    integer :: num = 0
    integer, pointer :: heap(:) => null()
  contains
    procedure :: offer => offer
    procedure :: clear => clear
    procedure :: poll => poll
    procedure :: peek => peek
    procedure :: size => size_of
  end type
contains
  integer function compare(a,b)
    integer, intent(in) :: a, b
    compare = b-a
  end
  subroutine offer(this,item)
    class(t_priority_queue), intent(inout) :: this
    integer, intent(in) :: item
    integer :: n, i, t
    integer, allocatable :: tmp(:)
    if (.not.associated(this%heap)) allocate(this%heap(1))
    if (this%num == size(this%heap)) then
      allocate(tmp(this%num))
      tmp = this%heap
      deallocate(this%heap)
      allocate(this%heap(2*this%num))
      this%heap(1:this%num) = tmp
      deallocate(tmp)
    end if
    this%num = this%num+1
    this%heap(this%num) = item
    n = this%num
    do while (n > 1)
      i = n/2
      if (compare(this%heap(n),this%heap(i)) < 0) then
        t = this%heap(n)
        this%heap(n) = this%heap(i)
        this%heap(i) = t
      end if
      n = i
    end do
  end
  subroutine clear(this)
    class(t_priority_queue), intent(inout) :: this
    if (associated(this%heap)) deallocate(this%heap)
    this%num = 0
  end
  function poll(this) result(item)
    class(t_priority_queue), intent(inout) :: this
    integer :: item, n, i, j, tmp
    n = this%num
    item = this%heap(1)
    this%heap(1) = this%heap(n)
    this%num = this%num-1
    i = 1
    do while (2*i < n)
      j = 2*i
      if (j+1 < n .and. compare(this%heap(j+1),this%heap(j)) < 0) j = j+1
      if (compare(this%heap(j),this%heap(i)) < 0) then
        tmp = this%heap(j)
        this%heap(j) = this%heap(i)
        this%heap(i) = tmp
      end if
      i = j
    end do
  end
  function peek(this) result(item)
    class(t_priority_queue), intent(in) :: this
    integer :: item
    item = this%heap(1)
  end
  integer function size_of(this)
    class(t_priority_queue), intent(in) :: this
    size_of = this%num
  end
end module mod_priority_queue
program problem_committee
  use mod_priority_queue
  implicit none
  type(t_priority_queue) :: pq
  integer :: n, k, c(26) = 0, i, m
  character(1) :: s
  read(*,*) n, k
  do i = 1, n
    read(*,*) s
    m = ichar(s)-64
    c(m) = c(m)+1
  end do
  do i = 1, 26
    if (c(i) == 0) cycle
    call pq%offer(c(i))
  end do
  m = 0
  do while (pq%size() >= k)
    do i = 1, k
      c(i) = pq%poll()
    end do
    m = m+1
    do i = 1, k
      if (c(i) > 1) call pq%offer(c(i)-1)
    end do
  end do
  write(*,'(i0)') m
end program problem_committee

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define ll long long
#define MN 200005
using namespace std;
inline ll in(){
    ll x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
priority_queue<ll,vector<ll>,greater<ll> >q;
struct edge{
	int to,nxt;
}e[MN<<1];
ll a[MN],mn[MN],res;
int num[MN],h[MN];
int n,m,x,y,cnt,tot,ct;
bool vis[MN],tmp[MN];
inline void ins(int x,int y){
	e[++cnt].to=y;e[cnt].nxt=h[x];h[x]=cnt;
}
inline void dfs(int u){
	mn[tot]=min(mn[tot],a[u]);
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (vis[v]) continue;
		vis[v]=1;num[v]=tot;dfs(v);
	}
}
int main()
{
	n=in();m=in();
	memset(mn,0x3f,sizeof(mn));
	for (int i=1;i<=n;++i) a[i]=in();
	for (int i=1;i<=m;++i){
		x=in()+1;y=in()+1;
		ins(x,y);ins(y,x);
	}
	for (int i=1;i<=n;++i)
	if (!vis[i]){
		vis[i]=1;num[i]=(++tot);dfs(i);
	}
	if (tot==1) {printf("0");return 0;}
	for (int i=1;i<=tot;++i) res+=1ll*mn[i];
	for (int i=1;i<=n;++i){
		if (!tmp[num[i]]&&a[i]==mn[num[i]]) {tmp[num[i]]=1;continue;}
		else q.push(a[i]);
	}
	while (!q.empty()){
		if (ct==tot-2) break;
		ll x=q.top();q.pop();++ct;res+=1ll*x;
	} 
	if (ct==tot-2) printf("%lld",res);else printf("Impossible");
	return 0;
}

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

using namespace std;

int main() {

    int n;

    while(cin >> n, n) {

        int s[n];
        int ans = 0;

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

        sort(s, s + n);

        for(int i = 1; i < n - 1; ++i) {
            ans += s[i];
        }

        cout << ans / (n - 2) << endl;

    }

}

Measured memory_bytes: 1176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    int N, X, curr = 0, ret = 1; cin >> N >> X;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        curr += x;
        if(curr <= X) ret++;
        else break;
    }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

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

int main(){
  int a,b;
  int count=0;
  cin >> a >> b;
  vector<vector<int>> c;
  for(int i=a;i<b+1;i++){
      int s=i%10;
      int t=i/10000%10;
      int u=i/10%10;
      int v=i/1000%10;
      if(s==t&&u==v)
        count++;
    }


  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
def yakusu_count(x):
    # for i in range(1, x+1):
    #     if x % i == 0:
    #         count += 1
    # return count
    return len([i for i in range(1, x + 1) if x % i == 0])


def main():
    N = int(input())
    # count = 0

    # for i in range(1, N+1, 2):
    #     if yakusu_count(i) == 8:
    #         count += 1

    count = len([i for i in range(1, N+1, 2) if yakusu_count(i) == 8])

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
#define mod 1000000007
#define for(i,n) for(int i=0;i<(int)n;i++)
int main(){
	int n;
  cin>>n;
  int arr[n];
  for(i,n)cin>>arr[i];
  int  check[n];
  for(i,n)check[i] = 2;
  for(i,n){
    if(n%2==0){
    if(arr[i]%2==0){cout<<0;return 0;}
      check[arr[i]]--;
      if(check[arr[i]]<0){cout<<0;return 0;}
    }
    else{
    if(arr[i]%2!=0){cout<<0;return 0;}
      check[arr[i]]--;
      if(check[arr[i]]<0){cout<<0;return 0;}
    }
  }
if(n%2==0){
if(check[0]!=2){cout<<0;return 0;}
}
  else{
  if(check[0]!=1){cout<<0;return 0;}
  }
  int l = n/2;
  int ans = 1;
  for(i,l)ans = (ans*2)%mod; 
  
  cout<<ans;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

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

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

int main() {
	int a, b;

	cin >> a >> b;
	double fa = a, fb = b;

	cout << a / b << " " << a % b << " " << fixed << setprecision(5) <<(fa / fb) << endl;

	return 0;
}


Measured memory_bytes: 3284
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        
        System.out.println((A+B) * H / 2);
    }
}

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

class Main {

	void solve() {

		int a = inint(), b = inint();
		String ans = "No";
		if (a*b*1%2 == 1) ans = "Yes";
		if (a*b*2%2 == 1) ans = "Yes";
		if (a*b*3%2 == 1) ans = "Yes";
		out.println(ans);
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}
	
	public char[] incharar() {
		return in.next().toCharArray();
	}
	
}

Measured memory_bytes: 21204
#!/usr/bin/ruby
# encoding: utf-8

# B - RGB Boxes 

R,G,B,N = gets.split.map(&:to_i)

ans = 0

(0..N).each do |i|
  (0..N).each do |j|
    if ((N - R*i - G*j)%B == 0) && ((N - R*i - G*j)/B >= 0) then
        ans += 1
        #puts "[#{i},#{j},#{k}}"
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	ll ans = 0;
	repeq(i, 1, N) {
		ll cnt = N / i;
		ll sum = cnt * i + i;
		ans+= sum * (cnt / 2) + (cnt % 2) * sum / 2;

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


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(a=="abc")
        cout<<"Yes";
        else if(a=="acb")
            cout<<"Yes";
            else if(a=="bac")
               cout<<"Yes";
               else if(a=="bca")
                  cout<<"Yes";
                  else if(a=="cab")
                     cout<<"Yes";
                     else if(a=="cba")
                        cout<<"Yes";
                        else
                            cout<<"No";


	return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
using namespace std;
const int mo = 924844033;
const int N = 4005;
int n, k, a[N], m, f[N][N][2], g[N], fac[N] = {1};
//f[i][j][0 / 1]:把链拼一块。前i个点，选了j个边，上个点有没有选，方案 
int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i ++) fac[i] = 1ll * fac[i - 1] * i % mo;
	for(int i = 1; i <= min(k, n - k); i ++) {
		for(int j = i; j <= n; j += k) a[++ m] = j;
		for(int j = i; j <= n; j += k) a[++ m] = j;
	}
	f[1][0][0] = 1;
	for(int i = 2; i <= m; i ++) {
		f[i][0][0] = 1;
		for(int j = 1; j <= i / 2; j ++) {
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % mo;
			if(a[i] - a[i - 1] == k) f[i][j][1] = f[i - 1][j - 1][0];
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i ++) {
		g[i] = (f[m][i][0] + f[m][i][1]) % mo * 1ll * fac[n - i] % mo;
		if(i & 1) (ans += mo - g[i]) %= mo;
		else (ans += g[i]) %= mo;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
 int n,b,f,r,v;
 int count[5][4][11]={};
 cin >> n;
 for(int l=1;l<=n;++l){
  cin >> b >> f >> r >> v;
  count[b][f][r]+=v;
 }
 
 for(int i=1;i<=4;++i){
  for(int j=1;j<=3;++j){
   for(int k=1;k<=10;++k){
    cout << " " << count[i][j][k];
   }
  cout << endl;
  }
  if(i!=4) cout << "####################" << endl;
 }
 return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,count=0;
    cin>>n;
    std::deque<int> colors(8,0);
    for (int i=0;i<n;i++) {
        cin>>a;
        if (1<=a&&a<=399) {
            colors[0]=1;
        } else if (400<=a&&a<=799) {
            colors[1]=1;
        } else if (800<=a&&a<=1199) {
            colors[2]=1;
        } else if (1200<=a&&a<=1599) {
            colors[3]=1;
        } else if (1600<=a&&a<=1999) {
            colors[4]=1;
        } else if (2000<=a&&a<=2399) {
            colors[5]=1;
        } else if (2400<=a&&a<=2799) {
            colors[6]=1;
        } else if (2800<=a&&a<=3199) {
            colors[7]=1;
        } else if (a>=3200) {
            count++;
        }
    }
    int min_num=0,max_num=0;
    for (int j=0;j<colors.size();j++) {
        if (colors[j]==1) {
            min_num++;
            max_num++;
        }
    }
    if (min_num!=0) {
        cout<<min_num<<" "<<max_num+count<<endl;
    } else {
        cout<<1<<" "<<max_num+count<<endl;
    }
}

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

int main(){
    int tinggi[10000];
    int i, j, temp;

    for(i=0; i<10; i++){
        cin>>tinggi[i];
    }
    for(j=0; j<10; j++){
            for(i=1; i<10; i++){
                if(tinggi[i] > tinggi[i-1]){
                    temp = tinggi[i];
                    tinggi[i] = tinggi[i-1];
                    tinggi[i-1] = temp;
                }
        }
    }
    for(i=0; i<3; i++){
        cout<<tinggi[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int n;
long long a[N],ans;
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n+n);
	for(int i=1;i<=n+n;i++)
		ans+=a[i]*(i-1);
	printf("%.12lf",1.0*ans/(n+n-1));
}

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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 50;

int n;
vector<int> t[maxn];
int h[maxn], st[maxn], ft[maxn], sz[maxn], Time, up[maxn], par[maxn];
int seg[4 * maxn], lazy[4 * maxn];
vector<int> vec[4 * maxn];
bool visited[maxn];

void shift(int, int, int);

int get(int id, int L, int R, int idx){
	while (!vec[id].empty()){
		int u = vec[id].back();
		vec[id].pop_back();
		if (visited[u])
			continue;
		return u;
	}
	shift(id, L, R);
	int mid = (L + R) >> 1;
	if (idx < mid)
		return get(2 * id + 0, L, mid, idx);
	return get(2 * id + 1, mid, R, idx);
}

pair<int,int> get(int id, int L, int R){
	if (L + 1 == R)
		return {seg[id], L};
	shift(id, L, R);
	int mid = (L + R) >> 1;
	if (seg[2 * id + 0] == seg[id])
		return get(2 * id + 0, L, mid);
	return get(2 * id + 1, mid, R);
}

void add(int id, int L, int R, int l, int r, int val, int invec){
	if (r <= L or R <= l)
		return;
	if (l <= L and R <= r){
		seg[id] += val;
		lazy[id] += val;
		if (invec != -1)
			vec[id].push_back(invec);
		return;
	}
	shift(id, L, R);
	int mid = (L + R) >> 1;
	add(2 * id + 0, L, mid, l, r, val, invec);
	add(2 * id + 1, mid, R, l, r, val, invec);
	seg[id] = min(seg[2 * id + 0], seg[2 * id + 1]);
}

void shift(int id, int L, int R){
	if (lazy[id] == 0)
		return;
	int mid = (L + R) >> 1;
	add(2 * id + 0, L, mid, L, mid, lazy[id], -1);
	add(2 * id + 1, mid, R, mid, R, lazy[id], -1);
	lazy[id] = 0;
}

void add(int v, int u, int x){
	int val = 1;
	if (x == -1)
		val = -1;
	while (up[v] != up[u]){
		if (h[up[v]] < h[up[u]])
			swap(v, u);
		add(1, 1, n, st[up[v]], st[v] + 1, val, x);
		v = par[up[v]];
	}
	if (h[v] < h[u])
		swap(v, u);
	if (h[v] != h[u])
		add(1, 1, n, st[u] + 1, st[v] + 1, val, x);
}

bool cmp(int v, int u){ return sz[v] > sz[u]; }
void dfs(int v){
	sort(t[v].begin(), t[v].end(), cmp);
	if (par[v] != -1)
		t[v].erase(t[v].begin());
	st[v] = Time ++;
	bool flag = 0;
	for (auto u : t[v]){
		if (flag == 0)
			up[u] = up[v];
		else
			up[u] = u;
		dfs(u);
		flag |= 1;
	}
	ft[v] = Time;
}

void dfs_sz(int v, int p = -1){
	sz[v] = 1;
	par[v] = p;
	for (auto u : t[v]){
		if (u != p){
			h[u] = h[v] + 1;
			dfs_sz(u, v);
			sz[v] += sz[u];
		}
	}
}

int c[maxn], d[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int v, u;
		cin >> v >> u;
		v --, u --;
		t[v].push_back(u);
		t[u].push_back(v);
	}
	dfs_sz(0);
	dfs(0);
	for (int i = 0; i < n - 1; i++){
		cin >> c[i] >> d[i];
		c[i] --, d[i] --;
		add(c[i], d[i], i);
	}
	for (int i = 0; i < n - 1; i++){
		auto it = get(1, 1, n);
		if (it.first != 1)
			return cout << "NO\n", 0;
		int idx = it.second;
		int me = get(1, 1, n, idx);
		visited[me] = 1;
		add(c[me], d[me], -1);
		add(1, 1, n, idx, idx + 1, +n, -1);
	}
	cout << "YES\n";
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll A[111];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	
	ll mi=1LL<<60;
	for(int mask=0;mask<1<<N;mask++) if(__builtin_popcount(mask)>=K) {
		ll cur=0;
		ll tot=0;
		FOR(i,N) {
			if(mask&(1<<i)) {
				ll nex=max(cur+1,A[i]);
				tot += nex-A[i];
				cur=nex;
			}
			else {
				cur=max(cur,A[i]);
			}
		}
		mi=min(mi,tot);
	}
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool prime(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}


int main()
{
    int x;
    scanf("%d",&x);
    while(true)
    {
     if(prime(x)){
        printf("%d\n",x);
        return 0;}
    x++;
    }
    return 0;
}

Measured memory_bytes: 3832
N = int(input())
A = [int(i) for i in input().split()]
Num = [int(i) for i in range(1,N+1)]

List = []
for i in range(len(A)):
    List.append([A[i],i+1])


List.sort()
ans = []
for i in range(len(List)):
    ans.append(List[i][1])
print(*ans)

Measured memory_bytes: 27560
#include<iostream>

using namespace std;

int main(){
  int a, b ,c;
  cin >> a >>b >> c;
  int mx=10, mn=0;
  mx = max(a, max(b, c));
  mn = min(a, min(b, c));
  int md = a+b + c -mn-mx;
  cout << 10*mx+md+mn << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;



public class Main{

	public int x;
	public int y;



	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}

	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}

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

	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}

	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}

	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}


	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long[] a=new long[N];

		List<Long> list=new ArrayList<Long>();
		for(int i=0;i<N;i++) {
			a[i]=sc.nextLong();
			list.add(a[i]);
		}
		Collections.sort(list);

		for(int i=0;i<N;i++) {
			if(a[i]<=list.get(N/2-1)){
				System.out.println(list.get(list.size()/2));
			}else{
				System.out.println(list.get(list.size()/2-1));
			}


		}









		











	}
}



Measured memory_bytes: 102348
#include <cstdio>
#include <utility>
#include <vector>
#include <climits>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n, k; n = in(), k = in(), k || n;) {
		int r = INT_MIN;
		vector<int> s(n + 1);
		for (int i = 1; i <= n; i++) {
			s[i] = s[i - 1] + in();
			if (i >= k)
				r = max(r, s[i] - s[i - k]);
		}
		outl(r);
	}
}


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

using namespace std;

int main() {
	string s;
	int n,count,ans;
	count = 0;
	ans = 0;

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			count++;
		}
		else if(s[i]=='D') {
			count--;
		}

		if(count>ans){
			ans = count;

	}
	
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1, s2, s3, S;
  cin >> S;
  s1 = S/100;
  s2 = (S - s1*100)/10;
  s3 = (S - s1*100 - s2*10);
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--; Cw--; Dh--; Dw--;
    vector<string> S(H);
    rep(h, H) cin >> S[h];
    const int INF = 1e9;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    deque<P> dq;

    dist[Ch][Cw] = 0;
    dq.emplace_back(P(Ch, Cw));

    while(!dq.empty()) {
        P v = dq.front();
        int h = v.first;
        int w = v.second;
        dq.pop_front();
        int d = dist[h][w];

        rep(dir, 4) {
            int nh = h + dx[dir];
            int nw = w + dy[dir];

            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (dist[nh][nw] <= d) continue;
            if (S[nh][nw] == '#') continue;
            dist[nh][nw] = d;
            dq.emplace_front(nh, nw);
        }

        for (int dx=-2; dx<=2; dx++) {
            for (int dy=-2; dy<=2; dy++) {
                int nh = h + dx;
                int nw = w + dy;

                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (dist[nh][nw] <= d) continue;
                if (S[nh][nw] == '#') continue;
                dist[nh][nw] = d+1;
                dq.emplace_back(nh, nw);
            }
        }
    }

    int ans = dist[Dh][Dw];
    if (dist[Dh][Dw] == INF) ans = -1;
    cout << ans << endl;       
}

Measured memory_bytes: 10172
def resolve():
    import math
    n, m = list(map(int, input().split()))

    ans1 = math.factorial(n) // (math.factorial(n-2) * 2) if n > 1 else 0
    ans2 = math.factorial(m) // (math.factorial(m-2) * 2) if m > 1 else 0
    print(ans1 + ans2)
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mem(dp, v) memset(dp, v, sizeof dp);
using namespace std;

const int N = 1e3 + 7, inf = 1e9;
ll ar[N], dp[N][N], n, k, t;

int main()
{
    ll n, k, pw = 1;
    ios_base::sync_with_stdio(false);
    cin>>n;
    while(pw <= n)
    {
        pw *= 2;
    }
    cout<<pw-1<<"\n";
    return 0;
}


Measured memory_bytes: 256
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;

int main()
{
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	cout<<(n-x)*(m-y)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long l,n;
int main(){
	scanf("%lld%lld",&n,&l);
	long long s=1-l;
	long long ans=n*l+(1+n)*n/2-n;
	if(s<1)printf("%lld",ans-l);
	else if(s>n)printf("%lld",ans-l-n+1);
	else printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

AA = A + A

AA_re = list(reversed(AA))
A_re = list(reversed(A))

ans0 = 0
for i in range(N):
    a = A_re[i]
    for j in range(i + 1, N):
        b = A_re[j]
        if a < b:
            ans0 += 1


ans1 = 0
for i in range(N):
    a = AA_re[i]
    for j in range(i + 1, 2 * N):
        b = AA_re[j]
        if a < b:
            ans1 += 1


sa = ans1 - ans0
m = 10 ** 9 + 7
matu = ans0 + sa * (K - 1)
ans = (ans0 + matu) * K // 2

if K == 0:
    print(int(ans0))
    exit()

ans = ans % m


print(int(ans))


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

namespace ConsoleApp15
{
    class Class372
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int[] W = new int[N+1];
            int[] E = new int[N + 1];
            
            int e = 0, w = 0;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'W') w++;
                if (S[N - 1 - i] == 'E') e++;
                W[i + 1] = w;
                E[N - 1 - i] = e;
            }
            int min = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                min = Math.Min(min, W[i] + E[i+1]);
            }
            Console.WriteLine(min);
        }
    }
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    map<int,int>mp;
    rep(i,n){
        mp[a[i]]=mp[a[i]-1]+1;
    }
    int ans=0;
    for(auto&p:mp){
        ans=max(ans,p.second);
    }
    cout<<n-ans<<endl;
}

Measured memory_bytes: 13544
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,w,i,j,k,l,m,n,x,y;
	string	ans = "Possible";
	string	s;
	cin >> h >> w;
	vector<string>	bd(h);
	for(i=0;i<h;i++) cin >> bd[i];
	x = y = 0;
	if (bd[0][0]!='#') {
		ans = "Impossible";
	}
	bd[0][0] = 'o';
	while(x!=(w-1) || y!=(h-1)) {
		if (x!=(w-1)) {
			if (bd[y][x+1] == '#') {
				bd[y][x+1] = 'o';
				x++;
				continue;
			}
		}
		if (y!=(h-1)) {
			if (bd[y+1][x] == '#') {
				bd[y+1][x] = 'o';
				y++;
				continue;
			}
		}
		ans = "Impossible";
		break;
	}
	for(i=0;i<h;i++) for(j=0;j<w;j++) {
		if (bd[i][j]=='#') {
			ans = "Impossible";
			break;
		}
	}
	//for(i=0;i<h;i++) cout << bd[i] << endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584