akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int A, B;

void solve() {
    int num = 0;
    for (int i = A; i <= B; ++i) {
        string s = to_string(i);
        bool flag = true;
        for (int j = 0; j < int(s.size()); ++j) {
            if (s[j] != s[int(s.size()) - j - 1]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            num++;
        }
    }
    printf("%d\n", num);
}

int main() {
    cin >> A >> B;
    solve();
    return 0;
}

Measured memory_bytes: 3740
s=int(input())

def find_power(n,mod=10**9+7):
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n,mod=10**9+7):
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
mod = 10**9+7
NUM = 2000
p_lis=find_power(NUM,mod)
ip_lis=find_inv_power(NUM,mod)

def comb(n,r,mod=10**9+7):
    if n<r:
        return 0
    elif n>=r:
        return (p_lis[n]*ip_lis[r]*ip_lis[n-r])%(mod)

ans=0
for i in range(1,s):
    nokori=s-3*i
    if nokori<0:
        continue
    num = comb(nokori+i-1,i-1)
    ans+=num

print(ans%mod)

Measured memory_bytes: 65676
N = int(input())
A = list(map(int,input().split()))
flag = 1
count = 0
while flag == 1:
    for i in range(N):
        if A[i]%2 != 0:
            flag = 0
            break
        else:
            A[i] = int(A[i]/2)
    count += 1
print(count-1)

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

const int MAXN = 205;

int N;
char s[5], res[MAXN];

int main(){
	scanf("%d", &N);
	
	int prv, cur;
	
	printf("?");
	for(int i = 1; i <= N; i++){
		printf(" %d", i);
	}
	printf("\n");
	fflush(stdout);
	
	scanf("%s", s);
	prv = (s[0] == 'R');
	
	int left = 1, right = N;
	while(left < right){
		int mid = (left + right + 1) / 2;
		
		printf("?");
		for(int j = 1; j <= N; j++){
			printf(" %d", mid + j - 1);
		}
		printf("\n");
		fflush(stdout);
		
		scanf("%s", s);
		cur = (s[0] == 'R');
		
		if(cur == prv){
			left = mid;
		}else{
			right = mid - 1;
		}
	}
	int L = left + 1, R = left + N - 1;
	
	if(L > 1)res[L - 1] = prv ? 'R' : 'B';
	if(R < 2 * N)res[R + 1] = prv ? 'B' : 'R';
	
	for(int i = 1; i < L - 1; i++){
		printf("? %d", i);
		for(int j = L; j <= R; j++){
			printf(" %d", j);
		}
		printf("\n");
		fflush(stdout);
		
		scanf("%s", s);
		cur = (s[0] == 'R');
	
		res[i] = cur ? 'R' : 'B';
	}
	for(int i = R + 2; i <= 2 * N; i++){
		printf("? %d", i);
		for(int j = L; j <= R; j++){
			printf(" %d", j);
		}
		printf("\n");
		fflush(stdout);
		
		scanf("%s", s);
		cur = (s[0] == 'R');
	
		res[i] = cur ? 'R' : 'B';
	}
	
	for(int i = L; i <= R; i++){
		printf("? %d", i);
		
		for(int j = 1; j < L - 1; j++){
			printf(" %d", j);
		}
		for(int j = R + 2; j <= 2 * N; j++){
			printf(" %d", j);
		}
		printf("\n");
		fflush(stdout);
		
		scanf("%s", s);
		cur = (s[0] == 'R');

		res[i] = cur ? 'R' : 'B';
	}
	
	res[2 * N + 1] = 0;
	printf("! %s\n", res + 1);
	
	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma region BIT
struct BIT
{
	vector<int> bit;
	int n;
	//i-indexed
	BIT() { init(-1); }
	BIT(int n_) { init(n_); }
	void init(int n_)
	{
		n = n_;
		bit.clear();
		bit.resize(n + 1, 0);
	}
	int sum(int i)
	{
		int s = 0;
		while (i > 0)
		{
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x)
	{
		if (i == 0)return;
		while (i <= n)
		{
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum0(int i)
	{
		return sum(i + 1);
	}
	void add0(int i, int x)
	{
		add(i + 1, x);
	}
};
#pragma endregion

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n, q; cin >> n >> q;
	vector<vector<int>> v(500100);
	vector<int> c(n); rep(i, n)cin >> c[i];
	vector<pair<int, int>> query(q);
	vector<vector<int>> u(n);
	rep(i, q)
	{
		int l, r; cin >> l >> r;
		--l, --r;
		query[i] = { l,r };
		u[l].push_back(r);
	}
	map<pair<int, int>, int> mp;
	BIT bit(n);
	rrep(i, n)
	{
		if (v[c[i]].size() > 0)bit.add(v[c[i]].back(), 1);
		v[c[i]].push_back(i);
		for (int x : u[i])
		{
			mp[{i, x}] = x - i + 1 - bit.sum(x);
		}

	}
	rep(i, q)cout << mp[{query[i].first, query[i].second}] << endl;
}

Measured memory_bytes: 90972
import java.util.*

fun main(args: Array<String>) {
    val (N, K) = readIntList()
    val P = readLongList()
    var max = P.take(K).sum()
    var now = max

    for (pos in K until N) {
        now -= P[pos-K]
        now += P[pos]
        if (now > max)
            max = now
    }
    println((max+K)/2.0)
}

fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 61372
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>
inline void read(T &x) {
	Finish_read=0;x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;Finish_read=1;
}
template<class T>
inline void print(T x) {
	if(x/10!=0)
		print(x/10);
	putchar(x%10+'0');
}
template<class T>
inline void writeln(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
	putchar('\n');
}
template<class T>
inline void write(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
}
/*================Header Template==============*/
ll s=1;
int n,k;
int main() {
	read(n);
	read(k);
	while(n--) {
		if(s>k)
			s+=k;
		else
			s*=2;
	}
	writeln(s);
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int a[12]={0,2,0,1,0,1,0,0,1,0,2,0};
	int x,y;
	cin>>x>>y;
	if(a[x-1]==a[y-1])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int lu,i,nr,u;
stack<int>st;
char s[100010];
int main()
{
   // ifstream cin ("a.in");
   // ofstream cout ("a.out");
    cin>>s;
    lu=strlen(s);
    for(i=0; i<lu; ++i)
    {
        if(st.empty())st.push(s[i]-'0');
        else
        {
            u=st.top();
            if(u+s[i]-'0'==1)st.pop(),nr+=2;
            else st.push(s[i]-'0');
        }
       /// cout << st.size()<<'\n';
    }
    cout<<nr;
    return 0;
}


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

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	long long s = 0, k = int64_t(n) * int64_t(n + 1) / 2LL;
	vector < int > a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		s += a[i];
	}
	if (s % k)
		cout << "NO\n";
	else {
		k = s / k;
		bool fucked_up = 0;
		for (int i = 0; i < n; ++i) {
			int t = k - a[(i + 1) % n] + a[i];
			fucked_up = fucked_up || (t < 0 || t % n);
		}
		if (fucked_up)
			cout << "NO\n";
		else
			cout << "YES\n";
	}
}


Measured memory_bytes: 3688
#include<stdio.h>
int main(void){
  int a[5];
  scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
  printf("%d",15-a[0]-a[1]-a[2]-a[3]-a[4]);
  return 0;
}

Measured memory_bytes: 1680
// author -> LetsGoAC
#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  ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) cout<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
vector   <int> Fact(100005 , 0);
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int mod_inverse(int n , int m)
{   //mod = m; // change const mod;
    int modi = power(n , m-2);
    return modi;
}
int  pct(int x)
{    return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void cal_fac()
{
     Fact[0] = Fact[1] = 1;
     for(int i=2; i<1e5; i++)
         Fact[i] = (Fact[i-1]*i)%mod;
}
int C(int n , int k)
{
    int res = Fact[n];
    res = (res * mod_inverse( Fact[k] , mod ))%mod;
    res = (res * mod_inverse( Fact[n-k] ,mod ))%mod;
    return res;
}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- 1.cpp --------------------------------- */
const int maxn = 1e6+5;
void solve(int tc)
{
    //cout<<"Case #"<<tc<<": \n";
    int n,i,j,k,m,q,l,r,x,t;
    string s;
    cin>>s;

    m = 0;
    for(char x:s)
        m += (x -'0');
    //cout<<m<<endl;
    if( (m%9) == 0l)
        cout<<"Yes";
    else
        cout<<"No";
}   
signed main()
{
    // 1.cpp
    RAGE;
 //   db();  
    int t=1;
    //  cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
 //   timeit();
    return 0;
}
/*
    1. To find 2's complement , reverse all the bits after 1st set bit. (right - >left.)
*/


Measured memory_bytes: 4520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);

  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  bool exist = false;
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool match = true;
      for (int k = 0; k < m; k++) {
        if (!match) break;
        for (int l = 0; l < m; l++) {
          if (a[i+k][j+l] != b[k][l]) {
            match = false;
            break;
          }
        }
      }

      if (match) {
        exist = true;
        break;
      }
    }
  }

  if (exist) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n , kk ; cin >> n >> kk;
    vector<ll> v(n);
    rep(i,n) cin >> v.at(i);

    vector<vector<vector<ll>>> tbl(51,vector<vector<ll>>(51,vector<ll>(51,-LINF)));

    for(int i=0;i<=n;i++){ //i個宝石を取る 1ループ目
        for(int l=0;l<=i;l++){ //左からl個取り、 2ループ目
            ll r = i-l; //右からr=i-l取ることを考える
            vector<ll> juery(0);
            ll juerysum = 0;
            for(int k=0;k<l;k++){
                juery.push_back(v.at(k));
                juerysum+=v.at(k);
            }
            for(int k=n-1;k>=n-r;k--){
                juery.push_back(v.at(k));
                juerysum+=v.at(k);
            }
            sort(juery.begin(),juery.end());
            tbl.at(0).at(i).at(l) = juerysum;
            for(int j=1;j<=i;j++){ //j個返却することを考える
                tbl.at(j).at(i).at(l) = tbl.at(j-1).at(i).at(l) - juery.at(j-1);
            }
        }
    }
    ll ans = 0;
    for(int z = 0;z<=kk;z++){
    rep(i,51){
        rep(j,51){
            rep(k,51){
                if(i+j==z) ans = max(ans,tbl[i][j][k]);
            }
        }
    }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll A,B,m;cin>>A>>B>>m;
  ll a[A],b[B];
  rep(i,0,A)cin>>a[i];
  rep(i,0,B)cin>>b[i];

  ll x[m],y[m],c[m];
  rep(i,0,m){
    cin>>x[i]>>y[i]>>c[i];
    x[i]--,y[i]--;
  }

  ll mi=INF;
  rep(i,0,m){
    mi=min(mi,a[x[i]]+b[y[i]]-c[i]);
  }

  ll mia=*min_element(a,a+A);
  ll mib=*min_element(b,b+B);

  out(min(mi,mia+mib));




  return 0;
}


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

int main(){
  int n;
  char c;
  bool flag = false;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> c;
    if(c == 'Y')
      flag = true;
  }
  if(flag) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		String b = stdIn.next();
		
		if (a.charAt(0) == b.charAt(2) && a.charAt(1) == b.charAt(1) && a.charAt(2) == b.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int Search(string t,char s){
    
    int len = t.size();
    for(int i=0;i<len;i++){
        if(t[i] == s) return i;
    }
    
    return -1;
}
int main(void){

    string t = "abcdefghijklmnopqrstuvwyz";
    string s;
    cin >> s;
    int len = s.size();
    
    for(int i=0;i<len;i++){
        if(Search(t,s[i]) != -1) t[Search(t,s[i])] = ' ';
    }
    
    len = t.size();
    for(int i=0;i<len;i++){
        if(t[i] != ' '){
            cout << t[i] << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
}

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

using namespace std;


template <class T>
std::istream& operator>>(std::istream& in, std::vector<T>& data) {
    for (auto& item : data) {
        in >> item;
    }
    return in;
}

template <class T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& data) {
    bool first = true;
    for (const auto& item : data) {
        if (!first) {
            out << " ";
        }
        out << item;
        first = false;
    }
    return out;
}


vector<int> nums;
vector<char> symbols = {'0', '1', '3', '4', '5', '6', '7', '8', '9'};
int counter = 0;

void gen_numbers(int current) {
    if (current >= 1000000) {
        return;
    }
    if (current % 13 == 5) {
        nums.push_back(current);
        ++counter;
    }
    for (int c = 0; c <= 9; ++c) {
        if (c == 0 && current == 0) {
            continue;
        }
        gen_numbers(10 * current + c);
    }

}


int main() {
#ifdef LOCAL
    freopen("atcoder/2/input.txt", "r", stdin);
#endif

    gen_numbers(0);
    int real_count = counter;

    int mod = (int)1e9 + 7;
    string s;
    cin >> s;
//    reverse(s.begin(), s.end());

    vector<vector<int64_t>> dp(s.size() + 1, vector<int64_t>(13, 0));
    dp[0][0] = 1;

    int64_t power = 1;

    for (int idx = 0; idx < s.size(); ++idx) {
        for (int rem = 0; rem < 13; ++rem) {
            if (s[idx] == '?') {
                for (int i = 0; i <= 9; ++i) {
                    int new_rem = (10 * rem + i) % 13;
//                    if (new_rem >= 10 && idx < 1) {
//                        continue;
//                    }

                    dp[idx + 1][new_rem] += dp[idx][rem];
                    dp[idx + 1][new_rem] %= mod;
                }
            } else {
                int new_rem = (10 * rem + (s[idx] - '0')) % 13;
//                if (new_rem >= 10 && idx < 1) {
//                    continue;
//                }
                dp[idx + 1][new_rem] += dp[idx][rem];
                dp[idx + 1][new_rem] %= mod;
            }
        }
//        power *= 10;
//        power %= 13;
    }

//    for (const auto& vec : dp) {
//        cout << vec << "\n";
//    }

//    cout << "real: " << real_count << "\n";
    cout << dp[s.size()][5] << "\n";


    return 0;
}











Measured memory_bytes: 13944
#include "bits/stdc++.h"
using namespace std;

const int MAXN = 2e5 + 5;
const long long MAX = 2e9, INF = 1e18;

int n;
long long a[MAXN];
long long finalAns, sumL[MAXN][2], sumR[MAXN][2];
long long ans[MAXN][3];
bool found[MAXN][3];

long long dp(int pos, int rem){
	if(pos >= n)
		return (rem == 0) ? 0:-INF;
	if(found[pos][rem])
		return ans[pos][rem];
	found[pos][rem] = true;
	ans[pos][rem] = dp(pos+2, rem)+a[pos];
	if(rem > 0)
		ans[pos][rem] = max(ans[pos][rem], dp(pos+1, rem-1));
	return ans[pos][rem];
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%lld", &a[i]);
		a[i] += MAX;
	}
	if(n%2 == 0){
		finalAns = max(dp(0, 0), dp(0, 1));
	}else{
		finalAns = max(dp(0, 1), dp(0, 2));
	}
	printf("%lld\n", finalAns-(MAX*(n/2)));
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	string str;
	int A,B;
	std::cin >> A >> B;
	std::cin >> str;
	for (size_t i = 0; i < A; i++) {
		if (str[i] < '0' || '9' < str[i]) {
			std::cout << "No" << '\n';
			return 0;
		}
	}
	if (str[A] != '-') {
		std::cout << "No" << '\n';
		return 0;
	}
	for (size_t i = 0; i < B; i++) {
		if (str[A+1+i] < '0' || '9' < str[A+1+i]) {
			std::cout << "No" << '\n';
			return 0;
		}
	}

	std::cout << "Yes" << '\n';
	return 0;
}


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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;

bool solve(int v){
        int sum = 0;
        for(int i = v; i >= 1; i--){
                if(sum + i <= n) sum += i;
        }
        return sum == n;
}

int main()
{
        cin >> n;
        int lo = 1, hi = n;
        while(lo != hi){
                int mi = (lo + hi) / 2;
                if(solve(mi)) hi = mi;
                else lo = mi + 1;
        }
        int sum = 0;
        for(int i = lo; i >= 1; i--){
                if(sum + i <= n){
                        cout << i << '\n';
                        sum += i;
                }
        }
        return 0;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100+10;

int n,m,c,col[N][N];

void go(int& x,int& y) {
	if (x&1) {
		if (y==m) ++x;
		else ++y;
	} else {
		if (y==1) ++x;
		else --y;
	}
}

int main() {
	n=read(),m=read(),c=read();
	for (int i=1,x=1,y=1;i<=c;++i) {
		int s=read();
		while (s--) col[x][y]=i,go(x,y);
	}
	for (int i=1;i<=n;++i) {
		for (int j=1;j<=m;++j) printf("%d ",col[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3808
import math
import cmath
def check(inp):
    if inp==2:
        return True
    for num in xrange(2,int(math.sqrt(inp)+1)):
        if inp%num==0:
            return False
    return True
st=set()


while True:
    try:
       str=raw_input().strip()

    except EOFError:
        break
    #print str
    num=int(str)
    st.add(num)
sum=0
for nm in st:
    if check(nm):
        sum+=1
print sum


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

int main() {
int ans = 0;
  int N, K;
  cin >> N >> K;
  rep(i ,N){
    int h;
    cin >> h;
    if(h >= K)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    static int h;
 
    private static void maxHeapify(int[] a, int i) {
        int l = i * 2;
        int r = i * 2 + 1;
 
        int largest = (l <= h && a[l] > a[i])? l : i;
        if(r <= h && a[r] > a[largest]) largest = r;
 
        if(largest != i) {
            int tmp = a[i];
            a[i] = a[largest];
            a[largest] = tmp;
            maxHeapify(a, largest);
        }
    }
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
  
        h = sc.nextInt();
        int[] a = new int[h + 1];
 
        for(int i = 1; i <= h; i++) {
            a[i] = sc.nextInt();
        }
 
        for(int i = h / 2; i >= 1; i--) {
            maxHeapify(a, i);
        }
 
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= h; i++) {
            sb.append(" ").append(a[i]);
        }
        System.out.println(sb);
 
        sc.close();
    }
}


Measured memory_bytes: 166648
// https://atcoder.jp/contests/abc050/tasks/abc050_a
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B;
  char c;
  cin >> A >> c >> B;

  (c == '+') ? cout << A + B : cout << A - B;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define ALL(v) (v).begin(),(v).end()
#define FOR(i, n) for(ll (i)=0; (i)<(n); (i)++)
#define RFOR(i, n) for(ll (i)=(n)-1; (i)>=0; (i)--)
#define REP(i, x, n) for(ll (i)=(x); (i)<(n); (i)++)
#define RREP(i, x, n) for(ll (i)=(n)-1; (i)>=x; (i)--)

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

        char a;
        cin >> a;
        if ('a' <= a && a <= 'z') cout << "a" << endl;
        else cout << "A" << endl;

        return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int64_t N, K;
    cin >> N >> K;
    cout << int64_t (K * pow(K - 1, N - 1)) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan= new Scanner(System.in);
String A=scan.next();
String B=scan.next();
String C=scan.next();
String D=scan.next();
String E=scan.next();
int a=Integer.parseInt(A);
int b=Integer.parseInt(B);
int c=Integer.parseInt(C);
int d=Integer.parseInt(D);
int e=Integer.parseInt(E);
if(a>=c+e&&b>=d+e&&c-e>=0&&d-e>=0)
System.out.println("Yes");
else
System.out.println("No");
}
}

Measured memory_bytes: 26296
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    char c;
    cin >> c;
    cout << (char)(c + 1) << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

void imie() {
	cout << "hello" << "\n";
}

const ll INF = 1e18 + 5;

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

	vector<double> dp(n+1); //heads at n
	dp[0] = 1;

	for (int i = 0; i < n; i++) {
		double p_heads;
		cin >> p_heads;
		for (int j = i+1; j >= 0; j--) {
			dp[j] = (j==0 ? 0 : p_heads * dp[j - 1]) + (1 - p_heads) * dp[j];
		}
	}

	double prob = 0;
	for (int i = n/2+1; i < n+1; i++) {
		prob += dp[i];
	}

	cout << setprecision(10) << prob;

}

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

	solve();

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


llong get_digit(llong a, llong b){
    return max(to_string(a).size(), to_string(b).size());
}

int main(int argc, char**argv){
    llong n;
    cin >> n;

    llong ans = 999999999999;
    for (llong i = 1; i <= floor(sqrt(n)); i++){
        if (n % i == 0){
            ans = min(ans, get_digit(i, n/i));
        }
    }
    cout << ans << endl;

    return 0;
}












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

bool isKaibun(string s)
{
    string temp = s;
    reverse(s.begin(), s.end());
    return temp == s;
}

bool isStrongKaibun(string s)
{
    int N = s.size();
    if (N == 1)
    {
        return true;
    }
    else
    {
        string zenhan = s.substr(0, (N - 1) / 2);
        string kouhan = s.substr((N + 3) / 2 - 1);
        return isKaibun(zenhan) && isKaibun(kouhan);
    }
}

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

    if (!isKaibun(S))
    {
        cout << "No" << endl;
        return 0;
    }

    bool ans = isStrongKaibun(S);

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
}


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

int main(){
	int tc, angka;
	int s[15], h[15], c[15], d[15];
	memset(s, 0, sizeof(s));
	memset(h, 0, sizeof(h));
	memset(c, 0, sizeof(c));
	memset(d, 0, sizeof(d));
	char card;
	scanf("%d", &tc); getchar();
	for(int i=0; i<tc; i++){
		scanf("%c %d", &card, &angka);
		if(card=='S') s[angka] = 1;
		else if (card=='H') h[angka] = 1;
		else if (card=='C') c[angka] = 1;
		else if (card=='D') d[angka] = 1;
		getchar();
	}
	
	for(int j=1; j<=13; j++){
		if(s[j]!=1) printf("S %d\n", j);
	}
	for(int k=1; k<=13; k++){
		if(h[k]!=1) printf("H %d\n", k);
	}
	for(int l=1; l<=13; l++){
		if(c[l]!=1) printf("C %d\n", l);
	}
	for(int m=1; m<=13; m++){
		if(d[m]!=1) printf("D %d\n", m);
	}
	
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  rep(i, A)
  {
    if (S.at(i) < 48 || S.at(i) > 57)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  if (S.at(A) != '-')
  {
    cout << "No" << endl;
    return 0;
  }
  for (int i = A + 1; i < A + B + 1; i++)
  {
    if (S.at(i) < 48 || S.at(i) > 57)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << 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 srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define rsort(a) sort(all(a)); reverse(all(a))
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
void maxi(int &a, int b) {if(a<b) a = b;}
void mini(int &a, int b) {if(a>b) a = b;}
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
const int MOD = 1e9+7;
//ll fact[N];






void solve()
{
    int n;
    cin>>n;
    vi x(n), y(n);
    vi plus(n), minus(n);
    
    int max1, max2, min1, min2;
   
    int ans = 0;
    rep(i,n) {
        cin>>x[i] >> y[i];
        if(i==0) {
            max1 = min1 = x[0] + y[0];
            max2 = min2 = x[0] - y[0];
        }
        plus[i] = x[i] + y[i];
        minus[i] = x[i] - y[i];
        max1 = max(max1, plus[i]);
        min1 = min(min1, plus[i]);
        max2 = max(max2, minus[i]);
        min2 = min(min2, minus[i]);
        
    }
    // cerr<<plus<<"\n";
    // cerr<<max1<<" "<<min1<<" "<<max2<<" "<<min2<<"\n";
    ans = max(max1 - min1, max2 - min2);

    cout<<ans;
}

int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}








ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}
/*
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 6368
//106
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;
string s;

int main() {
	cin >> A >> B;
	//int ans = max(A, max(B, C)) * 10 + A + B + C - max(A, max(B, C));
	cout << (A-1)*(B-1) << endl;

	return 0;
}

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

int binarySearch(int* a, int key, int left, int right){
//	cout << "called binarySearch(a, " << key << ", " << left << ", " << right << ")" << endl;  
	if(left + 1 == right){
		if(a[left] == key)
			return left;
		else if(a[right] == key)
			return right;
		else
			return -1;
	}else{
		int center = (left + right) / 2; // ?????????????????°?????????
		if(a[center] == key){
			return center;
		}else if(key < a[center]){
			return binarySearch(a, key, left, center);
		}else{
			return binarySearch(a, key, center, right);
		}
	}
}

int main(){

	int n, q;
	cin >> n;
	int S[n];
	for(int i=0; i<n; i++)
		cin >> S[i];
	
	cin >> q;
	int T[q];
	for(int j=0; j<q; j++)
		cin >> T[j];

	int cnt = 0;
	// ????????¢?´¢?????????????????????
	for(int j=0; j<q; j++){
		if(binarySearch(S, T[j], 0, n-1) >= 0)
			cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void){
    int n,i;
    double s[1000],avg,ans;
    while(true){
        cin>>n;
        avg=0;
        ans=0;
        if(n==0) break;
        for(i=0;i<n;i++){
            cin>>s[i];
            avg+=s[i];
        }
        avg/=n;
        for(i=0;i<n;i++){
            ans+=pow(s[i]-avg,2);
        }
        printf("%.8lf\n",sqrt(ans/n));
    }
    
    return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
string S;
cin>>N>>S;
int cnt=0;
rep(i,N-2){
    if(S.substr(i,3)=="ABC"){
        cnt++;
    }
}
cout<<cnt<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int main()
{
	int i = 0, a, x;
	int f[26];
	string in, out;
	for (int j = 0; j < 26; j++)
	{
		f[j] = 0;
	}
	cin >> in;
	
	while (in[i] != '\0')
	{
		for(int j = 0; j < 26; j++)
		{
			if (in[i] == (char)('a' + j))
			{
				f[j] = i+1;
			}
		}
		i++;
	}

	if (i < 25) {
		for (int j = 0; j < 25; j++) 
		{
			if (f[j] == 0) {
				out = in + (char)('a' + j);
				break;
			}
		}
	}
	else {
		if (in == "zyxwvutsrqponmlkjihgfedcba")
		{
			out = "-1";
		}
		else {
			for (int j = 25; j > 0; j--) {

				if ((int)(in[j]) > (int)(in[j - 1]))
				{
					string str = in.substr(0, j - 1);
					char max = in[j - 1];

					for (int k = 25; k > j - 1; k--)
					{
						if ((int)(in[k]) > (int)(max)) {
							max = in[k];
							out = str + max;
							break;
						}
					}
					break;
				}
			}
		}
	}

/*	for (int l = 0; l < 26; l++)
	{
		cout << f[l];
	}
*/
	cout << out;
//	cin >> a;
	return 0;
}

Measured memory_bytes: 256
<?php
/**
 * AGC034
 * A - Kenken Race
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d %d %d", $n, $a, $b, $c, $d);
$s = trim(fgets(STDIN));

$dp_funuke[$b - 1] = true;
$dp_funuke[$b] = true;
for ($i = $b + 1; $i <= $d; $i++) {
    if (($s[$i - 1] ?? '#') !== '.') {
        $dp_funuke[$i] = false;
        continue;
    }
    $dp_funuke[$i] = ($dp_funuke[$i - 1] or $dp_funuke[$i - 2]);
}

if (! $dp_funuke[$d]) {
    echo 'No', PHP_EOL;
    exit;
}

$dp_sunuke[$a - 1] = true;
$dp_sunuke[$a] = true;
for ($i = $a + 1; $i <= $c; $i++) {
    if (($s[$i - 1] ?? '#') !== '.') {
        $dp_sunuke[$i] = false;
        continue;
    }
    $dp_sunuke[$i] = ($dp_sunuke[$i - 1] or $dp_sunuke[$i - 2]);
}

if (! $dp_sunuke[$c]) {
    echo 'No', PHP_EOL;
    exit;
}

if ($c > $d) {
    $no_flag = true;
    for ($i = max($a, $b); $i <= min($c, $d); $i++) {
        if (($s[$i - 2] ?? '#') === '.' and $s[$i - 1] === '.' and ($s[$i] ?? '#') === '.') {
            $no_flag = false;
            break;
        }
    }
    if ($no_flag) {
        echo 'No', PHP_EOL;
        exit;
    } 
}

echo 'Yes', PHP_EOL;


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

void solve(int a, int b) {
    int count = 0;
    for (int i = 1; i < a; i++) {
        for (int j = i + 1; j < a; j++) {
            int k = b - i - j;
            if (k > j && k <= a) {
                count++;
                //cout << i << j << k << endl;
            }
        }
    }
    cout << count << endl;
}

int main() {
    int a, b;
    while (1) {
        cin >> a >> b;
        if (a + b == 0) break;
        solve(a, b);
    }
}

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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define rep(var,n)  for(int var=0;var<(n);++var)
#define ALL(c)  (c).begin(),(c).end()


#include <vector>
using namespace std;

vector<int> primes;
vector<int> smallest_prime_factor; // not used

int sieve(int nmax){
    primes.clear();
    smallest_prime_factor.assign(nmax+1, 0);

    for (int n=2; n<=nmax; ++n) {
        if (!smallest_prime_factor[n]) {
            primes.push_back(n);
            for (int kn=n; kn<=nmax; kn+=n) {
                if (!smallest_prime_factor[kn]) {  // ←このチェックをせずに上書きを続けると largest_prime_factor[] が出来上がる
                    smallest_prime_factor[kn] = n;
                }
            }
        }
    }
    return primes.size();
}


void solve(int N) {
    for(int p:primes){
        if (p % 5 == 1) {
            cout << p;
            --N;
            if (N == 0) {
                cout << endl;
                return;
            }
            cout << " ";
        }
    }
}

int main() {
    sieve(55555);

    int N; cin>>N;
    solve(N);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <cstring>
#include <random>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

int main() {

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

    int n;
    cin >> n;

    vector<pii> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(all(a));

    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        int pos = (n - 1) / 2;
        if (i <= pos) {
            ++pos;
        }
        ans[a[i].second] = a[pos].first;
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";

}



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

int main(){
  string S;
  cin >> S;
  if (S == "SUN") {
      cout << "7" << endl;
  } else if (S == "MON") {
      cout << "6" << endl;
  }else if (S == "TUE") {
      cout << "5" << endl;
  }else if (S == "WED") {
      cout << "4" << endl;
  }else if (S == "THU") {
      cout << "3" << endl;
  }else if (S == "FRI") {
      cout << "2" << endl;
  }else {
      cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

#define rep(i,n) for(int i=0;i< (n);++i)
typedef long long ll;

using namespace std;


int main(){
    ll N,M;
    cin>>N>>M;
    
    vector<vector<ll> >vec(N+1,vector<ll>(2,0));
    
    for(ll i=0;i!=M;++i){
        ll n;
        cin>>n;
        string st;
        cin>>st;
        
        if(st=="AC"){
            if(vec[n][0]==0){
                vec[n][0]=1;
            }
            
        }else if(st=="WA"){
            if(vec[n][0]!=1){
                ++vec[n][1];
            }
        }
       // cout<<"vec["<<n<<"][0]"<<vec[n][0]<<":vec["<<n<<"][1]"<<vec[n][1]<<endl;
    }
    
    ll ans_ac=0;
    ll ans_wa=0;
    
    for(ll i=1;i<=N;++i){
        ans_ac+=vec[i][0];
        if(vec[i][0]==1){
            ans_wa+=vec[i][1];
        }
    }
    
    
    cout<<ans_ac<<" "<<ans_wa<<endl;
    
    
}



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

const int N = 15;

char t[N];

int main() {
  int n;
  scanf("%d", &n);
  vector<string> a;
  for (int i = 0; i < n; i++) {
    scanf("%s", t);
    a.push_back(string(t, t + strlen(t)));
  }
  map<string, int> mp;
  for (string s : a) {
    sort(s.begin(), s.end());
    mp[s]++;
  }
  long long ans = 0;
  for (auto p : mp)
    ans += 1LL * p.second * (p.second - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 16628
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

vector<int> gen_primes(int m) {
	vector<int> primes;
	primes.push_back(2);
	for (int i = 3; i <= m; i += 2) {
		for (int prime : primes) {
			if (i < prime * prime) {
				primes.push_back(i);
				break;
			}
			if ((i % prime) == 0) {
				break;
			}
		}
	}
	return primes;
}

int main(int argc, char *argv[])
{
	vector<int> primes = gen_primes(55555);
	int n;
	cin >> n;
	string delim = "";
	int cnt = 0;
	for (int a : primes) {
		if ((a % 100) == 1) {
			cout << delim << a;
			delim = " ";
			if (++cnt >= n) {
				break;
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    int ans=INF;
    
    for(int j=-100;j<=200;j++){
        int sum=0;
        for(int i=0;i<N;i++){
            sum+=(A[i]-j)*(A[i]-j);
        }
        ans=min(ans,sum);
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll k,a,b;
int main()
{
    //IOS;
    cin>>k>>a>>b;
    if(a%k==0)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        if((a/k+1)*k<=b)
        {
            cout<<"OK"<<endl;
        }
        else
        {
            cout<<"NG"<<endl;
        }
    }
    return 0;
}
/*

*/


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

#define ll long long
#define ld long double
#define ff first
#define ss second
#define eps 1e-9
#define pi acos(-1.0)
#define all(v) v.begin(),v.end()

#define MAX 500005

vector<ll> p;
bool vis[MAX];

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

    ll n, d;
    cin >> n >> d;

    ll c=0;
    ll x, y;
    for(int i=0;i<n;i++)
    {
        cin >> x >> y;

        if((x*x +y*y) <= d*d) c++;
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3696
#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;
  }

  if ((A + B) == (C + D) ) {
    cout << "Balanced" << endl;
  }
   
  if ((A + B) < (C + D) ) {
    cout << "Right" << endl;
  }
}

 


Measured memory_bytes: 3628
N = list(map(int,input().split()))
drinks = [list(map(int,input().split())) for i in range(N[0])]
drinks.sort()

counter=0
amount=0
flag=0

for i in range(N[0]):
    if flag==1:
        break
    while(drinks[i][1]!=0):
        drinks[i][1] -=1
        counter +=1
        amount += drinks[i][0]
        if counter==N[1]:
            flag=1
            break
print(amount) 
    



Measured memory_bytes: 27880
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;


using namespace std;



void solve()
{
	int n, K;
	scanf("%d%d", &n, &K);
	int cnt = 0;
	while (n) {
		cnt++;
		n/= K;
	}
	printf("%d\n", cnt);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parsemap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x=parseInt(readline())
    for i in 1:1000
        if (360*i)%x==0
            println(360*i÷x)
            break
        end
    end
end
main()

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

typedef long long ll;
const int maxn = 200;
int a[maxn], cnt;
int num[50], t;

inline void insert(int p, int x) {
  for (int i = cnt++; i > p; i--) a[i] = a[i - 1];
  a[p] = x;
}

int main () {
  ll n; cin >> n;
  for (int i = 0; n; i++) num[t++] = n & 1, n >>= 1;
  for (int i = 1; i < t; i++) a[cnt++] = i;
  for (int i = 1; i < t; i++) a[cnt++] = i;
  a[cnt++] = a[cnt++] = t;

  int cur = t + 1;
  for (int i = t - 2; i >= 0; i--)
    if (num[i]) insert(i, cur), a[cnt++] = cur++;

  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d ", a[i]);
  return 0;
}


Measured memory_bytes: 256