akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
int main()
{
    long H,W;
    std::cin >> H >> W;
    char a[100][100];
    for(long i=0; i<H; i++){
        for(long j=0; j<W; j++){
            std::cin >> a[i][j];
        }
    }
    long count;
    std::vector<long> Hs;
    for(long i=0; i<H; i++){
        count=0;
        for(long j=0; j<W; j++){
            if(a[i][j]=='.'){
                count++;
            }
        }
        if(count==W){
            Hs.push_back(i);
        }
    }
    std::vector<long> Ws;
    for(long j=0; j<W; j++){
        count=0;
        for(long i=0; i<H; i++){
            if(a[i][j]=='.'){
                count++;
            }
        }
        if(count==H){
            Ws.push_back(j);
        }
    }

    for(long i=0;i<H; i++){
        auto result1=std::find(Hs.begin(),Hs.end(),i);
        for(long j=0; j<W; j++){
            auto result2=std::find(Ws.begin(),Ws.end(),j);
            if(result1==Hs.end() && result2==Ws.end()){
                std::cout << a[i][j];
            }            
        }
        if(result1==Hs.end()){
            std::cout << std::endl;
        }
    }
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define fi first
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef vector<ll>  vi;
typedef pair<ii, ll>  iii;
typedef pair<double, double>  iidb;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(nodo*2)+1,mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define offset 9000

const ll MOD=1e9+7;

#define cmplog 20
#define tam 600000


using namespace std;
ll pos[tam];
int main()
{	
	ios::sync_with_stdio(false);cin.tie(0);
	ll n,x,m;
	cin>>n>>x>>m;
	ll ciclo=x;
	set<ll> s;
	vector<ll> v;
	while(s.find(ciclo)==s.end())
	{
		
		s.insert(ciclo);
		pos[ciclo]=v.size();
		v.pb(ciclo);

		ciclo*=ciclo;ciclo%=m;
		
		
	}
	//cout<<ciclo<<" "<<pos[ciclo]<<endl;
	ll ini=pos[ciclo],j=0;
	ll valor=0;
	while(n>0 && j<ini)
	{
		valor+=v[j];j++;
		n--;
	}

	if (n==0){cout<<valor<<endl;return 0;}
	ll l=v.size()-ini;
	ll vueltas=(n/l),completo=0;
	forr(i,ini,v.size())completo+=v[i];
	//cout<<vueltas<<' '<<completo<<endl;
	valor+=vueltas*completo;

	forr(i,0,n%l)
		valor+=v[ini+i];
	cout<<valor<<endl;

		

}

Measured memory_bytes: 6712
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+5;
using namespace std;

int t,n,m,x,y,ans;

int main(){
	scanf("%d%d",&n,&m);
	printf("%d\n",(n+2*m)/(2*m+1));

	return 0;
}

Measured memory_bytes: 380
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
  int i, j, n, *a, mini, t, counter = 0;

  scanf("%d",&n);
  a = malloc(sizeof(int)*n);
  for(i=0;i<n;i++) scanf("%d", &a[i]);

  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if(a[j] < a[mini])mini = j;
    }
    if(i != mini) counter++;
    t = a[i]; a[i] = a[mini]; a[mini] = t; 
  }

  for(j=0;j<n;j++){
      printf("%d",a[j]);
      if(j==n-1) printf("\n");
      else printf(" ");
  }
  printf("%d\n",counter);

  return 0;
}


Measured memory_bytes: 1968
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N; cin >> N;
    vector<ll> h(N);
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    int res = 0, tmp = 0;
    for (int i = 1; i < N; i++){
        if (h[i-1] >= h[i]){
            tmp++;
            res = max(res,tmp);
        } else {
            tmp = 0;
        }
    }
    cout << res << endl;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = 2010, inf = 1e9, mod = 924844033;
const ll INF = 1e18;

int n, k, dp[2][N], ans[N], f[N], c[N][N];
void add(int &a, int b){
	a += b;
	if(a >= mod)
		a -= mod;
}
int main()
{                         
	f[0] = 1;
	for(int i = 1; i < N; i++)
		f[i] = 1ll * f[i - 1] * i % mod;
	for(int i = 0; i < N; i++)
		c[0][i] = 1;
	for(int i = 1; i < N; i++)
		for(int j = 1; j < N; j++)
			c[j][i] = (c[j][i - 1] + c[j - 1][i - 1] ) % mod;
	

	cin >> n >> k;
	
	vector< int > ord;

	for(int i = 1; i <= min(n, k + k); i++)
		for(int j = i; j <= n; j += k + k)
			ord.pb(j);	

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		int x = ord[i - 1];
		for(int j = n; j >= 0; j--){ 
			if(x - k >= 1)
				add(dp[0][j + 1], dp[0][j]);
			if(x - k >= 1 && x - k - k < 1)
				add(dp[0][j + 1], dp[1][j]);
			if(x + k <= n){                    
				add(dp[1][j + 1], dp[0][j]);
				add(dp[1][j + 1], dp[1][j]);
			}
			add(dp[0][j], dp[1][j]);
			dp[1][j] = 0;
		}
	}

	for(int i = 0; i <= n; i++)
		ans[i] = 1ll * (dp[0][i] + dp[1][i]) * f[n - i] % mod;
	for(int i = n; i >= 0; i--)
		for(int j = i + 1; j <= n; j++)
			ans[i] = (ans[i] - 1ll * ans[j] * c[i][j] % mod + mod) % mod;
	
	cout << ans[0];
	return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli i,k,x,a,b,n,j;
		cin>>k>>x;
		a=x-k+1;
		a=max((lli)-1000000,a);
		b=x+k-1;
		b=min((lli)1000000,b);
		for(i=a;i<=b;i++)
		cout<<i<<" ";
	}
}
/*
contest
tt
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}


signed main(){
	IOS();
	vector<pint>ans;
	while(1){
		int N;
		cin>>N;
		if(!N)break;
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int A=0,B=0,C=0,D=0,mi=INF;
		rep(i,0,a+1){
			rep(j,0,b+1){
				rep(k,0,c+1){
					rep(l,0,d+1){
						if(i*10+j*50+k*100+l*500<N)continue;
						int t=0;
						int sum = i*10+j*50+k*100+l*500 - N;
						int aa,bb,cc,dd;
						t+=sum/500;
						aa=sum/500;
						sum%=500;
						t+=sum/100;
						bb=sum/100;
						sum%=100;
						t+=sum/50;
						cc=sum/50;
						sum%=50;
						t+=sum/10;
						dd=sum/10;
						sum%=10;
						if(chmin(mi,t+a-i+b-j+c-k+d-l)){
							A = i;
							B = j;
							C = k;
							D = l;
						}
					}
				}
			}
		}
		if(A)ans.push_back({10,A});
		if(B)ans.push_back({50,B});
		if(C)ans.push_back({100,C});
		if(D)ans.push_back({500,D});
		ans.push_back({-1,-1});
	}
	rep(i,0,ans.size()){
		if(ans[i].fi==-1){
			if(i!=ans.size()-1)cout<<endl;
		}
		else cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	}
}


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


int main() {

	int k;
	char s[101];

	cin >> k;
	cin >> s;

	if (int(strlen(s)) > k)
	{
		for (int i = 0; i < k; i++)
		{
			cout << s[i];
		}

		cout << "..." << endl;

	}
	else
	{
		cout << s << endl;
	}

}

Measured memory_bytes: 3632
# ABC103B

s = input()
t = input()
n = len(s)
ans = 'No'
for i in range(n):
    #print(f"s = {s}\nt = {t}\n==========")
    if s == t:
        ans = 'Yes'
        break
    s = s[-1] + s[:-1]
print(ans)


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

using namespace std;

typedef unsigned int uint;
typedef long long int llint;
typedef unsigned long long int ullint;

//#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i " : " << i << endl;
#define debug(i) i
#else
#define dump(i)
#define debug(i)
#endif
#define rep(i, max) for (int i = 0; i < (max); ++i)

inline void solve() {
  int a, b, k;
  cin >> a >> b >> k;
  int kk = k;
  int bb = b - k;
  for (int i = a; i <= b; ++i) {
    if (kk > 0 || i > bb) {
      cout << i << endl;
      --kk;
    }
  }
}

int main() {
        /*
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        //*/
#ifdef DEBUG
        clock_t _begin = clock();
#endif

        solve();

#ifdef DEBUG
        cerr << "[*] time : " << (double)(clock() - _begin) * 1000 / CLOCKS_PER_SEC << " [ms]" << endl;
#endif
        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


// 139_c
public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int[] h = new int[n];
        int tmp_count = 0;
        int total_count = 0;
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (h[j - 1] >= h[j]) {
                    tmp_count++;
                } else {
                    break;
                }
            }
            if (tmp_count > total_count) {
                total_count = tmp_count;
            }
            if (total_count > n - i) {
                break;
            }
            tmp_count = 0;

        }

        System.out.println(total_count);

    }

}


Measured memory_bytes: 51196
INF = float("inf") #const

def main():
    n,m = map(int,input().split())
    issafe = [True]*n
    for i in range(m):
        a = int(input())
        issafe[a] = False
    dp = [0]*(n+1)
    dp[0],dp[1] = 1,1

    for i in range(2,n+1):
        if issafe[i-1]:
            dp[i] += dp[i-1]
        if issafe[i-2]:
            dp[i] += dp[i-2]

    print(dp[n]%(10**9+7))


if __name__ == "__main__":
    main()


Measured memory_bytes: 463476
N,M = map(int,input().split())
ST = []
CH = []
for _ in range(N):
    ST.append(list(map(int,input().split())))
for _ in range(M):
    CH.append(list(map(int,input().split())))

for n in range(N):
    x,y = ST[n]
    ansp = -1
    minp = 10**10
    for p in range(M):
        px,py = CH[p]
        d = abs(px-x)+abs(py-y)
        if d < minp:
            minp = d
            ansp = p+1
    print(ansp)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}


int main() {
    int N,M; cin >> N >> M;
    int cnt=0;
    vector<ll> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    vector<set<int> > A(N,set<int>());
    for(int i=0;i<M;i++){
        int a,b; cin >> a >> b;
        a--;b--;
        A[a].insert(b);
        A[b].insert(a);
        //cerr << a << "\t" << b << endl;
    }
    for(int i=0;i<N;i++){
        bool f=true;
        //cerr << "\n" << i << "\t";
        for(auto x : A[i]){
            if(H[i]<=H[x]){
                f=false;break;
            }
        }
        if(f){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 18056
#include <iostream>
#include <vector>
#include <cstring>

#define LL long long
using namespace std;
#define MAXN 60
#define MAXA 60

int N, M, S;

struct edge
{
    int v, a, b;
};
vector<edge> G[MAXN];
int C[MAXN], D[MAXN];
LL dp[MAXN][MAXA * MAXN];
LL ans[MAXN];

inline void add(int u, int v, int a, int b)
{
    G[u].push_back({v, a, b});
    G[v].push_back({u, a, b});
}
int main()
{
    scanf("%d%d%d", &N, &M, &S);
    int u, v, a, b;
    for (int i = 1; i <= M; i++)
    {
        scanf("%d%d%d%d", &u, &v, &a, &b);
        add(u, v, a, b);
    }
    for (int i = 1; i <= N; i++)
    {
        scanf("%d%d", &C[i], &D[i]);
    }

    memset(dp, 0x3f, sizeof(dp));
    memset(ans, 0x3f, sizeof(ans));

    if (S > 2500)
        S = 2500;
    dp[1][S] = 0;
    for (int t = 0; t <= N; t++)
    {
        for (int i = 1; i <= N; i++)
        {
            for (int k = 0; k < G[i].size(); k++)
            {
                for (int j = 0; j <= 2500; j++)
                {
                    if (j + G[i][k].a <= 2500)
                        dp[i][j] = min(dp[i][j], dp[G[i][k].v][j + G[i][k].a] + G[i][k].b);
                    if (ans[i] > dp[i][j])
                    {
                        ans[i] = dp[i][j];
                    }
                }
            }

            for (int j = 0; j <= 2500; j++)
            {
                if (j >= C[i])
                    dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + D[i]);
                if (ans[i] > dp[i][j])
                {
                    ans[i] = dp[i][j];
                }
            }
        }
    }
    for (int i = 2; i <= N; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5468
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;


stack<double> s;
vector<string> exps;

void calculate(string op) {

  double op1,op2;

  op2=s.top();
  s.pop();

  op1=s.top();
  s.pop();

  //cout << op << endl;
  if(op=="+") {

    s.push((double)(op1+op2));

  }

  else if(op=="-") {

    s.push((double)(op1-op2));

  }

  else if(op=="*") {

    s.push((double)(op1*op2));

  }

  else if(op=="/") {

    s.push((double)((double)op1/(double)op2));

  }

}

int main() {

  string buf;

  char* tp;
  bool is_op;


  while(getline(cin,buf)) {

    while(s.empty()==false) s.pop();

    exps.clear();

    tp=strtok((char*)buf.c_str()," ");

    while(tp!=NULL) {

      exps.push_back(tp);

      tp=strtok(NULL," ");

    }

    for(int i=0;i<exps.size();i++) {

      //cout << operands.top() << endl;
      
      is_op=false;

      if(exps[i]=="+" || exps[i]=="-" || exps[i]=="*" || exps[i]=="/") calculate(exps[i]);

      else s.push(atof(exps[i].c_str()));

      //cout << s.top() << endl;

    }

    printf("%6f\n",s.top());

  }


  return 0;

}

Measured memory_bytes: 0
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#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 umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>k;
if(k==1)
{cout<<0;return ;}
cout<<n-k;











return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main{
    public static void main(String[] a){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) {
				break;
			} else if (n != 0) {
				int ua = 0;
				int ub = 0;
				for(int i=0; i<n; i++) {
					int va = sc.nextInt();
					int vb = sc.nextInt();
					if (va > vb) {
						ua += va+vb;
					} else if (vb > va) {
						ub += va + vb;
					} else if (vb == va) {
						ua += va;
						ub += vb;
					}
				}
				System.out.println(ua + " " + ub);
			}
		}
	}
}

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

using namespace std;

int n;

int main(){
        double r = 0;

        cin >> n;

        for (int i=0; i<n; i++) {
                double x;
                string s;
                cin >> x >> s;
                if (s == "JPY")
                        r += x;
                else
                        r += x * 380000;
        }

        cout << r << endl;


        return 0;
}


Measured memory_bytes: 256
def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
A, B = map(int, input().split())

Aprime = set(prime_factorize(A))
Bprime = set(prime_factorize(B))
ABintr = Aprime & Bprime

# print(Aprime, Bprime)
print(len(ABintr))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss seconds
#define endl '\n'
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
int main()
{
    ll m,n;
    cin>>m>>n;
    cout<<power(m,n)<<endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

vector<ll> v[200001];
bool vis[200001];
ll c;

void dfs(ll x, ll p) {
    vis[x]=true;
    c++;
    for(auto i:v[x]) {
        if(i==p) continue;
        if(!vis[i]) dfs(i,x);
    }
}

void solve(ll tt) {
    ll n,m;
    cin>>n>>m;
    repf(i,1,n+1) vis[i]=false;
    repf(i,0,m) {
        ll x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll ans=0;
    repf(i,1,n+1) {
        if(!vis[i]) {
            c=0;
            dfs(i,-1);
            ans=max(ans,c);
        }
    }
    cout<<ans<<endl;
} 

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 24048
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint l(n);
    rep(i, n) cin >> l[i];
    sort(rall(l));
    int sum = accumulate(all(l), 0);
    yns(sum > l[0]*2);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Hs = list(map(int, input().split()))

tmp_total = 0
tmp_best = 0
for i in range(N-1):
    if Hs[i+1] <= Hs[i]:
        tmp_total += 1
    else:
        if tmp_total > tmp_best:
            tmp_best = tmp_total
        tmp_total = 0
if tmp_total > tmp_best:
    tmp_best = tmp_total
print(tmp_best)

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

using namespace std;
#define ll long long 
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
const int N = 2e5+100;
const int mod = 1e9+7;
int siz[N],n;
ll mul[N],fac[N],ans[N];
vector<int> g[N];

ll fpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b&1)  ret = ret*a%mod;
        b >>= 1;
        a = a*a%mod;
    }
    return ret;
}
void predfs(int u, int fa) {
    siz[u] = mul[u] = 1;
    for(int v : g[u]) {
        if(v == fa) continue;
        predfs(v,u);
        siz[u] += siz[v];
        mul[u] = mul[u]*mul[v]%mod;
    }
    mul[u] = mul[u]*siz[u]%mod;
}
void dfs(int u, int fa, ll tmp) {
    for(int v : g[u]) if(v != fa) tmp = tmp*mul[v]%mod;
    ans[u] = fac[n-1]*fpow(tmp, mod-2)%mod;
    for(int v : g[u]) if(v != fa) dfs(v, u, tmp*fpow(mul[v], mod-2)%mod*(n-siz[v])%mod);
}
int main(){
    scanf("%d", &n);
    _for(i,1,n) {
        int x,y;         
        scanf("%d%d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fac[0] = 1;
    _rep(i,1,n) fac[i] = fac[i-1]*i%mod;
    predfs(1, 0);
    dfs(1,0,1);
    _rep(i,1,n) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 19444
#include <iostream>

using namespace std;

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int min = 0;

    min = h2 * 60 + m2 - k - h1 * 60 - m1;

    cout << min;
    }


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

char al[30];

int N,K;
string s;
int main (){
    cin >> N >> K >> s;
    for(char c = 'a'; c!='z'; c++) al[c-'a']=c;
    int i = 0;
    for(char c = 'A'; c!='Z'; c++) {
        if(s[K-1] == c) s[K-1] = al[i];
        i++;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
　const S=input[0];
  var score=0;
　for(var i=0;i<S.length;i++){
   if(S[i]==="p"){
     score--;
   }
 }
  console.log(Math.floor(S.length/2)+score);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 32444
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    long C = sc.nextLong();
    long[] x = new long[N];
    long[] v = new long[N];
    long ans = 0;
    
    for(int i=0; i<N; i++){
      x[i] = sc.nextLong();
      v[i] = sc.nextLong();
    }
    
    long sum1 = 0;
    long sum2 = 0;
    long[] a = new long[N+1];
    long[] b = new long[N+1];
    
    for(int i=0; i<N; i++){
      sum1 += v[i];
      a[i+1] =  sum1 - x[i];
      a[i+1] = Math.max(a[i], a[i+1]);
      sum2 += v[N-i-1];
      b[i+1] = sum2 - (C - x[N-i-1]);
      b[i+1] = Math.max(b[i], b[i+1]);
    }
    
    for(int i=0; i<N; i++){
      long t1 = Math.max(a[i+1], a[i+1] - x[i] + b[N-i-1]);
      long t2 = Math.max(b[i+1], b[i+1] - (C-x[N-i-1]) + a[N-i-1]);
      long t3 = Math.max(t1, t2);
      ans = Math.max(ans, t3);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 88720
<?php

// 標準入力を一行ずつ配列に代入します
$line = fgets(STDIN); // 標準入力からの入力値を変数に代入

if($line < 105){
    echo 0;
} elseif ($line < 135) {
    // code...
    echo 1;
} elseif ($line < 165) {
    echo 2;
} elseif ($line < 189) {
    echo 3;
} elseif ($line < 195) {
    echo 4;
} else {
    echo 5;
}



?>

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll n;

    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}

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

long int ar[100][3];
typedef long long ll;

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

    string s; cin >> s;
    string q = s;
    reverse(s.begin(), s.end());
    if(s!=q){
        cout << "No\n"; return 0;
    }
    int n = s.end()-s.begin();
    string a = s.substr(0, (n-1)/2);
    string b = s.substr((n+1)/2, n);
    string c = a;
    string d = b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    if(a==c && b==d) cout << "Yes\n";
    else cout << "No\n";
}

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

int main() {
  int n,x;
  vector<int> l(n);
  cin>>n>>x;
  for (int i=0;i<n;++i) {
    cin>>l[i];
  }
  int d=0;
  int count=0;
  int j=0;
  while (d<=x & j<=n) {
    d=d+l[j];
    count+=1;
    j+=1;
  }
  cout << count << endl;
}



Measured memory_bytes: 16640
stack = gets.split.reduce([]) do |stack, c|
  if c == '+' 
    stack << stack.pop + stack.pop
  elsif c == '-'
    tail = stack.pop
    prev = stack.pop
    stack << prev - tail
  elsif c == '*' 
    stack << stack.pop * stack.pop
  elsif c == '/'
    tail = stack.pop
    prev = stack.pop
    stack << prev / tail
  else
    stack << c.to_i
  end
  stack
end
p stack.pop


Measured memory_bytes: 6872
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int a,b;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	if(a <= 9 && b <= 9) cout << a * b << endl;
	else cout << -1 << endl;
	return 0; 
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
  ll h, n; cin >> h >> n;
  rep (i, 0, n) {
    ll a; cin >> a;
    h -= a;
  }
  if (h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  

}


Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	int N, Q;
	List<long> ps = new List<long>();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		var I = G();
		N = I[0];
		Q = I[1];
		var s = 1L;
		var p = 1L;
		while (N != 1 && s < MOD)
		{
			ps.Add(s);
			s += p;
			p *= N;
		}
		for (int i = 0; i < Q; i++)
		{
			I = G();
			Console.WriteLine(Solve(I[0], I[1]));
		}
		Out.Flush();
	}
	long Solve(long u, long v)
	{
		if (N == 1) return Min(u, v);
		var a = F(u);
		var b = F(v);
		var c = new List<int>();
		var i = 0;
		while (i < Min(a.Count, b.Count) && a[i] == b[i]) c.Add(a[i++]);
		// Console.WriteLine("{0} <-> {1}: {2}", string.Join("", a), string.Join("", b), string.Join("", c));
		return G(c);
	}
	long G(List<int> u)
	{
		var n = 0L;
		var p = 1L;
		foreach (var i in u.Reverse<int>())
		{
			n += i * p;
			p *= N;
		}
		return n + ps[u.Count];
	}
	List<int> F(long u)
	{
		var n = 0;
		while (n + 1 < ps.Count && ps[n + 1] <= u) n++;
		u -= ps[n];
		var r = new List<int>();
		while (u > 0)
		{
			r.Add((int)(u % N));
			u /= N;
		}
		while (r.Count < n) r.Add(0);
		r.Reverse();
		return r;
	}
}


Measured memory_bytes: 17644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;
ull e = 10007;
const double pi = 3.14159265359;


int main() {
    int A, B;
    cin >> A >> B;
    if ((B % A) == 0) cout << A + B << endl;
    else cout << B - A << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<=200000;i++){
    if(i*a%b==c) {
      cout<<"YES"<<endl;
   return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/

bool judge(vector<vector<int>> &_G,vector<ll> &_h, int p){

    for(auto x : _G[p]){
        if(_h[p] <= _h[x]) return false;
    }

    return true;
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> parent(n+1);
    vector<int> children(n+1, 0);
    for(int i = 2; i <= n; i++){
        cin >> parent[i];
        children[parent[i]]++;
    }

    for(int i = 1; i <= n; i++) cout << children[i] << endl;

return 0;
}

Measured memory_bytes: 4768
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
   
    string s;

    cin>>s;

    int x=s.length();

    for(int i=0;i<x;i++){
        cout<<"x";
    }
    cout<<endl;



    return 0;
}

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

int main() {
  int N, X, F=0;
  cin >> N;

  X = N;
  for (int i = 0; i < 8; i++)
  {
    F += X % 10;
    X /= 10;
  }
  
  if ((N % F) == 0)
  {
    cout << "Yes" << endl;  
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main(){
  ll longs;
  cin >> longs;
  string str;
  cin >> str;

  bool a = false;
  bool b = false;
  bool c = false;

  int count = 0;

  rep(i, longs){
    if(str.at(i-2) == 'A' && str.at(i-1) == 'B' && str.at(i) == 'C'){
      count ++;
    }
  }
cout << count << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();

    let mut edges = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let (u, v, w) = i.read3::<usize, usize, usize>();
        let (u, v, w) = (u - 1, v - 1, w);

        edges[u].push((v, w));
        edges[v].push((u, w));
    }
    let start = 0;
    let mut ds = vec![None; n];
    let mut q = vec![start];
    ds[start] = Some(0);


    while let Some(u) = q.pop() {
        let d = ds[u].unwrap();
        for &(v, w) in &edges[u] {
            if ds[v].is_none() {
                ds[v] = Some(d + w);
                q.push(v);
            }
        }
    }
    for d in ds {
        writeln!(o, "{}", d.unwrap() % 2).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 16636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll x[n];
    vector<pair<ll,ll>> a;
    for(ll i=0;i<n;i++){
        cin>>x[i];
        a.push_back(make_pair(x[i],i));
    }
    sort(a.begin(),a.end());
    ll ans[n];
    for(ll i=0;i<n;i++){
        if(i<n/2){
            ans[a[i].second]=a[n/2].first;
        }else{
            ans[a[i].second]=a[(n/2)-1].first;
        }
    }
    for(ll i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 9196
N = int(input())

arr = [[0 for _ in range(10)] for _ in range(10)]

arr[1][1] += 1
arr[2][2] += 1
arr[3][3] += 1
arr[4][4] += 1
arr[5][5] += 1
arr[6][6] += 1
arr[7][7] += 1
arr[8][8] += 1
arr[9][9] += 1

if N < 10:
  print(N)
  exit()

for i in range(11, N+1):
  if i % 10 == 0:
    continue
  tmp = str(i)
  first = tmp[0]
  last = tmp[-1]
  # print(first, last)
  arr[int(first)][int(last)] += 1

sum_diag = 0
sum_other = 0

for i in range(1, 10):
  for j in range(1, 10):
    if i == j:
      sum_diag += arr[i][j]*arr[i][j]
    else:
      sum_other += arr[i][j] * arr[j][i] * 2

# print(arr)

print(int(sum_diag + sum_other/2))


Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for(double i = 0; i < 1e4 + 5; i += 1){
    if((int)(i * 0.08) == A && (int)(i * 0.10) == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
data = [0] * (N + 2)
cnt = 0
for i in range(N):
    if S[i] == "#":
        cnt += 1
    data[i + 1] = cnt
data[-1] = cnt
ans = float("inf")
for i in range(N + 1):
    turn = data[i] + N - i - data[-1] + data[i]
    if ans > turn:
        ans = turn
print(ans)

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

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];
  int ans = 0;
  rep(i,n) ans += b[i];
  rep(i,n-1) {
    if (a[i] + 1 == a[i+1]) {
      ans += c[a[i]-1];
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inline flip f a b = f b a  

// memoization
let inline memo size f =
  let dp = Array.create size None
  let rec g x =
    match dp.[x] with
    | None ->
      let v = f g x
      dp.[x] <- Some v
      v
    | Some v -> v
  g

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match Array2D.get dp x y with
    | None ->
      let v = f g x y
      Array2D.set dp x y (Some v)
      v
    | Some v -> v
  g

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify array i f = Array.set array i (f (Array.get array i))

let bin = Array.create (3 * 100000) 0L

let N = readInt ()
let A = readInts ()

A |>
Array.iter (fun a -> Array.modify bin a ((+) 1L))

let calc n = (n * (n - 1L)) / 2L

let result =
  bin
  |> Array.map calc

let sum = result |> Array.sum

[0..(N-1)]
|> List.map (fun x -> sum - result.[A.[x]] + calc (bin.[A.[x]] - 1L))
|> List.iter (printfn "%d")


Measured memory_bytes: 51908
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

#define LIM 1000010

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned short int usi;

int n, c;
usi btn[31];
usi psh[31];
int dp[31][1<<16];

int solve(){
	
	CLR(dp);
	int res = 0;
	queue<pair<int, usi> > qu;
	qu.push(make_pair(0, 0));
	
	while(!qu.empty()){
		
		int k = qu.front().first;
		usi stt = qu.front().second;
		qu.pop();
		
		if( k >= n )
			continue;
		
		usi mid_stt = (stt|btn[k]);
		
		for(int i=0; i<c; ++i){	

			usi next_stt = mid_stt&(~psh[i]);
			int tmp=0;
			
			for(int j=0; j<16; ++j){
			
				tmp += BIT(mid_stt, j) & BIT(psh[i], j);
			}
			
			if( dp[k+1][next_stt] < dp[k][stt] + tmp ){
				
				dp[k+1][next_stt] = dp[k][stt] + tmp;
				qu.push(make_pair(k+1, next_stt));
			}
		}
	}
	
	for(int i=0; i<(1<<16); ++i){
	
		res = max(res, dp[n][i]);
	}
	
	return res;
}	

int main(){

	while(cin>>n>>c, (n||c)){
		
		usi t;
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<16; ++j){
				cin >> t;
				btn[i] = (btn[i]<<1) | t;
			}
		}
		
		
		for(int i=0; i<c; ++i){
			for(int j=0; j<16; ++j){
				cin >> t;
				psh[i] = (psh[i]<<1) | t;
			}
		}
	
		cout << solve() << endl;
	}
	
	return 0;
}

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

int main(){
        ll h, w;
        scanf("%lld %lld", &h, &w);
        std::vector<std::vector<ll>> mp(h+2, std::vector<ll>(w+2, 0));

        for(ll i=0; i<h; i++){
                std::string s;
                std::cin >> s;
                for(ll j=0; j<w; j++) mp[i+1][j+1] = (s[j]=='#');
        }

        std::vector<std::vector<bool>> used(h+2, std::vector<bool>(w+2, 0));
        std::queue<std::pair<ll,ll>> que;
        que.push({1,1});
        while(!que.empty()){
                ll x, y;
                std::tie(x,y) = que.front();
                que.pop();
                used[x][y] = 1;

                bool flag = 0;
                if(mp[x-1][y]&&used[x-1][y]==0 || mp[x][y-1]&&used[x][y-1]==0) flag = 1;
                if(mp[x+1][y] && mp[x][y+1]) flag = 1;
                if(flag){
                        puts("Impossible");
                        return 0;
                }

                if(mp[x+1][y]) que.push({x+1, y});
                if(mp[x][y+1]) que.push({x, y+1});
        }
        puts("Possible");
        return 0;
}

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


int main() {
    int N,X;
    cin >> N >> X;
    vector<int> V(N);
    rep(i,N) {
        cin >> V[i];
    }
    int sum = 0;
    rep(j,N) {
        sum += V[j];
    }
    sort(V.begin(),V.end());
    cout << N + (X - sum)/V[0] << endl;
}



Measured memory_bytes: 3592
n = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(n + 1)]

def check(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return 0
    return 1

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in 'ACGT':
        if check(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 3872
R,G,B,N = list(map(int,input().split()))

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 40684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,count,n;
		while(true){
			count=0;
			n=sc.nextInt();
			if(n==0) break;
			for(i=0;i<n/4;i++){
				count+=sc.nextInt();
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 12000