akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  string s;
  cin >> s;
  int cnt[26] = {};
  for(int i=0;i<s.size();i++){
    cnt[s[i]-'a']++;
  }

  for(int i=0;i<26;i++){
    if(cnt[i]>=2){
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;
  return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 3e3+5;

ll n , s , a[N] , dp[N][N] , mod = 998244353;

ll solve(int i , int sum)
{
    if (i > n) return sum == s;

    if (dp[i][sum] != -1)
        return dp[i][sum];

    ll ans = (2*solve(i+1 , sum))%mod;
    if (sum + a[i] <= s) ans += solve(i+1 , sum+a[i]);

    ans %= mod;
    return dp[i][sum] = ans;
}

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

    cin >> n >> s;
    for(int i=1; i<=n; i++)
        cin >> a[i];

    memset(dp , -1 , sizeof(dp));
    cout << solve(1,0) << '\n';

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a, b;
  cin >> a >> b;
  int c = 1;
  for(int i = 0; i < a; i++) {
    if(c > b) c += b;
    else c *= 2;
  }
  cout << c << endl;
}


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

mod = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for x in range(N+1):
    y = (K-A*x) / B
    if y.is_integer():
        ans += nCr(N, x) * nCr(N, int(y)) % mod

print(ans % mod)


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

int main(){
  int n,k; cin >> n >> k; double ans=0; double dans=0; int deme;
  rep(i,n){
    ans = 1/(double)n; deme =i+1;
    while(deme<k){
      deme *= 2; ans /= 2;
    }
    dans += ans;
  }
  printf("%.10lf",dans);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	var result float64
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		result = result + (float64(1) / float64(a))
	}
	fmt.Print(1 / result)
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	string s;
	ll ans = 0;
	//float ans = 0;
	//string ans;

	cin >> n;

	V a(n);
	rep(i, n) cin >> a[i];

	ll now = a[0] - 1;
	ans = -1;
	ll cnt = 1;

	rep(i, n) {
		if (now == 1) {
			ans = cnt;
			break;
		}
		cnt++;
		now = a[now] - 1;
	}

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_b();

	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void solve() {
    float r;
    cin >> r;
    float pi = 3.14159;
    float ans = (float)2 * pi * r;

    cout << fixed << setprecision(4) << ans << "\n";
}

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

    // std::ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    // int t;
    // cin>>t;

    // while(t--)
    solve();

    return 0;
}

Measured memory_bytes: 3776
#include <stdio.h>

#include <algorithm>

using namespace std;

int W, H;
int m[10][10000];

int max_one;

void calculate() {
  int cur = 0;
  for (int c = 0; c < W; ++c) {
    int one_count = 0;
    for (int r = 0; r < H; ++r) {
      one_count += m[r][c];
    }
    cur += max(one_count, H - one_count);
  }
  max_one = max(max_one, cur);
}

void permute(int r) {
  if (r == H) {
    calculate();
    return;
  }
  permute(r + 1);
  for (int i = 0; i < W; ++i) {
    m[r][i] = 1 - m[r][i];
  }
  permute(r + 1);
  for (int i = 0; i < W; ++i) {
    m[r][i] = 1 - m[r][i];
  }
}

int getMaxOne() {
  max_one = 0;
  permute(0); 
  return max_one;
}

int main() {
  //freopen("Osenbei.in", "r", stdin);
  while (scanf("%d%d", &H, &W) == 2 && H != 0 && W != 0) {
    for (int r = 0; r < H; ++r) {
      for (int c = 0; c < W; ++c) {
        scanf("%d", &m[r][c]);
      }
    }
    int result = getMaxOne();
    printf("%d\n", result);
  }
  return 0;
}

Measured memory_bytes: 2996
#include<stdio.h>
 
int main(void) {
  int a, b, c;
  int max, x, y;
  
  scanf("%d %d %d", &a, &b, &c);
  
  if(a <= 0||a >100) {
    puts("No");
  }
  if(c <= 0||c >100) {
    puts("No");
  }
  if(b <= 0||b >100) {
    puts("No");
  }
  if(a >= b && a>= c) {
    max = a;
    x = b;
    y = c;
  }
  else if(b >= a && b>= c) {
    max = b;
    x = a;
    y = c;
  }
  else {
    max = c;
    x = a;
    y = b;
  }
  
  if(max == x + y) {
    puts("Yes");
  }
  else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 128
use proconio::input;
use proconio::marker::Usize1;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        K: usize,
    }

    let mut v = vec![0; N];
    for _ in 0..K {
        input! {
            D: usize,
            A: [Usize1; D],
        }

        for a in A {
            v[a] += 1;
        }
    }

    println!(
        "{:?}",
        v.iter()
            .fold(0, |acc, &x| { acc + if x == 0 { 1 } else { 0 } })
    );
}


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

using namespace std;

const int Nmax = 1e5+5;
typedef long long ll;

bool used[Nmax][2], ok;
int x, y, i, n, m, bip, nonbip, iso;
vector<int> v[Nmax];

void dfs(int node, int par)
{
    used[node][par] = 1;
    par ^= 1;
    if(used[node][par]) ok = 1;

    for(auto it : v[node])
        if(!used[it][par])
            dfs(it, par);
}

int main()
{
    //freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=1; i<=m; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    for(i=1; i<=n; ++i)
        if(v[i].empty()) ++iso;
            else if(!used[i][0] && !used[i][1])
            {
                ok = 0;
                dfs(i, 0);
                if(!ok) ++bip;
                    else ++nonbip;
            }

    cout << (ll)iso * (2*n-iso) + (ll) 2 * bip * (bip + nonbip) + (ll) nonbip * nonbip << '\n';

    return 0;
}


Measured memory_bytes: 12544
while True:
    q = int(raw_input())
    if q == -1: break
    ls = [q/2.]
    while abs(ls[-1]**3.-q) >= 0.00001*q:
        ls.append(ls[-1]-((ls[-1]**3-q)/(3.*ls[-1]**2)))
    else:
        print ls[-1]

Measured memory_bytes: 4308
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

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

  ll Max = max(a, max(b, c));
  ll diff = Max * 3 - a - b - c;
  if (diff % 2) diff += 4;
  cout << diff / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define MAX_N 40
#define MAX_K 3
#define INF (1<<29)

int n;
int p[MAX_N+1], t[MAX_N+1];

int dp[MAX_N+1][MAX_K+1];

void disp(){
	cout << "--- table ---" << endl;
	for(int i=0;i<=n;i++){
		for(int k=0;k<=3;k++){
			if(dp[i][k] == INF)
				cout << -1 << " ";
			else
				cout << dp[i][k] << " ";
		}
		cout << endl;
	}
}

int I=0;
void solve(){
	I++;
	
	for(int i=0;i<=n;i++) for(int k=0;k<=3;k++) dp[i][k] = INF;
	
	dp[0][0] = 0;
	for(int i=0;i<n;i++){
		//		if(I==5) disp();
		for(int k=0;k<=3;k++){
			if(dp[i][k] == INF) continue;
			int ta = (k+1)*(abs(p[i+1]-p[i])); // direct
			int tb = (k+1)*p[i] + p[i+1]; // home and go
			if(k != 3 && ta <= t[i+1] - t[i]){
				dp[i+1][k+1] = min(dp[i+1][k+1], dp[i][k] + abs(p[i+1]-p[i]));
			}
			if(tb <= t[i+1] - t[i]){
				dp[i+1][1] = min(dp[i+1][1], dp[i][k] + (p[i]+p[i+1]));
			}
		}
		// check
		bool flg = true;
		for(int k=0;k<=3;k++){
			if(dp[i+1][k] != INF) { flg = false; }
		}
		if(flg) {
			cout << "NG " << i+1 << endl;
			return;
		}
	}
	int res = INF;
	for(int k=0;k<=3;k++){
		res = min(res, dp[n][k]);
	}
	if(res == INF)
		cout << "NG " << n << endl;
	else
		cout << "OK " << res + p[n] << endl;
}

int main(void){
	while(true){
		cin >> n;
		if(n == 0) break;
		p[0] = t[0] = 0;
		for(int i=1;i<=n;i++) cin >> p[i] >> t[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    vl as(5);
    cin>>as;

    int m = INF;
    int mi = 0;
    rep(i, 5) {
        if (as[i] % 10 && m > as[i] % 10) {
            m = as[i] % 10;
            mi = i;
        }
    }
    int ans = 0;
    rep(i, 5) {
        if (i == mi) continue;
        ans += as[i];
        if (ans % 10) ans = (ans / 10 + 1) * 10;
    }
    ans += as[mi];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
S = list(input())
len_S = len(S)
a = [0]*(len_S+1)
for i, s in enumerate(S):
    if s == '<':
        a[i+1] = a[i]+1
for i, s in enumerate(S[::-1]):
    inv_i = len_S-1-i
    if s == '>':
        a[inv_i] = max(a[inv_i+1]+1, a[inv_i])
print(sum(a))


Measured memory_bytes: 30896
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int N = scanner.nextInt();
			if (N == 0) {
				break;
			}

			ArrayList<Plant> plants = new ArrayList<Plant>();
			for (int i = 0; i < N; i++) {
				String name = scanner.next();
				int P = scanner.nextInt();
				int A = scanner.nextInt();
				int B = scanner.nextInt();
				int C = scanner.nextInt();
				int D = scanner.nextInt();
				int E = scanner.nextInt();
				int F = scanner.nextInt();
				int S = scanner.nextInt();
				int M = scanner.nextInt();

				int cost = A + B + C + (D + E) * M;
				int gain = F * S * M - P;

				plants.add(new Plant(name, gain, cost));
			}

			Collections.sort(plants);
			for (Plant plant : plants) {
				System.out.println(plant.name);
			}
			System.out.println("#");

		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

class Plant implements Comparable<Plant> {
	int id, gain, cost;
	String name;

	Plant(String name, int gain, int cost) {
		this.name = name;
		this.gain = gain;
		this.cost = cost;
	}

	@Override
	public int compareTo(Plant p) {
		int diff = p.gain * this.cost - this.gain * p.cost;
		if (diff == 0) {
			return this.name.compareTo(p.name);
		}

		return diff;// 降順
	}
}

Measured memory_bytes: 37812
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int x;
	cin>>x;
	for(int i=x/105; i<=x/100; i++){
		if(100*i<=x && x<=105*i){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int n, q;
  ll sum = 0;
  map<int, int> a;
  cin >> n;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    sum += x;
    a[x]++;
  }
  cin >> q;
  for (int i = 0; i < q; i++){
    int b, c;
    cin >> b >> c;
    if (a.count(b)) {
      int diff = c-b;
      ll add = a[b]*diff;
      sum += add;
      a[c] += a[b];
      a.erase(b);
    } 
    cout << sum << endl;
  } 
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000) ? cout << 1 : cout << 0;
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3224
import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- readLn
  as <- getInput n
  cs <- getInput n
  print $ countSm (sortBy (flip compare) as) cs

getInput n = replicateM n $ do
  [x,y] <- map read . words <$> getLine
  return (x,y)

countSm :: [(Int,Int)] -> [(Int,Int)]  -> Int
countSm [] _ = 0
countSm as cs =
  let
    (x,y):as' = as
    bFilt = filter (\(a,b) -> x < a && y < b) cs
    compY a b = snd a `compare` snd b
    in if null bFilt
      then countSm as' cs
      else (1 +) $ countSm as' $ delete (minimumBy compY bFilt) cs


Measured memory_bytes: 1020
//
//  main.c
//  t1
//
//  Created by qi on 2016/10/10.
//  Copyright © 2016年 vinchi. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char s[] = "CODEFESTIVAL2016";
    char q[20];
    int ans;
    ans = 0;
    scanf("%s", q);
    for (int i = 0; i<strlen(q); i++) {
        if (s[i]!=q[i]){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    ll n;
    ll ans = 0;

    cin >> n;

    if (n % 2 == 0)
    {
        n /= 2;
        while (n / 5 > 0)
        {
            ans += n / 5;
            n /= 5;
        }

        cout << ans << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = my_readln().split();
	auto N = tokens[0].to!ulong;
	auto M = tokens[1].to!ulong;
	ulong[][2][] v;
	v.length = N;
	foreach (i; 0..M)
	{
		auto tokens2 = my_readln().split();
		auto x       = tokens2[0].to!ulong - 1;
		auto y       = tokens2[1].to!ulong - 1;
		v[y][0]     ~= x;
		v[x][1]     ~= y;
	}

	ulong[] memo;
	memo.length = N;
	ulong search(ulong pos)
	{
		ulong r;
		foreach (e; v[pos][1])
		{
			r = max(r, memo[e] == 0 ? search(e) + 1 : memo[e] + 1);
		}
		stderr.writeln("a", pos, " ", r);
		memo[pos] = r;
		return r;
	}

	ulong ans;
	foreach (i; 0..N)
	{
		if (v[i][0].length != 0) continue;

		ans = max(ans, search(i));
		stderr.writeln("b", i, " ", ans);
	}
	writeln(ans);

	stdout.flush();
}

Measured memory_bytes: 26620
def execute(w):
    if len(w) % 2 == 1:
        return 'No'

    for i in range(len(w) // 2):
        if w.count(w[i]) % 2 == 1:
            return 'No'
    return 'Yes'


if __name__ == '__main__':
    print(execute(input()))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		//String s = sc.next();
		long count=0;
		long l=0,x=0;
		//long[][] array=new long[n][2];
		if(n==m) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(count);
	}
}




Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn=1e6+1111;

int arr[maxn];
int dp[maxn];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    memset(dp,0x3f3f3f,sizeof(dp));
    arr[0]=0x3f3f3f;
    dp[0]=dp[1]=0;
    for(int i=1;i<=n;++i){
        scanf("%d",arr+i);
        if(i>1) for(int j=1;j<=k&&i-j>0;++j){
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}

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

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

    long long int  sum =0;
    for(long long int i = 1; i < n+1 ; i++)
    {
        if( i%5!=0 && i%3!=0) 
        sum += i;
    }

    cout<<sum;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

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

int main()
{
    int32 n;
    cin >> n;
    vector<int32> a(n);
    REP(i,n)cin >> a[i];
    sort(ALL(a));
    int32 k = 2;
    while(k < a.size()){
        if(a[k] == a[k-1] && a[k-1 ]== a[k-2]){
            a.erase(a.begin() + k);
        }else{
            k++;
        }
    }
    n = a.size();
    int32 ans = 1;
    REP(i,n){
        int32 g = -1;
        REP(j,n){
            if(i == j)continue;
            if(g == -1){
                g = a[j];
            }else{
                g = gcd(g, a[j]);
            }
        }
        ans = max(ans, g);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <map>

class Dice {
    const std::map<char,int> index{ {'N',1}, {'E',2}, {'S',3}, {'W',4} };
    /* order: bottom, north, east, south, west, top */
    std::array<int,6> faces{{6, 5, 3, 2, 4, 1}};
    std::array<int,6> nums{{1, 2, 3, 4, 5, 6}};
public:
    Dice(){};
    Dice(std::array<int,6> d) { nums = d; }
    void rotate(char c);
    int get_top(void);
    ~Dice(){}
};
void Dice::rotate(char c) {
    const int i{index.at(c)}, j{(i+5)%4+1};
    if(!i) return;
    const int bottom{faces[0]};
    faces[0] = faces[i];
    faces[i] = faces[5];
    faces[5] = faces[j];
    faces[j] = bottom;
}
int Dice::get_top(void) {
    return nums[faces[5]-1];
}

int main() {
    std::array<int,6> faces;
    for(auto& x : faces) { std::cin >> x; }
    Dice dice{faces};
    std::string s{};
    std::getline(std::cin, s);
    std::getline(std::cin, s);
    for(auto c : s) { dice.rotate(c); }
    std::cout << dice.get_top() << std::endl;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
vector<int> a;
int cnt = 0;

void merge(int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> l(n1 + 1), r(n2 + 1);
    rep(i, 0, n1) l[i] = a[left + i];
    rep(i, 0, n2) r[i] = a[mid + i];
    l[n1] = INF;
    r[n2] = INF;
    int i = 0;
    int j = 0;
    rep(k, left, right){
        cnt++;
        if(l[i] <= r[j]){
            a[k] = l[i];
            i = i + 1;
        }else{
            a[k] = r[j];
            j = j + 1;
        }
    }
}

void margeSort(int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        margeSort(left, mid);
        margeSort(mid, right);
        merge(left, mid, right);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    margeSort(0, n);
    for(int ii = 0; ii < a.size(); ii++){
        if(ii) cout << ' ';
        cout << a[ii];
    }
    cout << endl;
    cout << cnt << endl;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        

        int[] tx = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int T = tx[0];
        int X = tx[1];

        Console.WriteLine(T / (double)X);

        
    }
    
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace  __gnu_pbds;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<
ii,
null_type,
less<ii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

void init() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 3e5+5;
const int MOD = 1e9+7;

ll arr[70];

int main() {
	init();
	ll n, sum = 0, num;
	cin >> n;
	lp(i, n){
		cin >> num;
		int j = 0;
		while(num > 0){
			arr[j] += num % 2;
			num /= 2;
			++j;
		}
	}
	num = 1;
	lp(i, 70){
		sum = (((ll)sum) + ((((ll)(((ll)arr[i] * (n-arr[i])) % MOD) * (num)) % MOD))) % MOD;
		num = (((ll)num) * 2) % MOD;
	}
	cout << sum;
	return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N; int K; cin >> K;
    int p[N]; for(int i=0;i<N;i++) cin >> p[i];
    sort(p,p+N);
    int ans=0;
    for(int i=0;i<K;i++){
        ans+=p[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int gcd(int a, int b) { int c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a * b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a * b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }

//int dx4[4] = { 0,1,0,-1 }, dy4[4] = { -1,0,1,0 };
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};


int main(){
	bool a[200010], b[200010]; 
	int n, m;
	cin >> n >> m;
	REP(i, 200010) a[i] = b[i] = false;
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		if (x == 1) a[y] = true;
		if (y == n) b[x] = true;
	}
	FOR(i, 2, n) {
		if (a[i] && b[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
Module Module1

    Sub main()
        Dim user1 = CInt(Console.ReadLine())
        Dim user2 = Console.ReadLine()
        Dim result As String = ""

        If Len(user2) > user1 Then

            result = Mid(user2, 1, user1) & "..."
        Else
            result = user2
        End If
        Console.WriteLine(result)
    End Sub
end module

Measured memory_bytes: 28296
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
#define p push_back
int main()
{
  ll  n,cnt=0;
  string s;
  cin>>n;

  vector<int>v1,v2;
  for(int i=1;i<=n;i++)
   {
    char ch ;
    cin>>ch;
    if(ch=='W')
      v1.push_back(i);
    else
      v2.push_back(i);
   }
  ll i =0,j=v2.size()-1;
 
  while(i<v1.size() && j>=0 )
  {
   // cout<<v1[i]<< " " <<v2[j]<<endl;
    if(v1[i]<v2[j])
    cnt++;
    i++;
    j--;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 4640
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    CNT = 0
    for i in range(1,N):
        if A[i] <= A[i-1]:
            CNT += A[i-1] - A[i]
            A[i] += A[i-1] - A[i]
    print(CNT)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 31456
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii p(n, 0);
  rep(i, 0, n) cin >> p[i];
  int ans = 0;
  rep(i, 1, n-1) {
    int a = p[i-1], b = p[i], c = p[i+1];
    if ((a < b and b < c) or (c < b and b < a)) 
      ans++;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1);
}
 
int main()
{
  int a,b;
  cin >> a >> b;
  printf("%d",a*b-a-b+1);
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int a,b;cin>>a>>b;
	cout<<1+2+3-a-b<<endl;
}

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

int main(void){
  int n;
  int tmp;

  while(cin >> n && n){
	int colsum[n+1];

	memset(colsum, 0, sizeof(colsum));
	for(int i=0;i<n;i++){
	  int sum=0;
	  for(int j=0;j<n;j++){
		cin >> tmp;
		printf("%5d", tmp);
		sum += tmp;
		colsum[j] += tmp;
	  }
	  printf("%5d\n", sum);
	  colsum[n] += sum;
	}
	for(int i=0;i<n+1;i++){
	  if(i!=n){
		printf("%5d", colsum[i]);
	  }else{
		printf("%5d\n", colsum[i]);
	  }
	}
  }
  
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int lcs[1001][1001];

int seek_lcs_body(const char* s1, int pos1, const char* s2, int pos2)
{
	if(s1[pos1] == s2[pos2]){
		return lcs[pos1][pos2] + 1;
	}
	else if(s1[pos1] != s2[pos2]){
		int max = lcs[pos1+1][pos2] > lcs[pos1][pos2+1]? lcs[pos1+1][pos2] : lcs[pos1][pos2+1];
		return max;
	}
	return 0;
}

int seek_lcs(const char* s1, const char* s2)
{
	int sz1=strlen(s1), sz2=strlen(s2);
	for(int i=1; i<=sz1; ++i){
		for (int j=1; j<=sz2; ++j){
			lcs[i][j] = seek_lcs_body(s1, i-1, s2, j-1);
		}
	}
	cout << lcs[sz1][sz2] << endl;
	return 0;
}

int main(){
	int q;
	scanf("%d",&q);

	for(int i=0; i<1001; ++i){
		lcs[i][0] = 0;
		lcs[0][i] = 0;
	}

	for(int i=0; i<q; ++i){
		string s1, s2;
		cin >> s1;
		cin >> s2;
		seek_lcs(s1.c_str(), s2.c_str());
	}
	return 0;
}


Measured memory_bytes: 7156
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<bool> ac(n);
  vector<int> cnt(n);
  for (int i = 0; i < m; ++i) {
    int x;
    static char s[10];
    scanf("%d%s", &x, s);
    --x;
    if (s[0] == 'A') {
      ac[x] = true;
    } else {
      if (!ac[x]) cnt[x]++;
    }
  }
  int ret = 0, wa_cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (!ac[i]) continue;
    ret++;
    wa_cnt += cnt[i];
  }
  printf("%d %d\n", ret, wa_cnt);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n;
  cin >> n;
  ll f[n][10];
  for(ll i = 0; i < n; i++){
    for(ll j = 0; j < 10; j++) cin >> f[i][j];
  }
  ll p[n][11];
  for(ll i = 0; i < n; i++){
    for(ll j = 0; j < 11; j++) cin >> p[i][j];
  }

  ll ans = -(1<<30);
  for(ll bit = 1; bit < (1 << 10); bit++){
    ll cnt = 0;
    for(ll i = 0; i < n; i++){
      ll c = 0;
      for(ll j = 0; j < 10; j++){
        if((bit & (1 << j)) && f[i][j]) c++;
      }
      cnt += p[i][c];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
int q;
cin>>q;
int tle=0,wa=0,ac=0,re=0;
while(q--)
{
string s;
cin>>s;
if(s=="TLE")
{
tle++;
}
else if(s=="WA")
{
wa++;
}
else if(s=="AC")
{
ac++;
}
else if(s=="RE")
{
re++;
}
}
cout<<"AC"<<" "<<"x"<<" "<<ac<<"\n";
cout<<"WA"<<" "<<"x"<<" "<<wa<<"\n";
cout<<"TLE"<<" "<<"x"<<" "<<tle<<"\n";
cout<<"RE"<<" "<<"x"<<" "<<re<<"\n";


return 0;
}

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define lint long long

using namespace std;

int main()
{
  lint N,ans=0,min=10000000000;
  cin >> N;

  for(int i=0;i<N;i++){
    lint p;
    cin >> p;
    if(p<min){
      min = p;
      ans += 1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def nCr(a, b):
    if a - b < b:
        return nCr(a, a - b)
    ans = 1
    for i in xrange(1, b + 1):
        ans *= a - i + 1
    for i in xrange(1, b + 1):
        ans //= i
    return ans


n, m = [int(x) for x in raw_input().split()]
a = [int(x) for x in raw_input().split()]

s = 0
for i in xrange(n):
    a[i] = s = (s + a[i]) % m

from collections import Counter

cnter = Counter(a)
cnter[0] += 1

ans = 0

for i, cnt in cnter.items():
    if cnt >= 2:
        ans += nCr(cnt, 2)

print ans


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

int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
	int X,Y;
	cin>>X>>Y;
	bool a = false;
	for(int i=0; i<=X; i++){
		if(((2*i)+(4*(X-i)))==Y){
			a = true;
			break;
		}
	}
	if(a){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3648
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            t %=10;
            if (t==2 ||t==4 ||t==5 ||t==7 || t==9){
                out.println("hon");
            } else if (t==0 ||t==1 ||t==6 ||t==8){
                out.println("pon");
            } else {
                out.println("bon");
            }
        }

        private static int naib(int a, int b) {
            return a / (nod(a, b)) * b;
        }

        private static int nod(int a, int b) {
            while (a != 0 && b != 0) {
                if (a > b) {
                    a = a % b;
                } else {
                    b = b % a;
                }
            }
            return a + b;
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 32776
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>

using namespace std;

int X[200000];
int X2[200000];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
		X2[i] = X[i];
	}
	sort(begin(X), begin(X) + N);

	int m = N / 2 - 1;

	for (int i = 0; i < N; i++)
	{
		if (X[m] < X2[i])
			cout << X[m] << endl;
		else
			cout << X[m + 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/

int fact[N];
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p *1ll* p) % m;
    return (y%2 == 0)? p : (x *1ll* p) % m;
}
int ncr(int n, int r){
    int ans = fact[n];
    ans = (ans * power(fact[n-r], M-2,M)) % M;
    ans = (ans * power(fact[r], M-2,M)) % M;
    return ans;
}
int find_ans(int i1, int j1, int i2, int j2){
    return ncr(i2-i1+j2-j1,i2-i1);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    fact[0] = 1;
    rep(i,1,N) fact[i] = (fact[i-1] * i) % M;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int h,w,a,b;
        cin >> h >> w >> a >> b;
        int ans = 0;
        rep(i,1,h-a+1){
            int ni = i;
            int nj = b;
            // trace(ni, nj);
            ans = (ans + find_ans(1,1,ni,nj) * find_ans(ni,nj+1,h,w)) % M;
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 11436
#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()
{
    string s;
    int n = 0;
    cin >> s;
    n = s.length();
    rep(i, n / 2)
    {
        if (s[i] != s[n - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    string s1 = s.substr(0, (n - 1) / 2);
    string s2 = s.substr((n + 3) / 2 - 1);

    rep(i, s1.length() / 2)
    {
        if (s1[i] != s1[s1.length() - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, s2.length() / 2)
    {
        if (s2[i] != s2[s2.length() - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())


def solve(n, p):
    ans = 0
    cnt = 1
    tmp = 1
    while tmp >= 1:
        tmp = n // p**cnt
        ans += tmp
        cnt += 1
    return ans


primes = set(range(2, n+1))

for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))

primes = list(primes)


li = [solve(n, x) + 1 for x in primes]
mod = 10**9 + 7

ans = 1
for x in li:
    ans *= x
    ans %= mod

print(ans)

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

using namespace std;

int main(int argc, char *argv[]) {
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a) & 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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

bool is_kaibun(int n){
  int digits[5];
  int m = n;
  int k = 0;
  for(int i=0;i<5;i++){
    if(n > 0) k++;
    digits[i] = m % 10;
    m /= 10;
  }
  int p = k / 2;
  for(int i=0;i<p;i++){
    if(digits[i] != digits[k-i-1]){
      return false;
    }
  }
  return true;
}

int main() {
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  for(int i=A;i<=B;i++){
    if(is_kaibun(i)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for(char c : s) {
        st.insert(c);
    }
    if(s.size() == st.size()) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right
import itertools

A,B,Q=map(int, sys.stdin.readline().split())

S=[  int(sys.stdin.readline()) for i in range(A) ]
T=[  int(sys.stdin.readline()) for i in range(B) ]
X=[  int(sys.stdin.readline()) for i in range(Q) ]


for x in X:
	sx=bisect_left(S, x)
	tx=bisect_left(T, x)

	s_temp=[]
	if sx==0:
		s_temp.append(S[sx])	
	elif 0<sx<A:
		s_temp.append(S[sx-1])
		s_temp.append(S[sx])
	else:
		s_temp.append(S[sx-1] )


	t_temp=[]
	if tx==0:
		t_temp.append(T[tx])	
	elif 0<tx<B:
		t_temp.append(T[tx-1])
		t_temp.append(T[tx])
	else:
		t_temp.append(T[tx-1] )


	ans=float("inf")

	for s in s_temp:
		for t in t_temp:
			ans=min(ans, abs(s-x)+abs(s-t) )

	for t in t_temp:
		for s in s_temp:	
			ans=min(ans, abs(t-x)+abs(s-t) )

	print ans


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;

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

	string s;
	cin >> s;
	vector<char> sta;
	for(int i=0; i<s.size(); i++) {
		if(s[i] == 'B') {
			if(!sta.empty()) {
				sta.pop_back();
			}
		}
		else {
			sta.push_back(s[i]);
		}
	}
	for(auto j : sta) {
		cout << j;
	}
	cout << endl;
	return 0;
}


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

int main() {
	char a;
	cin >> a;
	if (a>='a' && a<='z') cout << "a" << endl;
	else cout << "A" << endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 1; i < (int)s.size(); i++) {
    if (s[i - 1] != s[i]) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3756
#include<cstdio>
int f[5007];
int min(int a,int b){return a<b? a:b;}
int main()
{
    int n,p,ans=0;
    scanf("%d%d",&n,&p),f[0]=1;
    for(int i=1;i<n;++i) for(int k=min(i,n-i+1),j=k;j<n;++j) (f[j]+=f[j-k])%=p;
    for(int i=0;i<n;++i) (ans+=1ll*(n-i)*f[i]%p)%=p;
    printf("%d",ans);
}

Measured memory_bytes: 128