akhauriyash/Code-Regression huggingface dataset:
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define bp __builtin_popcountll
#define MOD  1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
const int N = 200005;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
set<string> s;
ll n;
void solve(string t)
{
	ll chk = 1;
	map<char,bool> y;
	ll tot = 0;
	vector<ll> v;
	for(ll i=0;i<n;i++)
	{
		if(t[i]=='#')  v.pb(i),tot++;
		y[t[i]] = 1;
	}	
	if(!tot)   
	{
		s.insert(t);
	}
	else
	{
        char small = 'a';
        while(y[small])  small++;
        string o;
        o = t;
        o[v[0]] = small;
        solve(o);
        ll start = (1<<(tot-1));
        ll end = (1<<tot);
        for(ll i=start;i<end;i++)
        {
        	o = t;
            ll cnt = bp(i);
            if(cnt==1)   continue;
            for(ll j=0;j<tot;j++)
            {
            	if(i & (1<<j))
            	{
                     o[v[tot-1-j]] = small;    
            	}
            }
            solve(o);
        }
	}
}
void solve()
{
    string t;
    cin >> n;
    for(ll i=0;i<n;i++)  t += '#';
    solve(t);
    for(auto X:s)   cout<<X<<"\n";
}
 
int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
    	solve();
    }
}

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

int main(){
    string code;
    cin >> code;
    bool flag {false};
    for(int i = 1;i < 4;i++){
        if (code[i-1] == code[i]){ flag = true;}
    }
    if(flag){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
    return 0;
}

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

using ll=long long;

int main() {
    ll i,j,n,r=0;
    string S;
    cin >> S;
    n = S.size();

    for(i=0; i<(1<<(n-1)); i++) {
        ll t=S.at(0)-'0', tt=0;
        for(j=0; j<n-1; j++) {
            if(1<<j & i) {
                if(j<n-2) {
                    tt += t;
                    t = 0;
                }
            } else {
                t *= 10;
            }
            t += S.at(j+1)-'0';
        }
        tt += t;
        r += tt;
    }

    cout << r << endl;
}

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

const int maxn = 2e5+5;
int n, a[maxn];

map<int,int> mp;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    int ans = 0;
    for (int k = 31; k >= 0; k--) {
        for (int i = 0; i < n; i++) {
            if (!mp.count(a[i])) continue;
            int t = (1<<k)-a[i];
            //cout << a[i] << ' ' << t << ' ' << mp.count(t) << endl;
            if (mp.count(t) && (t != a[i] || (t == a[i] && mp[t] > 1))) {
                if (--mp[t] == 0) mp.erase(t);
                if (--mp[a[i]] == 0) mp.erase(a[i]);
                //cout << t << ' ' << a[i] << '\n';
                ans++;
            }
        }
    }
    cout << ans << '\n';
}



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

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  double conc = 0;
  int ansswater = 0;
  int anssuger = 0;
  vector<int> water(31,0);
  for (int i=0; i<31; i++){
    if (i == 0) water[i] = 1;
    else if ((i*100 <= F) && (((i-A >= 0) && (water[i-A] == 1)) || ((i-B >= 0) && (water[i-B] == 1)))) water[i] = 1;
  }
  for (int i=0; i<31; i++){
    if (water[i] == 0) continue;
    vector<int> suger(i*E+1,0);
    for (int j=0; j<i*E+1; j++){
      if (100*i+j>F) break;
      if (j==0) suger[j] = 1;
      else if(((j-C >= 0) && (suger[j-C] == 1)) || ((j-D >= 0) && (suger[j-D] == 1))) suger[j] = 1;
    }
    for (int j=i*E; j>-1; j--){
      if (suger[j] == 1){
        if (conc <= (double)100.0*j/(100.0*i+j)){
          conc = 100.0*j/(100.0*i+j);
          ansswater = 100*i+j;
          anssuger = j;
        }
        break;
      }
    }
  }
  cout << ansswater << ' ' << anssuger << endl;
}


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

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

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

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    
    int a = ( n + (x-1) ) / x;
    int ans = a * t;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,M,X,Y; cin >> N >> M >> X >> Y;
  int max_x = -200;
  int min_y = 200;
  rep(i,N) {
    int x; cin >> x;
    max_x = max(max_x, x); 
  }
  rep(i,M) {
    int y; cin >> y;
    min_y = min(min_y, y); 
  }
  bool war = true;
  if(min(Y,min_y) > max(X,max_x)) war = false;
  cout << (war ? "War" : "No War") << endl;  
  return 0;
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int D, N;
  cin >> D >> N;

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (int)pow(100, D);
  }
  if (N == 100) {
    ans += (int)pow(100, D);
  }
  // ll ans = (ll)N * (ll)pow(100, D);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 760
#include <iostream>

using namespace std;

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


  if (N & 1) {
    cout << "No" << endl;
  } else {
    bool can = true;
    for (int i = 0, j = N /2; i < N/2 && j < N; j++,i++) {
      if (S[i] != S[j]) can = false;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		double ans = 0;
		if(n<k) {
			long count = 0;
			for(int i=1;i<=n;i++) {
				int tmp_count = 1;
				while((i<<tmp_count)<k) {
					tmp_count++;
				}
				count += 1<<(20-tmp_count);
			}
			ans = (double)count/(double)(1<<20)/n;
		}else {
			long count = 0;
			for(int i=1;i<=k-1;i++) {
				int tmp_count = 1;
				while((i<<tmp_count)<k) {
					tmp_count++;
				}
				count += 1<<(20-tmp_count);
			}
			double ans1 = (double)(n-k+1)/(double)n;
			double ans2 = (double)count/(double)(1<<20)/n;
			ans = ans1 + ans2;
		}
		System.out.println(ans);
		in.close();
	}

}


Measured memory_bytes: 21204
import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();

            if(n==0 && x==0) break;
            int count=0;
            for(int i=1; i<n; ++i){
                for(int j=i; j<n; ++j){
                    if(i==j) {
                        continue;
                    }
                    int num = x - (i+j);
                    if(num<1) {
                        break;
                    }
                    if(num<j) {
                        break;
                    }
                    if(i != num && j != num && num <= n) {
                        count++;
                    }
                    num = 0;
                }
            }
            System.out.println(count);}
    }
}

Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n;
    vector<LL> a;
    Problem(LL n):n(n),a(n){};

    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        LL cnt[2]={},sum[2]={};
        //plus
        if(a[0]<=0){
            cnt[0]=1-a[0];
            sum[0]=1;
        }else{
            sum[0]=a[0];
        }
        for(int i=1; i<n; ++i){
            LL s= sum[0]+a[i];
            if(sum[0]< 0 and s<=0){
                cnt[0]+=1-s;
                sum[0]=1;
            }else if (sum[0]>0 and s>=0){
                cnt[0]+=s+1;
                sum[0]=-1;
            }else{
                sum[0]+=a[i];
            }
            DBG(sum[0],cnt[0])
        }
        //minus
        if(a[0]>=0){
            cnt[1]=a[0]+1;
            sum[1]=-1;
        }else{
            sum[1]=a[0];
        }
        for(int i=1; i<n; ++i){
            LL s= sum[1]+a[i];
            if(sum[1]< 0 and s<=0){
                cnt[1]+=1-s;
                sum[1]=1;
            }else if (sum[1]>0 and s>=0){
                cnt[1]+=s+1;
                sum[1]=-1;
            }else{
                sum[1]+=a[i];
            }
            DBG(sum[1],cnt[1])
        }
        DBG(cnt[0],cnt[1])
        cout << min<LL>(cnt[0],cnt[1]) <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



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

const int N = 200005;

int main() {
   string s, t;
   cin >> s >> t;
   sort(s.begin(), s.end());
   sort(t.rbegin(), t.rend());
   if(s < t) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
   return 0;
}


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

using namespace std;

int p,q,r;

int formula(string & str , int & i){
    int rtn;
    char c = str[i++];
    switch (c){
    case '0':
    case '1':
    case '2':
        rtn = c - '0';
        break;
    case 'P':
        rtn = p;
        break;
    case 'Q':
        rtn = q;
        break;
    case 'R':
        rtn = r;
        break;
    case '-':
        rtn = 2 - formula(str,i);
        break;
    case '(':
        int rhs = formula(str,i);
        //i++; // )
        char op = str[i++];
        //i++;
        int lhs = formula(str,i);
        if(op == '+') rtn = max(rhs,lhs);
        if(op == '*') rtn = min(rhs,lhs);
        i++;
        break;
    }
    return rtn;
}

int main(){
    string str;
    while(cin >> str , str != "."){
        int c=0;
        for(p=0; p<3; p++){
            for(q=0; q<3; q++){
                for(r=0; r<3; r++){
                    int i=0;
                    if(formula(str,i) == 2) c++;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(){
  int i,j,num[10],temp;
  for(i=0;i<=9;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<=2;i++){
    for(j=i+1;j<=9;j++){
      if(num[i]<num[j]){
        temp=num[i];
        num[i]=num[j];
        num[j]=temp;
      }
    }
    printf("%d\n",num[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void)
{
        int n;
        int b = 0;
        int i;

        scanf("%d", &n);

        int a[n];

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

        for(i = 0; i < n - 2; i++){
                if((a[i] > a[i + 1] && a[i + 1] > a[i + 2]) || (a[i] < a[i + 1]
&& a[i + 1] < a[i + 2])){
                        b++;
                }
        }

        printf("%d\n", b);

        return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define drep(i,n) for (int i = n-1; i >= 0; --i)
using namespace std;
inline int in() { int x; scanf("%d", &x); return x;}
typedef vector<int> vi;

int main() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vi x(n), f(n);
  rep(i,n) {
    cin >> x[i];
  }
  int cnt = 0;
  rep(i,n) {
    if (x[i] < a) break;
    f[i] = 1; cnt++;
  }
  if (n-cnt < m) {
    drep(i,n) {
      if (!f[i]) continue;
      if (x[i] > b) break;
      f[i] = 0; cnt--;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

void dfs(int node, vector<int> adj[], int dp[], bool vis[]){
	vis[node] = true;
	for(int i=0; i<adj[node].size(); i++){
		if(!vis[adj[node][i]]){
			dfs(adj[node][i], adj, dp, vis);
		}
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	}
}

void addEdge(vector<int> adj[], int u, int v){
	adj[u].push_back(v);
}

int findLongestPath(vector<int> adj[], int n){
	int dp[n+1];
	bool vis[n+1];
	memset(dp, 0, sizeof dp);
	memset(vis, false, sizeof vis);

	for(int i=1; i<=n; i++){
		if(!vis[i]){
			dfs(i, adj, dp, vis);
		}
	}
	
	int ans = 0;
	for(int i=1; i<=n; i++){
		ans = max(ans, dp[i]);
	}
	return ans;
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> adj[n + 1]; 
	for(int i=0; i<m; i++){
		int u,v;
		cin>>u>>v;
		addEdge(adj, u, v);
	}
//	for(int j=1; j<=n; j++){
//		cout<<j<<"->";
//		for(int i=0; i<adj[j].size(); i++){
//			cout<<adj[j][i]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<findLongestPath(adj, n);
}

Measured memory_bytes: 9600
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

ll dp[310][310]; // rightest, size
int main(void){
    ll n,k;cin >> n >> k;
    vector<ll> h(n+1,0);
    rep(i,n)cin >> h[i+1];

    const long long INF = 1001001001000;
    for (int i = 0; i < 310; ++i)
    {
        for (int j = 0; j < 310; ++j)
        {
            dp[i][j] = INF;
        }
    }

    //dp[1][0] = 0;
    dp[0][0] = 0;
    for(int x = 1;x <= n;x++){ // 選ぶ集合のうち最も右側のもの
        for(int y = 1;y <= x;y++){ //　いくつ選んだか
            ll _min = INF;
            for(int z = 0;z < x;z++){
                mins(_min , dp[z][y - 1] + max(0ll,h[x] - h[z]));
            }
            dp[x][y] = _min;
        }
    }
    ll ans = INF;
    for(int i = 0;i < 310;i++)mins(ans,dp[i][n - k]);
    cout << ans << endl;

}

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

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    print(min({p + q, q + r, p + r}));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200 + 10;
ll a[maxn];

const int L = 63;
ll d[L];
bool add(ll x){
    for(int i = L - 1; i >= 0; i--) if(x & 1ll << i){
        if(d[i] == -1){d[i] = x; return true;}
        x ^= d[i];
    }
    return false;
}

int main(){
//    Fast;
    int t; scanf("%d", &t); while(t--){
        memset(d, -1, sizeof d);

        int n; scanf("%d", &n);
        for(int i = 0; i < n; i++) scanf("%lld", a + i);
        char s[maxn]; scanf("%s", s);
        int flag = 0;
        for(int i = n - 1; i >= 0; i--){
            if(add(a[i]) && s[i] == '1'){
                flag = 1;
                break;
            }
        }
        printf("%d\n", flag);
    }
    return 0;
}



Measured memory_bytes: 3812
fun main(args: Array<String>) {
    val (n,m)= readLine()!!.split(" ").map { it.toInt() }
    val dp = IntArray(n+2)
    dp[0] = 1
    val broken = (1..m).map { readLine()!!.toInt() }.toSet()

    (0..n-1).forEach { i ->
        dp[i+1] += if((i+1) in broken) 0 else dp[i]
        dp[i+2] += if((i+2) in broken) 0 else dp[i]
        dp[i+1] %= 1000000007
        dp[i+2] %= 1000000007
    }
    println(dp[n])
}

Measured memory_bytes: 47784
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
    // 入力
    ll N;
    cin>>N;
    vector<ll> dist(N+1,-1);
    vector<vector<pair<int, int>>> childdist(N+1);
    stack<ll> stack;
    ll u,v,w;
    FOR(i,1,N-1){
        cin>>u>>v>>w;
        childdist[u].emplace_back(v,w%2);
        childdist[v].emplace_back(u,w%2);
    }
    dist[1]=0;
    stack.push(1);
    bool pop=false;
    ll ver=-1;
    vector<ll> init(N+1,0);
    while(stack.empty()==false){
        ver=stack.top();
        pop=true;
        FOR(i,init[ver],childdist[ver].size()-1){
            init[ver]++;
            if(dist[childdist[ver][i].first]==-1){
                dist[childdist[ver][i].first]=(dist[ver]+childdist[ver][i].second)%2;
                stack.push(childdist[ver][i].first);
                pop=false;
                break;
            }
        }
        if(pop) stack.pop();
        // if(stack.empty()==false) cout<<"pop "<<stack.top()<<endl;
        // cout<<"while"<<endl;
        // if(stack.empty()==false) cout<<"whiletop"<<stack.top()<<endl;
    }

        // cout<<"whileend"<<endl;
    FOR(i,1,N){
        cout<<dist[i]%2<<endl;
    }


    return 0;
}

Measured memory_bytes: 7936
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N = in();
	vint A(N);
	rep(i,N) A[i] = in();
	vint B = A;
	sort(B.begin(), B.end());
	int s = B[N / 2 - 1], t = B[N / 2];
	rep(i,N) {
		if (A[i] >= t) cout << s << endl;
		else cout << t << endl;
	}
	return 0;
}


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

int main()
{
    int a,b,x,y;
    double z;

    cin >> a >> b;
    x = a / b;
    y = a % b;
    z = (1.0 * a) / b;

    printf("%d %d %.5f\n",x,y,z);
    
    return 0;
}


Measured memory_bytes: 3204
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
A = LI()
A.sort()
if k % 2 and all([a < 0 for a in A]):
    ret = 1
    A.reverse()
    for i in range(k):
        ret = ret * A[i] % mod
    print(ret)
    exit()

i = 0
ret = A.pop() if k % 2 else 1
while k > 1:
    x = A[i] * A[i + 1]
    y = A[-1] * A[-2]
    if y > x:
        A.pop()
        A.pop()
        ret = ret * y % mod
    else:
        ret = ret * x % mod
        i += 2
    k -= 2
    ret %= mod

print(ret)





Measured memory_bytes: 123008
#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>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)

using namespace std;


int main(void){
    string s;
    cin >> s;

    string sbs = s.substr(0,5);
    string sbs2 = s.substr(6,7);
    string sbs3 = s.substr(14,5);

    cout << sbs << ' ' << sbs2 << ' ' << sbs3 << endl;

    

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String str=br.readLine();
		String[] num=str.split(" ");
		int a=Integer.parseInt(num[0]);
		int b=Integer.parseInt(num[1]);
		
		int d=a/b;
		int r=a%b;
		String f=String.format("%.5f",(double)a/b);
		
		System.out.println(d+" "+r+" "+f);
	}
}

Measured memory_bytes: 24804
from math import sqrt
n = int(input())
p = []
for _ in range(n):
    x, y = map(int, input().split())
    p.append([x, y])

cnt = 0
total = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        cnt += 1
        xi, yi = p[i]
        xj, yj = p[j]
        total += sqrt((xi - xj) ** 2 + (yi - yj) ** 2)

ans = total / cnt * (n - 1)
print(ans)


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

int main(){
  int a, b;
  cin >> a >> b;
  bool ans = false;
  for (int i = 1; i <= 3; ++i) {
    if(a * b * i % 2) ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const int INF = 1000000007;
const int MOD = 1000000007;

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

int main(){
    int n, m, k;
    while(true){
        scanf("%d%d%d", &n, &m, &k);
        if((n|m|k) == 0) break;
        vector<double> ep(n * m + 1);
        fill(ep.begin(), ep.end(), 0);
        ep[0] = 1;
        for(int i = 0; i < n; ++i){
            for(int j = m * i; j >= 0; --j){
                for(int l = 1; l <= m; ++l){
                    if(j + l > n * m) break;
                    ep[j + l] += ep[j] / m;
                }
                ep[j] = 0;
            }
        }
        double ans = 0;
        for(int i = 0; i <= n * m; ++i){
            ans += max(i - k, 1) * ep[i];
        }
        printf("%.12f\n", ans);
        ep.clear();
    }
    
    return 0;
}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int sum=0;
    for (int i=0;i<s.size();i++){
        sum+=(s[i]-'0');
        sum%=9;
    }
    cout<<(sum==0?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3776
n = int(input())
#n,k = map(int,input().split())
a = list(map(int,input().split()))
#mod = pow(10,9) + 7
sum = 0
for i in range(1,n+1):
    if i%2 == 1 and a[i-1]%2 ==1:
        sum += 1
print(sum)
'''
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
print(a)
'''

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

vector<vector<int> > g;
int dp[110000];

int main(void){
  int H, W;
  cin >> H >> W;
  int const MOD = 1e9+7;
  char a[H][W];
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) cin >> a[i][j];
  int dp[H][W];
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  bool used[H][W];
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) used[i][j] = false;
  
  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));

  while(que.size()){
    auto q = que.front(); que.pop();
    int y = q.first;
    int x = q.second;
//    cout << x << ", " << y << endl;
    if(used[y][x]) {continue;}
    used[y][x] = true;
    if(x < W-1 && a[y][x+1] != '#'){
      dp[y][x+1] += dp[y][x];
      dp[y][x+1] %= MOD;
      que.push(make_pair(y, x+1));
    }
    if(y < H-1 && a[y+1][x] != '#'){
      dp[y+1][x] += dp[y][x];
      dp[y+1][x] %= MOD;
      que.push(make_pair(y+1, x));
    }
  }

//  for(int i=0; i<H; i++) {for(int j=0; j<W; j++) {cout << dp[i][j] << " ";} cout << endl;};
  cout << dp[H-1][W-1] << endl;  
  return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(b == 0) return a;
	return gcd(b,a % b);
}

signed main(){
	int a,b,k,g,cnt = 0;
	cin >> a >> b >> k;
	g = gcd(a,b);
	for(int i = g;i >= 1;i--){
		if(g % i == 0) cnt++;
		if(cnt == k){
			cout << i << endl;
			return 0;
		}
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll D, G;
	cin >> D >> G;
	vector<ll> p(D), c(D);
	REP(i, D) cin >> p[i] >> c[i];

	ll stmax = 1<<D;
	vector<bool> bits(D);
	ll res = 100000000;
	REP(i, stmax-1){
		REP(j, D){
			bits[j] = (i>>j & 1);
		}
		ll solved = 0;
		ll score = 0;
		REP(j, D){
			if(bits[j]){
				solved += p[j];
				score += (100*(j+1)*p[j]+c[j]);
			}
		}
		if(score < G){
			ll maxind = -1;
			REP(j, D) if(!bits[j] && maxind<j) maxind = j;
			REP(j, p[maxind]){
				solved += 1;
				score += 100*(maxind+1);
				if(j==p[maxind]-1) score += c[maxind];
				if(score>=G) break;
			}
		}
		if(score >= G){
			res = min(res, solved);
		}
	}
	cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> A;
    int i;

    for(i=0;i<N;i++){
        int Ai;
        cin >> Ai;
        A.emplace_back(Ai,i+1);
    }

    sort(A.begin(),A.end());

    for(auto v : A){
        cout << v.second << endl;
    }

    if(A.empty()==true){
        puts("Empty");
    }

}

Measured memory_bytes: 1780
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }
    // annotate for rust-analyzer
    let mut a: Vec<u64> = a;

    a.sort();
    a.reverse();
    let ans: u64 = (0..n - 1).map(|x| a[(x + 1) / 2]).sum();

    println!("{}", ans);
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,e,m,n,t;
    string s1,s2, s3;
    
    /*
    cin>>t;
    while(t--)
    {
        
    }
    */
    cin>>a>>b>>c;
    if(a>0&&c>0)
    {
        if(a>=c)
        {
            a=a-c;
            c=0;
        }
        else
        {
            c=c-a;
            a=0;
        }
    }
    if(b>0&&c>0)
    {
        if(b>=c)
        {
            b=b-c;
            c=0;
        }
        else
        {
            c=c-b;
            b=0;
        }
    }
    cout<<a<<" "<<b;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char t[1121];
int p[187]; /*187 primes*/
int s[15][1121];

void createtable(){
  int i=2,j;
  for(;i<=1120;i++)
    if(!t[i])
      for(j=i*2;j<=1120;j+=i)
        t[j]=1;
  for(i=2,j=0;i<=1120;i++)
    if(!t[i])p[j++]=i;
}

void createsum(){
  /* http://inazz.jp/pku/3132/ */
  int i=0,k,n;
  s[0][0]=1;
  for(;i<187;i++)
    for(k=14;k;k--)
      for(n=p[i];n<1121;n++)
        s[k][n]+=s[k-1][n-p[i]];
}

int main(){
  int n,k;
  createtable();
  createsum();
  while(scanf("%d%d",&n,&k)&&n)printf("%d\n",s[k][n]);
  return 0;
}

Measured memory_bytes: 668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007
#define MSG(a) cout << #a << " " << a << endl;
#define print(a) cout << a << endl;
template <class T, class C>
void chmax(T &a, C b)
{
    a > b ?: a = b;
}
template <class T, class C>
void chmin(T &a, C b) { a < b ?: a = b; }

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

// vector の出力
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    size_t last = v.size() - 1;
    for (size_t i = 0; i < v.size(); ++i)
    {
        out << v[i];
        if (i != last)
            out << " ";
    }
    return out;
}

int main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //////////////////////////////////////////

    string s;
    cin >> s;
    int l = s.length() - 1;
    if (l % 2 == 1)
    {
        l -= 1;
    }
    while (l > 0)
    {
        if (s.substr(0, l / 2) == s.substr(l / 2, l / 2))
        {
            print(l);
            return 0;
        }

        l -= 2;
    }
    print(0);

    return 0;
}


Measured memory_bytes: 3660
import java.util.*;

public class Main{
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    
    double tan;
    
	double temp = (double) a*a*b/2.0d;
    
    if (x <= temp) {
      tan = (double)a*b*b/(2.0d*x);
    } else {
      tan = (double)2.0d*(a*a*b-x)/(a*a*a);
    }
    
    double result = Math.toDegrees(Math.atan(tan));
    
    System.out.println(result);
    
  }
}

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

int main() {
	int N, a, b, c = 1'000'000'000;
	cin >> N;
	for (; N; --N) {
		cin >> a;
      	b = 0;
		while (a % 2 == 0) {
			a /= 2;
			++b;
		}
		if (b < c)
			c = b;
	}
	cout << c;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int n, k;

vector<pair<int, int>> s;
int main()
{
    cin >> k >> n;
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        s.emplace_back(b, a);
    }
    sort(s.begin(), s.end());
    int mx = -1, t = 0;
    for (int i = 0; i < n; ++i)
    {
        int b = s[i].first;
        int a = s[i].second;
        if (a >= mx)
            mx = b, ++t;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	ll ans = s[0] - '0';
	ll ans2 = 0;
	FOR(i,0,s.size())ans2 += s[i] - '0';
	ans--;
	ans += (s.size()-1)*9;
	cout<<max(ans,ans2)<<endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
int main() {
	ll x, y,ans=0;
	cin >> x >> y;
	while (x <= y) {
		x *= 2;
		++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;

    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}



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

typedef long long ll;
#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(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) cout << a - 1 << endl;
    else cout << a << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forr(a,b,v) for(int v=a; v<=b; v++)
#define ford(a,b,v) for(int v=a; v>=b; v--)
const int N = 100005;
int main () {
    int n;
    int A[N];
    // store the sum of the result in a long long pair
    ll s = 0;
    cin >> n;
    forr(1,n,i) {
        cin >> A[i];
    }

    forr(1,n-2,i) {
        if (A[i] < 0) {
            A[i] *= -1;
            A[i+1] *= -1;
        }
        s += A[i];
    }
    // if n is 2, we only need to consider those
    // Also , if the last 2 elements are either both positive 
    // or both negative then we simply flip their signs too
    if ( (n==2) or 
         (A[n] > 0 and A[n-1] > 0) or 
         (A[n] < 0 and A[n-1] < 0) ) {
        s += max(A[n-1] + A[n], -A[n-1]-A[n]);
    }
    else {
        // find the min element in the list (excluding last 2 elements)
        int* mni = min_element( A+1, A+n-2);
        int mnv = *mni;

        if ( mnv > min(abs(A[n-1]), abs(A[n])) ) {
            s += max(A[n-1] + A[n], -A[n-1]-A[n]);
        }
        else {
            s -= mnv * 2;
            s += abs(A[n-1]);
            s += abs(A[n]);
        }
    }

    cout << s << endl;
    return 0;
}


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

signed main() {
  int N,K;
  cin>>N>>K;
  std::vector<int> v(26,0);
  for(int i=0;i<N;i++){
    string s;cin>>s;
    v[s[0]-'A']++;
  }
  int ans=0;
  sort(v.begin(),v.end());
  while(v[25]){
    for(int i=0;i<K;i++)v[25-i]--;
    sort(v.begin(),v.end());
    if(v[0]>=0)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n,k;
	cin >> n >> k;
	vll a(n);
	fi(n) cin >> a[i];
	ll lo = 1, hi = 1e9;
	while(lo < hi){
		ll mid = lo + (hi-lo)/2;
		ll z = 0;
		fi(n) z+=((a[i]+mid-1)/mid-1);
		if(z <= k) hi = mid;
		else lo = mid+1;
	}
	cout << lo;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <cstdio>
#define N 25
using namespace std;

int h, w, mx, d[N][N][N][N];
int dy[4]{-1, 0, 1, 0};
int dx[4]{0, 1, 0, -1};
string a[N];

bool ch(int p, int q) {
	if (p < 0 || p >= h || q < 0 || q >= w) return 0;
	if (a[p][q] == '#') return 0;
	return 1;
}

int main()
{
	int i, j, k, ih, iw, jh, jw, kh, kw;
	cin >> h >> w;
	for (ih = 0; ih < h; ih++) {
		for (iw = 0; iw < w; iw++) {
			for (jh = 0; jh < h; jh++) {
				for (jw = 0; jw < w; jw++) {
					if (ih != jh || iw != jw) d[ih][iw][jh][jw] = 1e9;
				}
			}
		}
	}
	for (i = 0; i < h; i++) cin >> a[i];
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			for (k = 0; k < 4; k++) {
				if (ch(i, j) && ch(i + dy[k], j + dx[k])) d[i][j][i + dy[k]][j + dx[k]] = 1;
			}
		}
	}
    for (kh = 0; kh < h; kh++) {
		for (kw = 0; kw < w; kw++) {
			for (ih = 0; ih < h; ih++) {
				for (iw = 0; iw < w; iw++) {
					for (jh = 0; jh < h; jh++) {
						for (jw = 0; jw < w; jw++) {
							d[ih][iw][jh][jw] = min(d[ih][iw][jh][jw], d[ih][iw][kh][kw] + d[kh][kw][jh][jw]);
						}
					}
				}
			}
		}
    }
    for (ih = 0; ih < h; ih++) {
		for (iw = 0; iw < w; iw++) {
			for (jh = 0; jh < h; jh++) {
				for (jw = 0; jw < w; jw++) {
					if (d[ih][iw][jh][jw] < 1e9) mx = max(mx, d[ih][iw][jh][jw]);
				}
			}
		}
	}
    cout << mx << endl;
    return 0;
}

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

int main() {
  int x = 0, n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i<n;i++){
    if(s[i] == 'I') x++;
    if(s[i] == 'D')x--;
    ans = max(ans, x);
  } 
  cout << ans << endl;
}

Measured memory_bytes: 3600
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		BigDecimal A = new BigDecimal(sc.nextLong());
		BigDecimal B = new BigDecimal(sc.nextLong());
		BigDecimal C = new BigDecimal(sc.nextLong());

		BigDecimal l = C.subtract(A).subtract(B);
		if (l.compareTo(BigDecimal.ZERO) != 1) {
			System.out.println("No");
		}else {
			if (l.multiply(l).compareTo(A.multiply(B).multiply(BigDecimal.valueOf(4))) != 1) {
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
		}

	}
}

Measured memory_bytes: 35980
#include<bits/stdc++.h>
using namespace std;
int judge(string s){
    string a;
    for(int i=0; i<s.length(); i++){
        a.push_back(s.at(s.length()-i-1));
    }
    return s.compare(a);
}
int main(){
    string str;
    string half;
    cin >> str;
    for(int i=0; i<(str.length()-1)/2; i++){
        half.push_back(str.at(i));
    }
    if(judge(str)==0&&judge(half)==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,m,i,j;cin>>n>>m;
	vector<int>D(n);
	vector<pair<int,int>>sD(n);
	for(i=0;i<n;i++){cin>>D[i];sD[i]=mp(D[i],i);}
	SO(sD);
	vector<vector<pair<int,int>>>go(n);
	vector<int>ans(m,1000000000);
	string S(n,'W');
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(mp(b,i));
		go[b].pub(mp(a,i));
	}
	vector<bool>aaa(n,false);
	for(i=0;i<n;i++){
		int t=sD[i].sec;
		//cerr<<"t="<<t<<endl;
		if(aaa[t]){continue;}
		bool ok=false;
		for(auto it:go[t]){
			int u=it.fir;
			if(D[u]<=D[t]){
				if(S[u]=='W'){S[t]='B';}
				else{S[t]='W';}
				if(D[u]==D[t]){aaa[u]=true;}
				ans[it.sec]=D[t];
				ok=true;
				break;
			}
		}
		if(!ok){cout<<-1<<endl;return 0;}
		
		
	}
	cout<<S<<endl;
	for(i=0;i<m;i++){cout<<ans[i]<<endl;}
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector <long long> h(n);
    rep(i,n) cin >> h[i];

    vector <bool> good(n,true);

    rep(i,m){
        int a=0 , b=0;
        cin >> a >> b;
        long long ha = h[a-1], hb = h[b-1];
        if(ha > hb){
            good[b-1] = false;
        }
        if(ha < hb){
            good[a-1] = false;
        }
        if(ha == hb){
            good[a-1] = false;
            good[b-1] = false;
        }
    }

    int ans = 0;
    rep(i,n){
        if(good[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    ll n, limit;
    cin >> n >> limit;
    vector<pair<ll, ll>> luggage(n);
    for (int i = 0; i < n; ++i) cin >> luggage[i].first >> luggage[i].second;
    vector<vector<ll>> dp(110, vector<ll>(100100));
    for (int j = 0; j < n; ++j) {
        ll w = luggage[j].first;
        ll v = luggage[j].second;
        for (int i = 0; i < limit; ++i) {
            dp[j + 1][i] = max(dp[j + 1][i], dp[j][i]);
            if (i + w <= limit) dp[j + 1][i + w] = max(dp[j + 1][i + w], dp[j][i] + v);
        }
    }
    ll ans = 0;
    for (int k = 0; k <= limit; ++k) ans = max(ans, dp[n][k]);
    cout << ans << endl;
}


Measured memory_bytes: 87296
#include<stdio.h>

#define N 5000000

int left(int);
int right(int);
void maxHeapify(int);
void buildMaxheap(void);

int heap,A[N];

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

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

  buildMaxheap();

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


int left(int i){
  return i*2;
}

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

void maxHeapify(int i){
  int l,r,max,con;
  l = left(i);
  r = right(i);

  if(l <= heap && A[l] > A[i]){
    max = l;
  }
  else max=i;
  if(r <= heap && A[r] > A[max]){
    max = r;
  }
  if(max != i){
    con = A[max];
    A[max]=A[i];
    A[i]=con;
    maxHeapify(max);
  }
}

void buildMaxheap(){
  int i;
  for(i = heap/2;i > 0;i--){
    maxHeapify(i);
  }
}

Measured memory_bytes: 2556