akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  vector<string> dow = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;
  cout << 7 - distance(dow.begin(), find(dow.begin(), dow.end(), s)) << endl;
  return 0;
}


Measured memory_bytes: 3612
n = int(input())
s = input()

dp = tuple(set() for _ in range(4))
dp[0].add('')
# dp[x]:=x文字の構成可能なset

for c in s:
    for k in range(2, -1, -1):
        for incomplete_key in dp[k]:
            dp[k + 1].add(incomplete_key + c)

print(len(dp[3]))

# dp


Measured memory_bytes: 3188
def 解():
    iN = int(input())
    #aA = map(int,input().split())
    aA = sorted(map(lambda x,y:x-y,map(int,input().split()),range(1,iN+1)))
    iL = len(aA)
    if iL % 2 :
        iMed = aA[(iL-1)//2]
    else:
        iMed = aA[iL//2]
    print(sum(abs(a-iMed) for a in aA))

解()


Measured memory_bytes: 25708
// Problem : 
// 			B - Making Triangle
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;++i) cin >> v[i];
	int ans=0;
	sort(v.begin(),v.end());
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
		{
			for(int k=j+1;k<n;++k)
			{
				if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[j]!=v[k])
				ans++;
			}
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>

const int TOWN = 10;
const int INF = 1000000000;

using namespace std;

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

	while (cin >> n , n) {

		int d[TOWN][TOWN];
		for (int i = 0; i < TOWN; i++) {
			for (int j = 0; j < TOWN; j++) {
				if (i == j)			d[i][j] = 0;
				else				d[i][j] = INF;
			}
		}

		int num_of_town = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			cin >> d[a][b];
			d[b][a] = d[a][b];
			num_of_town = max(num_of_town, max(a, b));
		}
		num_of_town++;
		//	cout << "num_of_town = " << num_of_town << "\n";



		for (int k = 0; k < num_of_town; k++) {
			for (int i = 0; i < num_of_town; i++) {
				for (int j = 0; j < num_of_town; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}

		//cout << "\n";
		//for (int i = 0; i < num_of_town; i++) {
		//	for (int j = 0; j < num_of_town; j++) {
		//		cout << i << " " << j << " " <<  d[i][j] << "\n";
		//	}
		//}
		//cout << "\n";

		int ans_d = INF;
		int ans_t;
		int tmp = 0;
		for (int i = 0; i < num_of_town; i++) {
			for (int j = 0; j < num_of_town; j++) {
				tmp += d[i][j];
			}
			if (ans_d > tmp) {
				ans_d = tmp;
				ans_t = i;
			}
			tmp = 0;
		}
		cout << ans_t << " " << ans_d << "\n";
	}
	
 	return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

 




vector<int> G[100001];//グラフを表している G[i]: から有効辺で繋がっている点を列挙したリスト
int MEMO_MAX_LENGTH[100001];//M_M_L[i]: iから始めた時の最長の有効パスの長さ

int max_path(int now_v){//now_vから始めた時の最長の有効パスの長さを求める
	if(MEMO_MAX_LENGTH[now_v] != -1){//初期値(-1)ではなかったら　すなわちすでにメモされてたら
		return MEMO_MAX_LENGTH[now_v];
	}
	int max_len = 0;
	rep(i,G[now_v].size()){
		int next_v = G[now_v][i];
		max_len = max(max_len, max_path(next_v) + 1);
	}
	//もしこのノードが終端だった場合は、max_lenは0のままなので、0が返る
	MEMO_MAX_LENGTH[now_v] = max_len;
	return max_len;
}

int main(void){
	int n,m,x,y;
	cin>>n>>m;
	rep(i,m){
		cin>>x>>y;
		G[x].push_back(y);
	}

	reps(i,n){//初期化
		MEMO_MAX_LENGTH[i] = -1;
	}

	int ans = 0;
	reps(i,n){
		ans = max(ans, max_path(i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using LL = long long;
using P = pair<LL, LL>;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007

int main() {
  IN(N); IN(M);

  vector<P> shop;
  REP(i, N) {
    IN_LL(a); IN_LL(b);
    shop.push_back(make_pair(a, b));
  }
  SORT(shop);
  int m = 0;
  LL ans = 0;
  REP(i, N) {
    if (m + shop[i].second < M) {
      ans += shop[i].first * shop[i].second;
      m += shop[i].second;
    } else {
      ans += shop[i].first * (M - m);
      break;
    }
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a <<endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
using namespace std;
 
char c[128];
 
void init(){
    c['('] = ')';
    c[')'] = '(';
    c['i'] = 'i';
    c['w'] = 'w';
    c[' '] = ' ';
}
 
int main(){
    string str;
    int cnt = 0;
 
    init();
    cin >> str;
 
    if(str.size()%2==1){
	if(str[str.size()/2] != 'w' && str[str.size()/2] != 'i'){
	    cnt++;
	}
    }
 
    for(int i = 0 ; i < str.size()/2 ; i++){
	if(str[i] != c[str[str.size()-i-1]]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) {
		cin >> p[i];
		p[i]--;
	}
	
	vector<int> idx(n);
	rep(i,n) idx[p[i]] = i;
	
	set<int> sidx;
	ll res = 0;
	rep(i,n){
		sidx.insert(idx[i]);
		auto itr = sidx.find(idx[i]);
		
		
		ll l1 = 0;
		ll r1 = 0;
		
		// L
		auto litr = itr;
		if(litr != sidx.begin()){
          litr--;
			l1 = idx[i] - *litr;
		}
		else{
			l1 = idx[i]+1;
		}
		
		// R
		auto ritr = itr;
		if(++ritr != sidx.end()){
			r1 = *ritr - idx[i];
		}
		else{
			r1 = n - idx[i];
		}
		
		// cout << l1 << r1 << endl;
		res += ( l1 * r1  ) * (i+1);
	}
	
	cout << res << endl;
	return 0;
}

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int ans = 0;
            char[] c = new char[S.Length];
            for(int i=0; i<S.Length; i++)
            {
                c[i] = S[i];
                if(i >= 1)
                {
                    if(c[i] == c[i - 1])
                    {

                        if (c[i] == '1')
                        {
                            c[i] = '0';
                        }
                        else
                        {
                            c[i] = '1';
                        }
                        ans++;
                    }
                }
            }

            Console.WriteLine(ans);


        }
    }
}

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


int main() {
  int a,b;
  cin >> a >> b;
  rep(n,25)
    if(a*n+1-n>=b){
      cout << n << endl;
      break;
    }
}


Measured memory_bytes: 256
fn main () {
    fn input () -> (usize, usize) {
        let mut ab = String::new();
        std::io::stdin().read_line(&mut ab).unwrap();
        let ab: Vec<_> = ab.trim().split_whitespace().flat_map(str::parse).collect();
        (ab[0], ab[1])
    }

    let (N, T) = input();
    let mut cost = None;
    for _ in 0..N {
        let (c, t) = input();
        if t <= T {
            cost = match cost {
                Some(x) if x > c => Some(c),
                None => Some(c),
                _ => cost,
            };
        }
    }
    if let Some(c) = cost {
        println!("{}", c);
    } else {
        println!("TLE");
    }
}


Measured memory_bytes: 4352
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l = []
for i in range(n):
    l.append(i+1)
full_list = list(itertools.permutations(l))

a = full_list.index(p) + 1
b = full_list.index(q) + 1
print(abs(a-b))

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

int N;
int c;
vvi a;
vector<int> memo;

int rec(int bits) {
    if (memo[bits] != -inf) {
        return memo[bits];
    }
    int ret = 0;
    rep(i, N) for (int j = i + 1; j < N; j++) if ((bits >> i & 1) && (bits >> j & 1)) {
        ret += a[i][j];
    }
    for (int b = (bits - 1) & bits; b > 0; b = (b - 1) & bits) {
        chmax(ret, rec(b) + rec(b ^ bits));
    }

    return memo[bits] = ret;
}

void solve() {
    cout << rec((1 << N) - 1) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    scanf("%lld", &N);
    a = std::vector<std::vector<long long>>(N, std::vector<long long>(N));
    memo = vi(1 << N, -inf);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%lld", &a[i][j]);
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 int N,M,Q;
 
 vector<int> a(50),b(50),c(50),d(50);

   

     
int dfs(int n,vector<int> L);

      
   
int main()
{ int i,j;
  cin >> N >> M >> Q;
  for(i=0;i<Q;i++)
  {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i) ;
    a.at(i)--;
    b.at(i)--;
    
  }
 vector<int> R={0,0,0,0,0,0,0,0,0,0};
 cout << dfs(0,R) << endl;
}
 

   
int dfs(int n,vector<int> L)
{ 
  int ma,poin;
  int i,j,k;
 
  
   if(n==N)  
   {
     poin=0;
     for(i=0;i<Q;i++)
     {
       if(L.at(b.at(i))-L.at(a.at(i))==c.at(i))
       {
         poin+=d.at(i);
       }
     }
   return poin;
   }

  
   if(n!=N)
   {
     ma=0;
     if(n==0)
     {
     k=1;
     }
     else
     {
     k=L.at(n-1);
     }
       for(i=k;i<M+1;i++)
     {
      L.at(n)=i;
       ma=max(ma,dfs(n+1,L));
     }
     return ma;
   }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
vector<string> s;
int h,w;
vector<vector<int> > ver;
vector<vector<int> > pal;

void v(int a,int b,int now,int num){
    if(now>=w-1){
        for(int i=b; i<=now; i++) ver[a][i]=num;
    }
    else if(s[a][now+1]=='#'){
         for(int i=b; i<=now; i++) ver[a][i]=num;
    }
    else v(a,b,now+1,num+1);
}

void p(int a,int b,int now,int num){
    if(now>=h-1){
        for(int i=a; i<=now; i++) pal[i][b]=num;
    }
    else if(s[now+1][b]=='#'){
        for(int i=a; i<=now; i++) pal[i][b]=num;
    }
    else p(a,b,now+1,num+1);
}

 
int main(){
    cin >> h >> w;
    s.resize(h);
    rep(i,h) cin >> s[i];
    vector<vector<int> > imi(h,vector<int>(w));
    ver=imi;
    pal=imi;
    rep(i,h)rep(j,w){
        ver[i][j]=-1;
        pal[i][j]=-1;
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                ver[i][j]=0;
                pal[i][j]=0;
                continue;
            }
            if(ver[i][j]==-1) v(i,j,j,0);
            if(pal[i][j]==-1) p(i,j,i,0);
            //cout << i << j << ' ' << ver[i][j]/*+pal[i][j]*/ << endl;
            ans=max(ans,ver[i][j]+pal[i][j]+1);
        }
    }
    cout << ans << endl;    
return 0;
}

Measured memory_bytes: 51456
def main():
    S = input()

    key = "keyence"

    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False
if (main()):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=1; i<=(n);i++)
typedef long long ll;

int main(){
    int a, b, c; cin >> a >> b >> c;
    for(int i = a; i < a*b; i += a){
        if(i%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ed "\n";
int main()
{
    int h = 0;
    string s;
    cin >> s;
    const char *x = s.c_str();
    char y = x[0];
    for (int i = 1; i < 4; i++)
    {
        if(y==x[i]) {h=1; break;} 
        y = x[i];
    }
    if (h==0)
    {
        cout << "Good" << ed;
    }
    else
    {
        cout << "Bad" << ed;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  std::vector<int> a(n+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  std::vector<int> result(n+1);
  int count=0;
  for(int i=n;i>0;i--){
    int multi=0;
    for(int search=i*2;search<=n;search+=i){
      multi+=result[search];
    }
    if(a[i]==0){
      if(multi%2==1){
        result[i]=1;
        count++;
      }else{
        //nothing
      }
    }else{
      if(multi%2==1){
        //nothing
      }else{
        result[i]=1;
        count++;
      }
    }
  }
  cout<<count<<endl;
  for(int i=1;i<=n;i++){
    if(result[i]==1){
      cout<<i<<endl;
    }
  }


  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n, k, r, s, p;
char t[2*maxN + 1];
bool safe[maxN];

int getValue(char hand)
{
  if (hand == 'r')
    return p;
  else if (hand == 's')
    return r;
  else
    return s;
}

int memo[maxN];
int solve(int i = 0)
{
  if (i >= n) return 0;
  if (memo[i] != -1) return memo[i];
  int ans = max(solve(i + k * (1 + (t[i] == t[i + k]))) + getValue(t[i]), solve(i + k));
  return memo[i] = ans;
}

int main()
{
  while (scanf("%d %d", &n, &k) != EOF)
  {
    memset(safe, false, sizeof(safe));
    memset(t, '\0', sizeof(t));
    scanf("%d %d %d", &r, &s, &p);
    scanf(" %s", t);

    memset(memo, -1, sizeof(memo));
    lli ans = 0;
    for (int i = 0; i < k; i++)
      ans += solve(i);
    // for (int i = 0; i < n; i++)
    //   ans += getValue(t[i]);

    // for (int i = 0; i + k < n; i++)
    //   if (!safe[i] && t[i] == t[i + k])
    //   {
    //     ans -= getValue(t[i]);
    //     safe[i + k] = true;
    //   }

    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        sc.close();

        if(s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0,k) + "...");
        }
    }
}


Measured memory_bytes: 38204
import itertools
N, M = map(int,input().split())

lamp = []
for i in range(M):
  lamp.append(list(map(int, input().split()[1:])))

P = list(map(int, input().split()))

result = 0
for i in itertools.product([0,1], repeat=N):
  for j in range(M):
    re = 0
    for s in lamp[j]:
      re += i[s-1]
    if re % 2 != P[j]:
      break
  else:
    result += 1
print(result)

Measured memory_bytes: 3064
import java.util.*;

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

    public static void main(String[]$) {
        int w = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(Math.max(0, Math.abs(a - b) - w));
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <numeric>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;

int gcd(int x, int y) {
	while (y != 0) {
		int r = x % y;
		x = y; y = r;
	}
	return x;
}


int main() {
	int N, M;
	string S, T;
	cin >> N >> M >> S >> T;

	int g = gcd(N, M);
	for (int k = 0; k < g; k++) {
		if (S[N / g * k] != T[M / g * k]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << (ll)N*M/g << endl;
}


Measured memory_bytes: 512
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int n = cin.NextInt();
            int m = cin.NextInt();
            string str = n.ToString() + m.ToString();
            int sum = int.Parse(str);
            for(int i = 1; i < 1000; i++)
            {
                if (i * i == sum)
                {
                    Console.WriteLine("Yes");
                    break;
                }else if (i == 999)
                {
                    Console.WriteLine("No");
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] hako = new int[n];
            for(int i=0;i< n; i++)
            {
                hako[i] = int.Parse(str[i]);
            }
            int div = 0;
            for (int i = 0; i < n; i++)
            {

                while (true)
                {
                    if (hako[i] % 2 == 0)
                    {
                        div++;
                        hako[i] /= 2;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.Write(div);
        }
    }
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b)
{
    if (a < b)
    {
        a = b;
    }
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b)
{
    if (a > b)
    {
        a = b;
    }
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ll N;
    cin >> N;
    ll AC = 0;
    ll WA = 0;
    ll TLE = 0;
    ll RE = 0;
    string input;
    rep(i, N)
    {
        cin >> input;
        if (input == "AC")
        {
            ++AC;
        }
        else if (input == "WA")
        {
            ++WA;
        }
        else if (input == "TLE")
        {
            ++TLE;
        }
        else if (input == "RE")
        {
            ++RE;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    int d = 0;
    while(n >= (1LL<<d))d++;
    vector<vi> dp(d+1,vi(3,0));
    dp[d][0] = 1;
    for(int i = d; i > 0; i--)rep(j,3)rep(k,3){
        int t = 2*j+(n>>(i-1)&1)-k;
        if(t >= 0)(dp[i-1][min(t,2LL)] += dp[i][j]) %= MOD;
    }
    cout << (dp[0][0] + dp[0][1] + dp[0][2])%MOD << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int r, c;
	while(cin >> r >> c)
	{
		if(!r && !c)
		{
			break;
		}
		else if(r * c % 2)
		{
			cout << "no" << endl;
		}
		else
		{
			cout << "yes" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll oddsum[500005];
ll evensum[500005];
ll a[500005];
int main(){
    fastread;
    ll n,i,j,k,l;
    ll m;
    cin>>n>>m;
    ll sum=0;
    for(i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll cnt=0;
    for(i=1;i<=n;i++){
        double kola=(double)sum/(double)(4*m);
        if(kola<=a[i])
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes";
    else
        cout<<"No";
}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int n, ans = 1;
    cin >> n;
    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
        if (i > 0)
        {
            for (int j = 0; j < i; j++)
            {
                if (h[j] > h[i])
                {
                    break;
                }
                if (j == i - 1)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

using Long = long long;

Long Fliegel( Long y, Long m, Long d ) {
    if ( m <= 2 ) {
	m += 12;
	--y;
    }
    return (Long)(floor(365.25*y) + floor(y/400.0) - floor(y/100.0) + floor(30.59*(m-2)) + d - 678912.0);
}

int main() {

    Long mjd_base = Fliegel( 2012, 12, 21 );
    vector<Long> maya_unit( {13, 20, 20, 18, 20} );
    vector<Long> greg_unit( {0} );
    Long maya_cycle = 13*20*20*18*20;
    Long g[3], m[5];
    
    string s;
    while ( cin >> s && s != "#" ) {

	int cnt = 0;
	for ( auto& c : s ) {
	    if ( c == '.' ) {
		++cnt;
		c = ' ';
	    }
	}

	stringstream ss( s );

	if ( cnt == 2 ) {//西暦

	    ss >> g[0] >> g[1] >> g[2];
	    
	    Long mjd = (Fliegel(g[0], g[1], g[2]) - mjd_base)%maya_cycle;

	    for ( int i=maya_unit.size()-1; i>=0; --i ) {
		m[i] = mjd%maya_unit[i];
		mjd /= maya_unit[i];
	    }

	    cout << m[0] << "." << m[1] << "." << m[2] << "." << m[3] << "." << m[4] << endl;
	}
	else {//マヤ暦

	    ss >> m[0] >> m[1] >> m[2] >> m[3] >> m[4];

	    Long mjd = m[0];
	    for ( int i=1; i<maya_unit.size(); ++i ) {
		mjd *= maya_unit[i];
		mjd += m[i];
	    }
	    mjd += mjd_base;

	    mjd += 678881;
	    Long a = 4*mjd + 3 + (Long)(4*floor(3.0*floor(1.0 + 4.0*(mjd+1)/146097.0)/4.0));
	    Long b = 2 + 5*(Long)floor( (a%1461)/4.0 );

	    g[0] = (Long)floor(a/1461.0);
	    g[1] = 3 + (Long)floor(b/153.0);
	    g[2] = 1 + (Long)floor( (b%153)/5.0 );
	    if ( g[1] > 12 ) {
		g[1] -= 12;
		++g[0];
	    }
	    
	    cout << g[0] << "." << g[1] << "." << g[2] << endl;
	}
      
    }

    return 0;
}



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

nums = [int(input()) for x in range(N)]

a = sorted(nums)[-1]#max(nums)
b = sorted(nums)[-2]#max(nums.remove(max_num))



if a == b:
    for _ in nums:
        print(a)
else:
    for x in [b if x == a else a for x in nums]:
        print(x)

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    long n=in();
    cout << (n)*(n-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int like[100010];

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

	map<string, int> m;

	rep(i, n) {
		string a; cin >> a;
		sort(all(a));
		m[a]++;
	}

	int ans = 0;

	for (auto p : m) {
		ans += p.scd * (p.scd - 1) / 2;
	}

	cout << ans << endl;
}



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

using namespace std;
typedef long long lint;
typedef long double ldb;
typedef unsigned long long uli;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define I(i, a) for(auto i : a)
#define pb push_back
#define rs resize
#define mk make_pair
#define asg assign
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define era erase
#define fi0(x) memset(x, 0, sizeof(x))
#define y1 adjf

int n;
set<int> a;
int x;

int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	scanf("%d%d", &n, &x);
	if(x == 1 || x == 2 * n - 1){printf("No"); ret 0;}
	F(i, 1, 2 * n){
		if(abs(x - i) > 1)a.ins(i);
	}
	printf("Yes\n");
	int pr = (2 * n - 4)/2;
	F(i, 0, 2 * n - 1){
		if(i == pr){printf("%d\n", x - 1); cont;}
		if(i == pr + 1){printf("%d\n", x); cont;}
		if(i == pr + 2){printf("%d\n", x + 1); cont;}
		printf("%d\n", *(a.begin()));
		a.era(a.begin());
	}
	ret 0;
}

Measured memory_bytes: 10880
#include<stdio.h>
#define max 500000
#define sent 2000000000

int L[max/2+2],R[max/2+2];
int cnt;

void marge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1 = mid-left;
  int n2 = right-mid;
  for(i=0;i<n1;i++){
    L[i] = A[left +i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1] = R[n2] = sent;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}


void margesort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid = (left + right)/2;
    margesort(A,n,left,mid);
    margesort(A,n,mid,right);
    marge(A,n,left,mid,right);
  }
}


int main(){
  int A[max],i,n;
  cnt=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  margesort(A,n,0,n);

  printf("%d", A[0]);
  for(i=1;i<n;i++){
    printf(" %d", A[i]);
  }
printf("\n" );
  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 5600
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    val nums = scala.collection.mutable.Map[Int, Int]()
    for (i <- a) {
      // -1
      nums.put(i - 1, nums.get(i - 1).fold(1)(_ + 1))
      // 0
      nums.put(i, nums.get(i).fold(1)(_ + 1))
      // +1
      nums.put(i + 1, nums.get(i + 1).fold(1)(_ + 1))
    }

    println(nums.values.max)
  }
}


Measured memory_bytes: 69552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;
int main()
{
  int n, x;
  cin >> n >> x;
  int ans = n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    x -= a[i];
  }
  sort(whole(a));
  ans += (x/a[0]);
  cout << ans << endl;
  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x,int y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(int x,int y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(int x,int y)
{
    return (x%mod *1LL* y%mod)%mod;
}
inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

bool OK(vector<int>moves , int idx){
    bitset<32006>dp;
    dp[16002+idx] = 1;

    for(int m : moves){
        dp = (dp<<m) | (dp>>m);
    }
    return dp[16002];
}

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

    ///FastIO;


    string s;
    cin>>s;
    int x,y;
    cin>>x>>y;

    int turn = 0 , f = 0;
    vector<int>movex, movey;

    for(int i=0; i<s.size(); i++){
        if(s[i] == 'F') f++;
        if(s[i] == 'T' || i == s.size()-1){
            if(turn){
                movey.pb(f);
            }
            else{
                if(movex.size() == 0 && movey.size() == 0) x -= f;
                else movex.pb(f);
            }
            f = 0;
            turn ^= 1;
        }
    }

    if(OK(movex , x) && OK(movey,y)) cout<<"Yes";
    else cout<<"No";

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 384
n = int(input())
ans = 0
anss = 0
for i in range(1,n+1):
    t = 0
    while i%2 == 0:
        t +=1
        i = i/2
    if t > ans:
        ans = t
        anss = i*(2**t)
    else:
        pass

if n == 1:
    anss = 1
print(int(anss))

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    for(int i = 0;i < m;i++){
        int k;
        cin >> k;
        a[i].resize(k);
        for(int j = 0;j < k;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
  
    vector<int> p(m);
    for(int i = 0;i < m;i++) cin >> p[i];
    int ans = 0;
    for(int i = 0; i < (1<<n);i++){
      bool ok = true;
      for(int j = 0;j < m;j++){
          int c = 0;
          for(int id : a[j]){
              if((i>>id) & 1) c++;
          }
          c %= 2;
          if(c != p[j]) ok= false;
      }
      if(ok) ans++;
    }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<lint> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> bridge(M);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		bridge[i] = { a,b };
	}

	lint incon = 1LL * N * (N - 1) / 2;
	vector<lint> ans(M);
	UnionFind uf(N);
	for (int i = M - 1; i >= 0; i--) {
		ans[i] = incon;
		if (!uf.is_same(bridge[i].first, bridge[i].second)) {
			incon -= 1LL * uf.size(bridge[i].first)*uf.size(bridge[i].second);
			uf.unify(bridge[i].first, bridge[i].second);
		}
	}

	for (const auto &e : ans) cout << e << "\n";

	return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//昇順
int acs(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
  int n;
  scanf("%d", &n);
  int x[n], a[n];
  for (int i=0; i<n; i++) {
    scanf("%d", x+i);
    a[i] = x[i];
  }
  qsort(a, n, sizeof(int), acs);
  for (int i=0; i<n; i++) {
    if (x[i] <= a[n/2-1]) printf("%d\n", a[n/2]);
    else printf("%d\n", a[n/2-1]);
  }
  return 0;
}


Measured memory_bytes: 3692
n, k = map(int, input().split())
g = list(map(lambda x: int(x)-1, input().split()))

visited = [False] * n
dist = [0] * n
v = 0
leng = 0

for i in range(n+10):
    if i == k: print(v+1); exit()
    if visited[v]:
        leng = i - dist[v]
        k -= dist[v]
        break
    visited[v] = True
    dist[v] = i
    v = g[v]

for i in range(k % leng):
    v = g[v]

print(v+1)


Measured memory_bytes: 32376
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string str;
	cin>>str;
	
	if(str[0] == 'R' && str[1] == 'R' && str[2] == 'R')
	{
		cout<<3<<endl;
	}
	else if((str[0] == 'R' && str[1] == 'R') || (str[1] == 'R' && str[2] == 'R'))
	{
		cout<<2<<endl;
	}
	else if(str[0] == 'R' || str[1] == 'R' || str[2] == 'R')
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;


int main(){
	char a;
	cin >> a;
	
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
		cout << "vowel";
	else
		cout << "consonant";
	
	
	
	return 0;
};

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


int main(){
  int n,i;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(i=0;i<n;++i){
    cin >> s[i] >> t[i];
  }
  string x;
  int ha,ans;
  ha=0;
  ans=0;
  cin >> x;
  for(i=0;i<n;++i){
    if(x==s[i]){
      ha=1;
    }
    if(ha==1){
      ans=ans+t[i];
      if(x==s[i]){
        ans=ans-t[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s[2005];
int r,c;
int mat[2005][2005][4];
int row[]= {1,0,-1,0,1,-1,1,-1};
int colm[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>r>>c;
    for(int i=0; i<r; i++)
        cin>>s[i];
    for(int i=0; i<r; i++)
    {
        int cnt=0;
        for(int j=0; j<c; j++)
        {
            if(s[i][j]=='.')
                cnt++;
            else
                cnt=0;
            mat[i][j][0]=cnt;
        }
        cnt=0;
        for(int j=c-1; j>=0; j--)
        {
            if(s[i][j]=='.')
                cnt++;
            else
                cnt=0;
            mat[i][j][1]=cnt;
        }
    }
    for(int i=0; i<c; i++)
    {
        int cnt=0;
        for(int j=0; j<r; j++)
        {

            if(s[j][i]=='.')
                cnt++;
            else
                cnt=0;
            mat[j][i][2]=cnt;
        }
        cnt=0;
        for(int j=r-1; j>=0; j--)
        {

            if(s[j][i]=='.')
                cnt++;
            else
                cnt=0;
            mat[j][i][3]=cnt;
        }
    }
    int mx=0;
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
        {
            if(s[i][j]=='.')
            {
                int ans=0;
                for(int k=0; k<4; k++)
                    ans+=mat[i][j][k];
                ans-=3;
                mx=max(ans,mx);
            }
        }
    }
    cout<<mx<<endl;



    return 0;
}


Measured memory_bytes: 70300
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.14159265358979;
const int INF=1000000007;
const ll LMAX=1000000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int h,n; cin>>h>>n;
  int sum=0;
  rep(i,n){
    int a; cin>>a;
    sum+=a;
  }
  if(sum>=h)
  puts("Yes");
  else
  puts("No");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());

	ll hen1=0;
	ll hen2=0;
	ll ans;
	for(int i=n-1; i>0; i--){
		if(a.at(i)==a.at(i-1)){
			if(hen1==0){
				hen1=a.at(i);
				i--;
			}else{
				if(hen2==0){
					hen2=a.at(i);
					ans = hen1*hen2;
					cout << ans << endl;
					return 0;
				}
			}
		}
	}
	ans = hen1*hen2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int n;
    cin >> n;
    vector <string> a(n);
    for(int i=0 ; i<n ; i++){
        string x; cin >> x;
        sort(all(x));
        a[i] = x;
    }
     sort(all(a));
    // for(auto x : a)
    //     cout << x << endl;
    int ans = 0;
    int c = 1;
    for(int i=0 ; i<n-1; i++){
        if(a[i]==a[i+1])
            c++;
        else {
            ans += (c*(c-1))/2;
            c= 1;
        }
    }
    ans += (c*(c-1))/2;
    cout << ans << endl;
}

Measured memory_bytes: 5760