akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, a, b, c, d, ans = 0;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    bool f = true;
    for(int i = a + 1; i <= max(c, d); i++){
        if(s[i] == '#' && s[i - 1] == '#'){
            f = false;
        }
    }
    bool f2 = true;
    if(f && c > d){
        f2 = false;
        for(int i = max(1, b); i <= min(d, n - 2); i++){
            if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
                f2 = true;
                break;
            }
        }
    }
    cout << ((f && f2)? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll h[n];
    rep(i,0,n-1) cin>>h[i];
    ll hoge = h[0];
    if(n==1) {
        cout<<"Yes"<<endl;
        return 0;
    }
    else {
        rep(i,1,n-1){
            if(hoge-h[i]>1){
                cout<<"No"<<endl;
                return 0;
            }
            else{
                if(hoge<h[i]){
                    hoge = h[i];
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

{
    int n;
    cin>>n;
    int r=n/10;
    int r1=r/10;

        if(n%10==7)
        {
           cout<<"Yes"<<endl;
        }
        //
        else if(r%10==7)
        {
            cout<<"Yes"<<endl;
        }

        //

        else if(r1%10==7)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

set<pii> s;
int mx[nmax],mn[nmax];
int a[nmax];
bool kol[nmax];

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

    int n,k;
    cin >> n >> k;
    if(k == n || k == 1) return cout << 1,0;
    fo(i,0,n) cin >> a[i];
    fo(i,0,k) s.insert({a[i],i});
    mn[0] = (*s.begin()).F;
    mx[0] = (*s.rbegin()).F;
    fo(i,1,n-k+1){
        s.erase({a[i-1],i-1});
        s.insert({a[i+k-1],i+k-1});
        mn[i] = (*s.begin()).F;
        mx[i] = (*s.rbegin()).F;
    }
    int tt = 0;
    fo(i,0,n){
        int tnow = 1;
        while(i < n-1 && a[i] < a[i+1]) i++,tnow++;
        if(tnow < k) continue;
        tt++;
    }
    ll ans = n-k+1;
    fo(i,1,n-k+1){
        if(mn[i-1] == a[i-1] && mx[i] == a[i+k-1]){
            ans--;
        }
    }
    if(tt > 0) ans -= tt-1;
    cout << ans;

    return 0;
}



Measured memory_bytes: 14464
N, K = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

ans = 10**9

bound =  x.bsearch_index{|e| e>=0}

#全部負の座標のとき
if bound == nil
  puts x[N-K].abs
  exit
end

#x>=0からi個，x<0からK-i個
0.upto(K) do |i|
  next if N-bound < i || bound < K-i
  right =
    if i != 0
      x[bound+i-1]
    else
      0
    end
  left =
    if i != K
      x[bound - (K-i)].abs
    else
      0
    end

  tmp =
    if right > left
      2*left + right
    else
      2*right + left
    end

  ans = tmp if tmp < ans
end

puts ans


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

vector<vector<int>> g;
vector<int> counter;
void dfs(int v,int pre = -1){
  for(int nv : g[v]){
    if(nv == pre) continue;
    counter[nv] += counter[v];
    dfs(nv,v);
  }
}

int main(){
  int n,q;
  cin>>n>>q;
  g.resize(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a].pb(b); g[b].pb(a);
  }
  counter.resize(n);
  rep(i,q){    
    int p,x;
    cin>>p>>x;
    p--;
    counter[p] += x;
  }
  dfs(0);
  rep(i,n){
    cout << counter[i] << endl;
  }
}


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

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

using namespace std;

struct Node {
	int id;
	bool visited;
	vector<int> adj;
	int prev;
	Node() {
		visited = false;
		prev = -1;
	}
};

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


	Node* nodes = new Node[N];
	rep(i, N)nodes[i].id = i;

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		nodes[a].adj.push_back(b);
		nodes[b].adj.push_back(a);
	}

	int count = 1;
	nodes[0].visited = true;
	queue<Node> q;
	q.push(nodes[0]);

	while (!q.empty()) {
		Node now = q.front();
		q.pop();

		rep(i, now.adj.size()) {
			int idx = now.adj[i];
			if (nodes[idx].visited) continue;

			count++;
			nodes[idx].visited = true;
			nodes[idx].prev = now.id;
			q.push(nodes[idx]);
		}
	}

	if (count < N) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		for (int i = 1; i < N; i++) {
			cout << ++nodes[i].prev << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 18608
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef __int128 LL;
inline __int128 read()
{
    __int128 x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
inline void print(__int128 x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9)
        print(x / 10);
    putchar(x % 10 + '0');
}
int main()
{
    LL x, k, d;
    x = read(), k = read(), d = read();

    if (x < 0)
        x = -x;
    if (x >= 0)
    {
        if ((x - k * d) >= 0)
        {
            print(x - k * d);
        }
        else
        {
            int t = (x / d);
            if ((k - t) % 2)
                print(-(x - d * t - d));
            else
                print(x - d * t);
        }
    }

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  vector<LL> a(n);
  for(LL&x:a) cin >> x;
  LL answer = 0;
  REP(i,n) REP(j,i) {
    if(a[i] < a[j]) ++answer;
  }
  answer = answer*k%p;
  LL pa = k*(k-1)/2%p;
  sort(a.begin(),a.end());
  for(LL x:a) answer = (answer + (lower_bound(a.begin(),a.end(),x) - a.begin()) * pa) % p;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad( replicateM)
import Data.Function( on)
import Data.List( groupBy, sort, sortBy)
main = do
    [n,k] <- return . map read . words =<< getLine
    ps <- replicateM n getLine
    let sorted = sort ps
	gs = groupBy ((==) `on` head) sorted
	datalist = map length gs
	process n list
	  | length list < k	= n
	  | otherwise	=
		let (kps, rem) = splitAt k list
		    l = filter (0/=) $ map pred kps
		in process (n+1) (sortBy (flip compare) $ l++rem)
    print $ process 0 datalist

Measured memory_bytes: 10620
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

int R, C;
int F[10][10000];
bool input() {
    cin >> R >> C;
    if (R == 0 && C == 0) return false;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> F[i][j];
        }
    }
    return true;
}

int count(int flag) {
    static int G[10][10000];
    memcpy(G, F, sizeof(G));
    for (int y = 0; y < R; y++) {
        if (flag & (1 << y)) {
            for (int x = 0; x < C; x++) {
                G[y][x] = !G[y][x];
            }
        }
    }
    int ans = 0;
    for (int x = 0; x < C; x++) {
        int b = 0, w = 0;
        for (int y = 0; y < R; y++) {
            (G[y][x] ? b : w)++;
        }
        ans += max(b, w);
    }
    return ans;
}

void solve() {
    int ans = 0;
    for (int i = 0; i < (1 << R); i++) {
        ans = max(ans, count(i));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1940
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    string S, T;
    cin >> S >> T;
    int slen, tlen;
    slen = (int) S.size();
    tlen = (int) T.size();

    int i = slen - tlen;
    while (i >= 0)  {
        bool accepted = true;
        for (int j = 0; j < tlen; j++) {
            if (S[i + j] != '?' && S[i + j] != T[j]) {
                accepted = false;
                break;
            }
        }
        if (accepted) {
            break;
        }
        i--;
    }

    if (i < 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int j = 0; j < slen; j++) {
        if (j >= i && j < i + tlen) {
            putchar(T[j - i]);
        } else {
            if (S[j] == '?') {
                putchar('a');
            } else {
                putchar(S[j]);
            }
        }
    }
    putchar('\n');

    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, m, a[101],b[101],c[101],d[101];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < m; i++){
		cin >> c[i] >> d[i];
	}
	
	for(int i = 0; i < n; i++){
		int cnt = INF, pos = 0;
		for(int j = 0; j < m; j++){
			if(chmin(cnt, abs(a[i]-c[j])+abs(b[i]-d[j]))) pos = j;
		}
		cout << pos+1 << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
N, M = map(int, input().split())
G = [[False] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a][b] = True
    G[b][a] = True

ans = 0
for p in permutations(range(2, N + 1)):
    bl = G[1][p[0]]
    for x, y in zip(p[:-1], p[1:]):
        bl &= G[x][y]
    ans += int(bl)

print(ans)

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

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int dx=x2-x1;
    int dy=y2-y1;
    cout<<x2-dy<<endl;
    cout<<y2+dx<<endl;
    cout<<x1-dy<<endl;
    cout<<y1+dx<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll n, a[N], k, m;
ll y[N], p[N], o[N], ans[N];
ll G[N];
ll C = 1;
ll cyc[N];
ll M[N];
vector<ll> V[N];
ll pos[N], end[N];
ll Z[N];
void f() {
	for (int i = 1; i <= n; i ++) {
		p[i] = i; 
	}
	for (int i = 1; i <= m; i ++) {
		swap(p[o[i]], p[o[i] + 1]);
	}
	for (int i = 1; i <= n ; i ++) {
		G[i] =(p[i]);
	}
	for (int i = 1; i <= n; i ++) {
		if (M[i]) continue;
		if (i == p[i]) {
			M[i] = 1;
			C ++;
			cyc[i] = C;
			pos[i] = 0;
			V[C].pb(i);
			continue;
		}
		ll x = i;
		ll y = G[i];
		C ++;
		cyc[x] = C;
		pos[x] = V[C].size();
		V[C].pb(x);
		M[x] = 1;
		while (y ^ x) {
			cyc[y] = C;
			pos[y] = V[C].size();
			V[C].pb(y);
			M[y] = 1;
			y = G[y];
		}
	}
	for (int i = m; i; i --) {
		//swap(y[o[i] ], y[o[i] + 1]);
	}
	for (int i = 1; i <= n; i ++) {
		ll cc = cyc[i];
		ll ps = pos[i];
		ll res = ps + k;
		res %= ll(V[cc].size());
		ll id = V[cc][res];
		ans[i] = y[id];
	}
	
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
	}
	for (int i = 1; i <= n; i ++) {
		y[i] = a[i] - a[i - 1]; 
	}
	for (int i = 1; i <= n; i ++) {
		//cout << y[i] << ' ';
	}
	//cout << endl;
	cin >> m >> k;
	for (int i = 1; i <= m; i ++) {
		cin >> o[i];
	}
	f();
	//scout << C << endl;
	cout << ans[1] << '\n';
	Z[1] = ans[1];
	for (int i = 2; i <= n; i ++) {
		Z[i] = ans[i] + Z[i - 1];
		cout << Z[i] << '\n';
	}
    return (0);
}

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

int main() {
    ll n, p;   cin >> n >> p;
    vector<vector<ll>> dp(n+1, vector<ll>(n+1));
    dp[0][0]=1LL;

    for(int i=0; i<n; i++){
        ll x;  cin >> x;
        if(x%2==0){
            dp[i+1][0] = dp[i][0]*2LL;
            dp[i+1][1] = dp[i][1]*2;
        }else{
            dp[i+1][0] = dp[i][0]+dp[i][1];
            dp[i+1][1] = dp[i][0]+dp[i][1];
        }
    }
    cout << dp[n][p] << endl;
}

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

const int mod=1000000007;
int n,w,K;
ll dp[101][10];
int main(){
    cin>>n>>w>>K;
    dp[0][0]=1;
    rep(i,n){
        rep(j,w){
            rep(k,1<<(w-1))if((k&(k>>1))==0){
                /*
                bool flag=true;
                rep(l,w-2){
                    if((k>>l&1)&&(k>>(l+1)&1)){
                        flag=false;
                        break;
                    }
                }
                if(!flag) continue;
                */
                if(k>>j&1){
                    dp[i+1][j+1]+=dp[i][j];
                    dp[i+1][j+1]%=mod;
                }
                else if(j>0&&(k>>(j-1)&1)){
                    dp[i+1][j-1]+=dp[i][j];
                    dp[i+1][j-1]%=mod;
                }
                else{
                    dp[i+1][j]+=dp[i][j];
                    dp[i+1][j]%=mod;
                }
            }
        }
    }
    cout<<dp[n][K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b)*x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

// m is a large prime integer. Usually 1000000007 is used.
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m)%m;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, x; cin >> n >> x;
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());

  vector<ll> fact(n);
  fact[0] = 1;
  for(int i=1; i<n; i++) {
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  vector<ll> modinv(n+1);
  for(int i=1; i<=n; i++) {
    modinv[i] = mod_inverse(i, mod);
  }

  unordered_map<int, ll> mp;
  unordered_map<int, ll> mp2;

  rep(i, n) {
    auto r = x%s[i];
    mp[r] += fact[n-1];
    mp[r] %= mod;
  }

  bool flag = true;
  while(flag) {
    flag = false;
    for(auto e: mp) {
      auto r = e.first;
      auto it = upper_bound(s.begin(), s.end(), r);
      auto k = distance(s.begin(), it);
      if (k==0) {
        mp2[e.first] += mp[e.first];
        mp2[e.first] %= mod;
      }
      for(int i=0; i<k; i++) {
        flag = true;
        auto pos = r%s[i];
        mp2[pos] += e.second * modinv[k];
        mp2[pos] %= mod;
      }
    }
    mp = mp2;
    mp2.clear();
  }

  ll ans = 0;
  for(auto e: mp) {
    ans += e.second*e.first;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007//10^9+7
#define PI acos(-1)

using namespace std;

struct num_t {
	int idnum;
	int num;
	int bl;
} ;

int compare_num(const void *a, const void *b) {
	struct num_t *A = (struct num_t *)a;
	struct num_t *B = (struct num_t *)b;
	if(A->num - B->num >0){
		return 1;
	}else if(A->num - B->num >0){
		return -1;
	}else{
		return 0;
	}
}

int compare_idnum(const void *a, const void *b) {
	struct num_t *A = (struct num_t *)a;
	struct num_t *B = (struct num_t *)b;
	if(A->idnum - B->idnum >0){
		return 1;
	}else if(A->idnum - B->idnum >0){
		return -1;
	}else{
		return 0;
	}
}

int main(void)
{
	//変数の宣言
	int n;
	static struct num_t x[200010];
	int t;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&t);
//		scanf_s("%d",&t);
		x[i].idnum=i;
		x[i].num=t;
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	qsort(x,n,sizeof(num_t),compare_num);

	for(i=0;i<n;i++){
		if(i<n/2){
			x[i].bl=1;
		}else{
			x[i].bl=0;
		}
	}

	temp1=x[n/2-1].num;
	temp2=x[n/2].num;

	qsort(x,n,sizeof(num_t),compare_idnum);

	for(i=0;i<n;i++){
		if(x[i].bl==1){
			printf("%d\n",temp2);
		}else{
			printf("%d\n",temp1);
		}
	}

	//	printf("計算部分終了\n");

	//出力

	//printf("%lld",temp1*temp2);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 6868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(ll i=(a);i<(b);i++)
#define fore(i,a,b) for(ll i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 200005;

int n,m,K;
ll a[MAXN],b[MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>m>>K;
	forn(i,0,n) cin>>a[i];
	forn(i,0,m) cin>>b[i];
	
	forn(i,1,n) a[i]+=a[i-1];
	forn(i,1,m) b[i]+=b[i-1];
	
	ll ans=0;
	forn(i,0,m){
		if(b[i]<=K) ans=max(ans,i+1);
	}
	forn(i,0,n){
		if(a[i]>K) break;
		ll ba=i+1;
		for(int L=0,R=m-1;L<=R;){
			int mid=(L+R)/2;
			if(b[mid]+a[i]<=K){
				ba=max(ba, i+1+mid+1);
				L=mid+1;
			}
			else R=mid-1;
		}
		ans=max(ans,ba);
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 6768
n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= m:
  print(0)
  exit()

d = [0] * (m-1)
x.sort()

for i in range(m-1):
  d[i] = x[i+1] - x[i]
d.sort(reverse=True)
mx = x[-1] - x[0]
r = n - 1
dsum = sum(d[:r])
print(mx - dsum)

Measured memory_bytes: 86056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    double arr[n] = {0};
    double multi = 1;
    fr(i,0,n){
    	cin>>arr[i];
    	multi*=arr[i];
    }
    double sum = 0;
    fr(i,0,n){
    	sum+= (multi)/arr[i];
    }
    double ans = multi/sum;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>

using namespace std;

int main()
{
	stack<int> sta;
	int num;
	while(scanf("%d", &num) != EOF){
		if(num == 0 && sta.empty() == 0){
			printf("%d\n",sta.top());
			sta.pop();
		}else{
			sta.push(num);
		}
	}
	return 0;
}

Measured memory_bytes: 1036
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%s %s",s,t);
    printf("%s%s\n",t,s);
    return 0;
}

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

using namespace std;

using ll = long long;

void max_self(ll &a, ll b) {
 a = max(a, b);
}

int main() {

 int n, W;
 scanf("%d%d", &n, &W);
 vector<ll> dp(W+1);
 for(int item = 0; item < n; item++) {
 	int weight, value;
 	scanf("%d%d", &weight, &value);

	for(int weight_already = W-weight; weight_already >= 0; --weight_already) {
	    max_self(dp[weight_already+weight], dp[weight_already] + value);
	 }
  }

  ll ans = 0;
  for(int i = 0; i <= W; ++i) max_self(ans, dp[i]);

  printf("%lld", ans);
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	sort(rall(a));

	println(accumulate(a.begin(), a.begin() + k, 0));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,d,x;
  cin >> n >> d >> x;
  rep(i,n){
    ll a;
    cin >> a;
    x+=(d-1)/a+1;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
T = [[0]*19 for _ in [0]*19]


def count25(x):
    c2 = c5 = 0
    while x % 2 == 0:
        x //= 2
        c2 += 1
    while x % 5 == 0:
        x //= 5
        c5 += 1
    return c2, c5


for _ in range(N):
    a, *b = input().split('.')
    x = int(a) * 10**9
    if b:
        x += int(b[0])*10**(10-len(b[0]))
    c2, c5 = count25(x)
    T[min(18, c2)][min(18, c5)] += 1

ans = 0
for c2 in range(19):
    for c5 in range(19):
        tt = T[c2][c5]
        if tt == 0:
            continue

        for i in range(18-c2, 19):
            for j in range(18-c5, 19):
                if c2 == i and c5 == j:
                    ans += tt*(tt-1)
                else:
                    ans += tt * T[i][j]

print(ans//2)


Measured memory_bytes: 74072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}
ll MOD = 1000000007;

vector<ll> mfact(1,1);

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}
ll ipow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b % 2 == 1)res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

void factorize(map<ll,ll>& fac, vector<ll>& sieved, ll a){
    while(a != 1){
        if(fac.find(sieved[a]) == fac.end())fac[sieved[a]] = 0;
        fac[sieved[a]]++;
        a/=sieved[a];

    }
}
void primesieve(vector<ll>& res,ll n){
    res = vector<ll>(n+1, -1);
    for(int i = 2;i <= n;i++){
        if(res[i] != -1)continue;
        res[i] = i;
        for(int j = 2;j*i <= n;j++){
            res[j*i] = i;
        }
    }
}
vector<ll> primesuntil(ll n){
    vector<ll> res;
    vector<ll> sieved;
    primesieve(sieved, n);
    for(int i = 2;i <= n;i++){
        if(sieved[i] == i)res.push_back(i);
    }
    return res;
}
int gcd(int a, int b){
    if(b == 0)return a;
    return gcd(b, a%b);
}

int main(){
    ll S;cin>>S;
    ll res = 0;
    for(ll i = 1;i <= S/3;i++){
        ll r = mcomb((S - i*3)+(i-1), i-1);
        res = (res + r)%MOD;
    }
    cout<<res;
}

Measured memory_bytes: 3636
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(n);
	FOR(i,0,n) cin >> a[i];
	
	ll l1 = 0;
	ll l2 = 0;
	
	VSORTR(a);
	ll cnt = 1;
	FOR(i,0,n){
	    if (i>=1){
	        if (a[i]==a[i-1]) cnt+=1;
	        else cnt=1;
	    }
		if(l1==0 && cnt>=2){
			l1 = a[i];
		}else if(l2==0 && ((l1==a[i] &&cnt>=4)or(l1!=a[i] &&cnt>=2))) {
			l2 = a[i];
		}
	}
	cout << l1 * l2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

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

	// 下に殿タイミングで行くか考える

	vector<int> upSum(n + 1, 0);
	vector<int> downSum(n + 1, 0);

	Rep(i, 1, n + 1) {
		upSum[i] = upSum[i - 1] + a[0][i - 1];
		downSum[i] = downSum[i - 1] + a[1][i - 1];
	}

	// 上と下とじゃ一つずれる
	int ans = 0;

	Rep(i, 1, n + 1) {
		int tmp = upSum[i] + downSum[n] - downSum[i - 1];
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
d={}

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
for i in make_divisors(a[0]):
    d[i]=1


for g in range(1,n):
    if g==1:
        new={}
        for i,m in d.items():
            if a[g]%i==0:
                d[i]+=1
                if not a[g]//i in d.keys():
                    new[a[g]//i]=1
        d.update(new)
    else:
        for i,m in d.items():
            if a[g]%i==0:
                d[i]+=1

ans=1
for i,m in d.items():
    if m==n-1 or m==n:
        ans=max(ans,i)
print(ans)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		ans+=(s[i]-'0');
	}
	cout<<(ans%9==0?"Yes":"No")<<endl;
	return 0;
 } 

Measured memory_bytes: 3720
n = int(input())
s = input()
r, g, b = [], [], []
cnt = 1
for i in s:
    if i == 'R':
        r.append(cnt)
    elif i == 'G':
        g.append(cnt)
    else:
        b.append(cnt)
    cnt += 1
rd = set(map(lambda x: x * 2, r)) #以下2つ目の条件を満たさないもの(j - i = k - j)の数え上げ
gd = set(map(lambda x: x * 2, g))
bd = set(map(lambda x: x * 2, b))
ddc = 0
for i in r:
    for j in g:
        if i + j in bd:
            ddc += 1
for j in g:
    for k in b:
        if j + k in rd:
            ddc += 1
for i in r:
    for k in b:
        if i + k in gd:
            ddc += 1
print(len(r) * len(g) * len(b) - ddc) #1つ目の条件を満たすモノから2つ目の条件を満たさないものを引く

Measured memory_bytes: 9764
#include<bits/stdc++.h>
using namespace std;
int i,j,n,k,a,b,c;
int main(){
  cin>>n>>k;
  vector<int> x(n);
  for(;i<k;i++){
    cin>>a;
    for(j=0;j<a;j++){
      cin>>b;b--;
      x[b]++;
    }
  }
  for(i=0;i<n;i++)if(x[i]==0)c++;
  cout<<c;
}

Measured memory_bytes: 3632
package main

import (
        "fmt"
        "os"
)

func main() {
        var a, b, c, d, e, k int
        fmt.Scan(&a, &b, &c, &d, &e, &k)

        arr := []int{e, d, c, b, a}

        l := len(arr)
        for i := 0; i < l; i++ {
                for j := 0; j < l; j++ {
                        if i == j {
                                continue
                        }
                        if arr[i] - arr[j] > k {
                                fmt.Print(":(")
                                os.Exit(0)
                        }
                }
        }
        fmt.Print("Yay!")
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

int n,a[110];
int mi = 1e7,ma = 0;
int ans;

int main()
{
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		if(mi > a[i])mi = a[i];
		if(ma < a[i])ma = a[i];
	}
	
	cout << ma - mi << endl;
	
	
	return 0;
}

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

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


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int digit(int n) {
    int ans = 0;
    while(n){
        n/=10;
        ans++;
    }
    return ans;
}
int pow(int x, int n){
    int ans = 1;
    rep(i,n) ans *= x;
    return ans;
}
int x[6]={0,9,0,900,0,90000};
int main(void) {
    int n; cin >> n;
    int d = digit(n);
    int ans = 0;
    if(d%2==1) ans = n - pow(10,d-1) + 1, d--;
    d--;
    while(d>0){
        ans += x[d];
        d -= 2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
list=[]
for i in range(10):
    a=int(input())
    list.append(a)
A=sum(sorted(list,reverse=True)[:3])

lst=[]
for i in range(10):
    a=int(input())
    lst.append(a)
B=sum(sorted(lst,reverse=True)[:3])

print(A,B)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
 
 

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i,0,N) cin>>A[i];
    int X[N + 1]={0};
    ll ret = 0;
    rep(i,0,N){
        if (i+A[i]<N) X[i+A[i]]++;
        if (i-A[i]>=0){
            ret+=X[i-A[i]];
        } 
    }
    cout << ret << endl;
}

Measured memory_bytes: 5200
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<sstream>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#include<stdlib.h>
#include<time.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
vector<long long> Prime;
void SieveOfEratosthenes(long long e) //setup vector<long long>Prime(~x)
{
	bool *x=new bool[e];
	for (long long i = 0; i <= e; i++)x[i] = false;
	for (long long i = 2; i <= e; i++)
	{
		if (x[i]);
		else
		{
			Prime.push_back(i);
			for (long long l = i; l <= e; l += i)x[l] = true;
		}
	}
	return;
}
int StringToInt(string a)
{
	stringstream ss;
	int x;
	ss << a;
	ss >> x;
	return x;
}
string IntToString(int a)
{
	stringstream ss;
	string x;
	ss << a;
	ss >> x;
	return x;
}
int GetRandom(int MIN, int MAX)
{
	static int flag=0;
	if (flag == 0)
	{
		srand((unsigned int)time(NULL));
		flag = 1;
	}
	return MIN + (int)(rand()*(MAX - MIN + 1.0) / (1.0 + RAND_MAX));
}
int in()
{
	int x;
	cin >> x;
	return x;
}
void outl(string a)
{
	cout << a << endl;
	return;
}
void outl(int a)
{
	cout << a << endl;
	return;
}
void out(string a)
{
	cout << a;
	return;
}
void out(int a)
{
	cout << a;
	return;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
 (char)A=(int)65
 (char)a=(int)97
*/
////////////////////////////////////////////////////

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		char a[1500];
		string  b;
		cin >> a >> b;
		string T;
		for (int i = strlen(a) - 1; i >= 0; i--)
		{
			switch (a[i])
			{
			case'A':
				reverse(b.begin(), b.end());
				break;
			case'J':
				T = "";
				T += b[b.size() - 1];
				for (int h = 0; h < b.size() - 1; h++)T += b[h];
				b = T;
				break;
			case'M':
				for (int l = 0; l < b.size(); l++)
				{
					if (b[l] >= '0'&&b[l] <= '9')
					{
						if (b[l] == '9')b[l] = '0';
						else b[l] += 1;
					}
				}
				break;
			case'P':
				
				for (int l = 0; l < b.size(); l++)
				{
					if (b[l] >= '0'&&b[l] <= '9')
					{
						if (b[l] == '0')b[l] = '9';
						else b[l] -= 1;
					}
				}
				break;
			case'C':
				T = "";
				for (int l = 1; l < b.size(); l++)T += b[l];
				T += b[0];
				b = T;
				break;
			case'E':
				string r="", l="",m="";
				for (int j = 0; j < b.size(); j++)
				{
					if (j < b.size() / 2)r += b[j];
					else if (j == b.size() / 2 && b.size() % 2 == 1)m += b[j];
					else l += b[j];
				}
				b = l + m + r;
				break;
			}
		}
		cout << b << endl;

	}


}

Measured memory_bytes: 1220
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input()) - 1

print(a[k])


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt() - i - 1;
		}
		sc.close();

		Arrays.parallelSort(a);
		int mid = a[n / 2];

		long ans = 0L;
		for (int i = 0; i < a.length; i++) {
			ans += Math.abs(a[i] - mid);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 91596
N = int(input())
p = list(map(int, input().split()))
count = 0
#print(p)

q = sorted(p)
#print(q)

for i in range(N):
  if p[i] != q[i]:
    count += 1
    
if count <= 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	ll ans=0, anum=0, bnum=0, cnum=0;

	cin>>n;

	vs s(n);

	rep(i, n){
		cin>>s[i];
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A'){
			cnum++;
		} else if(s[i][0]=='B'){
			bnum++;
		} else if(s[i][s[i].size()-1]=='A'){
			anum++;
		}

		int ptr=0;
		while(1){
			ptr=s[i].find("AB", ptr);
			if(ptr<s[i].size()){
				ans++;
				ptr++;
			} else{
				break;
			}
		}
	}

	if(cnum==0){
		cout<<ans+min(anum, bnum)<<endl;
	} else if(anum+bnum>0){
		cout<<ans+min(anum, bnum)+cnum<<endl;
	} else{
		cout<<ans+cnum-1<<endl;
	}
}


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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;


void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0 && A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}


void shellSort(int A[],int n){
    for(int h=1; ;){
        if(h>n)break;
        G.push_back(h);
        h=3*h+1;
    }

    for(int i=G.size()-1;i>=0;i--){
        insertionSort(A,n,G[i]);
    }
}


int main(){
    cin>>n;

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

    shellSort(A,n);

    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;i--){
        printf("%d",G[i]);
        if(i)printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i=0;i<n;i++)printf("%d\n",A[i]);
    return 0;
}


Measured memory_bytes: 7140
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>

using namespace std;

#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    bool flag = false;
    for(auto i : v) {
        if(i % 2 == 0) {
            if((i%3 == 0) || (i%5 == 0)) {
                continue;
            } else flag = true;
        }
    }
    if(flag) {
        cout << "DENIED\n";
    } else
        cout << "APPROVED\n";
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] line = sc.nextLine().split(" ");
        int[] arr = new int[n];
        int temp;
        int count = 0;
        for(int x = 0; x < n; x++){
            arr[x] = Integer.parseInt(line[x]);
        }

        for(int i=0; i < n; i++){
            int min = i;
            for(int j = i+1; j < n; j++){
                if(arr[min] > arr[j]){
                    min = j;
                }
            }
            if(i != min){
                temp = arr[i];
                arr[i] = arr[min];
                arr[min] = temp;
                count++;
            }
        }
        for(int x = 0; x < n; x++){
            if(x == n-1){
                System.out.println(arr[x]);
            }else{
                System.out.print(arr[x]);
                System.out.print(" ");
            }
        }
        System.out.println(count);
        

    }
}

Measured memory_bytes: 26272
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    int n, l, r; string s;
    cin >> n; l = n/100; r = n%100;
    if(l && l <13){
        if(r && r < 13) s = "AMBIGUOUS";
        else s = "MMYY";
    }else{
        if(r && r < 13) s = "YYMM";
        else s = "NA";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,i,m,a[100],count=0;
	double s=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	s=s/4.0/m;
	for(i=0;i<n;i++)
	{
		if(a[i]>=s)
		count++;
	}
	if(count>=m)
	cout<<"Yes";
	else
	cout<<"No";
}

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

int main() {

  int A, B, C; cin >> A >> B >> C;
  if (C > A + B + 1) {
    cout << A + 2 * B + 1 << endl;
  }
  else {
    cout << B + C << endl;
  }
  
    
}


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

#define ll long long
#define pi acos(-1)
#define valid(a , b) a >= 0 && a < r && b >= 0 && b < c && arr[a][b] == '.'

int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.cpp", "r" , stdin);
    //freopen("output.cpp" , "w" , stdout);
    #endif // ONLINE_JUDGE
    //*/
    int h , n;cin >> h >> n;
    ll mx = 0;
    for(int i = 0 ; i < n ; i++){
        int a;cin >> a;
        mx += a;
    }
    if(mx >= h)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
f = 0
d = 0

for i in range(n):
    a.append(a[i])

for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            f += 1

for i in range(n):
    for j in range(1, n):
        if a[i] > a[i + j]:
            d += 1

ans = ((f + f + d*(k - 1))*k//2)%mod
print(ans)

Measured memory_bytes: 9148
package main

import (
	"fmt"
)

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

	max := 0
	now := 0
	for _, str := range s {
		if string([]rune{str}) == "I" {
			now++
		} else {
			now--
		}
		if max < now {
			max = now
		}
	}
	fmt.Println(max)

}


Measured memory_bytes: 512