akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

#define MAX_H 20
#define MAX_W 20
#define MAX_G 10

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

struct S {
    int y, x, t;
    S(int y, int x, int t) : y(y), x(x), t(t) {}
};

#define INF (1<<28)

string field[MAX_H];
int number[MAX_H][MAX_W];
int graph[MAX_G][MAX_G];
int dp[MAX_G][1<<MAX_G]; 
int h, w;
int garbage_count;

inline int solve(int v, int s) {
    if (dp[v][s] != INF) return dp[v][s];
    if (s == ((1<<garbage_count)-1)) return 0;
    int min_cost = INF;
    for (int i = 0; i < garbage_count; i++) {
        if (s & (1<<i)) continue;
        min_cost = min(min_cost, solve(i, (s + (1<<i))) + graph[v][i]);
    }
    return dp[v][s] = min_cost;
}

int main() {
    while (cin >> w >> h) {
        if (w == 0 && h == 0) break;
        memset(graph, -1, sizeof(graph));
        memset(number, -1, sizeof(number));
        for (int i = 0; i < MAX_G; i++) for (int j = 0; j < (1<<MAX_G); j++) dp[i][j] = INF;
        for (int i = 0; i < h; i++) 
            cin >> field[i];
        
        int cur = 1;
        for (int i = 0; i < h; i++) 
            for (int j = 0; j < w; j++) {
                if (field[i][j] == 'o') number[i][j] = 0;
                if (field[i][j] == '*') number[i][j] = cur++;
            }
        garbage_count = cur;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (field[i][j] == 'o' || field[i][j] == '*') {
                    bool visited[h][w]; memset(visited, 0, sizeof(visited));
                    queue<S> q;
                    q.push(S(i, j, 0)); visited[i][j] = true;
                    while (!q.empty()) {
                        S s = q.front(); q.pop();
                        if (field[s.y][s.x] == 'o' || field[s.y][s.x] == '*') {
                            graph[number[i][j]][number[s.y][s.x]] = s.t;
                        }
                        for (int k = 0; k < 4; k++) {
                            int ny = s.y + dy[k];
                            int nx = s.x + dx[k];
                            if (0 <= ny && ny < h && 0 <= nx && nx < w && !visited[ny][nx] && field[ny][nx] != 'x') {
                                visited[ny][nx] = true;
                                q.push(S(ny, nx, s.t+1));
                            }
                        }
                    }
                }
            }
        }

        bool possible = true;
        for (int i = 0; i < garbage_count; i++) 
            for (int j = 0; j < garbage_count; j++) 
                if (graph[i][j] == -1) {
                    possible = false;
                    break;
                }

        if (!possible) cout << -1 << endl;
        else cout << solve(0, 0) << endl;
    }
    return 0;
}

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

int main(){
    int s = 0, i, r = 0;
    string x;
    cin >> x;
    for(i=0; i<x.length(); i++){
        if(x[i] == 'S'){
            s++;
        }else{
            if(s > 0){
                s--;
            }else{
                r += 2;
            }
        }
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

int main(){
 long long n,i,max=-9999999999,Rmin=9999999999;
 cin >> n;
 long long R[n];
 for (i=0;i<n;++i) {
   cin >> R[i];
   if (i>0 && R[i]-Rmin > max) {
     max=R[i]-Rmin;
   }
   if (R[i]<Rmin) Rmin=R[i];
 }
 cout << max << endl;
 return 0;
}



Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int d, g;
    cin >> d >> g;
    vec p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }

    int res = INF;

    // 全完する問題を決め打ち　足りない分は点数が高いものから
    rep(f, 1 << d) {
        int cnt = 0;
        lint score = 0;

        rep(i, d) {
            int bit = (f >> i) & 1;
            if (bit) {
                cnt += p[i];
                lint base = (i+1) * 100;
                base *= p[i];
                score += base;
                score += c[i];
            }
        }

        if (score < g) {
            for (int i = d-1; i >= 0; --i) {
                int bit = (f >> i) & 1;
                if (bit) continue;
                rep(j, p[i]-1) {
                    cnt++;
                    score += (i+1) * 100;
                    if (score >= g) break;
                }
                if (score >= g) break;
            }
        }

        if (score < g) continue;
        res = min(res, cnt);
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by kinok on 2020/04/17.
//

#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>

using namespace std;


#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl



    int main() {
        int m,n;
        cin>>m>>n;
        cout<<(m*(m-1)+n*(n-1))/2<<endl;
      return 0;
    }






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

using namespace std;
const int INF = 1001001001;
int main() {
	int N, M;
	//vector<int>to[100005];
	cin >> N >> M; 
	vector<vector<int>>to(N);
	for (int n = 0; n < M; ++n) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		to[a].push_back(b); 
		to[b].push_back(a);
	}

	queue<int> q;
	vector<int> dist(N, INF);//深さ
	vector<int> pre(N, -1);//直前
	dist[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int u : to[v]) {
			if (dist[u] != INF) {
				continue;
			}
			else {
				dist[u] = dist[v] + 1;
				pre[u] = v;
				q.push(u);
			}
		}
	}

	bool bRet = true;
	for (int n = 1; n < N; ++n) {
		if (-1 == pre[n]) {
			bRet = false;
			break;
		}
	}
	if (bRet) {
		cout << "Yes" << endl;
		for (int n = 1; n < N; ++n) {
			cout << pre[n] + 1 << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N; cin>>N;
  int a[N];

  rep(i,N){
    cin>>a[i];
  }

  int l=0,r=0;
  ll ct=0;
  int now=0;

  while(true){
    //cout<< now <<" "<<l <<" "<<r<<"\n";
    if(l==N) break;
    if(l==r){
      now^= a[r]; ++r; continue;
    }
    if(r==N){
      ct+= r-l;
      now^= a[l]; ++l;
      continue;
    }
    //cout<< a[r] <<" "<<now <<" "<<(now & a[r]) <<"\n";
    if((now & a[r]) != 0){
      ct+= r-l;
      now^= a[l]; ++l;
      continue;
    }
      now^= a[r]; ++r;
  }

  cout<< ct<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>
#include <cmath>
#include <deque>
#include <numeric>

using namespace std;

long long a[100000];
long long K_sums[100000];
long long cum_sum_positive[100000];
int main(){
  int N;
  int K;
  cin >> N >> K;

  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  //long long sum_a = accumulate(a, a + N, (long long) 0);

  for(int i = 0; i < K; i++){
    K_sums[0] += a[i];
  }
  for(int i = 1; i < N - K + 1; i++){
    K_sums[i] = K_sums[i - 1] - a[i - 1] + a[i + K - 1];
  }

  if(a[0] > 0){
    cum_sum_positive[0] = a[0];
  } else {
    cum_sum_positive[0] = 0;
  }
  for(int i = 1; i < N; i++){
    if(a[i] > 0){
      cum_sum_positive[i] = cum_sum_positive[i - 1] + a[i];
    } else {
      cum_sum_positive[i] = cum_sum_positive[i - 1];
    }
  }

  long long ans = 0;
  for(int i = 0; i < N - K + 1; i++){
    long long tmp_ans = 0;
    long long left_positive_sum;
    if(i > 0){
      left_positive_sum = cum_sum_positive[i - 1];
    } else {
      left_positive_sum = 0;
    }
    long long right_positive_sum = 0;
    if(i < N - K){
      right_positive_sum = cum_sum_positive[N - 1] - cum_sum_positive[K + i - 1];
    } else {
      right_positive_sum = 0;
    }

    tmp_ans = left_positive_sum + right_positive_sum + max((long long) 0, K_sums[i]);
    ans = max(ans, tmp_ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a;
    cin >> n >> a;
    n %= 500;
    if(n <= a){
        print("Yes");
    }else{
        print("No");
    }

}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>
using namespace std;

#define ll long long
#define dd double

ll  mod =100000009;

ll a[1000000];
ll b[1000000];



int main(){
    ll a,b;
    cin>>a>>b;
    
    ll  n1=a+b;
    ll n2=a-b;
    ll n3=a*b;
    
    cout<<max(n1,max(n2,n3))<<endl;
    return 0;
}


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

ll const INF = 40000000000;
ll dp[100][2][2][10];

int main(){
	ll k;
	cin >> k;
	
	ll r = INF;
	ll l = 0;
	
	int cnt = 0;
	
	while(r - l > 1){
		ll m = (r+l)/2;
		//m以下のルンルン数の数をカウントする。
		string s = to_string(m);
		int n = s.size();
		//dp初期条件
		for (int x = 0; x <= s[0] - '0'; ++x) {
			if(x == 0){
				dp[0][1][0][0] = 1;
			} else if (x == s[0] - '0'){
				dp[0][0][1][x] = 1;
			}else{
				dp[0][1][1][x] = 1;
			}
		}
		
		for (int i = 1; i <= n-1; ++i) {
			for (int smaller = 0; smaller < 2; ++smaller) {
				for (int zero = 0; zero < 2; ++zero) {
					for (int x = 0; x <= 9 ; ++x) {
						for (int nx = 0; nx <= 9; ++nx) {
							int d = s[i] - '0';
							int nsmaller = smaller;
							if(smaller == 0){
								if(nx > d) continue;
								if(nx == d) nsmaller = 0;
								if(nx < d) nsmaller = 1;
							}
							int nzero = 1;
							if(zero == 0){
								if(nx == 0) nzero = 0;
								dp[i][nsmaller][nzero][nx] += dp[i-1][smaller][zero][x];
							}else{
								if(abs(nx-x) > 1) continue;
								dp[i][nsmaller][nzero][nx] += dp[i-1][smaller][zero][x];
							}
						}
					}
				}
			}
		}
		
		ll count = -1;
		rep(smaller,2){
			rep(zero,2){
				rep(x,10){
					count += dp[n-1][smaller][zero][x];
				}
			}
		}
		
		if(count >= k){
			r = m;
		}else{
			l = m;
		}
		
		rep(i,60) {
			rep(smaller, 2) {
				rep(zero, 2) {
					rep(x, 10) {
						dp[i][smaller][zero][x] = 0;
					}
				}
			}
		}
	}
	cout << r << endl;
	
    return 0;
}



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

int main() {
  string s;  int64_t k;
  cin >> s >> k;
  int cnt = 1;  vector<int> seg;
  for (int i=0; i < s.size() - 1; i++) {
    if (s.at(i) == s.at(i + 1))  cnt++;
    else {
      seg.push_back(cnt);
      cnt = 1;
    }
  }
  seg.push_back(cnt);
  int64_t ans = 0;
  if (cnt == s.size())  ans = cnt * k / 2;
  else if (s.at(0) != s.at(s.size() - 1)) {
    for (int i=0; i < seg.size(); i++) {
      ans += seg.at(i) / 2;
    }
  ans *= k;
  }
  else {
    for (int i=1; i < seg.size() - 1; i++) {
      ans += seg.at(i) / 2;
    }
    ans *= k;
    ans += ( seg.at(0) + seg.at(seg.size() - 1) ) / 2 * (k - 1);
    ans += seg.at(0) / 2;
    ans += seg.at(seg.size() - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	int N,X;
	cin>>N>>X;
  	int m[N];
  	int total_amount = 0;
  	for(int i=0;i<N;i++) {
  		cin>>m[i];
  		total_amount+=m[i];
  	}
  	sort(m,m+N);
  	printf("%d\n", N+max(0,(X-total_amount)/m[0]));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr int N = 15;
int a[N][N];

int main(){
	int n; scanf("%d", &n);
	REP(i, N) REP(j, N) a[i][j] = -1;
	REP(i, n){
		int m; scanf("%d", &m);
		REP(j, m){
			int x, y; scanf("%d%d", &x, &y); x--;
			a[i][x] = y;
		}
	}
	int ans = 0;
	REP(i, 1<<n){
	// int i = 3; {
		bool ok = true;
		REP(j, n){
			if(!(i&(1<<j))) continue;
			REP(k, n){
				if(~a[j][k]){
					if(a[j][k] != !!(i&(1<<k))){
						DEBUG("wrong: %d -> %d\n", j, k);
						ok = false;
					}
				}
			}
		}
		if(ok){
			DEBUG("%d\n", i);
		 	LAR(ans, __builtin_popcount(i));
		}
	}
	printf("%d\n", ans);
}


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

int main()
{
	int n;
	long long y;
	cin >> n >> y;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			int k = n - i - j;
			if(k < 0)
				break;
			if(i * 10000 + j * 5000 + k * 1000 == y){
				cout << i << " " << j << " " << k << "\n";
				return 0;
			}
		}
	}

	cout << "-1 -1 -1\n";

	return 0;
}


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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<ll> cnt(1000005, 0);
  vector<ll> primes(1000005, 0);

  for (ll i = 0; i < N; i++) {
    ll a = A[i];
    for (ll j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        primes[j] = 1;
        cnt[j]++;
        for (ll k = 0; k < 100000; k++) {
          a /= j;
          if (a % j != 0) break;
        }
      }
    }
    if (a != 1) {
      cnt[a]++;
    }
  }

  ll check = 0;
  for (ll i = 0; i < 1000005; i++) {
    check = max(check, cnt[i]);
  }

  string ans = "pairwise coprime";
  if (check >= N) ans = "not coprime";
  else if (check > 1) ans = "setwise coprime";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 26620
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
const int maxs = 300300;
char s[maxs];
int n;
ll ans = 0, cnt = 0;
int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for(int i = 1; i <= n; ++i) {
        if(s[i] == 'W') 
            cnt++, ans += (i - cnt);
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 384
N = int(input())
numList = list(map(int,input().split()))

ctr = 0
def numEvener(N,numList):
  for i in range(0,N):
    if numList[i] % 2 == 0:
      numList[i] = int(numList[i] / 2)
    else:
      numList[i] = 0
  return numList
 
flag = True
while flag:
  numList = numEvener(N,numList)
  if not 0 in numList:
  	ctr += 1
  else:
    flag = False


print(ctr)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

vl b(8,-1);
bool ok(vl &a){
    vl cnt(8),cntR(17),cntL(17);
    rep(i,8){
        cnt[a[i]]++;
        cntR[i+a[i]]++;
        cntL[7-i+a[i]]++;
    }
    rep(i,8)if(cnt[i]>=2)return false;
    rep(i,17)if(cntR[i]>=2)return false;
    rep(i,17)if(cntL[i]>=2)return false;
    return true;
}
bool rec(vl &a,ll n){
    if(n==8)return ok(a);
    if(b[n]!=-1){
        a[n]=b[n];
        return rec(a,n+1);
    }
    rep(i,8){
        a[n]=i;
        if(rec(a,n+1))return true;
    }
    return false;
}
void solve(){
    ll n;cin>>n;
    rep(i,n){
        ll y,x;cin>>y>>x;
        b[y]=x;
    }
    vl c(8);
    rec(c,0);
    rep(i,8){
        rep(j,8){
            cout<<(j==c[i]?'Q':'.');
        }
        cout<<endl;
    }
}

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



Measured memory_bytes: 3220
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
 
using namespace std;

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

    if(n<a)cout<<0<<endl;
    else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>

using namespace std;

int main()
{
	int i,j,k,n;
	string S[50];
	char T[100],Temp1[100]={};
	string Temp;
	char A[1000]={};

	cin >> n;

	j=0;
	for(i=0;i<n;i++){
		cin >> T;
		sort(T,T+strlen(T));
		S[i]=T;
	}

	Temp=S[0];
	int l=0;
	for(i=1;i<n;i++){
		j=0;k=0;l=0;
		while((k<Temp.length())&&(j<S[i].length())){
		if(S[i][j]==Temp[k]){
			Temp1[l]=S[i][j];
			l++;j++;k++;
		}else if(Temp[k]>S[i][j]){
			j++;
		}else if(Temp[k]<S[i][j]){
			k++;
		}
		}
		Temp=Temp1;
		for(int m=0;m<100;m++){
			Temp1[m]=0;
		}
	}


	cout << Temp;
	cin >> n;

	return 0;
}


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

int main(){
	int N; cin >> N;
	vector<pair<string, int>> x;
	int p[N];
	for(int i=0; i<N; i++){
		string s;
		cin >> s >> p[i];
		p[i] = -p[i];
		x.push_back({s, p[i]});
	}
	sort(x.begin(), x.end());
	for(int i=0; i<N; i++){
		int q = x[i].second;
		for(int j=0; j<N; j++){
			if(p[j] == q){
				cout << j+1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

Vll X;
Vll Y;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N; 
    cin >> N;
    X.rs(N);
    repll(i,0,N) cin >> X[i];
    Y = X;
    sort(ALL(X));

    repll(i,0,N){
        if(Y[i] < X[N/2]) COUT(X[N/2]);
        else COUT(X[N/2-1]);
    }
}



Measured memory_bytes: 5376
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N, K = _li()
S = _s()

lr = 0
rl = 0
for i in range(N-1):
    if S[i] == 'L' and S[i+1] == 'R':
        lr += 1
    elif S[i] == 'R' and S[i+1] == 'L':
        rl += 1

ans = N - (lr + rl + 1)
cand = min(lr, rl)
ans += 2 * min(cand, K)
if K > cand:
    if lr > rl and (S[0] == 'L' or S[-1] == 'R'):
        ans += 1
    elif lr < rl and (S[0] == 'R' or S[-1] == 'L'):
        ans += 1
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 3010;
int n, m;
struct edge { int to, cost, time; };
vector<edge> G[MAX_N];
int solve(int start, int goal, int flag)
{
    vector<int> res(MAX_N, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, start));
    res[start] = 0;
    while(not que.empty())
    {
        int w = que.top().first, v = que.top().second;
        que.pop();
        if(res[v] < w) continue;
        for(int u = 0; u < G[v].size(); u++)
        {
            edge e = G[v][u];
            int num = (flag ? e.time : e.cost);
            if(w + num < res[e.to])
            {
                res[e.to] = w + num;
                que.push(P(res[e.to], e.to));
            }
        }
    }
    return res[goal];
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m, n | m)
    {
        for(int i = 0; i < MAX_N; i++) G[i].clear();
        for(int i = 0; i < n; i++)
        {
            int a, b, c, t; cin >> a >> b >> c >> t;
            a--, b--;
            G[a].push_back({b, c, t});
            G[b].push_back({a, c, t});
        }
        int k; cin >> k;
        for(int i = 0; i < k; i++)
        {
            int p, q, f; cin >> p >> q >> f;
            p--, q--;
            cout << solve(p, q, f) << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3320
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let s: i32 = sc.next();
    println!("{}:{}:{}", s / 3600, (s % 3600) / 60, s % 60);
}

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}



Measured memory_bytes: 5032
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;
bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;
int T[50001];

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	};
	int n, m, c;
	vector<int> coins;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> c;
		coins.push_back(c);
	}
	for (int i = 0; i <= n; i++)
		T[i] = INF;
	T[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = coins[i]; j <= n; j++) {
			T[j] = min(T[j], T[j - coins[i]] + 1);
		}
	}
	cout << T[n] << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 3348
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
int main() {
	int N, W;
	cin >> N >> W;
	vector<int>v(N);
	vector<int>w(N);
	vector<vector<int>>dp(N+1, vector<int>(W+1,0));
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i <N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j-w[i]>=0) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]]+v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
}



Measured memory_bytes: 6828
#include<stdio.h>
int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    int a,b,c=0;
    if(x == 1&& y ==1){
        printf("1000000\n");
    }
    else if(x >=4 && y>=4){
        printf("0\n");
    }
    else if(x >=4 && y <4){
        a = (4-y)*100000;
        printf("%d\n",a);
    }
    else if (x<4 && y>= 4){
        a = (4-x)*100000;
        printf("%d\n",a);
    }
    else {
        a = (4-x)*100000;
        b = (4-y)*100000;
        printf("%d\n",a+b);
    }
    return 0;
}

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



void solve(){
    int n, k;
    cin >> n >> k;

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

    int dp[k + 1];
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i >= arr[j] and dp[i - arr[j]] == 0){
                dp[i] = 1;
                break;
            }
        }
    }

    cout << (dp[k] == 1 ? "First" : "Second");

}


int main(){
    int t;
    t = 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 4020
n = gets.to_i
r = Array.new
 
r0 = gets.to_i
r1 = gets.to_i
max_r = r1 - r0
min_v = r0 < r1 ? r0 : r1
 
(n-2).times do
    r = gets.to_i
    current = r - min_v
    max_r = current if current > max_r
    min_v = r if r < min_v
end
  
puts max_r

Measured memory_bytes: 8832
# coding: UTF-8
def pprint(numlist):
  print(" ".join(map(str,numlist)))
N = int(input())
A = list(map(int,input().split()))
count = 0
flag = True
while flag:
  flag = False
  j = N - 1
  while j >= 1:
    if A[j-1] > A[j]:
      v = A[j]
      A[j] = A[j-1]
      A[j-1] = v
      flag = True
      count += 1
    j -= 1
pprint(A)
print(count)


Measured memory_bytes: 5604
#include <stdio.h>

int main() {
   int i,j,k,l,m,n;

   scanf("%d",&n);
   m=0;
   for (i=3;i<=n;i+=2) {
       l=0;
       for (j=i,k=3,l=0;j>=k*k;) {
           if (j%k==0)  l++;
             k+=2;
      }
      if (l==3) m++;
    }
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  vector<int> c(n, 0);
  rep(i, n) c[a[i]]++;

  int ans = 1;
  if (n & 1) {
    if (c[0] != 1) ans = 0;
    FOR(i, 1, n) {
      if (i % 2 == 1 && c[i] != 0) ans = 0;
      else if (i % 2 == 0) {
        if (c[i] != 2) ans = 0;
        else ans = (ans * 2) % mod;
      }
    }
  }
  else {
    rep(i, n) {
      if (i % 2 == 0 && c[i] != 0) ans = 0;
      else if (i % 2 == 1) {
        if (c[i] != 2) ans = 0;
        else ans = (ans * 2) % mod;
      }
    }
  }
  cout << ans << endl;




  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int n;
    cin >> n;
    
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
   cout << "No" << endl;

}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	int n;
	cin >> n;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	ll c = 0;
	REP(i, n - 1) {
		if (v[i] == i + 1) {
			++c;
			std::swap(v[i], v[i + 1]);
		}
	}
	cout << ((v[n - 1] == n) ? c + 1 : c) << endl;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
# 外周に'.'の壁を作れば境界の場合分け不要になる。

# input
h, w = map(int, input().split())
s_input = [input() for _ in range(h)]
s = [['.' for _ in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        s[i][j] = s_input[i-1][j-1]

def sweep(i, j, s): 
    global h; global w
    ans = 0 
    # inner 
    if 0 < i < h+1:
        if 0 < j < w+1:
            sweeps = [s[i][j+1], s[i+1][j+1], s[i+1][j], s[i+1][j-1], s[i][j-1], s[i-1][j-1], s[i-1][j], s[i-1][j+1]]
            for sw in sweeps:
                if sw == '#':
                    ans += 1
    return ans 

# calc
ans = [['' for _ in range(w)] for _ in range(h)]

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
            ans[i-1][j-1] = '#' 
        if s[i][j] == '.':
            ans[i-1][j-1] = str(sweep(i, j, s)) 
# output
for i in range(h):
    print(''.join(ans[i]))


Measured memory_bytes: 3188
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        sc.close();
        if(n == 1){
            System.out.println(p);
            return;
        }

        long ans = 1;
        for(int i = 2; i < p ; i++){
            //if(p % i == 0){
                long t = (long)Math.pow(i,n);
                if(p % t == 0){
                    ans = i;
                }
                if(t > p){
                    break;
                }                
            //}
        }
        System.out.println(ans);
    }
}

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

int main(){
	string a;
	int n;
	int x=0;
	int y=0;
	int z=0;
	int b=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a=="AC"){
			x++;
		}
		else if(a=="WA"){
			y++;
			
		}
		else if(a=="RE"){
			b++;
		}
		else if(a=="TLE"){
			z++;
		}
	}
	cout<< "AC"<<" "<<"x"<<" "<<x<<endl;
	cout<< "WA"<<" "<<"x"<<" "<<y<<endl;
	cout<< "TLE"<<" "<<"x"<<" "<<z<<endl;
	cout<< "RE"<<" "<<"x"<<" "<<b<<endl;
}

Measured memory_bytes: 3600
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll a, b; // -10^9 <= a <= b <= 10^9
    cin >> a >> b;

    if (0 < a) {
        cout << "Positive" << endl;
    } else if ((a <= 0) && (0 <= b)) {
        cout << "Zero" << endl;
    } else if ((b - a) % 2 == 1) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

ll a, b;

ll solve() {
  ll ans = 0;
  if (b - a + 1 <= 2) {
    for (ll i = a; i <= b; i++) ans ^= i;
    return ans;
  }

  if (a & 1) { ans ^= a; a++; }
  if (!(b & 1)) { ans ^= b; b--; }
  ll k = (b - a + 1) / 2;
  if (k & 1) ans ^= 1;
  return ans;
}

int main() {
  scanf("%lld%lld", &a, &b);
  printf("%lld\n", solve());
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 605;

int n, m;
vector<int> g[maxn];


double solve(int block) {
    vector<double> dp(n+10);
    dp[n] = 0;
    
    for (int at=n-1; at>=1; at--) {
	int outd = 0;
	double sum = 0;
	double hi = 0;
	for (int to: g[at]) {
	    outd++;
	    sum += dp[to];
	    hi = max(hi, dp[to]);
	}

	if (at == block && outd>=2) {
	    sum -= hi;
	    outd--;
	}

	dp[at] = 1 + sum/outd;
    }

    return dp[1];
}

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

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



    double res = 1e18;
    for (int i=0; i<=n; i++) {
	res = min(res, solve(i));
    }

    cout<<fixed<<setprecision(15)<<res<<endl;    
    return 0;
}


Measured memory_bytes: 4816
# coding: utf-8
# Your code here!

SIZE=2*10**6+10**5
#SIZE = 10000
MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

import sys
readline = sys.stdin.readline
read = sys.stdin.read


p,a,q,b = [int(i) for i in read().split()]


ans = choose(q+b+2,b+1) - choose(p+b+1,b+1) - choose(q+a+1,a) + choose(p+a,a)


print(ans%MOD)









        
        

Measured memory_bytes: 91100
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000000 + 7
N = int(readline())
C = np.array(read().split(), np.int64)

C.sort()

ans = (C * np.arange(N+1, 1, -1) % MOD).sum() % MOD
ans *= pow(2, N+N-2, MOD)

print(ans % MOD)

Measured memory_bytes: 25168
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    cin >> N;

    switch(N%10){
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
         cout << "bon" << endl;
        break;
    default:
        cout << "hon" << endl;
        break;
    }
}


Measured memory_bytes: 3652
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
N = int(input())
a = num_divisors_table(N)
ans = 0
for i in range(N+1):
  ans += i*a[i]
print(ans)

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

int main() {
    string s; cin >> s; 
    if (s == "RRR") cout << 3 << endl;
    if (s == "RRS") cout << 2 << endl;
    if (s == "RSR") cout << 1 << endl;
    if (s == "SRR") cout << 2 << endl;
    if (s == "SSR") cout << 1 << endl;
    if (s == "SRS") cout << 1 << endl;
    if (s == "RSS") cout << 1 << endl;
    if (s == "SSS") cout << 0 << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  REP(i,n){
    string s;
    cin >> s;

    int len = s.length();
    map<string, int> mp;
    string s1, s2;
    mp[s] = 1;
    for(int j = 1; j <=  len-1; ++j){
      s1 = s.substr(0,j);
      s2 = s.substr(j,len - j);
      //cout << s1 << " " << s2 << endl;
      //mp[s1+s2] = 1;
      //cout << s1 << " " << s2 << endl;
      mp[s2+s1] = 1;
      string re_s1 = s1, re_s2 = s2;
      reverse(ALL(re_s1));
      mp[re_s1 + s2] = 1;
      mp[s2 + re_s1] = 1;
      reverse(ALL(re_s2));
      mp[s1 + re_s2] = 1;
      mp[re_s2 + s1] = 1;
      mp[re_s1 + re_s2] = 1;
      mp[re_s2 + re_s1] = 1;
      
    }

    cout << mp.size() << endl;
  }
  return 0;
}




Measured memory_bytes: 3200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	in := input()
	d := parseInt(in)
	switch d {
		case 25:
			fmt.Print("Christmas")
		case 24:
			fmt.Print("Christmas Eve")
		case 23:
			fmt.Print("Christmas Eve Eve")
		case 22:
			fmt.Print("Christmas Eve Eve Eve")
	}
}

func input() string {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	return strings.TrimSpace(stdin.Text())
}

// func inputSlice() []string {
// 	stdin := bufio.NewScanner(os.Stdin)
// 	stdin.Scan()
// 	text := strings.TrimSpace(stdin.Text())
// 	return strings.Split(text, " ")
// }

func parseInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int h,w,m,a[300001],b[300001],p1,p2;
typedef pair<int,int> pi;
set<pi>st;
int main(){
	int i,j,x,y;
	cin>>h>>w>>m;
	vector<int>l,r;
	for(i=1;i<=m;++i){
		cin>>x>>y;
		st.insert(make_pair(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1){
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)l.push_back(x);
		if(b[y]>p2){
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)r.push_back(y);
	}
	for(i=0;i<l.size();++i){
		for(j=0;j<r.size();++j){
			if(st.find(make_pair(l[i],r[j]))==st.end()){
				cout<<p1+p2;
				return 0;
			}
		}
	}
	cout<<p1+p2-1;
}

Measured memory_bytes: 21752
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    ll mx = INFLL;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            string a = to_string(i);
            string b = to_string(n/i);
            ll len = max(a.length(), b.length());
            mx = min(mx, len);
        }
    }

    cout << mx << endl;
    return 0;
}




Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n,m;
	cin >> n >> m;
	vector<ll> x(n),y(n),z(n),a(n);
	rep(i,0,n)cin >> x[i] >> y[i] >>z[i];
	ll ans = 0;
	rep(i,0,8){//枚举8种状态(+-)x(+-)y(+-)z 
		int sta = i;//当前状态 
		rep(i,0,n)a[i] = (2*(sta&1)-1)*x[i] + (2*((sta>>1)&1)-1)*y[i] + (2*((sta>>2)&1)-1)*z[i];
		sort(all(a));
		ll sum = 0;
		rep(i,0,m)sum += a[n-1-i]; 
		ans = max(ans,sum);
	}
	cout << ans; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






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

int main() {
 int A,B,C,D;
 cin>>A>>B>>C>>D;
  if(A+B>C+D)cout<<"Left"<<endl;
  else if(A+B==C+D)cout<<"Balanced"<<endl;
  else if(A+B<C+D)cout<<"Right"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int x,n;
    int ans=INF;
    cin >>x>>n;
    Vi p(n+1);
    rep(i,n){
        cin>>p[i];
    }
    p[n]=999;
    sort(all(p));
    auto s1=p.begin();

    for(int i=-1;i<105;i++){
        if(i==*s1){
            s1++;
        }else{
            if(abs(x-ans)> abs(x-i)){
                ans=i;
            }
        
        }
        
    }


    
    cout<<ans<<endl;
}

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

using namespace std;

long long INF=1e15;

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

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

    long long sum=0;

    for(int i=0;i<n+1;i++)sum+=abs(a[i]-a[i+1]);

    for(int i=1;i<=n;i++){
        long long ans=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1664
o = input()
e = input()
ans = ''
for i in range(50):
    if len(e) == i & len(e) != len(o):
        ans += o[i]
        break
    elif len(o) - 1 == i:
        ans += o[i]
        ans += e[i]
        break
    else:
        ans += o[i]
        ans += e[i]
print(ans)

Measured memory_bytes: 3064
N = int(input())+1
yakusuu = 0
for i in range(1,int((N-N%2)/2)+2):
    cnt = 0
    ii = 1+ 2*(i-2)
    for j in range(1,ii):
        if ii % j == 0:
            cnt = cnt+1
    cnt = cnt+1
    if cnt == 8:
        yakusuu = yakusuu + 1
print(yakusuu)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define mid ((l+r)/2)
using namespace std;
int n,ans,a[222222],b[222222],t[888888];
void update(int l,int r,int p,int c,int v){
	if(l==r){t[p]=v;return;}
	mid>=c?update(l,mid,p*2,c,v):update(mid+1,r,p*2+1,c,v);
	t[p]=max(t[p*2],t[p*2+1]);
}
int query(int l,int r,int p){
	if(l==r)return l;
	return t[p]==t[p*2]?query(l,mid,p*2):query(mid+1,r,p*2+1);
}
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),update(1,n,1,i,b[i]);
	b[0]=b[n],b[n+1]=b[1];
	for(int tmp=n;tmp;){
		int p=query(1,n,1),d=b[p]-a[p],k=b[p+1]+b[p-1];
		if(!d){tmp--,update(1,n,1,p,0);continue;}
		if(d<k){printf("-1");return 0;}
		ans+=d/k,b[p]-=d/k*k,b[0]=b[n],b[n+1]=b[1],update(1,n,1,p,b[p]==a[p]?0:b[p]);
		if(b[p]==a[p])tmp--;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 10496
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.size(),ans=0;
  for(int i=0;i<n;++i)
  {
    if(s[i]!=t[i])
       ++ans;
       }
       cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3912