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

int main()
{
        float x1, y1, x2, y2, x3, y3, x4, y4;
        float vecx1, vecy1, vecx2, vecy2;

        while ( scanf( "%f %f %f %f %f %f %f %f",
                        &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4 ) == 8 ) {
                vecx1 = x1 - x2;
                vecy1 = y1 - y2;

                vecx2 = x3 - x4;
                vecy2 = y3 - y4;

                if ( vecx1 * vecx2 + vecy1 * vecy2 == 0 ) {
                        printf( "YES\n" );
                } else {
                        printf( "NO\n" );
                }
        }
        return 0;
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
const ll maxx = 2e5 + 5 ;
int main()
{
    ios;
    ll ans = 0 ;
    ll x , y ;
    cin >> x >> y;
    ll cnt = 0 ;
    while(1){
        ll next = x * 2;
        if(next <= y){
            ++ans ;
            x = next ;
        }
        else {
            br;
        }

    }
    cout << ans + 1  << el ;
    ro ;
}































Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 4000010
#define M 2010
#define mod 1000000007
#define ll long long
using namespace std;
ll fac[N],inv[N],f[M][M];
ll ksm(ll a,ll b=mod-2)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll q=ksm(a,b>>1);
	if(b&1) return q*q%mod*a%mod;
	return q*q%mod;
}
ll C(int a,int b){if(b>a || b<0) return 0;return fac[a]*inv[b]%mod*inv[a-b]%mod;}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(m==1){puts("1");return 0;}
	fac[0]=1;
	for(int i=1;i<=N-10;i++) fac[i]=fac[i-1]*i%mod;
	inv[N-10]=ksm(fac[N-10]);
	for(int i=N-11;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			const int r=n-i+(n-j+1)*(m-1)-1;
			f[i][j]=f[i-1][j]+(j?f[i][j-1]*(n-j+1)%mod*C(r,m-2):0);
			f[i][j]%=mod;
		}
	printf("%lld",f[n][n]);
	return 0;
}


Measured memory_bytes: 92928
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const ll mod = 1000000007ll;
#define MAX 200200

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll modpow(ll x, ll y, ll m){
    if(y == 0ll)return 1ll;
    ll res = 1ll, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
ll pom(ll x, ll y){
    return modpow(x, y, mod);
}

ll n, k, ans = 0;

int main(){
	scanf("%lld%lld", &n, &k);
	k = min(k, n-1);
	COMinit();
	for(ll i=0; i<=k; i++){
		ll tmp = COM(n, i);
		tmp = tmp * tmp % mod * (n-i) % mod * pom(n, mod-2) % mod;
		ans += tmp;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() 
{
    int n;
    cin >> n;
    vector<int> v(n+1);
    vector<int> v2(n+2);
    v2[0] = 0;
    v2[n+1] = 0;
    for (int i=1; i<n+1; i++)
        cin >> v2[i];
    int sum=0;
    for (int i=0; i<n+1; i++)
    {
        v[i] = v2[i+1] - v2[i];
        sum += abs(v[i]);
    }
    // for (int i=0; i<n+2; i++)
    //     cout << v2[i] << " " ;
    // cout << endl;
    // for (int i=0; i<n+1; i++)
    //     cout << v[i] << " " ;
    // return 0;
    // cout << sum;
    vector<int> res(n);
    for (int j=0; j<n; j++)
    {
        int sub = abs(v[j]) + abs(v[j+1]);
        int add = abs(v2[j+2]-v2[j]);
        res[j] = sum - sub + add;
        // int x = sum - abs(v[j]) - abs(v[j+1]) + abs(v2[j+1]-v2[j-1]);
    }
    for (int j=0; j<n; j++)
        cout << res[j] << endl;       

    return 0;
}

Measured memory_bytes: 2940
N,M = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
total = 0
Triger = 0
A.sort(reverse=True)
for i in A:
  total += i
Triger = total / 4 / M
a = 0
for j in range(M):
  if Triger > A[j]:
    a += 1
    break
if a == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
import math
a,b,C=map(int,input().split())


c=C/180*math.pi
d=math.sqrt(a**2+b**2-2*a*b*math.cos(c))
S=1/2*a*b*math.sin(c)
L=a+b+d
h=2*S/a

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))




Measured memory_bytes: 5708
N = int(input())
uvw = [list(map(int,input().split())) for i in range(N-1)]

graph = [[] for _ in range(N+1)]
for u,v,w in uvw:
    graph[u].append((v,w))
    graph[v].append((u,w))

ans = [0] * (N+1)

from collections import deque
todo = deque([(1,0)])
seen = [-1] * (N+1)

while todo:
    v,d = todo.pop()
    seen[v] = 0
    if d % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u,w in graph[v]:
        if seen[u]== 0:
            continue
        todo.append((u,d+w))

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 53420
#include <stdio.h>
int main(){

  int n,s[10000],small,i,j,blank,all;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%d",&s[i]);

  }

  for(i = 0; i < n-1; i++){

    for(j = 0; j < n-i-1; j++){
      
      if(s[j] > s[j+1]){

	blank=s[j];
	s[j]=s[j+1];
	s[j+1]=blank;

      }

    }

  }

  //printf("%d\n",s[0]);

  small=s[0];

  for(i = 1; i <= small; i++){

    all=0;
      
    for(j = 0; j < n; j++){

      if(s[j]%i == 0) all++;

    }
    
    if(all == n){
      
      printf("%d\n",i);
      
    }

  }
  
  return 0;
    
}

Measured memory_bytes: 604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var N = r.nextInt();
        var list = new List<int>();

        for(var i = 0; i < 2 * N; i++)
        {
            var L = r.nextInt();
            list.Add(L);
        }
        list.Sort();

        var ret = 0;
        for(var i = 0; i < (2 * N) - 1; i += 2)
        {
            if (list[i] == list[i + 1])
            {
                ret += list[i];
            } else
            {
                ret += list[i] > list[i + 1] ? list[i + 1] : list[i];
            }
        }

        Console.WriteLine(ret);

    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

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

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

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2904
def f(bed,cnt,left)
  return 1 if cnt == 10
  ret = 0
  left.each.with_index{|board,i|
    newleft = left.dup
    newleft.delete_at(i)
    if cnt%2==0
      c=cnt/2
      newbed=bed.map{|a|a.dup}
      newbed.each.with_index{|a,j|a[c]+=board[j]}
      if newbed.all?{|a|[2,3,5].include?(a[c])}
        ret += f(newbed,cnt+1,newleft)
      end
      newbed=bed.map{|a|a.dup}
      newbed.each.with_index{|a,j|a[c]+=board[4-j]}
      if newbed.all?{|a|[2,3,5].include?(a[c])}
        ret += f(newbed,cnt+1,newleft)
      end
    else
      r=cnt/2
      newbed=bed.map{|a|a.dup}
      newbed[r]=newbed[r].zip(board).map{|t,u|t+u}
      if newbed[r].all?{|t|[2,3,5].include?(t)}
        ret += f(newbed,cnt+1,newleft)
      end
      newbed=bed.map{|a|a.dup}
      newbed[r]=newbed[r].zip(board.reverse).map{|t,u|t+u}
      if newbed[r].all?{|t|[2,3,5].include?(t)}
        ret += f(newbed,cnt+1,newleft)
      end
    end
  }
  return ret
end


while (s=gets.chomp)!="END"
  boards=s.split.map{|t|t.chars.map{|c|c==?0?2:3}}
  bed = (0..4).map{[0]*5}
  p f(bed,0,boards)/(2**(3+boards.count{|a|a==a.reverse}))
end

Measured memory_bytes: 8868
//?????????????????????????????¢????????§???running -> printf(%d)???%.8f?????????????????£???
#include <iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
	
	int n;//n=??????????????°
	while(1){
		cin >> n;
		if(n == 0) break;
	
	
	int s[1000];//s=??????
	int i;
	double sum = 0;//????¨?????±???????sum
	
	double total = 0;
	for (i=0 ;i < n ;i++ ){
		cin >> s[i];
		sum += s[i];//????¨??????????
	}

	double m = sum/ n ;//??????
	
	double aa = 0;//?????£
	for (i=0 ;i<n ;i++){
		aa += (s[i] - m)*(s[i] - m)/n;//?????£
	}
	
	double a = sqrt(aa);//?¨??????????
	
	printf("%.4f\n" , a);
	}
	return 0;
}
	

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
string s[200010];
map<string,int>mp;
set<string>ans;
int main()
{
	int n,i,maxv=-1;
	set<string>::iterator it;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		mp[s[i]]++;
	}
	for(i=0;i<n;i++)
		maxv=max(maxv,mp[s[i]]);
	for(i=0;i<n;i++)
		if(mp[s[i]]==maxv)
			ans.insert(s[i]);
	for(it=ans.begin();it!=ans.end();it++)
		cout<<*it<<endl;
	return 0;
}

Measured memory_bytes: 37120
def main():
    n,x = map(int,input().split())
    l = list(map(int, input().split()))
    dist = 0
    count = 1
    for i in range(n):
        dist += l[i]
        if dist > x:
            break
        count += 1
    print(count)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    forn(i, s.size()) {
        cout << "x";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    from collections import deque
    n, m, *ab = map(int, open(0).read().split())
    l = [[] for _ in range(n+1)]
    for i, j in zip(*[iter(ab)] * 2):
        l[i].append(j)
        l[j].append(i)

    ll = [0 for _ in range(n+1)]
    vis = [False for _ in range(n+1)]
    que = deque()
    que.append(1)
    vis[1] = True
    while que:
        now = que.popleft()
        nx = l[now]
        for i in nx:
            if vis[i]:
                continue
            vis[i] = True
            ll[i] = now
            que.append(i)
    if all(vis[1:]):
        print("Yes")
        s = "\n".join(map(str, ll[2:]))
        print(s)
    else:
        print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 56728
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int N = int.Parse(input);
        if (N % 2 == 1) { Console.WriteLine(N/2); }
        else { Console.WriteLine(N / 2 - 1); }
    }
}


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

int DigitSum(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int X;
    cin >> X;
    int division = DigitSum(X);
    if(X % division == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int a,b;
int main()
{
    scanf("%d",&n);
    if(n==1){printf("Hello World");}
    else{
        scanf("%d%d",&a,&b);
        printf("%d",a+b);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input().split()
a_odd  = []
a_even = []
for i in range(n):
    if (i+1)%2 == 0:
        a_even.append(a[i])
    else:
        a_odd.append(a[i])
        
if n%2 == 0:
    print(" ".join(a_even[::-1] + a_odd))
else:
    print(" ".join(a_odd[::-1] + a_even))

Measured memory_bytes: 27584
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
using llint = long long int;

int n;
// vector<llint> va;
// vector<llint> vtotal;

map<llint, llint> mtotal;

llint comb(llint n, llint r)
{
  llint num = 1;
  for (llint i = 1; i <= r; i++)
  {
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main()
{
  llint ans = 0;
  cin >> n;
  // vtotal.reserve(n + 1);
  llint total = 0;
  for (int i = 0; i < n; i++)
  {
    llint x;
    cin >> x;
    total += x;
    mtotal[total]++;
  }

  ans += mtotal[0];

  for (const auto &elem : mtotal)
  {
    ans += comb(elem.second, 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int main() {
	int n , k, p[1005], tmp, output = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> p[i];
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (p[i] > p[j]) {
                tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
    for (int i = 0; i < k; i++) {
        output += p[i];
    }
    cout << output;
}

Measured memory_bytes: 3628
x,y=map(int,input().split())
tmp = abs(abs(x)-abs(y))
if (y == 0 and 0 < x) or (x == 0 and y < 0):
  print(tmp+1)
elif 0 <= x*y and x <= y:
  print(tmp)
elif 0 <= x*y and y < x:
  print(tmp+2)
else:
  print(tmp+1)

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

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(A.at(i)) == i) cnt++;
  }

  cout << cnt / 2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int n;
int q;

signed main()
{
    cin >> n;
    vi S(n);
    rep(i, n) cin >> S[i];

    cin >> q;
    vi T(q);
    rep(i, q) cin >> T[i];

    int cnt = 0;

    rep(i,q)
    {
        if(binary_search(all(S),T[i]))cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3804
X = int(input())

from math import sqrt
for i in range(1, X + 1):
    if i == 1:
        ans = i
    for b in range(2, int(sqrt(i)) + 1):
        tmp = b * b
        while tmp < i:
            tmp *= b
        if tmp == i:
            ans = i

print(ans)


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

int main(){
  string s; int K; cin >> s >> K;
  vector<string> sub;
  int count=0;
  for(int i=1; i<=min((int)s.size(),5); i++){
    for(int j=0; j<=s.size()-i; j++){
      sub.push_back(s.substr(j,i));
      count++;
    }
  }
  sort(sub.begin(),sub.end());
  string result="";
  int now=0;
  for(int i=0; i<count; i++){
    if(result!=sub[i]){
      result=sub[i];
      now++;
    }
    if(now==K){
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 1660
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] in = sc.nextLine().split(" ");
        long arg1 = Integer.parseInt(in[0]);
        long arg2 = Integer.parseInt(in[1]);
        long n = gcd(arg1, arg2);
        System.out.println(n);
    }

    static long gcd(long arg1, long arg2) {
        if (arg1 < arg2) {
            long v = arg1;
            arg1 = arg2;
            arg2 = v;
        }
        while (arg2 > 0) {
            long v = arg1 % arg2;
            arg1 = arg2;
            arg2 = v;
        }
        return arg1;
    }
}



Measured memory_bytes: 26184
#include<iostream>

int main(){

    size_t a, b, c;
    std::cin >> a >> b >> c;

    if(a == b && b != c){
        std::cout << "Yes" << std::endl;
    }else if(a == c && b != c){
        std::cout << "Yes" << std::endl;
    }else if(b == c && a != b){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

#define MAX 2000000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(int i) {
  int l, r, t, largest;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) {
    largest = l;
  } else {
    largest = i;
  }

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H; i++ ) cin >> A[i];

  for ( int i = H/2; i >= 1; i-- ) maxHeapify(i);

  for( int i = 1; i <= H; i++ ) cout << " " << A[i];

  cout << endl;

  return 0;
}


Measured memory_bytes: 4964
#include<stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b);
int main(void);
int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}
int main(void){
  int n,m,i,s;
  scanf("%d",&n);
  scanf("%d",&m);
  int x[m];
  for(i=0;i<m;i++){
    scanf("%d",&x[i]);
  }
  qsort(x,m,sizeof(int),asc);
  int y[m-1];
  for(i=0;i<m-1;i++){
    y[i] = x[i+1]-x[i];
  }
  qsort(y,m-1,sizeof(int),asc);
  s=0;
  for(i=0;i<m-n;i++){
    s = s + y[i];
  }
  printf("%d",s);
  return(0);
}


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

int main() {
    int x,ans=0;
    cin >>x;
    ans+=(x/500)*1000;
    x=x%500;
    ans+=(x/5)*5;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N;
    int a=0;
    int c[N]={0};
    for(int i=0; i<N; i++){
    cin>>c[i];}
    K=c[0];
    for(int j=0; j<N; j++){
    if(c[j]<=K){
    a++;}
    K=min(K,c[j]);}
    cout<<a<<endl;
    }


Measured memory_bytes: 1152
# ABC 118 B

import sys
import itertools

def resolve():
    N, M = map(int, input().split())
    arr = [0] * (M+1)
    for i in range(N):
        tmp = list(map(int, input().split()))
        for j in range(1, tmp[0]+1):
            arr[tmp[j]] += 1
    ans = 0
    for e in arr:
        if e == N:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int x, y;
  cin >> x >> y;
  string ans = "No";
  FOR(i, 0, x + 1) {
    if (((2 * i) + 4 * (x - i)) == y) ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); op ## op ## i)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    float n, a, b;
    cin >> n >> a >> b;
    if(b >= ceil(a / n) * n){
        cout("OK");
    }else{
        cout("NG");
    }
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N)cin>>A.at(i);
  rep(i,N){
    if(i==0)B.at(i)=0;
    else B.at(i)=2*A.at(i-1)-B.at(i-1);
  }
  ll ad=0;
  ad=2*A.at(N-1)-B.at(N-1);
  rep(i,N){
    if(i%2==0)cout<<B.at(i)+ad/2<<" ";
    else cout<<B.at(i)-ad/2<<" ";
  }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> pic;
    string line="";
    //read input
    for(int i=0;i<h;i++){
        cin >> line;
        line = '#' + line + '#';
        pic.push_back(line);
    }
    
    
    //print heder
    for(int k=0;k<(w+2);k++){
        cout << '#';
    }
    cout << endl;
    //print body
    for(int j=0;j<h;j++){
        cout << pic[j] << endl;
    }
    //print footer
    for(int k=0;k<(w+2);k++){
        cout << '#';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
    ll n,W;cin>>n>>W;
    vector <pair<ll,ll>> vec(n);
    for(int i=0;i<n;i++){
		ll x,y;cin>>x>>y;
		vec[i].first=x;
		vec[i].second=y;
    }
    vector <vector <ll>> dp(n+1,vector <ll> (W+1,0));
    for(int i=1;i<=n;i++){
		for(int j=1;j<=W;j++){
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(j-vec[i-1].first>=0){
				dp[i][j]=max(dp[i][j],vec[i-1].second+dp[i-1][j-vec[i-1].first]);
			}

			/*for(int x=0;x<=n;x++){
				for(int y=0;y<=W;y++){
					cout<<dp[x][y]<<" ";
				}
				cout<<endl;
			}
			cout<<endl;cout<<endl;*/

		}
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner

fun main(args: Array<String>){
	val sc = Scanner(System.`in`)
	val N = Integer.parseInt(sc.nextLine())

	val ans = when{
		N < 105 -> 0
		N < 135 -> 1
		N < 165 -> 2
		N < 189 -> 3
		N < 195 -> 4
		else    -> 5
	}

	println(ans)
}

Measured memory_bytes: 31272
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    cin>>a>>b;
    int x=0;
    int y=0;
    if(a=='A'){
    x=0;
    }else if(a=='B'){
    x=1;
    }else if(a=='C'){
    x=2;
    }else if(a=='D'){
    x=3;
    }else if(a=='E'){
    x=4;
    }else if(a=='F'){
    x=5;
    }
    
    if(b=='A'){
    y=0;
    }else if(b=='B'){
    y=1;
    }else if(b=='C'){
    y=2;
    }else if(b=='D'){
    y=3;
    }else if(b=='E'){
    y=4;
    }else if(b=='F'){
    y=5;
    }
    if(x>y){
        cout<<">"<<endl;
    }else if(x<y){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
}


Measured memory_bytes: 256
n=int(input())
y=list(map(int,input().split()))
from collections import Counter
lhs=Counter([j+y[j] for j in range(n)])
rhs=Counter([j-y[j] for j in range(n)])
count=0
for i in lhs:
   if i in rhs:
      count+=lhs[i]*rhs[i]

print(count)


Measured memory_bytes: 61268
from math import *
PI = 3.1415926535898
while True:
	try:
		n = input()
		base = 1
		ans = ""
		while base < n:
			base *= 2
		if base > n:
			base /= 2
		res = [base]
		n -= base
		while n > 0:
			base /= 2
			if n >= base:
				res.append(base)
				n -= base
		ans = ""
		for x in reversed(res):
			if len(ans) > 0:
				ans += " "
			ans += str(x)
		print ans
	except EOFError:
		break

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, K, Q;
	cin >> N >> K >> Q;
	vector<ll>A(Q);
	vector<ll>B(N);

	for (int i = 0; i < N; i++){
		B[i] = K;
	}

	for (int i = 0; i < Q; i++){
		cin >> A[i];
		int plus = A[i];
		B[plus-1] += 1;
	}
	for (int i = 0; i < N; i++){
		B[i] -= Q;
		if (B[i] <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}

	return 0;
}

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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,d,a,ans=0;
    cin>>n>>d>>a;
    d*=2;
    vector<pll> xh(n);
    for (int i = 0; i < n; i++)
    {
        ll x,h;
        cin>>x>>h;
        h=(h+a-1)/a;
        xh[i]=make_pair(x,h);
    }
    sort(all(xh));
    vector<ll> imos(n+1);
    ll nowBomb=0;
    
    ll l=0,r=0;
    while (l<n)
    {
        r=max(l,r);
        while (r<n-1 && xh[r+1].first-xh[l].first<=d)
        {
            r++;
        }
        nowBomb+=imos[l];
        ll needBomb=xh[l].second-nowBomb;
        if(needBomb>0)
        {
            ans+=needBomb;
            nowBomb=xh[l].second;
            imos[r+1]-=needBomb;
        }
        l++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    vector<vector<int>> d(N, vector<int>(N));
    vector<vector<int>> r(0, vector<int>(3));
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
        d[i][j] = A[i][j];
        r.push_back({A[i][j], i, j});
    }
    rep(k, N) rep(i, N) rep(j, N) {
        int x = d[i][k] + d[k][j];
        if (x < d[i][j]) {
            d[i][j] = x;
            d[j][i] = x;
        }
    }
    sort(r.begin(), r.end());
    ll ans = 0;
    rep (i, N * N) {
        int x = r[i][1], y = r[i][2], z = r[i][0];
        if (x == y) continue;
        if (A[x][y] > d[x][y]) {
            cout << -1 << endl;
            return 0;
        }
        bool f = true;
        rep(j, N) {
            if (j == x || j == y) continue;
            if (d[x][j] + d[j][y] == A[x][y]) {
                f = false;
                break;
            }
        }
        if (f) ans += A[x][y];
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 7860
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;

bool solve(int[] p, int t) {
  if (p.empty) return t == 0;
  if (t == 0) return true;
  if (t < 0) return false;
  int n = p.front;
  p.popFront;
  if (solve(p, t-n)) return true;
  if (solve(p, t)) return true;
  return false;
}

void main() {
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.map!(to!int).array;
  auto q = readln.chomp.to!int;
  auto m = readln.chomp.split.map!(to!int).array;

  foreach (m_i; m) {
    if (solve(a, m_i)) {
      "yes".writeln;
    } else {
      "no".writeln;
    }
  }
}

Measured memory_bytes: 1088
n, m = map(int, input().split())
d = []
i = 1
while i ** 2 <= m:
    if m % i == 0:
        d.append(i)
        j = m // i
        if j != i:
            d.append(j)
    i += 1
d.sort(reverse=True)
for t in d:
    if m // t >= n:
        print(t)
        exit()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (!isdigit(ch)) f=(ch=='-')?-f:f,ch=getchar();
	while (isdigit(ch)) ret=(ret<<1)+(ret<<3)+ch-48,ch=getchar();
	return ret*f;
}

inline bool check(const int &k){
	if (a[n]<=k&&(a[n-1]<=k||a[n+1]<=k)) return 1;
	if (a[n]>k&&(a[n-1]>k||a[n+1]>k)) return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k)) return 1;
        if((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k)) return 0;
    }
    return a[1]<=k;
}
int main(){
	n=read();
	for (int i=1;i<=2*n-1;i++) a[i]=read();
	int L=0,R=(n<<1)-1;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid)) R=mid-1;
		else L=mid+1;
	}
	printf("%d\n",L);
	return 0;
}

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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (int)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>

using namespace std;

int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll k , n,M=0;
    cin>>k>>n;
    vll v(n);
    fora(i,0,n)
    cin>>v[i];
    sort(all(v));
    fora(i,0,n-1)
    {
        M=max(M,v[i+1]-v[i]);
    }
    M=max(M,k-v[n-1]+v[0]);
    cout<<k-M<<endl;
    return 0;
}




Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

"""
・2,3^n,2
・3(1)
・1
・333
"""

import numpy as np

MOD = 10**9 + 7

N,A,B,C = map(int,readline().split())

if B&1:
    print(0)
    exit()

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

U = 10**5
x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)
x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

"""
・2,3^n,2：B2個
・3113：A-n個
・11：n個
・333333：m個
"""

B2 = B//2

answer = 0
for m in range(C//3+1):
    if B2 == 0:
        a = C-3*m; b = m; c = A-a
        if a < 0 or c < 0:
            continue
        x = fact[a+b+c] * fact_inv[a] % MOD
        x *= fact_inv[b]; x %= MOD
        x *= fact_inv[c]; x %= MOD
        answer += x
        continue
    n_min = max(0,A-C+3*m)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    x = fact[B2+A+m] * fact_inv[m] % MOD * fact_inv[B2] % MOD
    x *= fact_inv[A-n_min::-1]; x %= MOD
    x *= fact_inv[n_min:A+1]; x %= MOD
    # 2,3^n,2のところの3の振り分けを決める。B2個の非負整数の和がC-3m-(A-n)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    y = fact[B2-1+C-3*m-A+n_min:B2+C-3*m] * fact_inv[B2-1] % MOD
    y *= fact_inv[C-3*m-A+n_min:C-3*m+1]; y %= MOD
    answer += (x*y%MOD).sum()

answer %= MOD

print(answer)

Measured memory_bytes: 16404
#include<bits/stdc++.h>
using namespace std;
signed main()
{
 int a,b;
  cin>>a>>b;
  if((a+b)%3==0 || a%3==0 || b%3==0){
    cout<<"Possible\n";
  }else{
    cout<<"Impossible\n";
  }
}

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

using namespace std;
const int nmax = 8;
vector<vector<bool>> graph(nmax, vector<bool>(nmax, false));
vector<bool> visited(nmax, false);

int dfs(int v, int n, vector<bool> & visited){
    
    bool all_visited = true;
    
    for (int i = 0; i < n; i++){
        if(!visited[i]) all_visited = false;
    }
    
    if(all_visited) return 1;
    
    int res = 0;
    
    for (int i = 0; i < n; i++){
        if(!graph[v][i]) continue;
        if(visited[i]) continue;
        
        visited[i] = true;
        res += dfs(i, n, visited);
        visited[i] = false;
    }
    return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        
        graph[a][b] = true;
        graph[b][a] = true;
    }
    
    visited[0] = true;
    cout << dfs(0, n, visited) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

struct edge{
	int to;
	int cost;
};
class Situation{
public:
	int cost;
	int idx;
	int change;
	Situation(int cost_,int idx_,int change_){
		cost=cost_;
		idx=idx_;
		change=change_;
	}
	Situation();
	bool operator<(const Situation &s)const{
		return s.cost < this->cost;
	}
};
const int MAX_V = 101;
vector<edge> G[MAX_V];
int d[MAX_V][1001];
const int INF = 1000000000;
int m;

void dijkstra(int s){
	priority_queue<Situation> que;
	for(int i=0;i<101;i++)for(int j=0;j<1001;j++)d[i][j]=INF;
	d[s][0] = 0;
	que.push(Situation(0,s,0));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int v = p.idx;
		int k= p.change;
		if(d[v][k] < p.cost)continue;
		for(int i = 0; i < (int)G[v].size(); i++){
			edge e = G[v][i];
			if(k+1<=m&&d[e.to][k+1] > d[v][k]){
				d[e.to][k+1] = d[v][k];
				que.push(Situation(d[e.to][k+1],e.to,k+1));
			}
			if(d[e.to][k] > d[v][k] + e.cost){
				d[e.to][k] = d[v][k] + e.cost;
				que.push(Situation(d[e.to][k],e.to,k));
			}
		}
	}
}

int main(){
	int n,c;
	while(cin>>n>>m>>c&&(n|m|c)){
		for(int i=0;i<MAX_V;i++)G[i].clear();
		for(int i=0;i<m;i++){
			int f,t,ct;
			cin>>f>>t>>ct;
			edge e;
			e.cost=ct;
			e.to=t;
			G[f].push_back(e);
		}
		dijkstra(1);
		for(int i=0;i<1001;i++){
			if(d[n][i]<=c){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
INF = 1000000000

class Card:
	def __init__(self, suit, value):
		self.suit = suit
		self.value = value

	def __repr__(self):
		return self.suit + ' ' + str(self.value)


def partition(A, p, r):
	x = A[r]
	i = p - 1
	for j in range(p, r):
		if A[j].value <= x.value:
			i += 1
			A[i], A[j] = A[j], A[i]
	A[i + 1], A[r] = A[r], A[i + 1]
	return i + 1



def quickSort(A, p, r):
	if p < r:
		q = partition(A, p, r)
		quickSort(A, p, q - 1)
		quickSort(A, q + 1, r)


def merge(A, left, mid, right):
	L = A[left:mid]
	R = A[mid:right]
	L.append(Card("INF", INF))
	R.append(Card("INF", INF))
	i = 0
	j = 0
	for k in range(left, right):
		if L[i].value <= R[j].value:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1


def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)


if __name__ == "__main__":
	n = int(input())
	A = []
	for _ in range(n):
		suit, value = input().split()
		A.append(Card(suit, int(value)))

	B = A.copy()
	quickSort(A, 0, n - 1)
	mergeSort(B, 0, n)
	if A == B:
		print("Stable")
	else:
		print("Not stable")
	for card in A:
		print(card)


Measured memory_bytes: 27888
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Bits

main = do
  BS.getLine
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute as
  putStrLn $ unwords $ map show ans

compute :: [Int] -> [Int]
compute as = map (xor total) as
  where
    total = foldl1' xor as


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

void Main(){
    
}

int main(){
	int i = 1,x;

	while (1){
		cin>> x;
		if (x == 0) break;
		cout<<"Case "<<i<<": "<<x<<endl;
		i++;
	}
	return 0;
}


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

#define NMAX 400
#define INF 1000000

int max(int a,int b) {return (a>b)?a:b;}

int main(){
 
	int n,m;
	int a,b,c;
	int dp[NMAX][NMAX];

	cin>>n>>m;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j) dp[i][j]=-1*INF;
			else dp[i][j]=0;
		}
	}

	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		dp[a][b]=c;
	}

	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(dp[i][k]!=INF*-1&&dp[k][j]!=INF*-1) dp[i][j]=max(dp[i][j],dp[i][k]+dp[k][j]);
			}
		}
	}

	cout<<dp[0][n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> sort_x(n);
    rep(i, n) {
        cin >> x[i];
        sort_x[i] = x[i];
    }
    sort(sort_x.begin(), sort_x.end());
    int center_lo = sort_x[n/2-1];
    int center_hi  = sort_x[n/2];
    rep(i, n) {
        if ( x[i] <= center_lo ) {
            cout << center_hi << endl;
        }
        else {
            cout << center_lo << endl;
        }
    }
    return 0;
}


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

namespace ConsoleApp64 {
    class Program {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine());

            int ans = 1;

            for (int i = 2; i * i <= X; i++) {
                int now = 1;

                while(now <= X) {
                    now *= i;
                }

                ans = Math.Max(ans, now / i);
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<map>
#include<stack>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	int a[M],b[M];
	vector<int> arr[N];
	for(int i=0;i<M;++i){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		arr[a[i]].push_back(b[i]);
		arr[b[i]].push_back(a[i]);
	}
	/*
	for(int i=0;i<N;++i){
		for(int j=0;j<arr[i].size();++j){
			cout<<arr[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	stack<vector<int> >s;
	vector<int> path;
	path.push_back(0);
	s.push(path);
	int mark[N];
	for(int i=0;i<N;++i)mark[i]=0;
	int ans=0;
	while(!s.empty()){
		vector<int> now=s.top();
		/*
		for(int i=0;i<now.size();++i){
			cout<<now[i]<<" ";
		}
		cout<<endl;
		*/
		s.pop();
		for(int i=0;i<N;++i)mark[i]=0;
		for(int i=0;i<now.size();++i){
			mark[now[i]]=1;
		}
		for(int i=0;i<arr[now[now.size()-1]].size();++i){
			if(mark[arr[now[now.size()-1]][i]]!=1){
				now.push_back(arr[now[now.size()-1]][i]);
				s.push(now);
				now.erase(now.end()-1);
			}
		}
		if(now.size()==N) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
from sys import stdin
import itertools
n,m,x = [int(x) for x in stdin.readline().rstrip().split()]
a = []
for i in range(n):
    a.append([int(x) for x in stdin.readline().rstrip().split()])
k = list(itertools.product(range(0,2), repeat=n))
ans = -1
for i in range(len(k)):
    b = [0]*m
    money = 0
    o = 1
    for j in range(n):
        if k[i][j] == 1:
            for l in range(m):
                b[l] += a[j][l+1]
            money += a[j][0]
    for j in range(m):
        if b[j] < x:
            o = 0
            break
    if o == 1:
        if ans == -1:
            ans = money
        else:
            ans = min(ans,money)
print(ans)
        

Measured memory_bytes: 68976
def main():
  n = int(input())
  R = [list(map(int, input().split())) for _ in range(n)]
  B = [list(map(int, input().split())) for _ in range(n)]
  
  R = sorted(R, key=lambda p:p[1], reverse=True)
  B = sorted(B)
  ans = 0
  
  for xB, yB in B:
    for xR, yR in R:
      if xR < xB and yR < yB:
        R.remove([xR, yR])
        ans += 1
        break
  print(ans)

if __name__=="__main__":
  main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
vector<int>vec[109];

int main(){
  int n,d;
  cin>>n>>d;
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      int x;
      cin>>x;
      vec[i].push_back(x);
    }
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int sum=0;
      for(int k=0;k<d;k++){
	sum+=(vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);
      }
      for(int k=0;k<1000;k++){
	if(k*k==sum){
	  ans++;
	  break;
	}
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k-a<=0){
    cout<<1*k<<endl;
  }
  else if(k-a>0&&k-a-b<=0){
    cout<<1*a<<endl;
  }
  else if(k-a-b>0){
    cout<<1*a-1*(k-a-b)<<endl;
  }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++)
#define forever while(true)
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	forever
	{
		bool a[500][500];
	for (int i = 0; i < 500; i++) {
		for (int j = 0; j < 500; j++) {
			a[i][j] = false;
		}
	}
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) { break; }
		int p, q;
		roop(i, m) {
			cin >> p >> q;
			a[p - 1][q - 1] = true;
			a[q - 1][p - 1] = true;
		}
		bool ans[500];
		for (int i = 0; i < 500; i++) {
			ans[i] = false;
		}
		for (int i = 1; i < n; i++) {
			if (a[0][i]) { ans[i] = true; }
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (i == j) { continue; }
				if (a[0][i] && a[i][j]) { ans[j]=true; }
			}
		}
		int answer = 0;
		for (int i = 1; i < 500; i++) {
			if (ans[i]) { answer++; }
		}cout << answer<<endl;
	}
	return 0;
}




Measured memory_bytes: 3376
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int acnt[100001];
int bcnt[100001];

int main(){
  int a,b;
  int i;
  long long ans = 1;

  scanf("%d %d", &a, &b);

  for(i = 0;i < 100001;i++){
    acnt[i] = 0;
    bcnt[i] = 0;
  }

  for(i = 2;i <= a;i++){
    while(a % i == 0){
      acnt[i]++;
      a /= i;
    }
    if(a == 1) break;
  }
  acnt[a]++;

  for(i = 2;i <= b;i++){
    while(b % i == 0){
      bcnt[i]++;
      b /= i;
    }
    if(b == 1) break;
  }
  bcnt[b]++;

  for(i = 2;i <= 100000;i++){
    if(acnt[i] != 0 || bcnt[i] != 0){
      if(acnt[i] > bcnt[i]) ans = ans*pow(i,acnt[i]);

      else ans = ans*pow(i,bcnt[i]);
    }
  }

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

  return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
el = list(range(1, M + 1))
for _ in range(N):
    A = [int(x) for x in input().split()[1:]]
    for i, f in enumerate(el):
        if f not in A:
            el[i] = -1
print(len([x for x in el if x >= 1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    cin>>S>>Q;
    string rev_f, b;
    rev_f = b = "";
    bool rev = false;
    rep(i,Q){
        cin>>A;
        if(A == 1) {
            rev = !rev;
        }else{
            char c;
            cin>>B>>c;
            --B;
            if(B^rev){
                b.push_back(c);
            }else{
                rev_f.push_back(c);
            }
        }
    }
    reverse(ALL(rev_f));
    rev_f.append(S);
    rev_f.append(b);
    if(rev) reverse(ALL(rev_f));
    cout<<rev_f<<endl;
}

Measured memory_bytes: 1348
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#define N 110000
using namespace std;
int n,a[N],cnt;
int p1,p2; 
int main()
{
//	freopen("Decrementing.in","r",stdin);
//	freopen("Decrementing.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(;;)
    {
        for(int i=1;i<=n;i++)
        if(a[i]&1)++p1;
        else ++p2;
		if(p2&1)break;
        else if(p1>=2){++cnt;break;}
        bool flag=0;
        for(int i=n;i;i--)
        if(a[i]&1){
		  if(a[i]==1)flag=1;
		  else --a[i];
		  break;
        }
        if(flag){++cnt;break;}
        int gd=a[1];
        for(int i=2;i<=n;i++)gd=__gcd(gd,a[i]);
        for(int i=1;i<=n;i++)a[i]/=gd;
        ++cnt,p1=p2=0;
    }
    if(n==1||(cnt&1))puts("Second");
    else puts("First");
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

double dp[310][310][310];
// ここに「メモ」する。
// メモしてない場合は -1 であるように main でセット。

int N;
// 入力だけど、この値を rec の中でも使う

double rec(int i, int j, int k){
    // メモ化再帰
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return 0.0;

    // 返り値の計算
    double res = 0.0;
    // (再帰の)子が存在するか確かめてからね。
    if(i > 0) res += i * rec(i-1, j, k);
    if(j > 0) res += j * rec(i+1, j-1, k);
    if(k > 0) res += k * rec(i, j+1, k-1);
    res += N;
    res *=  1.0 / (i + j + k);

    // メモしながら返す。
    return dp[i][j][k] = res;
}

int main(void){
    cin >> N;
    /* rec の 引数は、
    i : 残りの寿司の数が1つの皿の数
    j : 残りの寿司の数が2つの皿の数
    k : 残りの寿司の数が3つの皿の数
    である。
     */
    int one = 0, two = 0, three = 0;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        if(a == 1) one++;
        else if(a == 2) two++;
        else if(a == 3) three++;
    }

    // dpテーブルを -1 で初期化(この書き方便利)
    memset(dp, -1, sizeof(dp));

    cout << setprecision(20) << rec(one, two, three) << endl;
    return 0;
}

Measured memory_bytes: 233088
import math
import sys
from collections import Counter
import bisect
readline = sys.stdin.readline


def main():
    cnt = 0
    arg = 0
    x = int(readline().rstrip())
    for i in range(1000):
        cnt += 1
        arg += x
        arg %= 360
        if arg == 0:
            break
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9300